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
ALSA__Creative_X_Fi_1
ALSA__HDA_NVidia_1
chris@whitefall # kmixremote list  ALSA__Creative_X_Fi_1
Master_0
PCM_0
Front_0
[...]
chris@whitefall # kmixremote get  ALSA__Creative_X_Fi_1 PCM_0 
100
chris@whitefall # kmixremote set  ALSA__Creative_X_Fi_1 PCM_0 70
chris@whitefall # kmixremote get  ALSA__Creative_X_Fi_1 PCM_0 
70

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
ALSA__Creative_X_Fi_1
ALSA__HDA_NVidia_1

SoundMenu additons. New KMix Configuration Dialog.

Responsive KMix

The new Configuration dialog (right). The Sound Menu (left) reflects the selected controls, and also shows the new “Pause” icon, as Clementine is currently playing and can be paused.

I took a small vacation from work to research relocation possibilities. While I was home I also spent time on completing the announced configuration dialog update and for updating the Sound Menu. KMix is more responsive,  playback changes being reflected by KMix. Thanks to the communication infrastructure established done during the Multimedia Sprint 2012 in Randa it was easy to keep KMix consistent. Additionally I refactored  the code for future additions like showing album picture.

  • Media Player playback status is reflected by Sound Menu. Shows media-playback-start or media-playback-pause.
  • Configuration dialog overhaul; Options are grouped in tabs and the apply button is responsive.
  • Configuration of the Sound Menu has been integrated in the configuration dialog as separate tab
  • Volume Overdrive up to 150% now officially supported for PulseAudio due to popular request.
  • Less CPU usage and latency for MPRIS2.
  • Sound Menu position optimized for all 4 panel positions (Bottom, Left, Top, Right)

The end of year 2013 is nearing. We will all see an exciting Year 2014 with Plasma 2 waiting in the wings.

See you all there,
Christian


Technical stuff

If you are interested in the source code changes, http://quickgit.kde.org/?p=kmix.git&a=commit&h=0f7a603e1d327f76dbd6a62d08315b1956794d42 is the biggest commit, and it also contains references to features and bugs. For the technical interested: It is based on KConfigDialog and KConfigSkeleton [1], which is a very cool technology I discovered recently. If you do not know KConfigDialog and KConfigSkeleton, here is a short overview:

KConfigSkeleton + KConfigDialog

  • KConfigSkeleton links configuration entries from a property file with variables (e.g. a QString)
  • There are methods to copy from property file to configuration variables and vice versa
  • KConfigDialog can use a KConfigSkeleton, to prefill e.g. a related QCheckBox
  • KDE Techbase recommends KConfigXT. But KMix is a fine example without.

The OpenSource Eclipse Kepler C++ KMix productivity boost

Today I’d like to share a revelation with you:

Developing C++ can actually be fun.

10reasons_6

How you work can define your productivity

In the next sections I will tell you a bit about how I develop KMix today, and why the newest toolchain gave me a productivity boost. As a peek ahead, this post is mainly about developing KDE applications with Eclipse.

If you just came across this post via searching for Eclipse,  C++ and cmake, then you might want to directly head to the practical example at the end of this post.

The core message is that the environment you work with can have a very high impact on productivity. As an example, see the picture to the right from my office: Isn’t this a more comfortable environment than – a cubicle? OK, I was talking about productivity, wasn’t I? So lets forget the image quickly. ;-)

The C++ nuisance and rant

Honestly, most of the time  C++ development is a nuisance for me. For a better understanding, you should know that I am a 95% Java developer nowadays. And if you do a lot of Java, C++ is full of strangeness:

CMake and Eclipse as a rescue boat

If you get good tool support, C++ can still be a very good language. CMake helps a lot. For the source code editor it is more complicated: In the past I used every viable tool for KMix development, including misc versions of emacs, vi, aXe, kate, KDevelop and Eclipse CDT. All have their own strengths, but I could use none of them well for KMix development. Then recently I did a new shot at Eclipse CDT (Kepler based), and I am actually delighted.

  • The CMake integration now works flawless for me
  • The C++ indexer is super-fast and reliable (a massive weakness in former versions)
  • Navigation for header to source and back finally works and is very fast. Signals and Slots are parsed correctly and can be navigated.
  • Call hierarchies work great most of the time. In some C++ specific constructs they do not work, but using “references” is a good alternative.
  • Even the strangest #define and #include constructs work as expected.
  • Warnings, Errors, TODO’s and so forth are shown by default very appropriately in the editor and the other Eclipse Views. Very comfortable if one is accustomed to Eclipse.

KMix is a pretty small project, so mileage may vary for your project. Still I recommend to try “Eclipse Kepler CDT” if you have not done so recently. It brought back the fun in development for me.

Practical guideline for developing KDE applications with Eclipse

The basic step to build an Eclipse project is:

