sb-internet (1077B)
1 #!/bin/sh 2 3 # Show wifi 📶 and percent strength or 📡 if none. 4 # Show if connected to ethernet or ❎ if none. 5 # Show 🔒 if a vpn connection is active 6 7 case $1 in 8 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 waybar ;; 9 3) notify-send " Internet module" "\- Click to connect 10 : wifi disabled 11 : no wifi connection 12 : wifi connection with quality 13 : no ethernet 14 : ethernet working 15 : vpn is active 16 " ;; 17 8) 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 " ", 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=" " || wifiicon=" " 25 fi 26 27 # Ethernet 28 [ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon=" " || ethericon=" " 29 30 # TUN 31 [ -n "$(cat /sys/class/net/libre*/operstate 2>/dev/null)" ] && tunicon=" " 32 33 printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"