I got a bit tired of the “ugly” look of xosd, the fonts have rough edges and I like it if it has a nice background.
So I wrote something myself.
My goal was writing a small plugin for gmpc that shows a the current song playing when pressing a key-combination. (a desktop wide key-binding). So first I had to write the desktop wide key-binding.
I started by looking at the code I copied once to bind the multimedia keys, and modified it to support other key’s, and allow me to bind and unbind keys. Beside the last one everything is working fine.
Then I started working on the display part. My first idea was to make something dashboard likely.
So make a nice overlay on the current display and display it on that.
So what I did is grab the root window gdk_screen_get_root_window and render the GdkWindow in a pixbuf.
The using cairo I rendered the pixbuf on a fullscreen window, made a 80% black overlay, and rendered on top of that.
The result was nice.. http://images.qballcow.nl/qosd/screenshot.png (the rendering of the text isn’t anything fancy yet).
But like most nice things, it was terrible slow (we need a decent Xcomposite), it was resonably ok on my mac (still 1 second delay), but on my fast laptop (with latest ati driver) you saw a screen build up.
It seems one of the slow thing was rendering the screenshot into a pixbuf. and then rendering the rest fullscreen.
So then not fullscreen, so I grabbed only the location of the screen where I wanted to draw the window and draw it there.
I ended up with this: http://images.qballcow.nl/qosd2.png.
The cairo_show_text function doesn’t support multiline, so I thought: Why not use pango for that.
This worked after a fashion (bit hackish here and there): http://images.qballcow.nl/qosd3.png
(the rounding isn’t perfect yet.)
So I thought what about a nice fade-in fade-out effect. But this appeared to be realy realy slow, so looking into the source of the delay I find out it was because of pango_cairo_layout_path and then drawing the outline and filling it.
moving it to pango_cairo_show_layout solved it. (made it look like this: http://images.qballcow.nl/qosd4.png, maybe even nicer).
But another curious thing showed up, it all went perfectly fine (<10% cpu when fading in and out). So I tried it with a bunch of different song with long titles (to test the wrapping) here I found out that when the “popup” became bigger then a certain size everything slowed down again.
If I find the time/energy, I might profile it a bit.
If you are interrested in the code let me know.