Tech tip #11: How to have animated wallpapers in KDE

I’ve seen many people asking how to have animated wallpapers in KDE. The current options include specialised Plasma Widgets, or the rather limited yet specialised array of animated effects, such as desktop globe, seasonal change, or virus simulations.

Unfortunately there isn’t a native way to accomplish this, but KDE being KDE, there’s always a workaround.

The idea is to use mplayer to play a constantly looping, muted, fullscreen video and tell it to play on all desktops, underneath all apps, and not show up as a window in the taskbar, switcher, or pagers.

Here’s the snippet:

mplayer -fixed-vo -loop 0 -nosound -fs -name 'animbg' /path/to/yourvideo.avi

Save it as file and chmod +x (not required but useful for convenience)

The -fixed-vo flag prevents reopening a new window every type the -loop 0 flag is called. -nosound and -loop is self explanatory, and -fs is fullscreen. The -name flag allows us to set a specific window class, which will be picked up by a specific KDE window rule we will create.

A quick note here that mplayer also has the -title flag, which we should be able to use to create a KDE window rule for, but it seems as though either mplayer creates the window and only afterwards changes the title, or KDE has a bug, and so the KDE window rule doesn’t match at runtime.

We can then go into System settings -> Window Behaviour -> Window Rules and press “New” to create a new window rule. Set the window class to an exact match as shown below. For more information you can view the KDE Userbase page on window rules.

In the Size & Position tab, check Desktop, and set it to Force All Desktops. In the Arrangement & Access tab, check Keep below, Skip taskbar, Skip pager, and Skip switcher, and set them all to Force Yes. Hit OK, and Apply your settings. For more information you can again see the KDE Userbase page on window attributes.

Tada! Now you have an animated wallpaper! You can set KDE System Settings -> Startup & Shutdown -> Autostart to run your .sh file.

Life & much, much more

Presenting the Nagger

Over Christmas one of my more humourous gifts to my parents was to allow them to remotely nag each other electronically. Since my dad is often overseas, this actually has some practical use.

The idea was to create a remotely synchronised dynamic wallpaper with text that could be set by another person remotely. Person A would type in some text, a wallpaper with the text formatted would be generated, Person B’s computer would detect that there is an update, download the wallpaper and set it immediately. (I originally wanted to make a pop up message, but realised that having "Go and exercise!" pop up during a powerpoint presentation with your boss wasn’t the best thing)

The system would operate as such: I would create a html form on my webserver to allow somebody to type in text. PHP would take the text and use GD to generate a .jpg file of an image with the text overlayed on top. Batch file on Windows computer would download the .jpg file (either on startup, or via cronw) via URL2FILE. Batch file will call imagemagick installed on the Windows computer to convert .jpg to .bmp because apparently that’s what Windows likes for wallpaper formats and converting on the server would mean a ultra big file download. Finally, batch file will tweak the registry to change the wallpaper and "refresh" it such that it changes immediately.

Here’s an example :)

PHP code:

if (isset($_POST['submit']) && isset($_POST['nag']) && !empty($_POST['nag'])) {
$width = 1280;
$height = 800;
$imgname = "wallpaper_blank.jpg"; # The empty blue background template
$im = imagecreatefromjpeg ($imgname);
$text = $_POST['nag'];
$textcolor = ImageColorAllocate($im, 255, 255, 255);
$font = 20;
$font_width = ImageFontWidth($font);
$font_height = ImageFontHeight($font);
$font_width = 10;
$text_width = $font_width * strlen($text);
// Position to align in center
$position_center = ceil(($width - $text_width) / 2);
$text_height = $font_height;
// Position to align in abs middle
$position_middle = ceil(($height - $text_height) / 2);
imagettftext ($im, 15, 0, $position_center, $position_middle, $textcolor,
'/path/to/ttf/fontfile/AllOverAgainAllCaps.ttf', $text); # We're offsetting this a little to give space for desktop icons
Imagejpeg($im, '/path/to/final/image/wallpaper.jpg', 100);
chmod('/path/to/final/wallpaper.jpg', 0644); # Ensure we can download it (depending on server setup)
echo 'Nag done!';
} else {
echo '<form action="" method="post">';
echo '<textarea name="nag" rows="10" cols="50"></textarea><br />';
echo '<input type="submit" name="submit" value="Nag!">';
echo '</form>';

Batchfile code:

C:\path\to\URL2FILE.EXE C:\path\to\save\wallpaper.jpg
C:\path\to\imagemagick\convert.exe C:\path\to\save\wallpaper.jpg C:\path\to\save\wallpaper.bmp
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\path\to\save\wallpaper.bmp"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 0
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

I thought it was cute, parents loved it.

P.S. If anybody knows a sane wait to input code into WordPress/Blogilo and have it immediately embedded in <code> tags as well as not lose whitespace, give me a poke.

Life & much, much more

Design, photography, and servers.

It’s been a hectic few days. First off, I was pleasantly surprised to read on the KDE dot news that the KPresenter template contest winners were announced. I was very happy to hear that my submission had been chosen for 1st place! Here’s a picture for those too lazy to click.

Secondly, I’ve been learning a little bit more about photography, and so here’s a little preview of one of my photos. I decided to burn-in the Gentoo logo on the bottom right so that it serves as a nicely patriotic wallpaper. It’s a vague enough shape to be mistaken for part of the picture, but recognisable enough to be Gentoo (I don’t like in-your-face logos). You can download a high res version here. Here’s a snapshot for the lazy. Perhaps other Gentoo users might appreciate another wallpaper!

Finally, I’ve purchased myself a basic VPS plan from JohnCompanies – of whom is the parent company of a very commendable company called, of whom I’m still very happy with. Although not as cheap (as in, cheap + high quality reviews) as alternatives such as Linode (who offers double the resources at the same price), I went on a gamble that my great technical support experience will transfer over into a similar great experience.

Unfortunately, JohnCompanies does not offer Gentoo on their VPSes, only on their dedicated server packages. After some quick debate, I went for Debian. I shall proceed to migrate a few of my sites to this new server as well as a few of my existing hacked-together serverside toys. If you experience any downtime or shoddiness with any of my sites (blog + email included), it’s probably just due to the migration.


Hello Planet KDE!

Hello all KDE users out there! If nothing got borked in the process this blog post should be aggregated in the Planet KDE feed :)

Obviously, this is my first post, and that warrants some introduction to any new readers out there.

My name is Dion Moult, I am a KDE-user (running on my favourite flavour Gentoo) and have joined Hans Chen in his path to become a KDE developer. My posts would document my progress and should be interesting as we do come from very different backgrounds. I actually described a bit about myself in my first post about “The Road to KDE Devland Moult Edition #0” – so I don’t see any benefit of repeating myself here.

The posts that appear here will be manually filtered from my blog posts with the tag “planetkde” – this means that you will not benefit from the vibrant and unpredictable publications on the full monty of my blog, but this should still add to the community that KDE has managed to create – something unquantifiable relative to “lines of code”.

In case you bothered to click that link to my first road-to-kde-devland post, you would know that I do graphic design too – and since nobody likes walls of text, here is a blue-ish wallpaper dedicated to KDE (not really, it was a design I had started on then stopped because I didn’t like it) and of course, it’s made with GIMP (sorry haven’t tried Krita yet):


In a nutshell: “hello” (I really should apply for law school or something)