dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit e9799c2a402acecd03f4e6d8701c5976b55c31a4
parent 498ca82b775c3a8c47b233c40b1bd9e9449497ad
Author: Alexander Balgavy <alexander.balgavy@spaceapplications.com>
Date:   Mon,  2 Oct 2023 17:41:45 +0200

dwmblocks: fix internet block script

Diffstat:
Mscripts/dwmblock-internet | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/scripts/dwmblock-internet b/scripts/dwmblock-internet @@ -5,8 +5,9 @@ # Show 🔒 if a vpn connection is active # Interfaces: -wired=eth0 -wireless=eth1 +# (list with `nmcli --get-values GENERAL.DEVICE,GENERAL.TYPE device show`) +wired=enp0s31f6 +wireless=wlp0s20f3 # there's probably a way to change these but I'd have to know all files to update... case "$BUTTON" in @@ -19,12 +20,17 @@ esac case "$(cat /sys/class/net/$wireless/operstate 2>/dev/null)" in down) wifiicon="📡 " ;; - up) wifiicon="$(awk '/^\s*e/ { print "📶", int($3) "% " }' /proc/net/wireless)" ;; + up) wifiicon="$(awk -v pat="^\\s*$wireless" '$0 ~ pat { print "📶", int($3) "% " }' /proc/net/wireless)" ;; # might need to do some calculations if this doesn't match up with `iwconfig` link quality # up) wifiicon="$(awk '/^\s*e/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;; esac ethicon="$(sed 's/down/❎/;s/up/🌐/' /sys/class/net/$wired/operstate 2>/dev/null)" -vpnicon="$(sed 's/.*/🔒/' /sys/class/net/tun*/operstate 2>/dev/null)" +if nmcli --terse device status | grep '^tun.*:connected' >/dev/null 2>&1; then + vpnicon=' 🔒' +else + vpnicon=' ' +fi +# vpnicon="$(sed 's/down/ /;s/up/🔒/;s/unknown/ /;' /sys/class/net/tun*/operstate 2>/dev/null)" -printf "%s%s%s\n" "$wifiicon" "$ethicon" "$vpnicon" +printf "%s%s%s" "$wifiicon" "$ethicon" "$vpnicon"