waybar: added pipewire listener for displaying audio status changes in real time
This commit is contained in:
@@ -201,6 +201,9 @@ riverctl spawn "wlclock --layer background --background-colour '#00000000' --clo
|
|||||||
#riverctl spawn "$HOME/.config/river/bar"
|
#riverctl spawn "$HOME/.config/river/bar"
|
||||||
riverctl spawn waybar
|
riverctl spawn waybar
|
||||||
|
|
||||||
|
# Start waybar audio listener
|
||||||
|
~/.local/bin/waybar_audio_event_bridge.sh &
|
||||||
|
|
||||||
# Idle configuration
|
# Idle configuration
|
||||||
riverctl spawn "swayidle -w timeout 1200 'wlopm --off \"*\"' resume 'wlopm --on \"*\"' before-sleep 'waylock -fork-on-lock'"
|
riverctl spawn "swayidle -w timeout 1200 'wlopm --off \"*\"' resume 'wlopm --on \"*\"' before-sleep 'waylock -fork-on-lock'"
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
"custom/audio": {
|
"custom/audio": {
|
||||||
"exec": "~/.local/bin/waybar_audio.sh",
|
"exec": "~/.local/bin/waybar_audio.sh",
|
||||||
|
"signal": 8,
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"format": "{icon} {text}",
|
"format": "{icon} {text}",
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
|
|||||||
26
.local/bin/waybar_audio_event_bridge.sh
Executable file
26
.local/bin/waybar_audio_event_bridge.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
SIG=8
|
||||||
|
|
||||||
|
get_waybar_pid() { pgrep -u "$USER" -x waybar | head -n1 || true; }
|
||||||
|
log() { echo "[waybar-audio-bridge] $*" >&2; }
|
||||||
|
|
||||||
|
WAYBAR_PID=""
|
||||||
|
while [[ -z "$WAYBAR_PID" ]]; do
|
||||||
|
WAYBAR_PID="$(get_waybar_pid)"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
log "connected to Waybar PID $WAYBAR_PID"
|
||||||
|
|
||||||
|
# read pw-mon output, but only care about Audio nodes
|
||||||
|
pw-mon 2>/dev/null | grep --line-buffered -E "Audio|Sink|Source|Stream|Node" | while read -r _; do
|
||||||
|
# small debounce to avoid spamming CPU when multiple updates arrive fast
|
||||||
|
sleep 0.2
|
||||||
|
if ! kill -0 "$WAYBAR_PID" 2>/dev/null; then
|
||||||
|
WAYBAR_PID="$(get_waybar_pid)"
|
||||||
|
[[ -z "$WAYBAR_PID" ]] && continue
|
||||||
|
log "reconnected to Waybar PID $WAYBAR_PID"
|
||||||
|
fi
|
||||||
|
kill -RTMIN+"$SIG" "$WAYBAR_PID" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
|
||||||
Reference in New Issue
Block a user