Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #!/bin/bash
  2. volume=$(amixer sget Master | grep -o -m 1 '[[:digit:]]*%' | tr -d '%')
  3.  
  4. if [ -n "$2" ]
  5. then
  6. percent_change=$2
  7. else
  8. percent_change=5
  9. fi
  10.  
  11. case "$1" in
  12. up)
  13. volume=$((volume + percent_change))
  14. if [ $volume -gt 100 ]
  15. then
  16. volume=100
  17. fi
  18. amixer sset Master $volume% unmute
  19. ;;
  20. down)
  21. volume=$((volume - percent_change))
  22. if [ $volume -lt 0 ]
  23. then
  24. volume=0
  25. fi
  26. amixer sset Master $volume% unmute
  27. ;;
  28. set)
  29. volume=$2
  30. amixer sset Master $volume% unmute
  31. ;;
  32. toggle)
  33. amixer sset Master toggle
  34. ;;
  35. mute)
  36. amixer sset Master mute
  37. ;;
  38. unmute)
  39. amixer sset Master unmute
  40. ;;
  41. esac
  42.  
  43. echo $volume
  44.  
  45. if [ -n "$(amixer sget Master | grep -o -m 1 'off')" ]
  46. then
  47. notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-muted-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
  48. elif [ "$volume" -eq "0" ]
  49. then
  50. notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-low-zero-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
  51. elif [ "$volume" -le "33" ]
  52. then
  53. notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-low-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
  54. elif [ "$volume" -lt "66" ]
  55. then
  56. notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-medium-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
  57. else
  58. notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-high-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement