Guest

rrob

By: a guest on Jan 12th, 2010  |  syntax: Bash  |  size: 0.80 KB  |  hits: 224  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #/bin/bash
  2. # Pulse Audio Sound Card Switcher v1,0 2010-01-13
  3. # Switch default sound card in pulseaudio to next one presented in system. Actual audio streams will not be forwarded.
  4.  
  5. totalsc=$(pacmd "list-sinks" | grep card: | wc -l) # total of sound cards: $totalsc
  6. if [ $totalsc -le 1 ]; then echo "Nothing to switch, system have only one sound card." ; exit ; fi # Check if is present more then one sound card.
  7. scindex=$(pacmd list-sinks | awk '$1 == "*" && $2 == "index:" {print $3}')  # index of default sound card: $scindex
  8. nextsc=$(( (scindex+1)%$totalsc )) # index of next sound card: $nextsc
  9. pacmd "set-default-sink $nextsc" > /dev/null # switch default sound card to next one
  10.  
  11. # CC BY - creative commons
  12. # Thanks God for help :) and guys lhunath, geirha, Tramp and others from irc #bash on freenode.net