-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "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" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ******************************************************** # | |
| # # | |
| # # | |
| # 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