Archive for the ‘Plasma’ Category

MPRIS2 and the Music Player Daemon

17th May 2012

If you tend to want to keep your music running when you log out, or control your music playing on a desktop machine from a laptop, for example, you may well use the Music Player Daemon (MPD).  If you use Ubuntu’s Unity desktop or KDE’s Plasma desktop, you may well wonder how to get the Ubuntu sound menu or Plasma’s Now Playing widget to talk to it.

Both of these use MPRIS2 to communicate with media players.  MPD, however, does not have an MPRIS2 interface.  Even if it did, it would take a bit of work to be able to use it from another computer.  What you need, then, is a “bridge” of some sort to translate.  One such possibility is mpDris2 (which, I hasten to point out, I haven’t tested).

You would run such a bridge on the computer you want to control MPD from, and point it to your MPD instance.  And voilà!  Every MPRIS2 client application that you run can talk to MPD, without knowing anything about the MPD protocol.

If you just want a headless music player on your local machine, though, you can always use Raven, which talks MPRIS2 natively.

New Now Playing Plasmoid, MPRIS2 dataengine

11th May 2012

One thing that will be in KDE Plasma Desktop 4.9 is a new version of the Now Playing widget.  Based on QML, it works much better, especially on panels (where its design is based heavily on my favourite KDE-3-era applet, kirocker).

Now Playing on a panel

In the background, it uses the new mpris2 dataengine.  This exclusively supports MPRIS2-capable media players (which these days is most), and doesn’t include any hacks to support XMMS 1, for example.  JuK and Dragon have both gained MPRIS2 support for the 4.9 release, and Ubuntu’s sound menu uses MPRIS2, which is compelling many other media players to support it.

Now Playing on the desktop

The result is a cleaner, more reliable design, and completely asynchronous behaviour, so it will use less power and (unlike the old nowplaying dataengine) it should never cause your desktop to freeze due to a badly-behaving media player.

Now Playing with the mouse over

The old nowplaying dataengine is still there (and will be until KDE Plasma Desktop 5 is released), but should not be used for new widgets.  Instead, you should use the mpris2 dataengine, and I highly recommend porting any existing widgets to mpris2 as well.

Overall, I’m really pleased with the design of MPRIS2, which allowed me to create the mpris2 dataengine with a minimum of fuss, and allowed for widgets to implement a seek bar without querying the media player once or twice a second to find the current position (and not take the performance/power hit if they didn’t care about the current playback position).

Screen locking with the Plasma netbook interface

4th September 2011

If you are using the Plasma desktop on your netbook in “netbook mode”, you may have noticed that screen locking (in all its forms – the Ctrl+Alt+L shortcut, typing “lock” into search-and-run, and automatic locking when suspending to RAM or when the screensaver starts) no longer works.  This is because KRunner doesn’t run in this case, and KRunner is (somewhat bizarrely) responsible for activating the screen locker.

The proper solution to this (and the one that should be implemented for 4.8, hopefully) is to get KWin to manage screen locking.  After all, it knows best when it comes to managing the screen.  But, until then, you can use the quick hack I came up with: putting screen locking into a kded module.

This works quite nicely with existing installations, as you can just compile and install the KDED module and be on your way.  One caveat: KRunner will retain the shortcut.  Once you’ve started the module for the first time (either from the Service Manager kcm or by logging out and in again), you will need to go to the Global Keyboard Shortcuts kcm and set Lock Session shortcut for KDE Dæmon.

Run the following commands to do this (you’ll need cmake and automoc, as well as development packages for Xorg and kdelibs):

git clone git://
cmake ../kscreenlockmgr -DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
sudo make install

Or, if you’re on ArchLinux, just grab kscreenlockmgr-git from AUR.

What’s Playing, Doc?

17th May 2009

So, I was round at a friend’s, and he was playing with Amarok and the Plasma widgets screensaver, and wanted a way to see what was currently playing when his computer was locked.  Of course, I pointed him towards the Now Playing applet, but it was overkill for what he wanted – he didn’t want the buttons, or the sliders – just a display of the current information.  Well, I was in the mood for playing, and it took me about 15 minutes to construct a javascript plasmoid, most of which was spent researching how to use data engines from them.

