aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-internet
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-27 03:44:14 +0300
committerawy <awy@tutamail.com>2024-08-27 03:44:14 +0300
commit8c24921832b2b6dc95bbb41dbfe2de7ff4fcf877 (patch)
treeb8bfc2d150de60d0f989843cb67bc0c6fd380366 /.local/bin/statusbar/sb-internet
parent01b0a486d1190b88ee40458b4e16bcd6fa0c93bc (diff)
update
Diffstat (limited to '.local/bin/statusbar/sb-internet')
-rwxr-xr-x.local/bin/statusbar/sb-internet27
1 files changed, 27 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
new file mode 100755
index 0000000..0cbf877
--- /dev/null
+++ b/.local/bin/statusbar/sb-internet
@@ -0,0 +1,27 @@
+#!/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
+
+printconnection() {
+ [ "$(cat /sys/class/net/eth0/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎"
+ [ -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ] && tunicon=" 🔒"
+ printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
+}
+
+if [ ! -n "$1" ]; then
+ printconnection
+else
+ if [ "$1" -eq 1 ]; then
+ if [ ! -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ];then
+ doas wg-quick up wg0
+ notify-send "🔒 Internet module" "Connected to VPN"
+ else
+ doas wg-quick down wg0
+ notify-send "🔒 Internet module" "Disconnected from VPN"
+ fi
+ elif [ "$1" -eq 3 ]; then
+ notify-send "🌐 Internet module" "\- Click to connect to vpn"
+ fi
+fi