diff options
Diffstat (limited to 'dot_config/waybar/executable_vpn-toggle.sh')
| -rw-r--r-- | dot_config/waybar/executable_vpn-toggle.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dot_config/waybar/executable_vpn-toggle.sh b/dot_config/waybar/executable_vpn-toggle.sh new file mode 100644 index 0000000..df13a3d --- /dev/null +++ b/dot_config/waybar/executable_vpn-toggle.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Toggle the wireguard interface managed by systemd-networkd. Polkit +# rule (etc/polkit-1/rules.d/50-networkd-wheel.rules) lets wheel-group +# members invoke networkctl up/down without a password prompt. +# +# After the state change, send SIGRTMIN+8 to waybar so the custom/vpn +# module refreshes immediately instead of waiting for the next interval. + +set -eu + +iface=hodor + +if ip link show "$iface" 2>/dev/null | grep -qE '<[^>]*\<UP\>'; then + networkctl down "$iface" +else + networkctl up "$iface" +fi + +# Refresh waybar's custom/vpn module right away. +pid=$(pidof waybar || true) +[ -n "$pid" ] && kill -SIGRTMIN+8 "$pid" 2>/dev/null || true |
