refactor(eww): Now use nmcli for network info

This commit is contained in:
GaspardCulis 2024-10-12 19:23:25 +02:00
parent a5df1080c8
commit 4277531d56
3 changed files with 5 additions and 4 deletions

View file

@ -53,7 +53,6 @@
(defwidget connectivity [] (defwidget connectivity []
(eventbox (eventbox
:onclick "bash -c 'iwgtk &> /dev/null &'"
(label (label
:class "connectivity" :class "connectivity"
:text "${ :text "${

View file

@ -11,7 +11,6 @@
home.packages = [ home.packages = [
pkgs.eww pkgs.eww
# Script dependencies # Script dependencies
pkgs.iw
pkgs.jq pkgs.jq
pkgs.dash pkgs.dash
pkgs.socat pkgs.socat

View file

@ -9,6 +9,9 @@ print_network_state() {
wlan*) wlan*)
echo wireless echo wireless
;; ;;
wlp*)
echo wireless
;;
usb*) usb*)
echo tethering echo tethering
;; ;;
@ -36,10 +39,10 @@ print_network_infos() {
"$(echo "$route_line" | awk '{ print $3 }')" "$(echo "$route_line" | awk '{ print $3 }')"
if [ "$state" = wireless ]; then if [ "$state" = wireless ]; then
signal=$(iw dev "$1" link | awk '($1 == "signal:") { print $2}') signal=$(nmcli -m multiline device wifi | grep '^\s*SIGNAL: ' | xargs | cut -d \ -f 2)
printf ',"wifi":{"signal":"%s","ssid":"%s"}' \ printf ',"wifi":{"signal":"%s","ssid":"%s"}' \
"$(wifi_strength "$signal")" \ "$(wifi_strength "$signal")" \
"$(iw dev wlan0 info | grep '^\s*ssid ' | xargs | cut -d \ -f 2-)" "$(nmcli -m multiline device wifi | grep '^\s*SSID: ' | xargs | cut -d \ -f 2)"
fi fi
fi fi
} }