add quick actions tab
This commit is contained in:
@@ -12,13 +12,14 @@ gen_output() {
|
||||
lvl=$(awk -v n="$percent" 'BEGIN{print int(n/34)}')
|
||||
sink_muted=$(ismuted "SINK")
|
||||
source_muted=$(ismuted "SOURCE")
|
||||
sink=$(wpctl inspect @DEFAULT_AUDIO_SINK@ 2>/dev/null | grep -m1 'node\.nick' | sed 's/.*= "\(.*\)"/\1/')
|
||||
|
||||
[ "$sink_muted" = 0 ] && icon="" || icon="${volicons[$lvl]}"
|
||||
[ "$sink_muted" = 0 ] && icon="" || icon="${volicons[$lvl]}"
|
||||
[ "$source_muted" = 0 ] && mic_icon="" || mic_icon=""
|
||||
|
||||
printf '{"icon":"%s","percent":%s,"sink_muted":%s,"mic_icon":"%s","microphone":%s,"source_muted":%s}\n' \
|
||||
printf '{"icon":"%s","percent":%s,"sink_muted":%s,"mic_icon":"%s","microphone":%s,"source_muted":%s,"sink":"%s"}\n' \
|
||||
"$icon" "$percent" "$([ "$sink_muted" = 0 ] && echo true || echo false)" \
|
||||
"$mic_icon" "$(vol SOURCE)" "$([ "$source_muted" = 0 ] && echo true || echo false)"
|
||||
"$mic_icon" "$(vol SOURCE)" "$([ "$source_muted" = 0 ] && echo true || echo false)" "$sink"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
@@ -26,7 +27,18 @@ case "$1" in
|
||||
setvol) setvol "$2" "$3" ;;
|
||||
*)
|
||||
gen_output
|
||||
pw-cli -m 2>/dev/null | rg --line-buffered "PipeWire:Interface:Client" | while read -r _; do
|
||||
|
||||
tmp=$(mktemp -d)
|
||||
pipe="$tmp/vol-events"
|
||||
mkfifo "$pipe"
|
||||
trap 'rm -rf "$tmp"; kill 0 2>/dev/null' EXIT INT TERM
|
||||
|
||||
# 1s polling fallback
|
||||
(while true; do sleep 1; echo poll; done) > "$pipe" &
|
||||
# PipeWire property-change events (fires on mute/volume change)
|
||||
(pw-cli -m 2>/dev/null | grep --line-buffered "changed") > "$pipe" &
|
||||
|
||||
while IFS= read -r _ < "$pipe"; do
|
||||
gen_output
|
||||
done
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user