-
-
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
| This Scripts and Config Snippets are for a little Symbol in the Waybar. If you Click on the Tunnelsymbol the OpenVPN-Client | |
| establish a Connection to the given Config (Systemd Openvpn-Client). If you do not Need the Tunnel then you can Click again on | |
| the Symbol and the VPN-Tunnel gets closed. The following moving Parts are needed: | |
| 1. The Waybar Config Snippit | |
| 2. The Toggle/Status Script | |
| 3. The Polkit Rule to allow the control of the OpenVPN-Client systemd-Unit by given user (a sudo nopasswd is also possible but | |
| not so granular and allows systemctl completly) |
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
| polkit.addRule(function(action, subject) { | |
| if (action.id == "org.freedesktop.systemd1.manage-units" && | |
| action.lookup("unit") == "[email protected]" && | |
| subject.user == "bigfreak") { | |
| return polkit.Result.YES; | |
| } | |
| }); |
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": "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": "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] | |
| 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