swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

sb-internet (1249B)


      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 $BLOCK_BUTTON in
      8   1) setsid -f "$TERMINAL" -e nmtui >/dev/null 2>&1 ; pkill -RTMIN+4 i3blocks ;;
      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 (routing)
     16 🔒: vpn is active
     17     " ;;
     18   8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;;
     19 esac
     20 
     21 # Wifi
     22 if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
     23   wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
     24 elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
     25   [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon="❌ "
     26 fi
     27 
     28 # Ethernet
     29 [ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌎" || ethericon="❎"
     30 
     31 # TUN
     32 [ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" 🔒"
     33 [ -n "$(cat /sys/class/net/route*/operstate 2>/dev/null)" ] && tunicon=" 🧭"
     34 
     35 printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"