sb-internet (1048B)
1 #!/bin/sh 2 3 # Show wifi w and percent strength or nw if none. 4 # Show ew if connected to ethernet or ne if none. 5 # Show v if a vpn connection is active 6 7 case $BLOCK_BUTTON in 8 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; 9 3) notify-send "Internet module" "\- Click to connect 10 WD: wifi disabled 11 NW: no wifi connection 12 W: wifi connection with quality 13 NE: no ethernet 14 EW: ethernet working 15 V: vpn is active 16 " ;; 17 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; 18 esac 19 20 # Wifi 21 if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then 22 wifiicon="$(awk '/^\s*w/ { print "W", int($3 * 100 / 70) "% " }' /proc/net/wireless)" 23 elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then 24 [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="NW " || wifiicon="W " 25 fi 26 27 # Ethernet 28 [ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="EW" || ethericon="NE" 29 30 # TUN 31 [ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" V" 32 33 printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"