cd kmix-git-trunk.obj; cmake -G”Eclipse CDT4 – Unix Makefiles” ../kmix-git-trunk

As a reference, kmix-git-trunk.obj is where I build kmix, kmix-git-trunk is the GIT checkout. After that you can import the project into Eclipse. Run the above command again whenever required and refresh the whole source tree in Eclipse (F5) after that. Personally I am using Eclipse only to edit the source code, to navigate and browse quickly through sources, headers and includes. Everything else I am doing from a console window, like building, running, debugging and version control (GIT).
(Update 2013-12-16: Debugging works fantastic from within Eclipse, so I will use that from now on)

Thanks if you read until the end. If you have any input, experience or feedback, please leave a comment.

Christian

Secret view in the new configuration dialog

2013-11.KmixConfigDialogI decided to devote some time to polishing KMix. I cannot reveal too much at this point, but here is a sneak preview of the new configuration dialog. This dialog got more and more crowded, so I decided on a tabbed design like many KDE applications use.Also it will be a central place for all the configuration, including Sound Menu and OSD.

Feedback is welcome, but keep in mind that this is a very early preview snapshot. I will commit the work in one or two weeks, when the development line gets “unfrozen”.

KMix Mission Statement 2013 and KDE 4.11

Dear KMix Users, and reader of this blog [1]. This is a mission statement.KMix KDE 4.11

“I am now happy. Happy with the KMix version shipping with KDE4.11. Happy that I can now declare Media Play control as stable.”

You might neither be surprised or impressed or as happy as I am now. Here is the explanation: For years I mainly maintained KMix for following up with changes dictated by the outside world. The last year was very different and awesome – last year’s KDE Randa Meeting brought enough motivation to do critically needed  KMix refactoring, and add support for media player contol (MPRIS2). KDE4.11 stabilizes the media player support. It is now really smoooooth. :-)

Enough talking about me, and back to you, the user. Integrating media player control (MPRIS2) was dramatical harder harder than I anticipated. Issues arose where I did not expect them. I sincerely apologize if you endured issues, hangs during start or running the KDE Desktop due to KMix. Please go for KDE 4.11. All will be well now. If not, let me know. :-)

I thank everybody involved, especially apachelogger for practical advice and Albert Astals Cid for coping with me technically being too late for KDE 4.11.


[1] Well, I guess that everybody reading this is a KMix user.  But not the other way round. ;-)

Back on track for Sound Menu

_TSF0831I had busy months after KDE 4.10, alas it was all about  KMix unrelated actions, like my Java Job and theatre performance in Jekyll & Hyde. So work has piled up, but I am happily announcing that I am back on track. I did an initial cleanup session some weeks ago and will continue this weekend. So what will happen (I’ll keep it short):

  • Fix hangs for MPRIS2 backend
  • Prepare for  KDE 4.11
  • Cleanup Reviewboard
  • Fix MPRIS2 polling: Trunk has a working version, but it consumes too much CPU.
  • API documentation: Especially about how to write a proper Backend, including polling versus event-based mode (the latter is strongly preferred).

So everybody who still waits for an answer from me should have it next week – don’t hesitate to contact me – I will promise not to bite. :)

Desktop Linux – Steam as a new Chance

I enjoy running my Desktop  under Linux. And while I am a long-term KDE supporter, my desktop diverges from the standard KDE setup quite drastically: There are no “Activities”, no noticeable Plasmoids  and nothing on the desktop except one folder view. This flexibility is exactly Linux greatest strength, but the average users neither needs nor want this. Wikipedia claims 1.19% desktop market share – a stagnation at best. I do not want it to go down. So who will give Linux Desktop a new push?

Canonical has recently started diverging drastically from other distributions – no KDE, no Gnome, just Unity including intentional AdWare and privacy issues and a built-in Software Shop. This un-unifying does not help Linux.

Now Valve has entered the Scene - providing Steam, developing the Linux based Steam Box, and doing native ports of their game engines and games. While at beta, Valve is already doing things the Linux way: You have desktop files, it integrates into the package system, installs requirements like 32-bit libs  and so forth. Valves investment is a good thing. They are tackling many issues that bring Linux forward, for example pushing hardware vendors like NVidia or providing a better fullscreen mode [1].
So I will be positive and count Valve’s work as a second chance for Linux Desktop and Multimedia. Users are more likely considering Linux if there are well-known games around.

KMix in Half Life 1

Half Life under Linux requires PulseAudio. In the middle: KMix OSD.

[1] Fullscreen mode has sometimes quirks:

  • Unexpectedly leaving fullscreen. For example some Flashplayer  applications or “Trine 2″ may leave fullscreen when you press KMix volume buttons (even w/o OSD)
  • Problems with global keyboard shortcuts. Apps can sometimes take away keys from fullscreen applications
  • Popups showing up. The image above shows the KMix OSD in Half Life.
Follow

Get every new post delivered to your Inbox.