lunes, 15 de marzo de 2010

Bash Script for Muting front Speaker

The following script will evaluate your "Speaker" audio output and change it to 0% or 100%, without modifying any other output.
This can be used to play audio from your speakers and your headphone output at the same time, or to roughly work-around the issue affecting some laptops where the speaker doesnt mute when a headphone is plugged (AKA jacksens not working)
It requires Alsamixer

export i=`amixer sget Speaker | grep 'Front Left:' | cut -d'%' -f1 | rev | cut -d'[' -f1`
if [ $i -eq 0 ]
then
amixer sset Speaker 100
else
amixer sset Speaker 0
fi

The script works by getting the amixer output for "Speaker" (you might need to change that); chopping it untill only a value is remaining (hence the cut | rev | cut); evaluating the output and then setting the volume to 100% or 0%

If this does not work you might need to change the Speaker output for some other, you can find your output's names by entering
amixer

in the terminal, and then changing any occurence of Speaker for your desired output's name.

No hay comentarios:

Publicar un comentario