summaryrefslogtreecommitdiff
path: root/warp-vpn.sh
blob: 2a1207b97f026c02e2f88307f2838f258ce49625 (plain)
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
#!/bin/sh

function status() {
    # warp-cli status | grep -q "Connected" && echo "󰔡" || echo "󰨙"
    tmp=$(warp-cli status)
    if [[ $tmp == *"Connected"* ]]; then
        echo "󰔡"
    elif [[ "$tmp" == *"Connecting"* ]]; then
        echo "󰨚"
        sleep 0.1
        pkill -RTMIN+4 waybar
    elif [[ "$tmp" == *"Disconnected"* ]]; then
        echo "󰨙"
    # else
        # echo "󰨙"
    fi
}

function connect() {
    warp-cli connect && pkill -RTMIN+4 waybar
}

function toggle() {
    warp-cli status | grep -q "Connected" && disconnect || connect
    pkill -RTMIN+4 waybar
}

function disconnect() {
    warp-cli disconnect && pkill -RTMIN+4 waybar
}

if [ "$1" ]; then
    $@
    exit
fi