2021-02-13 20:17:23 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
######################################################################
|
2021-02-15 00:12:27 +01:00
|
|
|
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
|
2021-02-13 20:17:23 +01:00
|
|
|
# @file : sb-internet
|
2021-02-15 00:37:34 +01:00
|
|
|
# @license : GPLv3
|
2021-02-13 20:17:23 +01:00
|
|
|
# @created : Saturday Feb 13, 2021 17:35:49 CET
|
|
|
|
#
|
|
|
|
# @description : internet block for dwmblocks
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
|
2022-11-03 10:28:43 +01:00
|
|
|
# Wifi ssid and icon if ethernet is connected.
|
2021-09-19 12:30:30 +02:00
|
|
|
ssid="$(wpa_cli status | grep -i ^ssid | sed -e 's/.*=//')"
|
|
|
|
state="$(wpa_cli status | grep -i ^wpa_state | sed -e 's/.*=//')"
|
2022-07-28 20:06:53 +02:00
|
|
|
case "$state" in
|
2022-11-04 21:09:13 +01:00
|
|
|
COMPLETED) str="$(printf " %s" $ssid)" ;;
|
2022-07-28 20:06:53 +02:00
|
|
|
INTERFACE_DISABLED) str="WIFI DOWN" ;;
|
|
|
|
*) str="$(printf "NO WIFI")";;
|
|
|
|
esac
|
2022-11-17 18:09:59 +01:00
|
|
|
eth="$(cat /sys/class/net/eth0/operstate &> /dev/null)"
|
2021-02-13 20:17:23 +01:00
|
|
|
if [ "up" = "$eth" ]; then
|
2022-11-03 10:28:43 +01:00
|
|
|
str="$(printf "%s / " "$str")"
|
2021-02-13 20:17:23 +01:00
|
|
|
fi
|
2023-01-19 19:17:02 +01:00
|
|
|
vpn="$(ip route | head -n1 | rev | cut -d' ' -f2 | rev)"
|
2023-01-19 19:17:37 +01:00
|
|
|
[ "tun0" = "$vpn" -o "tap0" = "$vpn" ] && str="$(printf "%s / " "$str")"
|
2021-02-13 20:17:23 +01:00
|
|
|
|
2021-04-09 11:20:27 +02:00
|
|
|
printf " %s " "$str"
|