Conky Transparency Fix for KDE4

I love the feeling of power that comes from doing something that google couldn’t help with :)

In this case, I’ve spent the past couple days messing with Conky (yes, it is as addicting as they say). A google search will tell you what it is, and another will show you all the cool things it can do. One thing that absolutely irked me, though, was the lack of transparency under KDE4. Basically, my options were:

  1. Use “own_window_type override”, which seemed to allow transparency, but conky would crash unless I set use_xft to no. So I got true transparency, but no sexy fonts.
  2. Use “own_window_type normal”, and use sexy fonts with use_xft set to true, but using the “pseudo-transparency” that conky uses would use the wrong wallpaper.
  3. Use #2 above, but set own_window_transparency to no, and use a solid color background.

While I was tweaking conky, I was using #3. Not the best I could hope for, but the best I could get without any help. And good enough for development.

When I asked google for help, I found out several things:

  1. Conky uses the wallpaper set on the “root window” for its pseudo-transparency.
  2. KDE4/Plasma uses its own desktop-drawing to draw the wallpaper.
  3. KDE4/Plasma does not update the root window’s wallpaper when it updates the desktop’s wallpaper.
  4. The latest and greatest KDE4 versions are phasing out DCOP support in favor of DBUS. DCOP, coupled with a program called “feh”, is what many workarounds to this issue have used.
  5. The DBUS interface to KDE4 is not yet fully developed, and, as such, has no way to get the current desktop wallpaper.
  6. A method has been pieced together that greps the user’s appletsrc file to get the user-set wallpaper:
    feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-appletsrc | tail --bytes=+11`"
  7. Nobody seems to have hacked together anything that works for those of us who use the slideshow feature of KDE4.

Figures. Anyway, after some more digging around, I’ve created a script which fixes the problem for slideshow-users:

# kde4bg - by Andrew Rowls <>

SLIDEPATH=`grep slidepaths ~/.kde/share/config/plasma-appletsrc | tail --lines=1 | tail --bytes=+12`
WALL=`ls --sort=time --time=atime "$SLIDEPATH" | head --lines=1`
feh --bg-scale "$SLIDEPATH/$WALL"

Part one (SLIDEPATH) greps your appletsrc file for the directory(ies) set as your slidepath. In the appletsrc file, this is probably a comma-separated list of directories, but I only wrote the script to handle one directory. Also, you may have noticed that I used the directory ~/.kde rather than ~/.kde4. I looked at the ctimes (modification times) of those files (basically, the times KDE4 last modified them). The ctime for ~/.kde4/share/config/plasma-appletsrc was about 5 days earlier than ~/.kde/share/config/plasma-appletsrc . A little further digging, and I found that the “kde4 version” had an old path to my slideshow directory, while the “kde version” had the current (ie, correct) path. If your KDE4 installation still uses ~/.kde4, change the directory appropriately.

Part two (WALL) gets the last-accessed file in that slidepath. Basically, every time Plasma changes the wallpaper, it has to *access* the image file, read it into memory, and display it. As long as the access times (read: wallpaper switches) are at least a minute apart, the current wallpaper will bubble to the top so we can grab its name. This, of course, assumes that 1) only your slideshow images are in your slidepath directory and 2) you don’t go messing with those image files very often.

Finally, part three uses feh to set the root window’s wallpaper, giving it the full path to the image file.

Now, every time you run this script, it will find the last-accessed (presumably by Plasma itself) file and set it as the background, at which point Conky can use that image for its pseudo-transparency. Since the script has to be manually run, you could put it on cron or as a part of Conky’s updating, like this:

${texeci 3 /path/to/kde4bg}

That’ll execute the script every 3 seconds from conky. You could put it as every 1 second, but I noticed that, when I tried it, the cpu usage would get a little carried away. 3 seconds is enough to keep cpu usage down while keeping the “transparency” sufficiently up-to-date.

Quick disclaimer: This was just a quick throw-together script, written based on my needs. The main issue with it right now is it only supports one slide directory. In KDE4, you can set multiple directories, but I really don’t know what that would do to the script. Probably just confuse it, but then it wouldn’t work.


Comments are closed.