2

I've been unable to piece together a proper solution to get alsamixer to properly manage my sound.

Here's my desired behavior:

  1. On rebooting, hibernating or sleeping and then waking up, I want all alsamixer levels and mute settings preserved.
  2. The mute key on my keyboard should toggle mute, the volume-up and volume-down buttons should increase or decrease the volume, and if applicable, remove muting.
  3. When I plug in headphones, there should be a different volume setting for them and the volume levels should automatically adjust themselves. Doesn't matter to me if master changes or if the headphone / speaker levels change. Just need to make sure that this works with the volume-{up,down} keys.

I use XMonad and xbindkeys to map my volume/mute keys to actions. Currently:

"amixer set Master 2dB+"
  XF86AudioRaiseVolume

"amixer set Master 2dB-"
  XF86AudioLowerVolume

"/path/to/mute.sh"
  XF86AudioMute

where mute.sh is

FILE=$HOME/.mute
if [ -f $FILE ]; then
  amixer set Master `cat $FILE`
  rm $FILE
else
  amixer get Master\
    | grep Mono\
    | grep -P -o '[\d]{1,3}'\
    | head -n 1\
    > $FILE
  amixer set Master 0
fi

Currently, when I restart my computer, it seems like random channels are muted. And my mute script actually just sets the volume level to zero, which isn't ideal. On the bright side, plugging in headphones does seem to adjust the volume level.

Any ideas how I could make the muting and restart behavior better?

----- EDIT 1 -----

Master toggle mutes speaker channel also:

$ amixer get Speaker | tail -n 1
  Front Right: Playback 87 [100%] [0.00dB] [on]
$ amixer set Master toggle
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 87 [100%] [0.00dB] [off]
$ amixer set Master unmute
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 87 [100%] [0.00dB] [on]
$ amixer get Speaker | tail -n 1
  Front Right: Playback 87 [100%] [0.00dB] [off]

----- EDIT 2 -----

Toggling is weird:

$ for x in Master Headphone Speaker; do amixer set $x toggle ;done
Simple mixer control 'Master',0
  Mono: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Headphone',0
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]

$ for x in Master Headphone Speaker; do amixer set $x toggle ;done
Simple mixer control 'Master',0
  Mono: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Headphone',0
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
6
  • The controls available in alsamixer depend on your hardware.
    – CL.
    Oct 2, 2013 at 13:05
  • Can you clarify what a control in alsamixer is? Is each vertical bar a control? I don't quite understand the relevance of your comment... please explain.
    – Espressofa
    Oct 2, 2013 at 17:17
  • Please show the output of amixer scontrols to see if there are any useful controls.
    – CL.
    Oct 2, 2013 at 18:39
  • It's at the following link. Thanks! pastebin.com/raw.php?i=tWUrSGaA
    – Espressofa
    Oct 2, 2013 at 22:07
  • Sorry, I meant amixer scontents.
    – CL.
    Oct 3, 2013 at 6:31

1 Answer 1

0

Your hardware has a master mute switch; use amixer set Master toggle.

To unmute, run amixer set Master unmute.

You should be able to set the Speaker and Headphone controls differently, and to use the Master control to set the overall volume.

Your hardware can automatically mute the speakers when headphones are plugged in, but your Auto-Mute Mode control is set to disabled. Apparently, you have some software that does the some.

4
  • Look at my latest comment: when I mute, it affects Master, Headphone, and Speaker; when I unmute it only affects Master!
    – Espressofa
    Oct 4, 2013 at 13:18
  • Strange. As a workaround, copy the Master mute status to the other two.
    – CL.
    Oct 4, 2013 at 14:30
  • Added a new edit. Sometimes, toggling doesn't work. If I call unmute, I have to unmute the headphones to get the speakers to work. Then if I mute the headphones, I have to unmute everything to get it to work.
    – Espressofa
    Oct 4, 2013 at 18:42
  • It also doesn't seem entirely deterministic. Sometimes alsamixer will show everything as unmuted but I can't hear anything.
    – Espressofa
    Oct 4, 2013 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .