Showing posts with label plasmoids. Show all posts
Showing posts with label plasmoids. Show all posts

Tuesday, 18 August 2009

How to make Conky play nicely with KDE 4.3

Up till recently, I stuck fervently to Gnome DE, since it was the default on Ubuntu 8.10. After I upgraded to Ubuntu 9.04, I decided to give Kubuntu a whirl (the current version of Kubuntu is KDE 4.2), but I could barely get it to run for an hour without a total system freeze, so I ditched that idea!

When KDE 4.3 came out, I was willing to give it another try, especially as a number of folks on the August Screenie Thread at the Ubuntu Forums said that it was much faster and better all around than 4.2...Well, they didn't let me down! However, this is not an I LOVE KDE thread...

Since I depend heavily on Conky to keep my system running, I needed KDE and Conky to play nicely together or I wouldn't be able to use it full-time. Since I already used a startup script to run Conky, I just let that run in KDE and, uh, got this:
From My Little Desktop Photos

After a bit of investigation (thank you, Internet), I discovered that the reason was twofold: first, Conky uses pseudo-transparency instead of ACTUAL transparency; second, KDE doesn't draw wallpaper to the root window, only to the plasma desktop. To clarify these points:
1) Pseudo-transparency in Conky means that it peeks at the root desktop and draws it as the background of the Conky window.
2) KDE draws wallpapers to the plasma desktop only, which is the lowest window on top of the root window. Instead, the root window is empty, which shows up in Conky as black. Yuck. Well, unless you really like black.

Anyway, after much tinkering, I have gotten my desktop to look like this:
From My Little Desktop Photos

Yay!

To get your Conky and KDE to cooperate, rather than pugilate (is that a word?):

Use feh to draw the current background to the root window.

Feh is a lightweight image viewer, but that's really irrelevant, since it does what we need it to here! To install it (if you haven't already), use:
sudo apt-get install feh

I will assume for the moment that you are already using a startup script to launch your Conky from the startup programs menu...Mine initially looked like this:
#!/bin/bash
sleep 15
conky &

I wanted to run feh just once before Conky started up, so that the root window was already drawn before Conky tried to peek at it, so I modified my conky_start.sh to be:
#! /bin/bash
feh --bg-scale `grep 'wallpaper=' ~/.kde/share/config/plasma-desktop-appletsrc | tail --bytes=+11`
sleep 15
conky -&

A couple of notes...The "--bg-scale" option assumes that you use "scale" to draw your wallpaper (as opposed to center, tile, etc.). If you do use another method, you can also use --bg-tile --bg-center, etc. instead. The feh looks at the plasma-desktop-appletsrc file to see what wallpaper is currently being used, and draws that to the background.

And as with all tweaks, there are a couple of pitfalls. First, because we're running feh just once before Conky starts, if you change backgrounds during your session, it won't change in Conky, a la this:
From My Little Desktop Photos

I would recommend doing a
killall conky
~/scripts/conky_start.sh

and restarting the plasma-desktop to redraw your Conky (I just log out and back in).

Another pitfall is that if you use the stock KDE wallpapers, this method may not work. That's because the "wallpaper=" field in plasma-desktop-appletsrc in this case points to a directory, not a file, and somehow KDE figures out which of several resolutions to use. Feh can't figure that out, so it draws nothing, and you're back to the black background. The workaround is to find the wallpaper you want, copy it into, say ~/Pictures/Wallpapers/ and select it from there with the Desktop Settings dialog.

Ensure that your Conky window doesn't overlap any plasmoids.

Regardless of whether you use own_window_hints below (see my previous post), plasmoids will always draw still lower. So if your Conky window overlaps, you'll get something like this:
From My Little Desktop Photos

(Keep in mind that I use Compiz to make my Conky semi-transparent, as in another previous post...)

Enjoy KDE!!!


Well, that's pretty self-explanatory...!