move net stuff to single script

This commit is contained in:
frosty 2024-07-04 16:48:07 -04:00
parent 83de97e20c
commit 676b63cd79
2 changed files with 23 additions and 3 deletions

View file

@ -4,11 +4,10 @@ Config
, bgColor = "#121212"
, fgColor = "#cccccc"
, position = Top
, template = " %XMonadLog% }{ <fc=#fc7932>%ip%</fc> @ %ssid% <fc=#777777>:</fc> VOL %volume% <fc=#777777>:</fc> %battery% <fc=#777777>:</fc> CPU %cpu% <fc=#777777>:</fc> RAM %memory% <fc=#777777>:</fc> %load% <fc=#777777>:</fc> <fc=#f7e83b>%date%</fc> "
, template = " %XMonadLog% }{ %network% <fc=#777777>:</fc> VOL %volume% <fc=#777777>:</fc> %battery% <fc=#777777>:</fc> CPU %cpu% <fc=#777777>:</fc> RAM %memory% <fc=#777777>:</fc> %load% <fc=#777777>:</fc> <fc=#f7e83b>%date%</fc> "
, commands =
[ Run XMonadLog
, Run Com "ipmon" [] "ip" 6000
, Run Com "ssidmon" [] "ssid" 6000
, Run Com "netmon" [] "network" 6000
, Run PipeReader "/tmp/pipe-volume" "volume"
, Run Com "batmon" [] "battery" 36000
, Run Com "cpumon" [] "cpu" 50

21
.local/bin/netmon Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
ADAPTER="wlan0"
address=$(ip route get 1)
address=${address#* via * dev * src }
address=${address% uid *}
ssid=
while read -r line; do
case $line in
*Connected\ network*)
ssid=${line##*Connected network}
ssid="${ssid#"${ssid%%[![:space:]]*}"}"
;;
esac
done <<EOF
$(iwctl station "$ADAPTER" show)
EOF
printf '<fc=#fc7932>%s</fc> @ %s\n' "$address" "$ssid"