pointfichiers/bar/eww/scripts/vpn_status

27 lines
494 B
Text
Raw Normal View History

2024-03-05 19:47:48 +01:00
#!/bin/dash
config=/etc/wireguard/ovh.conf
interface_name="ovh"
2024-03-05 19:47:48 +01:00
is_connected (){
if ip link show up | grep -q "$interface_name"; then
2024-03-05 19:47:48 +01:00
echo "true"
else
echo "false"
2024-03-05 19:47:48 +01:00
fi
}
connected="$(is_connected)"
if [ "$1" = "toggle" ]; then
if [ "$connected" = "false" ]; then
sudo wg-quick up "$config" > /dev/null
2024-03-05 19:47:48 +01:00
else
sudo wg-quick down "$config" > /dev/null
2024-03-05 19:47:48 +01:00
fi
eww update vpn_status="{\"connected\": $(is_connected)}"
exit 0
fi
echo "{\"connected\": $(is_connected)}"