The code I left him with was:

layout = new LinearLayout(plasmoid);

label = new Label();
label.text = 'No player'

plasmoid.dataUpdate = function(name, data) {
    label.text = 'Info:\n';
    for (var key in data) {
        label.text += key + ': ' + data[key] + '\n';

plasmoid.dataEngine("nowplaying").connectSource("org.mpris.amarok", plasmoid, 500);

This was in a file called “main.js” in a subfolder called “contents”. In the plasmoid folder (the folder containing the contents folder), I also put in a metadata.desktop file:

[Desktop Entry]
Name=Simple Now Playing
Comment=Now Playing as Matt likes it
X-KDE-PluginInfo-Author=Alex Merry
X-KDE-PluginInfo-Email=alex.merry [SPAMNO]@[SPAMNO]

Now it was just a case of calling plasmapkg -i . from within the plasmoid directory, and the simple widget was installed. This produces the following:


Of course, this will only work with Amarok, and doesn’t respond to Amarok being started or quit. That’s OK, it’s not much more work to deal with that:

layout = new LinearLayout(plasmoid);

label = new Label();
label.text = "No player found";

function firstSource() {
	var sources = plasmoid.dataEngine("nowplaying").sources;
	if (sources.length) {
		return sources[0];
	} else {
		label.text = "No player found";
		return '';

plasmoid.dataUpdate = function(name, data) {
	if (source == name) {
		label.text = 'Info:\n';
		for (var key in data) {
			label.text += key + ': ' + data[key] + '\n';	

source = firstSource();

npDataEngine = plasmoid.dataEngine("nowplaying");

npDataEngine.sourceRemoved.connect(function(name) {
	if (name == source) {
		source = firstSource();
		if (source) {
			npDataEngine.connect(source, plasmoid, 500);

npDataEngine.sourceAdded.connect(function(name) {
	if (!source) {
		source = name;
		npDataEngine.connect(source, plasmoid, 500);

if (source) {
	npDataEngine.connectSource(source, plasmoid, 500);

Of course, it’s not much work to only show the things you’re interested in, but this covers the interesting parts of the plasmoid.

Interesting note: it appears that if you replace the line label.text = 'Info:\n'; with label.text = '';, the subsequent calls to label.text += ... don’t work – you just end up with a blank label.

Now Playing with Art

21st February 2009

Michael Pyne added support for album art to Juk‘s D-Bus interface, and modified the now playing dataengine to get this artwork.  The dataengine already supported getting artwork from MPRIS-enabled players, and Amarok has provided album artwork over MPRIS for a while.

So I’ve now added the display of album artwork to the now playing widget:

The Now Playing applet with album artwork

The Now Playing widget with album artwork

Naturally, this disappears (and the text moves over to the left) when there is no album artwork available, and the image resizes to be as tall as the text when you resize the widget.

Oh, and I fixed the scrollbars to work when you use the mouse wheel on them.  This fix will be in the next release of 4.2 (although the artwork won’t be).

Now I need to improve the functionality of the widget when it’s on the panel.  And any help in generally making the widget prettier would be most welcome.  I really don’t like the scrollbars, and the album art needs a frame.

The Task-Oriented Revolution

12th January 2009

TheBlackCat posted this on an earlier post on this blog, and I thought it was worth sharing more prominently:

What I think will be a key revolution KDE will bring about is the task-oriented desktop. Plasma, Akonadi, Nepmuk, these are all parts of that. It will make computers smarter. Up until now computers did not care what you are doing, they cared about what you were using to do it. They organized themselves around what program you are using, not what you are doing with that program.

But people have different programs to accomplish the same task, and tasks often involve multiple programs. A computer that knows what you are doing and reorganizes itself to make that task easier is a huge leap forward in the way we work with computers. The Office 2007 ribbon interface is another example of that, but it is still embedded in the application-oriented desktop paradigm we have had up until now. It can even be taken a step further, allowing a computer to learn how you like to do certain tasks and organize itself appropriately. For instance such a computer could realize when you are chatting with your IT guy for a certain amount of time you generally pull up certain configuration programs, send him an email with an attachment, and check certain system monitoring applets. Let me get that all ready for your and stick them on a virtual desktop so you can get to it easily. KDE 4 provides the potential for a computer that automatically adapts itself to your work flow instead of you having to adapt yourself to its work flow. Imagine the benefit to businesses if you don’t have to train users to work with the system, the system will train itself to work with the users.

Everybody has different ways they like to do different things, but up until now the best they could do is try go set up their their desktop as best they can to make their most common tasks as easy as possible within the limits imposed by the system. Most people do not even bother to take advantage of the limited abilities their system provides, they simply use the default configuration. They never learn how they can modify and improve their computer experience, their efficiency, and their enjoyment. But a system that knows what users are trying to do, how they like to do it, and knows how take advantage of its own abilities to make those tasks easier would not need to rely on users spending the time and effort to learn the intricacies of the system, it would simply provide what they need when they need it.

Such a system requires four parts, I feel. First it needs a flexible and easily adaptable desktop. Plasma provides that. Second it needs something to track the relationships between data. Nepomuk and akondi provide that, or will soon. Third it needs programs that are able to understand how you perceive their relationship with the data and with each other. As I understand it is this is a major goal of KDE 4 over the long run.

Finally it needs to understand how you like to physically interact with the computer’s hardware. This, I feel, is still where KDE has serious limitations, and I think it is holding back the flexibility found in the rest of the desktop. The ability to configure the UI is amazing, but the ability to configure how the computer’s hardware interacts with and impacts the UI is very limited. Essentially we have keyboard shortcuts, that is it. Little else can be configured by the user.

The way we interact using the mouse is not flexible at all, we have three buttons and a scroll wheel. Modern mice generally have at least 5 buttons and a tilt wheel. The ability to dictate how the mouse interacts with the computer is pretty much limited to touching screen edges to activate a couple of effects, dragging windows across virtual desktops, and a few button presses on windows titles. Shortcuts involving mouse buttons are essentially unsupported. The ability to dictate how certain modes of interaction using the mouse effect the desktop environment is limited, in the relatively few cases where mouse interaction is configurable at all it has at most a couple of options.

Compiz has fairly extensive mouse interaction configuration, allowing pretty much any mouse button to be combined with a modifier key to control most aspects of the window manager. Windows 7 has some interesting ideas about moving windows, like the shaking windows to minimize others and dragging windows to screen edges to maximize them across half the screen. Of course certain people may not like these specific interactions, and in Windows 7 they do not appear very flexible, even compiz does not really support combining keyboard and mouse button presses beyond the use of modifier keys. But in KDE 4 the ability to dictate what effect a certain mouse interaction with a window or with a desktop will have is practically non-existent if you compare it to those examples, and is even more striking next to the extreme flexibility of the rest of the KDE 4 experience. So I think it important to be able to tell the system things like “shaking a window will have this effect”, “moving it to a screen edge will have this effect”, “tilting the scroll wheel left on the desktop will have this effect”, “meta+C+mouse button 5 on an applet will have this effect”.

This is even more limited when it comes to other types of devices. For instance there is no way at all to dictate what pushing a button on a joystick or a bluetooth device will do. They are simply not integrated into the KDE desktop interaction framework at all.

Another biggie that KDE, and Linux in general, essentially does not have at all is voice interaction. But I think this is an extremely natural way for people to interact, giving vocal commands is something people learn from a very early age. It is something that Microsoft has been working hard on supporting, and even most modern cell phones have it, but Linux in general and KDE in particular does not. Things like launching programs, switching desktops, and organizing windows seem particularly suited to voice commands since they are fairly simple and generally do not do anything terrible if there is a mistake.

The output side of hardware interaction is important as well. An example is having the computer know which printer you like to use when doing certain tasks (for instance a black and white office copier when printing PDFs, a color inkjet printer when printing photos). Or knowing that when you go into full screen when viewing a photo you want it to go full screen on your monitor, while if you set go into full screen mode with a video you want it to go full screen on your TV. Phonon and Solid seems to be trying to provide this to the Audio side of things, but it has applications for just about any output device.

Once you have the framework for being able to have a flexible method of interaction between input devices, output devices, programs, the desktop, and windows, it should become much easier for the computer to learn how you like to interact with it and adapt appropriately. For instance it could learn that when you are working with a text document and push the “play” button on your lirc remote you want amarok to open and start playing music, but if you stick a DVD in the drive and immediately after push the same button you want to open Dragon Player and play the DVD. It is extending the task-oriented desktop to the hardware side of things, to learn not only what you do and the process you use to do it but also what devices you use in that process and how you use them.

Think Better

17th December 2008

I suspect many of you will remember Apple’s adverts a few years back, with the tagline Think Different.

Think Different

Think Different

Not think better.  Not think world-changing.  Think different.

What does “different” mean from the point of view of a user or developer?  Different file formats.  Different systems.  Things that don’t interact.  A hundred different bugs in every application.  Just ask a web developer what they think about different browser implementations.

Developers get faced with choices between different systems all the time.  Why should I use system A instead of system B?  Does system A do something that system B doesn’t do, and do I care about that something?  If so, then this is an excellent reason to use system A.  Perhaps system A does the same thing as system B in every regard that matters to me, but does it better.  This is still a good reason to use system A, providing I haven’t already invested heavily in system B.

But “different” isn’t better automatically.  From the point of view of a commercial entity, “different” is generally worse by default.  “Different” costs money.  Is it worth it?  You have to justify that, justify why different is better in this case.

In light of this, I have a question for you, the contributing community of KDE.  What makes KDE better?  What makes it world-changing?

Doing something revolutionary

Let’s make this a bit more specific.  Most immediately I’m interested in what KDE has to offer the software industry at large.  What is KDE pioneering that would make a company that has historically based it’s business model on web applications built on Microsoft technology, but is now branching into open source because it’s not afraid to follow interesting trends, sit up and pay attention?  Consider a target audience of someone who thinks the time of the WIMP interface is over, but that the iPhone is a testament to the ingenuity of graphical designers and not software engineers (and software engineering is what we’re interested in here).  Consider the trend towards service-based computing.  Consider Google’s dominance.

Think about seamless integration of mobile devices, of reading something at your computer, then having to rush off and getting it onto your iPhone/eeePC/PDA/portable toaster with almost no interaction required.  Think of the problem of sifting through the cruft of the intarwebs (cat captions and all) to find that useful nugget of information.  Think of how your life revolves around trust networks (who do you ask for advice?), but how poor computers are at duplicating that.  In short, think of the unsolved problems in computing.

Is the semantic desktop (cf Nepomuk) a bold leap into the future of computing?  If so, how?

Is JOLIE integration into the desktop layer where it’s at?  Why?

Will Plasma revolutionise the way we interact with small form-factor devices?

What problems are KDE solving that haven’t been solved before?

Remember, we’re thinking here about why people who’ve never heard of KDE and see Linux as a server OS should be interested in what we’re doing.  We’re thinking about why budding young developers who don’t care about the GNU software libre philosophy but just want to work on an exciting, intellectually challenging and world-changing project might jump at the chance to get involved with KDE.

Doing something better

Secondly, why should people (again, who don’t care about the KDE desktop) use our development framework?  What makes us better?

Perhaps Eigen is the matrix library to end all matrix libraries?

What can Akonadi offer the world beyond the kdepim module?

How will Plasma make the hoards adore your application?

In what way are KComponents the light side to COM and CORBA’s dark side?

Why should you embed Marble into your application?

How is KDE solving the problems that developers care about in a better way than they have been solved before?

Final words

I’m fully convinced that KDE is awesome.  I care about software freedoms, and KDE is free.  I care about frameworks and APIs, and Qt/KDE beats the competition easily in that regard.  But I want to be able to evangelise KDE to other developers who don’t care about these things, and I don’t have the knowledge to do so.

Post your responses in the comments, or put them straight down on my Techbase page.  I will try to collate everything there.

Music in the Air

31st October 2008

I upgraded the Archlinux AUR mysqle package (an easy way to satisfy the most annoying dependency for Amarok 2) to 5.0.70, from 5.0.60.  I’m not sure why it was 5.0.60 in the first place, since 5.0.68 was out when I made the build script.  I blame the fact that 0 looks quite similar to 8 on a console…

Having a new job has meant that my KDE involvement has taken a dip over the last couple of months.  I realised today that I’d completely missed the hard freeze to get MPD support into the Now Playing dataengine for Plasma.  It will be in for 4.3, I promise.  I might even have pluggable backends by then, and a shared library between Now Playing and Kopete.

Speaking of Now Playing, the applet needs some serious work.  It works, providing you have it on the desktop, but it’s not as pretty as it could be.  Trying to put it on the panel seems to quite successfully screw up Plasma.  Which is a pity, really, because that’s where it’s most useful.  I will endeavour to fix this before the 4.2 is released, but help would be very much appreciated.  I don’t get on with user interface design.

Another pet project that never really got off the ground is my reimplementing of the slideshow screensaver.  Ever since I started using it (in KDE 3), the fact that it occasionally gets stuck has annoyed me.  I believe this is down to a design issue – it depends on the paint event being called to create a timer for changing the picture, but Qt compresses paint events and so it may happen that the timer never gets started.  I also don’t like the way effects are implemented.  But I haven’t even got it to a state when I think I can reasonably commit it to playground yet.

Life will calm down eventually, and I have plenty of stuff to do when it does.

Plasma == Shiny

14th July 2008

Of course, the title of this post should be “Plasma is in the class of shiny things”, but standard British keyboards don’t have a set containment symbol.

Here is my desktop:

A screenshot of the desktop

Plasma == Shiny

It’s quite simple, but demonstrates a couple of the cool things about Plasma.  Plasma is, of course, all about clocks.  And so it’s vitally important to make use of this.  Above, you can see that I have a clock showing “Seigo-time”.  Because it’s handy to know when the project maintainer is likely to be awake.

I have a notes plasmoid.  I don’t use it.  It just looks cool.

The now playing widget is displaying what Amarok is playing (with its dynamic playlist!  Woo!).  Just to the right is a little bar.  That’s because my mouse is hovering over the right side of the now playing widget.  If I was hovering at the left side, the bar would be on the left.  Cool, no?  Actually, in this case it wouldn’t, because it’s clever enough not to put the bar where it would disappear off the screen.  I can use this handle to resize it (top button), rotate it (second button), remove it (bottom button) or move it (everywhere else).  If it was configurable (as the clock is, say) it would have a little spanner button for that.

In the middle of the screen is the run dialog (accessible with ALT+F2).  It’s a bit off-centre because I moved it to allow you to see the handle on the now playing applet.  I’ve typed “ksnap” into the text box, and it’s filtered down to show ksnapshot.  Even cooler is what I get if I type in “=47*3”, for example.  I get a little calculator icon with “141” underneath.  Handy.

You know what else is cool?  If you don’t like how the now playing applet looks, you can make your own (I wouldn’t blame you, it’s pretty rubbish).  And you don’t have to faff around with supporting Amarok and Juk and XMMS and whatever else.  You can just use the now playing engine that I already did all the hard work for (control of players is coming soon).  Just ask for the “nowplaying” data engine, and grab the info you need from there.

Did I mention I like KDE 4?

Plasma Bugs

12th January 2008

Just to say that a few Plasma bugs/wishes are likely to be recurring themes on Rest assured we know about them.

  • Background image sometimes doesn’t load, and the background preview in the “Configure Desktop” dialog doesn’t always update. Fixed for 4.0.1.
  • Applethandles don’t always disappear when you move the cursor off the applet. This is due to a deficiency in the Qt Graphics Canvas hover event handling. We’re looking into either a sensible work around or for TrollTech to fix it. We have a 99% workaround for 4.0.1 (see aseigo’s comment on this post).
  • No panel configuration (apart from adding & removing applets). It’s coming.
  • If your desktop crashes (or you kill it with killall plasma – handy tip: use kquitapp) part way through your first run, only part of the config gets saved and you no longer have a panel. Fixed for 4.0.1 (see aseigo’s comment on this post).