Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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%
}
share|improve this question
    
Regarding binding commands to keyboard shortcuts: it depends solely on our window manager how this is done. –  Daniel Andersson May 30 '12 at 6:46
    
Yes, the problem is not how to bind the commands but to make them work. –  Emanuel Berg May 30 '12 at 13:57
add comment

1 Answer 1

up vote 4 down vote accepted

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%
}
share|improve this answer
    
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! –  Emanuel Berg May 30 '12 at 13:59
    
@EmanuelBerg: Try escaping the + signs (prepend \). –  Daniel Andersson May 30 '12 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? :) –  Emanuel Berg May 30 '12 at 18:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.