In this post, I have used Arch Linux with openbox running on my Lenovo Z560. The process should, however, work with all Linux Distros.
What is Xephyr?
From the Xephyr manual page
Xephyr – X server outputting to a window on a pre-existing X display
Xephyr is a kdrive server that outputs to a window on a pre-existing “host” X display.
In simple words, Xephyr allows you to nest X server within a X server. You can always create a new X server with startx — :1 , but what it actually does is create a new parallel X server in a new tty, which means only one X instance is handled at a time and you need to perform a Control, Alt, and Function combination each time you need to switch between X instances which is quite frustrating and inconvenient. Here is where Xephyr differs. It creates a new instance of X server within the current X server. The new X server behaves like any other application window. You can execute applications, as well as full Desktop sessions in the nested X server.
Advantages? Well, it is quite cool! Other than that, you can use it for conveniently testing out different Desktop Environments and window managers without any disruption to the current X session. You can also use it to forward X sessions via ssh without VNC. Although you can forward X applications using ssh without anything else, imagine forwarding multiple applications or a whole Desktop session.
Xephyr should be available on your Distro’s repository. Install it from there. Arch Linux users can install it from
$ sudo pacman -Syy xorg-server-xephyr
or download and compile it from http://www.freedesktop.org/wiki/Software/Xephyr
$ Xephyr -ac -screen 800x600 -reset :1 &
-ac : Disables access control restrictions and allows to forward the session
-screen : sets the resolution of the new X session. Set it according to your need.
:1 : This specifies that the new X session is display number “1“. Your current Display is most probably “0”
-reset: Resets the X server when the last X client is closed.
The Xephyr should start and you will get a blank new window.
The $DISPLAY environment variable tells the X client to which X server it should send its output to. Thus, $DISPLAY controls in which X server an X application pops up. As you must have figured it out, by default, $DISPLAY is set to “:0“.
Now, set the $DISPLAY to “:1” so that you can send output to the Xephyr window.
Then shoot up any X application and it will get displayed in the new X Server.
$ xterm & $ chromium &
Running Desktop Sessions
Time for some cool stuffs.
Running complete Desktop sessions is also possible in the new server. After setting the $DISPLAY to “:1″, run the command which shoots up the Desktop Session. eg. for awesome window manager, it would be awesome -c ~/.config/awesome/rc.lua.new
For KDE, dbus-launcher /usr/bin/startkde worked for me. The process is similar and simple for most other Desktop Environments and Window manager.
Here is a snapshot of my main openbox session in which an awesome (window manager) session is nested, in which in turn is a nested KDE4 session.
Forwarding the nested X session
One advantage of running nested X sessions using Xephyr is the ease and flexibility of forwarding the new X session.
Start the ssh daemon on the server machine. On Arch Linux, do this by
$ sudo rc.d start sshd
In this example, i will use the same machine as client and server. Start the new X server with Xephyr just as the above examples
$ Xephyr -ac -screen 800x600 -reset :1 &
Time to forward a X application (here, xterm) to the server,
$ ssh -XfC -c blowfish nimesh@localhost xterm
The usage is
ssh -XfC -c blowfish user@server application
I had a problem in forwarding the X session where i would get the following error
X11 forwarding request failed on channel 0
xterm: Xt error: Can’t open display:
xterm: DISPLAY is not set
This is caused when ipv6 is enabled but there are no ipv6 interfaces. I solved this by adding the following lines in /etc/ssh/sshd_config
As i said in the first lines of this post, my next aim is to use Xephyr to configure multi-seat using only one graphics card. Will post about it later.
Anyways, any corrections, feedback, queries, etc, feel free to comment.