Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. declare -i sinks_count=`pacmd list-sinks | grep -c index:[[:space:]][[:digit:]]`
  4. declare -i active_sink_index=`pacmd list-sinks | sed -n -e 's/\*[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`
  5. declare -i major_sink_index=$sinks_count-1
  6. declare -i next_sink_index=0
  7.  
  8. if [ $active_sink_index -ne $major_sink_index ] ; then
  9. next_sink_index=active_sink_index+1
  10. fi
  11.  
  12. #change the default sink
  13. pacmd "set-default-sink ${next_sink_index}"
  14.  
  15. #move all inputs to the new sink
  16. for app in $(pacmd list-sink-inputs | sed -n -e 's/index:[[:space:]]\([[:digit:]]\)/\1/p');
  17. do
  18. pacmd "move-sink-input $app $next_sink_index"
  19. amixer set Master toggle
  20. done
  21.  
  22. #display notification
  23. declare -i ndx=0
  24. pacmd list-sinks | sed -n -e 's/device.description[[:space:]]=[[:space:]]"\(.*\)"/\1/p' | while read line;
  25. do
  26. if [ $next_sink_index -eq $ndx ] ; then
  27. notify-send -i notification-audio-volume-high "Sound output switched to" "$line"
  28. exit
  29. fi
  30. ndx+=1
  31. done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement