blob: c3489711a8e34ee234ec8259e744e58225e96f65 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
if [ -n "$pid" ]; then kill -SIGRTMIN+8 "$pid" 2>/dev/null || true; fi
|