You are viewing benno37

Ben - Switching ALSA audio outputs

Jan. 11th, 2005

04:24 pm - Switching ALSA audio outputs

Previous Entry Share Next Entry

While its all well and good mixing audio output, so you can hear both the CD you are listening too, and
the audio stream from a VLC stream, it can get kind of confusing listening to two things at once.

So I to write a simple shell script which would mute the currently active output
stream, and unmute the other, which I could then easily bind this to a key in ratpoison.

I thought it would be easy, which it was, but the result is fairly gross. Surely someone can show me a better way
to do this:

#!/bin/sh

if [ `amixer cget iface=MIXER,name="PCM Playback Switch" | tail -1 | cut -d\, -f2` "==" off ]; then 
    amixer cset iface=MIXER,name="PCM Playback Switch" 1 > /dev/null; 
    amixer cset iface=MIXER,name="CD Playback Switch" 0 > /dev/null; 
else 
    amixer cset iface=MIXER,name="PCM Playback Switch" 0 > /dev/null; 
    amixer cset iface=MIXER,name="CD Playback Switch" 1 > /dev/null; 
fi