Skip to content

Instantly share code, notes, and snippets.

@f0xmulder
Forked from bigfreak85/1 Waybar OpenVPN Toggler
Created September 2, 2024 01:42
Show Gist options
  • Select an option

  • Save f0xmulder/c81b9f8351e291d12e11c58803eb817b to your computer and use it in GitHub Desktop.

Select an option

Save f0xmulder/c81b9f8351e291d12e11c58803eb817b to your computer and use it in GitHub Desktop.
Waybar Plugin openvpn toggler Shellscript for start/stop/status openvpn client (Systemd-unit)
"custom/vpn": {
"format": "{}",
"exec": "sudo bash /home/bigfreak/.config/sway/tools/vpnupdown status",
// "exec-if": "test -d /proc/sys/net/ipv4/conf/tun0",
"tooltip": "true",
"return-type": "json",
"interval": 1,
"on-click": "sudo bash /home/bigfreak/.config/sway/tools/vpnupdown toggle"
},
# ******************************************************** #
# #
# #
# vpnupdown #
# #
# By: Raffael Willems <[email protected]> #
# #
# Created: 2023/12/06 13:46:41 by Raffael Willems #
# Updated: 2023/12/06 21:48:41 by Raffael Willems #
# #
# ******************************************************** #
#!/bin/bash
STATUS="$(systemctl is-active [email protected])"
if [ "${STATUS}" = "inactive" ]; then
if [ $1 = 'toggle' ]; then
systemctl start [email protected]
sleep 1
ip route del 192.168.0.0/24 dev tun0
text="{\"text\":\"󱠽 \",\"class\":\"enabled\"}"
fi
text="{\"text\":\"󱠾\",\"tooltip\":\"imc closed\"}"
else
if [ $1 = 'toggle' ]; then
systemctl stop [email protected]
text="{\"text\":\"󱠾\",\"tooltip\":\"imc closed\"}"
fi
ADDR="$(ip -br addr show dev tun0 | awk '{ print $3 }')"
text="{\"text\":\"󱠽 \",\"class\":\"enabled\",\"tooltip\":\"$ADDR\"}"
fi
echo $text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment