Abenteuer aus tausend und einer Nacht.

There is a lot of software I really dont like. And I often write about it. So I thought, maybe I should start writing about software I like. And well, there is actually plenty of it.

Well, one piece of software I really do like is Xvfb. It is an X-Server, drawing on a virtual framebuffer. X-Servers like Xvnc and Xrdp are basing on it, the pgo-compilation of Firefox I was using used it to run Firefox in a virutal X-Server, and it should be much more versatile, but maybe its too unknown.

To start it, like most X-Servers, just do

$ Xvfb -ac :1 &

Then lets start a Window-Manager and an Xterm

$ fvwm -display :1 &
$ xterm -display :1 &

Now we have a twm running with an xterm. W00t. But we cannot see anything yet. So lets kill the server again and restart it with a few more arguments:

$ Xvfb -ac :1 -shmem -fbdir /tmp/fbdir &
$ fvwm -display :1 &
$ xterm -display :1 &


Now, lets get a screenshot:

$ cp /tmp/fbdir/Xvfb_screen0 ./screenshot.xwd
$ convert screenshot.xwd screenshot.png
$ rm screenshot.xwd

we get a file "screenshot.png" looking like



which looks like what we wanted to have. A fvwm with an xterm. Unfortunately, we cannot type anything inside it. And we cannot move the mouse. We have to use a trick here, and use the XTEST-Extension for Xvfb.

That is, kill Xvfb again, and run it with the XTEST-Extension:

$ Xvfb -ac :1 -shmem -fbdir /tmp/fbdir +extension XTEST &
$ fvwm -display :1 &
$ xterm -display :1 &

First, lets move the mouse on top of our xterm, since that is how to get the focus under fvwm in its default configuration, and then we can type in:

$ DISPLAY=:1 xdotool mousemove 100 100
$ DISPLAY=:1 xdotool type "apt-get moo"
$ DISPLAY=:1 xdotool key Return

And now lets get a screenshot like before

$ cp /tmp/fbdir/Xvfb_screen0 ./screenshot2.xwd
$ convert screenshot2.xwd screenshot2.png
$ rm screenshot2.xwd

Now our screenshot is



Well, its a bit more complicated than one would maybe want it. But compared to some other X11-Stuff, it is easy. And its very nice to have such a thing.