diff options
| author | ryukamish <[email protected]> | 2026-06-25 13:09:25 +0530 |
|---|---|---|
| committer | ryukamish <[email protected]> | 2026-06-25 13:09:25 +0530 |
| commit | b7535c43ee05e543842ea55da66c31aa444ea7af (patch) | |
| tree | 1d331f3a63d5312d16656970c7c7c77f1a31fba0 | |
| parent | 88ad6b51e3ed35a6c0f4e243be67b528ba991dc5 (diff) | |
fix: only show the status of vpn connection
| -rw-r--r-- | .config/waybar/config.jsonc | 2 | ||||
| -rwxr-xr-x | .local/bin/waybar-vpn | 35 |
2 files changed, 7 insertions, 30 deletions
diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 50bd582..898d5ea 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -80,7 +80,7 @@ }, "custom/vpn": { "format": "VPN: <span color='#aaaaaa'>{}</span>", - "exec": "~/.local/bin/waybar-vpn status", + "exec": "~/.local/bin/waybar-vpn", "return-type": "json", "interval": 30 }, diff --git a/.local/bin/waybar-vpn b/.local/bin/waybar-vpn index 008e743..f746aec 100755 --- a/.local/bin/waybar-vpn +++ b/.local/bin/waybar-vpn @@ -1,31 +1,8 @@ #!/bin/sh -# first user argument -cmd="$1" - -case "$cmd" in - connect) - # TODO: handle root permission password input - if [ -n $(type "nmcli") ]; then - nmcli connection show --active \ - rg -i 'wireguard' - fi - ;; - disconnect) - # `wg-quick` requires root permission to disconnect - # don't have the solution right now - ;; - status) - vpn=$(nmcli connection show --active | rg -i 'wireguard' | awk '{print $1}') - if [ -n "$vpn" ]; then - printf "{\"text\": \"$vpn\", \"class\": \"wireguard\", \"alt\": \"disconnected\" }\n" - else - printf "{\"text\": \"DC'D\", \"class\": \"wireguard\", \"alt\": \"disconnected\" }\n" - fi - ;; - *) - # print usage if not used with any of the below three commands - echo -e "Usage: %s {status|connect|disconnect}\n" - exit 1 - ;; -esac +vpn=$(nmcli connection show --active | rg -i 'wireguard' | awk '{print $1}') +if [ -n "$vpn" ]; then + printf "{\"text\": \"$vpn\", \"class\": \"wireguard\", \"alt\": \"disconnected\" }\n" +else + printf "{\"text\": \"DC'D\", \"class\": \"wireguard\", \"alt\": \"disconnected\" }\n" +fi |
