Thursday, February 9, 2012

HOWTO: Run your Games in a new Xserver

When I play a game that runs full screen on Linux but still want to have things running in the background I'd like to check on here and there without closing my game I typically launch my game into a new Xserver instance. This fairly simple setup allows you to change between Xserver instances by using ctrl+alt+f7 and ctrl+alt+f8.

To launch your application into a new Xserver instance you simply need to launch the program as follows (I'll use Desura in my example):

xinit /home/honey/desura/desura %U -- :1

Once you run this your screen will flick once or twice as the new X instance is created and the program is automatically launched within it. This new X will be accessible via the keyboard shortcut ctrl+alt+f8, to get back to your previous X instance simply press ctrl+alt+f7.

Now, one other thing to note is that on some Linux distributions you may be greeted with the following message when you try to run xinit as a normal user:

X: user not authorized to run the X server, aborting.

Don't panic, the fix for this is also simple. In terminal run:

sudo nano /etc/X11/Xwrapper.config

This will open a file for editing - we only need to adjust one line. Make sure somewhere in this file is the line:
allowed_users=anybody

Save and close the file and the above xinit file should now work. Happy gaming folks!

~Jeff Hoogland

15 comments:

  1. Would that cause Desura to launch all games on that X Server?

    ReplyDelete
  2. neat

    thanks for the tip!

    ReplyDelete
  3. ever heard of xnest or xephyr?
    you can run a gnome desktop in the window of a kde desktop or vice versa ... or any desktop environment combination for that matter

    ReplyDelete
    Replies
    1. Thats not really practical... If a non-full screen game was desired simply change the game settings.

      Delete
  4. Wow, so I'm not the only person who does this!

    ReplyDelete
  5. To go the other way around.... On slower computers, you can sometimes get a tiny bit more speed by not running all of those pesky desktop environments and other resource hogs.

    In which case, create a desktop file in /usr/share/xessions - a good way to start is to copy the xterm.desktop file and edit it to launch your game (as well as rename it). Then, when you go to log in, change your "session" to that game. I always thought that this would be a brilliant way of turn Linux into a console type setup.

    ReplyDelete
  6. Interesting, but not very useful as the games get spawned without any sound.
    Or maybe I'm doing something wrong?

    ReplyDelete
    Replies
    1. you must add your user to the audio group and reboot your computer.

      sudo add username audio

      Delete
    2. That did the trick, thanks.

      Delete
  7. Does this work with Minecraft? I didn't have any luck trying to do so.

    I get the following messages:

    Warning: unknown mime-type for "/path/to/Minecraft/" -- using "application/octet-stream"

    Error: no "view" mailcap rules found for type "application/octet-stream"

    waiting for X server to shut down ddxSigGiveUp: Closing log

    ReplyDelete
    Replies
    1. I've managed to launch minecraft in a new xserver, but it did not work very well; I usually get 20fps, but ran like this I got 5fps tops. Still tweaking the setup, gonna see if I can get it working better

      Delete
  8. Worked for Desura, but the games got launched behind the Desura window - and there's no alt+tab.

    ReplyDelete
    Replies
    1. All my Desura games launch full screen so this is a non-issue for me.

      Delete
  9. Nice way of launching a game. I don't have time to play games like I used to, but if ever the opportunity arises, this is how I will do it. More than likely though I will never play a game on my computers. Not enough time in the day, and ultimately more important things to do with my free time. Nice article though.

    ReplyDelete