Transparent Conky in KDE, part 2

I posted earlier about getting Conky to be transparent in KDE. Unsetting and resetting the “Show icons on desktop” and “Allow programs in desktop window” options would allow Conky to look correct when transparent. Otherwise it would be a black box.

This is OK but it's a hassle to do this every time I restart KDE. Via various posts on the Gentoo forums I finally realized WHY this works (I think). Conky's pseudo-transparency works by reading the root window, and then compositing itself onto that. The root window is apparently not what normally shows in KDE when you're looking at your desktop background. KDE apparently draws another window on top of the root window and displays the desktop window there (including your background wallpaper and icons). Underneath that is the REAL root window, and it's entirely blank by default. Conky sees that real root window and composites itself on top, resulting in blackness.

When you tell KDE not to "Show icons on desktop", apparently KDE then defaults to setting the background of the REAL root window. So switching this option on and off results in the real root window's appearance matching KDE's "fake" root window.

Interestingly, in KDE if you do this:

  1. Set "Show icons on desktop" to true.
  2. Set a background.
  3. Set "Show icons on desktop" to false, then back to true.
  4. Change your background.
  5. Start a transparent Conky.

Conky will be properly transparent, but it will use the FIRST background you selected, not the second. This leads me to believe I'm right.

So the real way to get a nice transparent Conky in KDE is to set the background of the root window using a program like feh.

ppurka posted in this thread a great automated way to do this in KDE:

feh --bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`

If you're like me and use centered wallpaper, use --bg-center instead. Incidentally this is the relevant section of my Conky config file:

own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_page

24 Responses to “Transparent Conky in KDE, part 2”

  1. Quoth Reinmar:

    First, I start conky without config file, and it was working good - icons were on my desktop and it has transparent window.
    So, I had been adding lines from config, which I know it made icons hide and when I added ‘double_buffer yes’, icons disappeared.
    Unfortunately - without double buffering conky blinks on my desktop, what looks awful…

  2. Quoth Reinmar:

    Ok - I set own_window like you, wallpaper using feh and double buffering on. Now everything is OK :) THX

  3. Quoth Logan:

    Brilliant! I had some trouble seemingly due to the fact that my wallpaper had a space in the filename, but I changed it, reset the default wallpaper, ran feh, and all is well. You have no idea how long I was looking for this solution.

  4. Quoth Brian:

    Glad it could be of help.

  5. Quoth Dmitriy:

    Genius, you are simply genius!
    hehe

  6. Quoth demon:

    Just to thanks your contribution.
    It works in opensuse 10.2 + kde3.5.5 + beryl 0.1.4
    To make it works at start, just make a script in your $HOME/.kde/Autostart

    Thx

  7. Quoth Ewilly:

    i found an easiest way to have conky transparent without installing / using feh on KDE :

    OLDWALLPAPER=`dcop kdesktop KBackgroundIface currentWallpaper 1`
    killall conky
    sleep 10 && conky -d
    dcop kdesktop KBackgroundIface setBackgroundEnabled false
    sleep 1 && dcop kdesktop KBackgroundIface setBackgroundEnabled true
    dcop kdesktop KBackgroundIface setWallpaper “$OLDWALLPAPER” 7

  8. Quoth Brian:

    Looks similar to what I was doing by hand before I started with feh. That’s a good idea.

  9. Quoth Ed Daniel:

    Sorry to throw a spanner in the works… is there a hack for those using the ‘gradient’ desktop background feature i.e. wallpaper set to ‘none’?

  10. Quoth calraith:

    For what it’s worth, appending this line to the bottom of .conkyrc works as well as autostarting feh; but since it only executes when conky launches, I think it’s a little more graceful.

    ${exec feh --bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`}

    Yes, I’m slightly obsessive at times. =)

    Ed Daniel: I would guess you could theoretically accomplish the same task by using Esetroot or gsetroot or some other ?setroot utility capable of setting gradients.

  11. Quoth Zach:

    Thanks for the solution, conky drove me nuts trying to get it properly transparent.

  12. Quoth dragon_788:

    Thanks Brian and calraith. I ended up using feh from within conky with a direct link to the wallpaper since the dcop command wasn’t working properly.

  13. Quoth Anonymous:

    NOTE with Beryl/Compiz:

    If you’re going to put the command in your .conkyrc file use $texeci instead of $exec. Personally for me on kdemod + compiz-fusion it caused some lag when using the compiz-fusion toys. Something like this

    ${texeci feh –bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`}

  14. Quoth Anonymous:

    Actually scratch last post. my bad.

  15. Quoth Brian:

    :)

  16. Quoth TommyHot:

    Even if I use feh and my conky gets transparent, after I click anywhere on the screen, conky diseappears.
    But I can still find it in ps -auxe =(

  17. Quoth TommyHot:

    Ok it seems I’ve solved my problem. I have to change: own_window_type desktop

    to

    own_window_type normal

  18. Quoth circuit_breaker:

    for the beryl+emerald+kde users:

    own_window yes
    own_window_transparent yes
    own_window_hints desktop,undecorated,below,sticky,skip_taskbar,skip_pager
    own_window_type override

    and use the feh recipe. now they stick to the fake KDE root background and don’t drag either.

  19. Quoth sammael:

    oh my god thank you my saviour i finally can get some sleep!!! this was nagging me ever since i discovered conky, thanks a lot once again

  20. Quoth jirka:

    Woks for me, thank you very much :)

  21. Quoth jirka:

    Works for me, thank you very much :)

  22. Quoth Al:

    I googled upon this site, I use gnome, with the default conkyrc it didn’t display icons on the desktop. This line: own_window_type desktop seemed to fix the icon issue.

  23. Quoth nrwilk:

    This works for me, but after I instantiate the transparent conky, if I click on the desktop, conky disappears.

    How can I fix this?

  24. Quoth chepioq:

    I use your “feh –bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`” for my conky for a long time but now with Kde4 it is not working and I know why…
    dcop in kde4 is replaced by d-bus and I don’t know how replaced dcop by d-bus.
    Can you help me?

Leave a Reply

You can use these tags in comments (Note: HTML is automatically escaped inside <pre> tags, nowhere else, so if you post source code, put it in <pre>):

<pre lang="some_programming_language"> 
<em>
<strong>
<a href="url">

NOTE: Comments are automatically spam-filtered. If your comment fails to appear, it was likely munched by the filter. Try not to link-spam or post anything that looks like it was typed by a robot.