Advertisement
geyslan

pa_sink_volume (pulseaudio volume controller)

May 23rd, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # pulseaudio volume controller
  5. # written by Geyslan G. Bem
  6. #
  7.  
  8. script=$(basename "$0")
  9. sinks=$(pacmd list-sinks | awk '/index: / { gsub(/*/, "", $0); print $2 }')
  10. opt=$1
  11. vol=${2:-5}
  12.  
  13. usage() {
  14.         echo -e "usage: $script [options]
  15.  where options are:
  16.  vol-up [%]\tincrease volume % (default: 5%)
  17.  vol-down [%]\tdecrease volume in % (default: 5%)
  18.  toggle\ttoggle mute/unmute"
  19. }
  20.  
  21. for sink in $sinks
  22. do
  23.         case $opt in
  24.         vol-up)
  25.                 pactl set-sink-volume $sink +$vol%
  26.                 ;;
  27.         vol-down)
  28.                 pactl set-sink-volume $sink -$vol%
  29.                 ;;
  30.         toggle)
  31.                 pactl set-sink-mute $sink toggle
  32.                 ;;
  33.         *)
  34.                 usage
  35.                 exit 0
  36.                 ;;
  37.         esac
  38. done
  39.  
  40. muted=$(pactl list sinks | awk '/Mute: yes/ { print $2; exit }')
  41.  
  42. case $opt in
  43. vol-up)
  44.         notify-send -i audio-volume-high "Volume increased"
  45.         ;;
  46. vol-down)
  47.         notify-send -i audio-volume-low "Volume decreased"
  48.         ;;
  49. toggle)
  50.         if [ "$muted" == "yes" ]; then
  51.                 notify-send -i audio-volume-muted "Sound muted"
  52.         else
  53.                 notify-send -i audio-volume-medium-symbolic "Sound unmuted"
  54.         fi
  55.         ;;
  56. esac
  57.  
  58. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement