eww-pulse-listener 555 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env zsh
  2. function print-volume {
  3. let volume="$(pamixer --get-volume)"
  4. local icon
  5. if [[ "$(pamixer --get-mute)" = "true" ]]; then
  6. icon='󰸈'
  7. elif ((${volume} > 50)); then
  8. icon='󰕾'
  9. elif ((${volume} >= 0)); then
  10. icon='󰖀'
  11. else
  12. icon='?'
  13. fi
  14. printf '%s%3d%%\n' "${icon}" "${volume}"
  15. }
  16. print-volume
  17. pactl subscribe | \
  18. while read line; do
  19. case "${line}" in
  20. "Event 'change' on sink"*)
  21. print-volume
  22. ;;
  23. esac
  24. done