Erwin Müller Blog

Start New X Session Under GNU/Linux

X.Org_Logo https://en.opensuse.org/File:X.Org_Logo.png

X.Org_Logo https://en.opensuse.org/File:X.Org_Logo.png

The X server under GNU/Linux is responsible for displaying the graphical user interface and the desktop environment. The X server is a separate client application that is not inside the kernel, which is different from the model of Microsoft Windows. Multiple X sessions can be started under GNU/Linux under which different desktop environment can be started and the graphical applications are isolated from each other.

What is the advantage of starting a new X session? A new X session can start applications that will not interfere with the applications already running on the original X session, that is useful to run either games, video, music or other applications that need the whole desktop to run. One example are automated graphical user interface tests like Java FEST or AssertJ Swing that are based on the Java Robot API. The tests are usually taking control of the mouse and keyboard to simulate user input and thus the computer can’t be used during the tests. One option is to setup a server to run those tests, aka a continues integration server. But if such a server is not available, a new X session can offer the solution.

X Session Script

A new X session can be started from the command line by using the startx command. We will use a simple script to setup the screen resolution and start the lightweight desktop environment OpenBox

  • compton will enable vsync, which is useful for games;
  • xrandr will change the output and screen resolution to the main monitor;
  • exec will start the desktop environment, but can also be any other application.

After the startx-openbox.sh was created, we can now start a new X session with Openbox.

If the command startx returns with the error that the user is not authorized to run the X server (see below) then the configuration in the /etc/X11/Xwrapper.config file must be changed to allow other users than root to run the X server.

To change the configuration, either the file /etc/X11/Xwrapper.config can directly be changed by modifying the value of allowed_users=anybody, or the command dpkg-reconfigure x11-common can be user.

dpkg-reconfigure x11-common

dpkg-reconfigure x11-common

Switching Between Sessions

The newly started X session is available on one of the virtual terminals that can be switched via the Ctrl+Alt+F1...F12 keys, i.e. Ctrl+Alt+F1 the first virtual terminal, Ctrl+Alt+F2 the second, etc. On my Debian Jessie system the new X session is on the 2. virtual terminal and the original X session is on the 7. virtual terminal. After the X session is started, Openbox is available. A right click on the empty desktop will show the main menu and a terminal can be started. Inside the Openbox, the games, applications or the tests can be run and the user is free to return to the original desktop via Ctrl+Alt+F7 key.

Openbox Menu

Openbox Menu

Sources

Leave a Reply