diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-20 17:02:53 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-20 17:02:53 +0200 |
commit | 52e41555b4413b12a61c77febbf84d9f18d6991e (patch) | |
tree | 64c5b0cf7ef9222e8c107c9e45a419358fc9bcd9 /.config | |
parent | de0478c141ee61dc15011c84319cf0848937901a (diff) |
eww: Update the way I handle wireless networks
Diffstat (limited to '.config')
-rw-r--r-- | .config/eww/eww.yuck | 7 | ||||
-rwxr-xr-x | .config/eww/scripts/wireless | 29 |
2 files changed, 32 insertions, 4 deletions
diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck index e599a52..08ac9c5 100644 --- a/.config/eww/eww.yuck +++ b/.config/eww/eww.yuck @@ -35,7 +35,7 @@ (defpoll battery :initial '{"icon":"","percentage":""}' :interval "1s" `scripts/battery`) -(defpoll wireless :interval "1s" +(defpoll wireless :initial '{"icon":"","ssid":""}' :interval "1s" `scripts/wireless`) ;; Windows @@ -97,11 +97,12 @@ :hexpand false :space-evenly false :width 30 - (label :text "") + ; (label :text "") + (label :text {wireless.icon}) (revealer :transition "slideright" :reveal wireless_rev :duration "350ms" - (label :text wireless))))) + (label :text {wireless.ssid}))))) (defwidget keymap [] (eventbox diff --git a/.config/eww/scripts/wireless b/.config/eww/scripts/wireless index 164fdbf..937aa28 100755 --- a/.config/eww/scripts/wireless +++ b/.config/eww/scripts/wireless @@ -1,3 +1,30 @@ #!/bin/sh -sudo wpa_cli status | sed -n 's/^ssid=//p' | ifne -n echo 'Not Connected' +export NOTIFY_SHORT=wireless +export NOTIFY_LONG=wireless + +readonly CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/eww-wireless" + +touch "$CACHE" + +ssid="$(sudo wpa_cli status | sed -n 's/^ssid=//p')" +read -r prev_ssid <"$CACHE" + +if [ "$ssid" != "$prev_ssid" ] +then + echo "$ssid" >"$CACHE" + if [ -z "$ssid" ] + then + notify 'Disconnected from the Network' \ + 'You are not connected to any network' + else + notify 'Connected to Network' "You are now connected to the network ‘$ssid’" + fi +fi + +if [ -n "$ssid" ] +then + jo icon= ssid="$ssid" +else + jo icon= ssid='Not Connected' +fi |