scripts

scripts to make my pc work
Index Commits Files Refs
statusbar/sb-internet2 (1007B)
   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) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
   9     3) notify-send "🌐 Internet module" "\- Click to connect
  10 📡: no wifi connection
  11 📶: wifi connection with quality
  12 ❎: no ethernet
  13 🌐: ethernet working
  14 🔒: vpn is active
  15 " ;;
  16     6) "$TERMINAL" -e "$EDITOR" "$0" ;;
  17 esac
  18 
  19 case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
  20     down) wifiicon="📡:  -%" ;;
  21     up) wifiicon="$(awk '/^\s*w/ { print "📶:", int($3 * 100 / 70) "%" }' /proc/net/wireless)" ;;
  22 esac
  23 
  24 case "$(cat /sys/class/net/e*/operstate 2>/dev/null)" in
  25     down) ip="" ;;
  26     up) ip="| $(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }')" ;;
  27 
  28 esac
  29 
  30 printf "%s%s%s%s\n" "$wifiicon" "$(sed "s/down//;s/up/ /" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)" "$ip"