aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_snx-vpn-toggle.sh
blob: c21643b75f79e67167dd1a8ed20a17933a2d90bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# Toggle the snx-rs (Check Point) tunnel.
#
# Refresh the waybar custom/snx-vpn module immediately with SIGRTMIN+9.
set -eu

state=$(timeout 2 snxctl status 2>/dev/null || echo Disconnected)

case "$state" in
  *"Disconnected"*)
    setsid -f snxctl connect >/tmp/snxctl.log 2>&1 &
    ;;
  *)
    snxctl disconnect >/dev/null 2>&1 || true
    ;;
esac

pid=$(pidof waybar || true)
if [ -n "$pid" ]; then kill -SIGRTMIN+9 "$pid" 2>/dev/null || true; fi