shortcut for toggling vpn

This commit is contained in:
Michael Zhang 2020-11-20 23:54:18 -06:00
parent 39930f86ce
commit d38b1d46f7
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
2 changed files with 25 additions and 1 deletions

View file

@ -27,7 +27,7 @@ bindsym ctrl+Print exec $HOME/.local/scripts/screenshot.sh fullscreen
bindsym shift+Print exec $HOME/.local/scripts/screenshot.sh window
bindsym $mod+p exec $HOME/.local/scripts/passmenu.sh
bindsym $mod+semicolon exec alacritty -e nvim $HOME/todos.md
bindsym $mod+m exec alacritty -e aerc
bindsym $mod+m exec $HOME/.local/scripts/toggle-vpn.sh sift-vpn-mzhang
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.

View file

@ -0,0 +1,24 @@
#!/bin/bash
# https://robertbasic.com/blog/toggle-a-vpn-connection/
VPN=$1
if [ -z "$VPN" ]
then
exit 1
fi
ACTIVE=`nmcli con show --active | grep "$VPN"`
if [ -z "$ACTIVE" ]
then
nmcli con up id "$VPN"
notify-send "connected to $VPN"
else
nmcli con down id "$VPN"
notify-send "disconnected from $VPN"
fi
exit 0