local/bin/audio.sh

   1 #!/bin/bash
   2 
   3 function inline(){ # {{{
   4     paste - - | sed 's/"//g' |
   5     sed 's/\s\+index: /\t/' |
   6     sed 's/\s\+[a-z.]\+name = /\t/'
   7 } # }}}
   8 
   9 if [[ ! $1 ]]; then
  10     pacmd list-sinks | awk '/index/ || /device.product.name/' | inline
  11     exit
  12 fi
  13 
  14 pacmd set-default-sink $1
  15 pacmd list-sink-inputs | awk '/index/ || /\tapplication.name/' | inline |
  16 while read id app; do
  17     echo "[$id] $app";
  18     pacmd move-sink-input $id $1
  19 done
  20