Technical

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:

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

Save it as whatever.sh file and chmod +x whatever.sh. (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.

Dion Moult

I've been developing software for well over 10 years, work as an architect (not the computer kind, the regular sort), and am classically trained as a pianist. I try to do the right thing when I get the chance in my field, such as through contributing to open-source communities and promoting sustainable living.

More Posts

Spread the love
Tagged: , , , , , ,

14 Comments

  1. Cool idea! Personally, I do not want this, but I want to say thanks for sharing such tech tips, they are appreciated.

  2. @why: Firstly because it doesn’t seem to be out yet, has a limited choice of videos, and seems as lot more resource intensive. And as always, alternatives are good :)

  3. This Dream Desktop stuff looks really nice indeed! Using more resources than mplayer, but mplayer would cover the plasmoids, which would be the biggest disadvantage for me.

  4. Ahh, you are right! I do not use widgets on the desktop (only on the dashboard) so I didn’t realise that.

    I hope somebody can implement this natively, but until then… :)

  5. Nice hack ;)

    mplayer also has the -rootwin option which makes it draw into to X root window (ie the place below every other window.) Unfortunately KDE (plasma-desktop) puts a ‘fake’ fullscreen desktop window above it (the actual plasma desktop with widgets etc…) so to see the mplayer running in the root window you have to get rid of that ;) For that you can create a similar rule as yours for the plasma desktop window, just use the “Detect Window Properties” button, click on the desktop and choose also the ‘Window type’ match (so you match only the desktop window and not the panels) and force the dimensions to 1×1 (maybe forcing it be minimized works too.)

    A second problem with this is, that for some reason KWin’s compositor doesn’t include the root window contents, so this only works with compositing (desktop effects) disabled ;(

    Another way that works with compositing and doesn’t need to hide the plasma desktop window is to use mplayer’s -wid option to actually output to plasma-desktop’s window ;) mplayer will then draw its output to the same window as plasma-desktop. The downside is, that you still don’t get widgets and if you have any that redraw themselves oftem, it doesn’t look good (though if plasma-desktop is set to a simple black background, it works pretty well). You just have to basically run:

    mplayer -wid WINDOWID video.avi

    To find out the WINDOWID of plasma-desktop, just run xwininfo, click on the desktop and look at its output:

    xwininfo: Window id: 0x1a00191 “plasma-desktop”

    You could run something like:

    mplayer -wid `xwininfo -name plasma-desktop | awk ‘/Window id:/ { print $4; }’` -loop 0 -nosound video.avi

    however the panels also have a ‘plasma-desktop’ name, so xwininfo might return their id … (though it seems to always return the desktop one, maybe because it is created as first)

    The nearest I got to having a movie on the desktop and working widgets was by forcing the mplayer’s window to be a desktop window so it would be on the save level as plasma-desktop (create a rule for mplayer, in ‘Appearance&Fixes’ force ‘Window type’ to Desktop) and forcing plasma-desktop to be partially transparent (create a rule for plasma-desktop, for active and inactive opacity to e.g 50% in ‘Appearance&Fixes’) which works pretty well with a black background in plasma-desktop… (the mplayer window might from time to time end up over the plasma-desktop one, in that case the easiest ‘fix’ is to restart plasma-desktop e.g. with ‘kquitapp plasma-desktop’)

    Of course the best would be, if plasma-desktop could be set up to have a transparent background itself… but the simple color plugin doesn’t allow alpha and I tried a transparent png as the background, but it just created an opaque black.

  6. @YoYo, it seems as though you’ve done quite a bit of research on this! I guess now we just need to wait for a native implementation.

    Personally, I stumbled across this by accident by alt-tabbing from a fullscreen video and liking the “music visualiser-esque” effect underneath the composited panels. Admittedly it did get annoying after a while, not to mention distracting.

  7. i have a question about this method. when i right click on a desktop i cant see the menu. what i did wrong ?

  8. That works for me (kubuntu 14.04 – kde 4.13.3)

    #!/bin/bash
    DESKTOPID=”$(xwininfo -name plasma-desktop | awk ‘/Window id:/{print $4}’)”
    mplayer -wid $DESKTOPID -loop 0 -nosound /PathToVidFile

    Many thanks for Dion Moult and YoYo for their invaluable input.

  9. Here is how I got it done. You will need xwinwrap. It can be made from https://github.com/ujjwal96/xwinwrap MAJOR props go out to ujjwal96. If you are reading this thank you for uploading your fork of this old app!! Anyway… here is the command I use to display the video. My desktop widgets are still visible and accessible.

    code: xwinwrap -ni -o 0.6 -fs -s -sp -st -b -nf -un — mplayer -fixed-vo -noconsolecontrols -nosound -fs -loop 0 -wid WID /path/to/your/vid

    As you can see there is some opacity to it so you will still see your original wallpaper and widgets. You can however use plain color black background and youre good. I hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *