aboutsummaryrefslogtreecommitdiff
path: root/dotfiles
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-05-03 23:54:41 +0300
committerYaroslav <contact@yaroslavps.com>2020-05-03 23:54:41 +0300
commit49d23f11f49daccf49e9c6cc9e7eabd6f4b4bfe4 (patch)
tree05fcb5719f4d9dd63e3e0d6811a30be9548e5b8e /dotfiles
parentff88fbca675945015a0c59b18be65b74cdd7d989 (diff)
downloadswayrice-49d23f11f49daccf49e9c6cc9e7eabd6f4b4bfe4.tar.gz
swayrice-49d23f11f49daccf49e9c6cc9e7eabd6f4b4bfe4.zip
goodbye openvpn, hello wireguard
Diffstat (limited to 'dotfiles')
-rw-r--r--dotfiles/.config/waybar/config2
-rwxr-xr-xdotfiles/.local/bin/addwgprofile3
-rwxr-xr-xdotfiles/.local/bin/barvpnstatus16
-rwxr-xr-xdotfiles/.local/bin/togglevpn24
4 files changed, 20 insertions, 25 deletions
diff --git a/dotfiles/.config/waybar/config b/dotfiles/.config/waybar/config
index bf558dd..95d1f84 100644
--- a/dotfiles/.config/waybar/config
+++ b/dotfiles/.config/waybar/config
@@ -174,8 +174,6 @@
},
"custom/vpn-status": {
"format": "<span color=\"#5b8277\">{}</span>",
- "signal": 6,
- "interval": "once",
"exec": "barvpnstatus"
},
"custom/mail-status": {
diff --git a/dotfiles/.local/bin/addwgprofile b/dotfiles/.local/bin/addwgprofile
new file mode 100755
index 0000000..7d0874c
--- /dev/null
+++ b/dotfiles/.local/bin/addwgprofile
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nmcli connection import type wireguard file ~/.config/wg0.conf
diff --git a/dotfiles/.local/bin/barvpnstatus b/dotfiles/.local/bin/barvpnstatus
index 7850d94..cca0201 100755
--- a/dotfiles/.local/bin/barvpnstatus
+++ b/dotfiles/.local/bin/barvpnstatus
@@ -1,9 +1,15 @@
#!/bin/sh
-if [ -f "$HOME/.cache/openvpnpid" ]; then
- printf " vpn"
- exit
-fi
+isup=$(ip a | grep wg0:)
-printf ""
+if [ -n "$isup" ]; then
+ printf " vpn\n"
+else
+ printf ""
+fi
+# For some goddamned weird reason sed crashes with a
+# "couldn't flush stdout: broken pipe" error when running from waybar itself
+# if I don't call sed from its hard location, so I had to call it using
+# /usr/bin/sed
+nmcli monitor | grep -E --line-buffered 'wg0: connected|wg0: disconnected' | /usr/bin/sed --unbuffered 's/wg0: connected/ vpn/g;s/wg0: disconnected//g'
diff --git a/dotfiles/.local/bin/togglevpn b/dotfiles/.local/bin/togglevpn
index f4dc1f1..0bdeacb 100755
--- a/dotfiles/.local/bin/togglevpn
+++ b/dotfiles/.local/bin/togglevpn
@@ -1,22 +1,10 @@
#!/bin/sh
-if [ -f "$HOME/.cache/openvpnpid" ]; then
- rm ~/.cache/openvpnpid
- sudo killall -SIGINT openvpn
- exit
-fi
+isup=$(ip a | grep wg0:)
-if [ ! -f "$HOME/.config/ovpn/conf.ovpn" ]; then
- notify-send " OpenVPN" "Can't start VPN. Configuration file is missing"
- exit
+if [ -z "$isup" ]; then
+ nmcli connection up wg0 && notify-send " VPN" "Wireguard VPN tunnel established" && exit
+ notify-send " VPN" "Error while trying to start Wireguard tunnel"
fi
-
-sudo openvpn "$HOME/.config/ovpn/conf.ovpn" &
-PID=$!
-notify-send " OpenVPN" "VPN is being initialized"
-echo $PID > ~/.cache/openvpnpid
-killall -40 waybar
-wait $PID
-notify-send " OpenVPN" "VPN service has stopped with exit code $?"
-rm -f ~/.cache/openvpnpid
-killall -40 waybar
+nmcli connection down wg0 && notify-send " VPN" "Wireguard VPN tunnel brought down" && exit
+notify-send " VPN" "Error while trying to close Wireguard tunnel"