eww-pulse-listener 611 B

1234567891011121314151617181920212223242526272829
  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. elif ((${volume} == 0)); then
  12. icon='󰕿'
  13. else
  14. icon='?'
  15. fi
  16. printf '%s%3d%%\n' "${icon}" "${volume}"
  17. }
  18. print-volume
  19. pactl subscribe | \
  20. while read line; do
  21. case "${line}" in
  22. "Event 'change' on sink"*)
  23. print-volume
  24. ;;
  25. esac
  26. done