From 51b27719a444764872f018a56e36ff406e892b27 Mon Sep 17 00:00:00 2001 From: Rubén Beltrán del Río Date: Tue, 14 Jul 2026 15:02:51 +0200 Subject: Update waybar config --- config/waybar/config.jsonc | 21 ++++++++++++--------- config/waybar/power_menu.xml | 5 +++++ config/waybar/scripts/ivpn.sh | 38 ++++++++++++++++++++++++++++++++++++++ config/waybar/scripts/mullvad.sh | 37 ------------------------------------- config/waybar/style.css | 8 ++++---- 5 files changed, 59 insertions(+), 50 deletions(-) create mode 100755 config/waybar/scripts/ivpn.sh delete mode 100755 config/waybar/scripts/mullvad.sh diff --git a/config/waybar/config.jsonc b/config/waybar/config.jsonc index 48bedc7..2a9c8b3 100644 --- a/config/waybar/config.jsonc +++ b/config/waybar/config.jsonc @@ -11,7 +11,7 @@ ], "modules-right": [ "idle_inhibitor", - "custom/mullvad", + "custom/ivpn", "custom/tailscale", "wireplumber", "custom/builds", @@ -105,8 +105,9 @@ "menu": "on-click", "menu-file": "$HOME/.config/waybar/power_menu.xml", // Menu file in resources folder "menu-actions": { - "shutdown": "shutdown", - "reboot": "reboot", + "logout": "niri msg action quit --skkip-confirmation", + "shutdown": "systemctl poweroff", + "reboot": "systemctl reboot", "suspend": "systemctl suspend", "hibernate": "systemctl hibernate" } @@ -117,7 +118,7 @@ "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}STP", "unknown-tag": "N/A", "interval": 5, - "timeout": "5", + "timeout": 5, "consume-icons": { "on": " " }, @@ -136,7 +137,9 @@ "playing": "" }, "tooltip-format": "{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}%", - "tooltip-format-disconnected": "MPD (disconnected)" + "tooltip-format-disconnected": "MPD (disconnected)", + "server": "music.bdr.place", + "port": 6600 }, "niri/language": { "format": "{short}" @@ -154,9 +157,9 @@ "return-type": "json", "interval": 3, }, - "custom/mullvad" : { - "exec": "~/.config/waybar/scripts/mullvad.sh --status", - "on-click": "~/.config/waybar/scripts/mullvad.sh --toggle", + "custom/ivpn" : { + "exec": "~/.config/waybar/scripts/ivpn.sh --status", + "on-click": "~/.config/waybar/scripts/ivpn.sh --toggle", "exec-on-event": true, "format": " {icon} ", "format-icons": { @@ -172,7 +175,7 @@ "icons": { "bitwarden": "/home/rbdr/.local/share/icons/Iconoir/pentagon.png", "signal desktop": "/home/rbdr/.local/share/icons/Iconoir/hexagon.png", - "mullvad vpn": "/home/rbdr/.local/share/icons/Iconoir/rhombus.png", + "ivpn": "/home/rbdr/.local/share/icons/Iconoir/rhombus.png", "Betterbird-systray-icon": "/home/rbdr/.local/share/icons/Iconoir/rhombus.png", "opensnitch-ui": "/home/rbdr/.local/share/icons/Iconoir/four-rhombuses.png", } diff --git a/config/waybar/power_menu.xml b/config/waybar/power_menu.xml index aa2a42c..c1a2ed5 100644 --- a/config/waybar/power_menu.xml +++ b/config/waybar/power_menu.xml @@ -1,6 +1,11 @@ + + + Log Out + + Suspend diff --git a/config/waybar/scripts/ivpn.sh b/config/waybar/scripts/ivpn.sh new file mode 100755 index 0000000..9ff88fc --- /dev/null +++ b/config/waybar/scripts/ivpn.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +ivpn_status_output () { + ivpn status +} + +ivpn_connected () { + ivpn status | grep -q '^VPN.*: CONNECTED' +} + +toggle_status () { + if ivpn_connected; then + ivpn disconnect + else + ivpn connect -f + fi +} + +case $1 in + --status) + status_output="$(ivpn_status_output)" + if echo "$status_output" | grep -q '^VPN.*: CONNECTED'; then + # Line after "VPN : CONNECTED" holds server + location, + # e.g. "de.gw.ivpn.net [de3.gw.ivpn.net], Frankfurt (DE), Germany" + server_line=$(echo "$status_output" | awk '/^VPN.*CONNECTED/{getline; sub(/^[ \t]+/, ""); print}') + protocol=$(echo "$status_output" | awk -F': ' '/^[ \t]*Protocol/{print $2}') + server_ip=$(echo "$status_output" | awk -F': ' '/^[ \t]*Server IP/{print $2}') + endpoint="${server_line%%,*} (${protocol})" + location="${server_line#*, } (${server_ip})" + echo "{\"text\":\"\",\"class\":\"connected\",\"alt\":\"connected\", \"tooltip\": \"${endpoint}\\n${location}\"}" + else + echo "{\"text\":\"\",\"class\":\"disconnected\",\"alt\":\"disconnected\", \"tooltip\": \"VPN is not active.\"}" + fi + ;; + --toggle) + toggle_status + ;; +esac diff --git a/config/waybar/scripts/mullvad.sh b/config/waybar/scripts/mullvad.sh deleted file mode 100755 index e02bb2f..0000000 --- a/config/waybar/scripts/mullvad.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -STATUS_KEY="state" -RUNNING="connected" - -mullvad_status () { - status="$(mullvad status --json | jq -r '.'$STATUS_KEY)" - if [ "$status" = $RUNNING ]; then - return 0 - fi - return 1 -} - -toggle_status () { - if mullvad_status; then - mullvad disconnect - else - mullvad connect - fi -} - -case $1 in - --status) - if mullvad_status; then - status_json=$(mullvad status --json) - endpoint=$(echo "$status_json" | jq -r '.details.endpoint | "\(.tunnel_interface) (\(.tunnel_type))"') - location=$(echo "$status_json" | jq -r '.details.location | "\(.country), \(.city) (\(.ipv4))"') - echo "{\"text\":\"\",\"class\":\"connected\",\"alt\":\"connected\", \"tooltip\": \"${endpoint}\\n${location}\"}" - else - echo "{\"text\":\"\",\"class\":\"disconnected\",\"alt\":\"disconnected\", \"tooltip\": \"VPN is not active.\"}" - fi - ;; - --toggle) - toggle_status - ;; -esac - diff --git a/config/waybar/style.css b/config/waybar/style.css index 8a2b108..8526488 100644 --- a/config/waybar/style.css +++ b/config/waybar/style.css @@ -133,7 +133,7 @@ button:hover { margin-right: 8px; } -#custom-mullvad, +#custom-ivpn, #custom-tailscale { padding: 0 2px; } @@ -148,16 +148,16 @@ button:hover { background-color: #90A6A2; } -#custom-mullvad { +#custom-ivpn { padding-bottom: 3px; } -#custom-mullvad.connected { +#custom-ivpn.connected { color: #0F261F; background-color: #FFB4F0; } -#custom-mullvad.disconnected { +#custom-ivpn.disconnected { color: #0F261F; background-color: #B5D1CC; } -- cgit