Running a nested X-Windows server

This post was written by eli on October 30, 2013
Posted Under: Linux,Virtualization

Why?

It’s sometimes desired to run an X-Windows program in a separate “screen” but not actually have another screen. The expensive way is to bring up a whole virtual server. But if it’s fine to run the program on the same computer, all we want is to have a window, in which the program is confined.

This is handy if the program has a tendency to steal focus with popups all the time.

It’s also useful for opening windows from a remote machine, and the regular X server refuses despite being generous with “xhost +”. The nested server isn’t picky with who it’s hosting.

Some installations

First, install Xnest if it’s not already installed, e.g. (as root)

# yum install Xnest

It’s also possible to install a very simple (and somewhat yucky) window manager

# yum install twm

Action

Then open a new window, which turns into a new X server:

$ Xnest -s 0 -ac :1 -geometry 1900x1020+5+0&

The dimensions given by the “geometry” flag are those making a full screen coverage on my monitor. This varies, of course.

Launch a Window Manager and a terminal window in the new X server. The former is necessary to make windows movable, resizable, etc.

$ twm -display :1
$ DISPLAY=:1 gnome-terminal &

Note that apparently nothing happens after launching the first command, because there are no clients in the Xnest window.

And then use the terminal to run applications inside the nested X-window server.

twm too yucky?

The Gnome Window Manager can be used instead of the command issuing twm:

$ DISPLAY=:1 gnome-wm &

The reason not to use Gnome’s window manager is that it allows minimizing windows. If that is done accidentally, the window is lost (unless a bottom panel is generated, which starts to get a bit messy for a simple task).

 

Add a Comment

required, use real name
required, will not be published
optional, your blog address