-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpn
More file actions
executable file
·71 lines (65 loc) · 1.82 KB
/
vpn
File metadata and controls
executable file
·71 lines (65 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
# shellcheck disable=1090,2154
. "${XDG_CACHE_HOME:-$HOME/.cache}/wal/colors.sh"
blockcolor=$color7
txtcolor=$color8
mullvad_notify="notify-send -i ~/.local/bin/i3blocks/img/mullvad.png -h string:x-canonical-private-synchronous:i3bvpn"
case $BLOCK_BUTTON in
1) # Left Click
if mullvad status | grep -q Disconnected; then
$mullvad_notify "Connecting to mullvad"
mullvad connect
while mullvad status | grep -q 'Connecting\|Disconn'; do
sleep 1
done
$mullvad_notify "$(mullvad status)"
$mullvad_notify "$(mullvad status -l)"
else
$mullvad_notify "Disconnecting from mullvad"
mullvad disconnect
while mullvad status | grep -q Disconnecting; do
sleep 1
done
sleep 1
$mullvad_notify "$(mullvad status -l)"
fi
;;
2) # Middle Click
if systemctl is-active mullvad-daemon; then
$mullvad_notify "Stopping Mullvad Daemon"
sudo systemctl stop mullvad-daemon
else
$mullvad_notify "Starting Mullvad Daemon"
sudo systemctl start mullvad-daemon
fi
;;
3) # Right Click
$TERMINAL --class float -e fzfmullvad
;;
4 | 5) # Scroll Up/Down
$mullvad_notify "$(mullvad status)"
$mullvad_notify "$(mullvad status -l)"
;;
esac
if mullvad_status=$(mullvad status); then
if echo "$mullvad_status" | grep -q Connected; then
status=
location=$(echo "$mullvad_status" | awk -F'in' '{print $2}' | xargs)
location_color="$color10"
else
status=
location="UNSECURED"
location_color="$color9"
fi
else
status=X
location="ERROR"
fi
printf "<b><span foreground='%s' background='%s'></span>" \
"$blockcolor" "$color0"
printf "<span foreground='%s' background='%s'> %s</span>" \
"$txtcolor" "$blockcolor" "$status"
printf "<span foreground='%s' background='%s'> %s </span>" \
"$location_color" "$blockcolor" "$location"
printf "<span foreground='%s' background='%s'></span></b>\n" \
"$color0" "$blockcolor"