dotfiles/de/home/.config/eww/scripts/bar/networking
2025-03-12 19:15:01 -07:00

33 lines
879 B
Bash
Executable file

#!/bin/bash
function ifstatus(){
is_wireless=false
is_ethernet=false
is_proton=false
is_homevpn=false
if nmcli -g TYPE connection show --active | grep -q "wireless";then
is_wireless='true'
fi
if nmcli -g TYPE connection show --active | grep -q "ethernet";then
is_ethernet='true'
fi
if nmcli -g TYPE,NAME connection show --active | grep -e "vpn" -e "wireguard" | grep -qi "proton";then
is_proton='true'
fi
if nmcli -g TYPE,NAME connection show --active | grep -e "vpn" -e "wireguard" | grep -qi "home";then
is_homevpn='true'
fi
echo $(jq -n --arg wifi "${is_wireless}" --arg wired "${is_ethernet}" --arg proton "${is_proton}" --arg homevpn "${is_homevpn}" '{wifi: $wifi, wired: $wired, proton: $proton, homevpn: $homevpn}')
}
ifstatus
ip monitor address | {
while read -r event; do
# echo hi ${event};
ifstatus
done;
}