scripts

scripts to make my pc work
Index Commits Files Refs
commit 502fca5617461fa9cd561cefbfd167e8c88e290e
parent bccc6c771cb434f3d861329aa1db2dc659217837
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Sat, 26 Jun 2021 01:30:33 -0300

Updated scripts folder

Diffstat:
Mstatusbar/sb-internet | 32++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/statusbar/sb-internet b/statusbar/sb-internet
@@ -1,30 +1,14 @@
 #!/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
+# Prints your local ip address, if you are connected both via wireless & ethernet then the ethernet ip is printed
 
-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
+# by github.com/klewer-martin
 
-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
+estatus="$(cat /sys/class/net/e*/operstate)"
 
-case "$(cat /sys/class/net/e*/operstate 2>/dev/null)" in
-    down) ip="" ;;
-    up) ip="| $(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }')" ;;
+if [ "$estatus" = "down" ]; 
+    then ip=$(ip -o a | awk '/: w.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }'); icon="📡";
+    else ip=$(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }'); icon="🌐";
+fi;
 
-esac
-
-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"
+printf "%s %s\n" "$icon" "$ip"