[download]

local/bin/audiomenu

   1 #!/bin/bash
   2 
   3 inline(){ # {{{
   4     paste - - | sed '
   5         s/"//g
   6         s/\s\+index: /\t/
   7         s/\s\+[a-z.]* = /\t/
   8     '
   9 } # }}}
  10 sinks(){ # {{{
  11     pacmd list-sinks |
  12     grep 'index\|device\.description' |
  13     inline
  14 } # }}}
  15 audio(){ # {{{
  16     sinks | awk -F \\t '/\*/ { print $NF }'
  17 
  18     while read id app; do
  19         echo " * $app"
  20         pacmd move-sink-input $id $1
  21     done < <(
  22         pacmd list-sink-inputs |
  23         grep 'index\|application\.name' |
  24         inline
  25     )
  26 } # }}}
  27 
  28 s=$(sinks | awk -F \\t '{ print $1, $3, $2 }' |
  29 icon -x audio | menu -i audio | awk '{ print $NF }')
  30 
  31 [[ $s ]] || exit
  32 pactl set-default-sink $s || exit
  33 
  34 export -f inline sinks audio
  35 notify audio $s
  36 volume