diff options
| -rw-r--r-- | config/waybar/config.jsonc | 92 | ||||
| -rwxr-xr-x | config/waybar/scripts/mullvad.sh | 38 | ||||
| -rwxr-xr-x | config/waybar/scripts/tailscale.sh | 39 | ||||
| -rw-r--r-- | config/waybar/style.css | 23 |
4 files changed, 159 insertions, 33 deletions
diff --git a/config/waybar/config.jsonc b/config/waybar/config.jsonc index 3ff0099..cb1b8b9 100644 --- a/config/waybar/config.jsonc +++ b/config/waybar/config.jsonc @@ -9,9 +9,10 @@ ], "modules-right": [ "idle_inhibitor", + "custom/mullvad", "custom/tailscale", - "pulseaudio", "network", + "pulseaudio", "power-profiles-daemon", "battery", "clock", @@ -19,10 +20,10 @@ "custom/power" ], "idle_inhibitor": { - "format": "<span font-family='Font Awesome 6 Free'>{icon}</span>", + "format": "{icon}", "format-icons": { - "activated": "", - "deactivated": "" + "activated": "SLP", + "deactivated": "CAF" } }, "clock": { @@ -34,40 +35,41 @@ "warning": 30, "critical": 10 }, - "format": "{capacity}% <span font-family='Font Awesome 6 Free'>{icon}</span>", - "format-full": "{capacity}% <span font-family='Font Awesome 6 Free'>{icon}</span>", - "format-charging": "{capacity}% <span font-family='Font Awesome 6 Free'></span>", - "format-plugged": "{capacity}% <span font-family='Font Awesome 6 Free'></span>", + "format": "{capacity} {icon}", + "format-full": "{capacity} {icon}", + "format-charging": "{capacity} 🜹", + "format-plugged": "{capacity} 🜙", "format-alt": "{time} <span font-family='Font Awesome 6 Free'>{icon}</span>", - "format-icons": ["", "", "", "", ""] + "format-icons": ["🝙"] }, "network": { - "format-wifi": "{essid} ", + "format-wifi": "<span font-weight='900'>{icon}</span>", "format-ethernet": "{ipaddr}/{cidr} <span font-family='Font Awesome 6 Free'></span>", "tooltip-format": "{essid} ({signalStrength}%) \n{ifname} via {gwaddr} <span font-family='Font Awesome 6 Free'></span>\n{ipaddr}/{cidr}", "format-linked": "{ifname} (No IP) <span font-family='Font Awesome 6 Free'></span>", "format-disconnected": "Disconnected <span font-family='Font Awesome 6 Free'>⚠</span>", - "format-alt": "{ifname}: {ipaddr}/{cidr}" + "format-alt": "{ifname}: {ipaddr}/{cidr}", + "format-icons": ["․", ":", "⸪", "⁛"] }, "power-profiles-daemon": { - "format": "<span font-family='Font Awesome 6 Free'>{icon}</span>", + "format": "{icon}", "tooltip-format": "Power profile: {profile}\nDriver: {driver}", "tooltip": true, "format-icons": { - "default": "", - "performance": "", - "balanced": "", - "power-saver": "" + "default": "⊠", + "performance": "⊠", + "balanced": "⊞", + "power-saver": "⊟" } }, "pulseaudio": { // "scroll-step": 1, // %, can be a float - "format": "{volume}% <span font-family='Font Awesome 6 Free'>{icon}</span> {format_source}", - "format-bluetooth": "{volume}% <span font-family='Font Awesome 6 Free'>{icon}</span> {format_source}", - "format-bluetooth-muted": "<span font-family='Font Awesome 6 Free'> {icon}</span> {format_source}", - "format-muted": "<span font-family='Font Awesome 6 Free'></span> {format_source}", - "format-source": "{volume}% <span font-family='Font Awesome 6 Free'></span>", - "format-source-muted": "<span font-family='Font Awesome 6 Free'></span>", + "format": "{volume} {icon} {format_source}", + "format-bluetooth": "{volume} {icon} {format_source}", + "format-bluetooth-muted": "×× {icon} {format_source}", + "format-muted": "×× ⌾ {format_source}", + "format-source": "{volume} ⌽", + "format-source-muted": "×× ⌽", "format-icons": { "headphone": "", "hands-free": "", @@ -75,12 +77,12 @@ "phone": "", "portable": "", "car": "", - "default": ["", "", ""] + "default": ["⌾"] }, "on-click": "pavucontrol" }, "custom/power": { - "format" : "<span font-family='Font Awesome 6 Free'> ⏻ </span>", + "format" : " ⍜ ", "tooltip": false, "menu": "on-click", "menu-file": "$HOME/.config/waybar/power_menu.xml", // Menu file in resources folder @@ -92,9 +94,9 @@ } }, "mpd": { - "format": " {stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {title}", - "format-disconnected": "⨯", - "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ", + "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {title}", + "format-disconnected": "DSC", + "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}STP", "unknown-tag": "N/A", "interval": 5, "consume-icons": { @@ -102,19 +104,45 @@ }, "random-icons": { "off": "", - "on": " " + "on": "⯴" }, "repeat-icons": { - "on": " " + "on": "🜄" }, "single-icons": { - "on": "1 " + "on": "🜃" }, "state-icons": { - "paused": "", - "playing": "" + "paused": "<span font-weight='600'>PAUSE</span>", + "playing": "" }, "tooltip-format": "{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}%", "tooltip-format-disconnected": "MPD (disconnected)" }, + "custom/tailscale" : { + "exec": "~/.config/waybar/scripts/tailscale.sh --status", + "on-click": "exec ~/.config/waybar/scripts/tailscale.sh --toggle", + "exec-on-event": true, + "format": " {icon} ", + "format-icons": { + "connected": "Τ", + "stopped": " 𝈜 " + }, + "tooltip": true, + "return-type": "json", + "interval": 3, + }, + "custom/mullvad" : { + "exec": "~/.config/waybar/scripts/mullvad.sh --status", + "on-click": "exec ~/.config/waybar/scripts/mullvad.sh --toggle", + "exec-on-event": true, + "format": "<span font-weight='900'> {icon} </span>", + "format-icons": { + "connected": "⛧", + "disconnected": "⛤" + }, + "tooltip": true, + "return-type": "json", + "interval": 3, + } } diff --git a/config/waybar/scripts/mullvad.sh b/config/waybar/scripts/mullvad.sh new file mode 100755 index 0000000..f73cf5b --- /dev/null +++ b/config/waybar/scripts/mullvad.sh @@ -0,0 +1,38 @@ +#!/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 + sleep 5 +} + +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/scripts/tailscale.sh b/config/waybar/scripts/tailscale.sh new file mode 100755 index 0000000..e2e1deb --- /dev/null +++ b/config/waybar/scripts/tailscale.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +STATUS_KEY="BackendState" +RUNNING="Running" + +tailscale_status () { + status="$(tailscale status --json | jq -r '.'$STATUS_KEY)" + if [ "$status" = $RUNNING ]; then + return 0 + fi + return 1 +} + +toggle_status () { + if tailscale_status; then + tailscale down + else + tailscale up + fi + sleep 5 +} + +case $1 in + --status) + if tailscale_status; then + T=${2:-"green"} + F=${3:-"red"} + + peers=$(tailscale status --json | jq -r --arg T "'$T'" --arg F "'$F'" '.Peer[] | ("<span color=" + (if .Online then $T else $F end) + ">" + (.DNSName | split(".")[0]) + "</span>")' | tr '\n' '\r') + exitnode=$(tailscale status --json | jq -r '.Peer[] | select(.ExitNode == true).DNSName | split(".")[0]') + echo "{\"text\":\"${exitnode}\",\"class\":\"connected\",\"alt\":\"connected\", \"tooltip\": \"${peers}\"}" + else + echo "{\"text\":\"\",\"class\":\"stopped\",\"alt\":\"stopped\", \"tooltip\": \"Tailscale is not active.\"}" + fi + ;; + --toggle) + toggle_status + ;; +esac diff --git a/config/waybar/style.css b/config/waybar/style.css index dd53eff..dac1db3 100644 --- a/config/waybar/style.css +++ b/config/waybar/style.css @@ -4,7 +4,8 @@ } window#waybar { - background-color: #0F261F; + /* background-color: #0F261F; */ + background-color: rgba(15, 38, 31, 0.95); color: #DAE6E3; transition-property: background-color; transition-duration: .5s; @@ -109,3 +110,23 @@ button:hover { color: #0F261F; background-color: #FAED8F; } + +#custom-tailscale.connected { + color: #0F261F; + background-color: #80FFCC; +} + +#custom-tailscale.stopped { + color: #0F261F; + background-color: #90A6A2; +} + +#custom-mullvad.connected { + color: #0F261F; + background-color: #FFB4F0; +} + +#custom-mullvad.disconnected { + color: #0F261F; + background-color: #B5D1CC; +} |