feat(waybar): add config

This commit is contained in:
2026-03-12 17:43:03 +01:00
parent f82afb4611
commit d7cb42a64c
6 changed files with 498 additions and 0 deletions

12
waybar/scripts/mic-status.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# mic volume for waybar custom module
vol=$(pamixer --default-source --get-volume 2>/dev/null || echo 0)
muted=$(pamixer --default-source --get-mute 2>/dev/null || echo false)
if [[ "$muted" == "true" ]]; then
printf '{"text": "󰍭", "class": "muted", "tooltip": "mic muted"}\n'
else
printf '{"text": "󰍬 %d%%", "class": "", "tooltip": "mic %d%%"}\n' "$vol" "$vol"
fi

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# wrap swaync subscription, hide when no notifications
swaync-client -swb 2>/dev/null | while read -r line; do
count=$(echo "$line" | jq -r '.text // "0"')
class=$(echo "$line" | jq -r '.class // "none"')
if [[ "$count" == "0" ]]; then
echo '{"text": "", "class": "none"}'
else
jq -nc --arg text "󰂚 $count" --arg class "$class" '{$text,$class}'
fi
done

21
waybar/scripts/ssh-session.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# detect remote ssh sessions and optionally disconnect them
# outputs waybar JSON; empty when no remote sessions
if [[ "$1" == "disconnect" ]]; then
pkill -HUP -f 'sshd-session:.*@' 2>/dev/null
exit 0
fi
count=$(pgrep -cf 'sshd-session:.*@' 2>/dev/null || echo 0)
if [[ "$count" -gt 0 ]]; then
# get remote session details
sessions=$(who 2>/dev/null | awk '$NF ~ /\([0-9]/ {gsub(/[()]/, "", $NF); print $1 "@" $NF}')
tooltip=${sessions:-"$count remote sessions"}
# replace newlines with \n for valid JSON
tooltip=${tooltip//$'\n'/\\n}
tooltip=${tooltip//\"/\\\"}
printf '{"text": "●", "class": "active", "tooltip": "%s"}\n' "$tooltip"
fi

40
waybar/scripts/vpn-status.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# check wireguard and tailscale status
# outputs waybar JSON; empty when inactive
parts=()
tooltip_parts=()
if command -v wg &>/dev/null; then
ifaces=$(wg show interfaces 2>/dev/null)
if [[ -n "$ifaces" ]]; then
parts+=("󰖂")
tooltip_parts+=("wireguard: $ifaces")
fi
fi
if command -v tailscale &>/dev/null; then
ts_json=$(tailscale status --json 2>/dev/null)
state=$(jq -r '.BackendState // empty' <<<"$ts_json")
if [[ "$state" == "Running" ]]; then
ts_ip=$(jq -r '.TailscaleIPs[0] // empty' <<<"$ts_json")
ts_name=$(jq -r '.Self.HostName // empty' <<<"$ts_json")
ts_exit=$(jq -r '.ExitNodeStatus.ID // empty' <<<"$ts_json")
parts+=("󰒒")
tip="tailscale: ${ts_name} ${ts_ip}"
if [[ -n "$ts_exit" ]]; then
tip="$tip (exit node)"
fi
tooltip_parts+=("$tip")
fi
fi
if [[ ${#parts[@]} -gt 0 ]]; then
text="${parts[*]}"
tip=$(printf '%s\\n' "${tooltip_parts[@]}")
# strip trailing \n
tip=${tip%\\n}
jq -nc --arg text "$text" --arg tooltip "$tip" --arg class "active" \
'{$text,$class,$tooltip}'
fi