Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

amixer toggle mutes but does not unmute Linux

Posted by Admin • Monday, July 22. 2013 • Category: Linux

It seems that the common approach to mute the audio in Ubuntu 13.04 is amixer -q sset Master toggle ... which works great when muting, but fails to unmute. This command is, for example, the default for openbox's handling of XF86AudioPlay shortcut.

The problem, it would appear, is that muting the Master channel causes other channels (eg Headphone and Front on my machine) to be muted as well. I have no idea why this works this way and why it doesn't undo what it did... and, frankly, I don't really care that much. It's much easier to code around this, see the following workaround script:


#!/bin/bash

LIST="Master Headphone Front"

if amixer sget Master | grep '\[off\]' > /dev/null ; then
        CMD=unmute
else
        CMD=mute
fi

for CONTROL in $LIST ; do
        amixer -q sset $CONTROL $CMD
done
 
Now, instead of amixer -q sset Master toggle I just run /usr/local/bin/my-mute-script.sh

It simply checks whether the Master channel is [on] or [off], and then either mutes or unmutes the preconfigured list of Channels. To see your list, try "amixer scontents", and look for everything that's [off] when muted.

Update: other people have had this issue.

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as (Linear | Threaded)
  1. No comments

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

What is the primary language of this blog? (Anti-SPAM question)


Submitted comments will be subject to moderation before being displayed.