Sonntag, 6. Februar 2011

Howto use Ratpoison as a Window Manager for KDE

Introduction

skip to the technical desciption
I love to use ratpoison as a Window Manager, as its a very small and simple tiling window manager, that does exactly what I expect it to do, most times, and integrates perfectly in toolchains, making heavy use of terminals, screen, vim and of course the famous vimperator firefox plugin.
Actually its a pain in everyday use of the computer to switch the fingers motoric focus to between the rattish rodent, formerly known as "mouse" and the keyboard.
So the aim of ratpoison, as the name says, is to ban the computer mouse, or whatever else pointing device you are addicted to use to, getting you, the computer user, into a more free, position as a ruler of your own hardware, and not the opposite (as in addicted to the hardware).
Linux terminal users used to have the reputation of having a black screen with a blinking light somewhere in the lower left area of the screen, typing in strange and lengthy character lines that result either in "?" (when even using ED in the terminal), or in some empty response or even many screens of strange characters scrolling fast over the one and only text window.
Though most linux users I know of even like 3D open gl extensions, using a animated cube to switch between full screen terminal desktops, within a graphically full pimped KDE screen.
On the other hand, it does not makes sense to have multiple desktop which such a versatile window manager, ratpoison is, I still like to have those shiny features a KDE desktop provides, sometimes, showing my the time of day in a nice desktop clock and the local weather conditions, that I need to pass through, when I need another pizza.
In the last weeks I decided, that I cannot miss, under any circumstance, the cool look of a halve transparent terminal window living on top of a cool desktop background.
But ratpoison is so simple, that is so simple, being far away from being a composite window manager and is it not easy to use ratpoison within a KDE4 session, with a plasma-desktop. So I will describe here in short, after the bit lengthy introduction, how to use ratpoison as a window manager for KDE4 anyway, using some of the cool look of a composite window manager too.

Now for the real thing

First of all you need to tune ratpoison a bit in .ratpoisonrc, to put the "plasma-desktop" windows into unmanaged mode, leaving them (nearly) untouched by the window manager So you need a line in $HOME/.ratpoisonrc:
unmanage plasma-desktop
As ratpoison isn't a composite window manager at all, you can add a simple transparency mode, using xcompmgr. This one can be tuned by some options introducing fading and drop shadows (useless for our borderless ratpoison windows), I simply use another line in $HOME/.ratpoisonrc to start that up:
exec xcompmgr -n
Now you should edit some kdm session to start a ratpoison-kde-session session start file. Those .desktop files can be found in /usr/share/xsessions. I use such session files to start gpg-agent, ssh-agent or some xprop or xset tunes, but finally you need:
export KDEWM="/usr/bin/ratpoison"
exec startkde "$@"
Now you should be able to startup a full KDE session using ratpoison as the window manager. The plasma-desktop is started unmanaged as a fullscreen root. The xcompmgr makes it possible to start a konsole or gnome-terminal or XFCE terminal or any other transparency capable terminal and have a cool dimmed transparent look for you former black and white text input windows.
If you want to focus the desktop, to setup some mini programs you can simply press ^t- to unselect a focused window and show the unmanaged background. You can also pad the ratpoison controlled area with ^t:set padding left top right bottom making the desktop more visible. I generally have some shortcuts to quickly show and hide dedicated parts of te desktop.
Now there are two slight problems I leave on TODO for now, one of which I already solved by a patch to the ratpoison code. The first problem is, that the KDE control panel is hidden invisible behind the desktop, as ratpoison has no means of stacking order or dock and desktop window types. This one can be solved by a very simple and short patch I already fed to the ratpoison development team.
The other problem is, that there is no way, to get input focus into plasma mini programs or panel main menu for example. This patch shouldn't be too hard too, but still needs a bit research in the ratpoison code.

Tuning xcompmgr

As it is very easy to use ratpoison to write hooks and custom keyboard commands, it is also very easy to control xcompmgr through simple scripts.
The atom used to control a windows opacity for example, is called _NET_WM_WINDOW_OPACITY, whose value us a 32bit unsined integer (cardinal), that expresses the opacity value from 0xffffffff for full opaque to 0x00000000 for full transparency. A simple call to xprop can change the opacity of the window:
xprop -f _NET_WM_WINDOW_OPACITY 32c \
        -set _NET_WM_WINDOW_OPACITY 0x90000000 \
Here xprop lets you select the window by mouse click.
Let's assume we want to change opacity to value x in ratpoison frame number y:
c=$(ratpoison -c "curframe");
ratpoison -c "fselect $x">/dev/null
id=$(ratpoison -c "info %i")
ratpoison -c "fselect $c">/dev/null
xprop -f _NET_WM_WINDOW_OPACITY 32c \
        -set _NET_WM_WINDOW_OPACITY $y \
        -id $id
It's all so easy now.
More help on this topic is available at ikrabbe dot ask at gmail dot com

1 Kommentar:

  1. Hi, I cannot get the kde panel to be shown... Could you please help me ?

    AntwortenLöschen