pointfichiers/bar/eww/scripts/vpn_status

26 lines
494 B
Bash
Executable file

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