diff options
| author | Mike Vink <mike1994vink@gmail.com> | 2023-06-27 13:23:15 +0200 |
|---|---|---|
| committer | Mike Vink <mike1994vink@gmail.com> | 2023-06-27 13:23:15 +0200 |
| commit | f4effc7665bf280c8587c6c65e4ee769d0244363 (patch) | |
| tree | 24a0246a65b637ef7b37c922f26bb2790e393f0a /shell-scripts/sb-internet | |
| parent | fe1eea2ebb749fc89a56a972d03a7797b9cc36e8 (diff) | |
stuff
Diffstat (limited to 'shell-scripts/sb-internet')
| -rw-r--r-- | shell-scripts/sb-internet | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/shell-scripts/sb-internet b/shell-scripts/sb-internet new file mode 100644 index 0000000..225d376 --- /dev/null +++ b/shell-scripts/sb-internet @@ -0,0 +1,26 @@ +#!/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 $BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 3) notify-send "🌐 Internet module" "\- Click to connect +❌: wifi disabled +📡: no wifi connection +📶: wifi connection with quality +❎: no ethernet +🌐: ethernet working +🔒: vpn is active +" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then + wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then + grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="📡 " || wifiicon="❌ " +fi + +printf "%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)" |
