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.

osdmixer.sh 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. usage="usage: $0 -c {up|down|mute} [-i increment] [-m mixer]"
  3. command=
  4. increment=5%
  5. mixer=Master
  6. label=Volume
  7. while getopts i:m:h o
  8. do case "$o" in
  9. i) increment=$OPTARG;;
  10. m) mixer=$OPTARG;;
  11. h) echo "$usage"; exit 0;;
  12. ?) echo "$usage"; exit 0;;
  13. esac
  14. done
  15. shift $(($OPTIND - 1))
  16. command=$1
  17. if [ "$command" = "" ]; then
  18. echo "usage: $0 {up|down|mute} [increment]"
  19. exit 0;
  20. fi
  21. display_volume=0
  22. if [ "$command" = "up" ]; then
  23. display_volume=$(amixer set $mixer $increment+ unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
  24. fi
  25. if [ "$command" = "down" ]; then
  26. display_volume=$(amixer set $mixer $increment- unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
  27. fi
  28. icon_name=""
  29. if [ "$command" = "mute" ]; then
  30. if amixer get Master | grep "\[on\]"; then
  31. display_volume=0
  32. icon_name="notification-audio-volume-muted"
  33. amixer set $mixer mute
  34. else
  35. display_volume=$(amixer set $mixer unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
  36. fi
  37. fi
  38. if [ "$icon_name" = "" ]; then
  39. if [ "$display_volume" = "0" ]; then
  40. icon_name="notification-audio-volume-off"
  41. else
  42. if [ "$display_volume" -lt "33" ]; then
  43. icon_name="notification-audio-volume-low"
  44. else
  45. if [ "$display_volume" -lt "67" ]; then
  46. icon_name="notification-audio-volume-medium"
  47. else
  48. icon_name="notification-audio-volume-high"
  49. fi
  50. fi
  51. fi
  52. fi
  53. #notify-send " " -i $icon_name -h int:value:$display_volume -h string:synchronous:volume
  54. osd_cat -p bottom -A center -c purple -s 2 -S black -u black -O 6 -d 1 -f -*-profont-*-*-*-*-40-*-*-*-*-*-*-* -b percentage -P $display_volume -T $label