You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nmixer 770B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env sh
  2. #
  3. # pbrisbin 2013 - amixer with notifications.
  4. #
  5. ###
  6. mixer() {
  7. local cmd="$1" level state icon message
  8. body="$(amixer sset Master "$cmd" |\
  9. sed '/.*Mono: Playback .* \[\(.*\)%\] .* \[\(on\|off\)\].*/!d; s//\1 \2/')"
  10. level="${body% *}"
  11. state="${body#* }"
  12. if [ "$state" = 'on' ]; then
  13. icon='audio-volume-low'
  14. message="Level: $level%"
  15. [ $level -gt 33 ] && icon='audio-volume-medium'
  16. [ $level -gt 66 ] && icon='audio-volume-high'
  17. else
  18. icon='audio-volume-muted'
  19. message="Muted"
  20. fi
  21. notify-send -t 1250 -i "$icon" 'Volume' "$message"
  22. }
  23. case "$1" in
  24. up) mixer '3%+' ;;
  25. down) mixer '3%-' ;;
  26. toggle) mixer 'toggle';;
  27. *)
  28. printf "usage: nmixer [up|down|toggle]\n" >&2
  29. exit 64
  30. ;;
  31. esac