Scripting KMix via DBUS : kmixremote

KMix has a long history of having a remote interface. But whether it was based on DCOP or DBUS, it has always been an expert tool. For some common tasks like muting the master or setting a volume, the hurdles have been too high for many users and script developers.
Starting with the next release KMix ships a small script kmixremote, that makes things very easy: You can mute, get and set volume levels, and list soundcards and controls. This bash script can also serve as a starting point for developers interested in creating scripts or 3rd party apps.
This was a two hour excursion back into bash scripting for me. I found it entertaining as I am not doing a lot of those anymore. I hope you find the result useful.

Local usage example:

Shown are (in this order) listing soundcards, listing controls of a specific soundcard. After that reading, modifying, and reading the (modified) volume level again:

chris@whitefall # kmixremote list
chris@whitefall # kmixremote list  ALSA__Creative_X_Fi_1
chris@whitefall # kmixremote get  ALSA__Creative_X_Fi_1 PCM_0 
chris@whitefall # kmixremote set  ALSA__Creative_X_Fi_1 PCM_0 70
chris@whitefall # kmixremote get  ALSA__Creative_X_Fi_1 PCM_0 

Remote usage example:

Remote usage does not differ from local usage. You only have to make sure you have a remote login, and permissions to access the X11 server where KMix is running. In the example, I am using “DISPLAY=:0”:

chris@remote-pc: ssh user@pc-with-kmix DISPLAY=:0 /usr/bin/kmixremote

14 responses to this post.

  1. Please note that, with PulseAudio enabled, having the “scripted volume changes” functionality is in direct contradiction with the documentation patch that will hopefully be accepted soon:

    So, if you are going to ship this, please document the implications somewhere. Basically, it needs to be explicitly said that the scripts that manipulate volumes in kmix are trusted to make no harmful changes.


    • Honestly, I do not understand the “documentation patch”. Could you elaborate how this applies to KMix? KMix does not create sinks, it only controls the volume of sinks for the given range.


      • Sorry for taking too long to reply. I reread the post, and after the phrase “KMix has a long history of having a remote interface” have to partially retract my comment. The issue is not new, and not really specific to PulseAudio.

        What the documentation patch says, in relation to KMix, is: any volume change that is not a result of user input is bad. But in practice, there are no such volume changes, unless a clueless user shoots himself in the ear.

        The changes done via the GUI are obviously user-initiated. It is OK to call kmixremote e.g. in response to a hotkey, as that’s still user input. It is OK to run kmixremote from a command line, as that’s still user input.

        What is not OK is that some clueless application author would read about kmixremote or about the D-BUS API and use that to change the volume when his application thinks that this is needed, potentially overriding the user’s choice (i.e. fighting with the user for the mixer controls). I think that a note about this potential of “fighting” would be useful in the same place which documents the D-Bus API and kmixremote.

      • Interesting read, Alexander. Do you think it is likely things like these would happen? What application do you have in mind? Media players only change volume on user demand, and I think usage w/o user interaction is also OK, like a tool that allows stuff like “mute my computer always at 23:00 local time”. This is also valid usage.

  2. hey, this is very cool! Controling kmix from the command line…


  3. Thanks, very useful! Also will be good to see android app for remote control kmix (or pulseaudio), because now I can’t find any way how to conrol pulseaudio volume from Android tablet. Is something like this planned?


  4. KMIX, on all three of my systems (latest KDE), has been nothing but a source of frustration and irritation. I despise it. I want one slider, my volume control keys, to control all sound events equally — in the sense that I want to unify the volume control. I don’t want a dozen sliders for a dozen apps. I don’t listen to a dozen apps at the same time so it makes absolutely no sense, in my case, to have separate sliders. What I would really like to see is a little checkbox that says something like: UNIFY VOLUME CONTROL. If this capability already exists, then I’d love to know how to do it (’cause nobody else seems to know about it). If it doesn’t, then for God’s sake please add it. I beg you.


    • Honestly, I feel insulted. Blurping out that you want (quoting) “something like: UNIFY VOLUME CONTROL” and presuming this what is in your head is obvious is a stupid assumption. Adding words like “for gods sake” will not help motivating me. Thank you.


      • The facts are this: KMIX doesn’t function as designed on any of my systems. If you want to feel insulted, that’s up to you; but pouting because of one negative comment doesn’t do squat to improve your software. I’m currently trying Veromix. Thank you.

      • Wrong. KMix actually functions as designed. It simply does not seem to match your taste – which you did not even bother to specify exactly. That is OK for me, but telling “I want” and “I despise” and “for gods sake” is NEITHER friendly NOR constructive. Destructive criticism does not solve any problems.

  5. If the option doesn’t already exist, the ability to lock (unify) all sound events under one slider would greatly benefit any number of users who neither use nor want a separate slider/control for each sound event or application.


    • All soundcards that I know already have a more or less “unified” channel. So by selecting that channel as master you should be done. You can do it probably since 10 years in KMix. Select the sound card (Pulseaudio) or PCM (ALSA, OSS) as master, and it will regulate all volumes for that soundcard.
      Please note, that for about 10 years there also was only one slider. I find it now pretty antiquated, but if you want that back then configure KMix to show only one. The new – user friendly way – is described in an older post: . You might need to wait until distributions pick up that version, but then it is pretty nice.


  6. […] звуковой микшер KMix добавлена поддержка удалённого управления с использованием DBus, […]


  7. […] звуковой микшер KMix добавлена поддержка удалённого управления с использованием DBus, […]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: