dbus control of volume?

Nils Kassube kassube at gmx.net
Wed Mar 17 19:19:21 UTC 2010


D. R. Evans wrote:
> Nils Kassube said the following at 03/17/2010 10:17 AM :
> > D. R. Evans wrote:
> >> In KDE3, the following command mutes the audio volume:
> >>   dcop kmix Mixer0 setVolume 0 0
> >>
> >> What's the right command to do the same thing in KDE4 (i.e., with
> >>  dbus)?
> >
> > Is it mandatory for you to use dbus? For scripts I always use
> > amixer to control the mixer settings.
> 
> The man page says that amixer is for ALSA. I don't pretend to
>  understand the morass that KDE4 sound is, but my understanding
>  (which could be completely wrong) is that ALSA has been superceded
>  by Phonon.

Others mentioned already, that ALSA is still in use. Therefore it works 
with amixer the same way as it works with kmix. However, I never tried 
it with pulse audio which is possibly installed depending on the Gnome 
applications on your system (but not on my systems).

> Just in case my understanding is wrong, I tried one of the examples
>  from the man page:
> 
> [H:N] amixer -c 1 -- sset Master playback -20dB
> amixer: Unable to find simple control 'Master',0

The problem is that the names of controls seem to vary a lot between 
different sound cards. What I do is use the command

amixer controls

For the sound card of this machine there is one group of output

numid=1,iface=MIXER,name='Front Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=64,step=0
  : values=64,64
  | dBscale-min=-64.00dB,step=1.00dB,mute=0

where the interesting part is the "numid=1" (you could use the name as 
well if you want to, but then you need proper quoting). Now I can set 
the volume with the command

amixer cset numid=1 11,11

or if I don't want any output of the command it would rather be

amixer -q cset numid=1 11,11

and the new value is 11,11 instead of the previous 64,64. BTW: You only 
need the -c option if you have multiple cards.


Nils




More information about the kubuntu-users mailing list