2024-04-23 04:34:15 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Show wifi and percent strength or if none.
|
|
|
|
# Show if connected to ethernet or if none.
|
|
|
|
# Show if a vpn connection is active
|
|
|
|
|
|
|
|
case $BLOCK_BUTTON in
|
|
|
|
1) networkmanager_dmenu && pkill -RTMIN+4 dwmblocks ;;
|
|
|
|
3) notify-send " Internet module" "\- Click to connect
|
|
|
|
: wifi disabled
|
|
|
|
: no wifi connection
|
|
|
|
: wifi connected
|
|
|
|
: no ethernet
|
|
|
|
: ethernet working
|
|
|
|
: vpn is active
|
|
|
|
" ;;
|
2024-05-04 12:27:08 +02:00
|
|
|
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
|
2024-04-23 04:34:15 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Wifi
|
|
|
|
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
|
|
|
|
if [ ! -e ~/.cache/bar_color ]; then
|
|
|
|
wifiicon="$(awk '/^\s*w/ { cmd="nmcli -t -f active,ssid dev wifi | grep yes | cut -d: -f2"; cmd | getline output; close(cmd); print " ", output }' /proc/net/wireless)"
|
|
|
|
else
|
2024-05-16 18:30:18 +02:00
|
|
|
wifiicon="$(awk '/^\s*w/ { cmd="nmcli -t -f active,ssid dev wifi | grep yes | cut -d: -f2"; cmd | getline output; close(cmd); print "^C3^ ^d^", output }' /proc/net/wireless)"
|
2024-04-23 04:34:15 +02:00
|
|
|
fi
|
|
|
|
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
|
|
|
|
if [ ! -e ~/.cache/bar_color ]; then
|
|
|
|
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon=" " || wifiicon=" "
|
|
|
|
else
|
2024-05-16 18:30:18 +02:00
|
|
|
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="^C5^ ^d^" || wifiicon="^C1^ ^d^"
|
2024-04-23 04:34:15 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ethernet
|
|
|
|
# [ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon=" " || ethericon=" "
|
|
|
|
|
|
|
|
# TUN
|
|
|
|
# [ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" "
|
|
|
|
|
|
|
|
# printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
|
|
|
|
printf "%s%s%s\n" "$wifiicon"
|