summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-internet
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-05-27 21:11:39 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-05-27 21:11:39 +0200
commit8e97cff50b77a5c381447e675ea448865aa69d74 (patch)
tree0334953d72201a7987d41d0df8d2ea9f1b06c76a /.local/bin/statusbar/sb-internet
parent5f6c5f827e1789f27339e2f0e63d298cecb039d8 (diff)
Bug fix in PATH export, added some of Luke's scripts
Diffstat (limited to '.local/bin/statusbar/sb-internet')
-rwxr-xr-x.local/bin/statusbar/sb-internet24
1 files changed, 24 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
new file mode 100755
index 0000000..ee1a160
--- /dev/null
+++ b/.local/bin/statusbar/sb-internet
@@ -0,0 +1,24 @@
+#!/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 $BLOCK_BUTTON in
+ 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
+ 3) notify-send "🌐 Internet module" "\- Click to connect
+📡: no wifi connection
+📶: wifi connection with quality
+❎: no ethernet
+🌐: ethernet working
+🔒: vpn is active
+" ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
+ down) wifiicon="📡 " ;;
+ up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
+esac
+
+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)"