3

I got this far (from .bashrc):

alias i="amixer -c 0 -- sset Master playback +1dB"
alias d="amixer -c 0 -- sset Master playback -1dB"
alias v4="amixer -c 0 -- sset Master playback 40%"
alias v8="amixer -c 0 -- sset Master playback 80%"

The first two rows should work, if I read the man amixer page correctly, and they don't produce an error message, but their behavior is unreliable: sometimes there's a huge change, most often nothing happens.

The last two rows work. I guess you could make like ten aliases. Still, you would like the increase/decrease functionality to bind to keyboard shortcuts.

Am I using amixer the wrong way or is there some other tool to do the trick? (alsamixer doesn't seem to have this functionality as CLI commands.)

Edit

At last, made it work. This was so long ago (how sad!), so I have lost track of who contributed what. Anyway, thanks. (Below: For bash users, put in .bashrc)

# volume
alias vol="alsamixer"
MASTER="amixer -q -c 0 sset Master playback"
alias i="$MASTER 2dB+"
alias d="$MASTER 2dB-"
alias mute="echo \" Audio muted.\"; $MASTER mute"
alias play="echo \" Audio un-muted.\"; $MASTER unmute"
alias unmute="play"
alias stop="mute"
v () {
  amixer -q sset Master playback $1%
}
2
  • Regarding binding commands to keyboard shortcuts: it depends solely on our window manager how this is done. May 30, 2012 at 6:46
  • Yes, the problem is not how to bind the commands but to make them work. May 30, 2012 at 13:57

1 Answer 1

5

For your first two aliases, it appears the +/- must go after the value to be treated as a relative change, instead of an absolute value (amixer man page):

alias i="amixer -c 0 -- sset Master playback +1db+"
alias d="amixer -c 0 -- sset Master playback +1db-"

I would replace the last two (and their 8 assumed brethren) with a single shell function:

v () {
  amixer -c 0 -- sset Master playback $i%
}
4
  • alias d="amixer -c 0 -- sset Master playback 1dB-" works (note no plus sign), alias i="amixer -c 0 -- sset Master playback 1dB+" does not work (nor with the first plus sign). Very strange! May 30, 2012 at 13:59
  • @EmanuelBerg: Try escaping the + signs (prepend \). May 30, 2012 at 14:15
  • Sorry, same old. But: amixer -c 0 -- sset Master playback 2dB+ works. I tested 3 and 4, they work as well. For some reason, it works to decrease by 1, but not increase by 1. To be a bug, it is a bit unlikely because it would be the first bug to be discovered. How about writing a function that increases by 3, and the decreases by 2? :) May 30, 2012 at 18:45
  • I'm not aware of older versions, but as current, you can use command like this: amixer -c 0 -- set Master 1dB+
    – F-3000
    Dec 1, 2016 at 10:33

You must log in to answer this question.

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