dotfiles/de/home/.config/eww/scripts/bar/networking
2025-08-31 14:00:02 -07:00

50 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
function ifstatus(){
is_wireless=false
is_ethernet=false
is_proton=false
is_proton_sc=false
is_homevpn=false
is_homevpn_full=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
vpn_cons=$(nmcli -g TYPE,NAME connection show --active | grep -e "vpn" -e "wireguard")
case ${vpn_cons} in
*ProtonVPN)
is_proton='true'
;;
*ProtonVPN-SC)
is_proton_sc='true'
;;
esac
# if grep -qe "ProtonVPN$" <<<${vpn_cons};then
# is_proton='true'
# fi
# if grep -qe "ProtonVPN-SC$" <<<${vpn_cons};then
# is_proton_sc='true'
# fi
# if grep -qe "HomeVPN$" <<<${vpn_cons};then
# is_homevpn='true'
# fi
# if grep -qe "HomeVPN-Full$" <<<${vpn_cons};then
# is_homevpn_full='true'
# fi
echo $(jq -n --arg wifi "${is_wireless}" --arg wired "${is_ethernet}" --arg proton "${is_proton}" --arg proton_sc "${is_proton_sc}" --arg homevpn "${is_homevpn}" --arg homevpn_full "${is_homevpn_full}" '{wifi: $wifi, wired: $wired, proton: $proton, proton_sc: $proton_sc, homevpn: $homevpn, homevpn_full: $homevpn_full}')
}
ifstatus
ip monitor address | {
while read -r event; do
# echo hi ${event};
ifstatus
done;
}