random-scripts/eww/eww-pulse-listener

29 lines
611 B
Plaintext
Raw Permalink Normal View History

2024-04-28 23:26:31 -07:00
#!/usr/bin/env zsh
function print-volume {
let volume="$(pamixer --get-volume)"
local icon
if [[ "$(pamixer --get-mute)" = "true" ]]; then
icon='󰸈'
2025-02-04 22:48:03 -08:00
elif (( ${volume} >= 50 )); then
2024-04-28 23:26:31 -07:00
icon='󰕾'
2025-02-04 22:48:03 -08:00
elif ((${volume} > 0)); then
2024-04-28 23:26:31 -07:00
icon='󰖀'
2025-02-04 22:48:03 -08:00
elif ((${volume} == 0)); then
icon='󰕿'
2024-04-28 23:26:31 -07:00
else
icon=''
fi
printf '%s%3d%%\n' "${icon}" "${volume}"
}
print-volume
pactl subscribe | \
while read line; do
case "${line}" in
"Event 'change' on sink"*)
print-volume
;;
esac
done