An X for every application

I picked up an odd tip the other day, by way of questions about window managers. falconindy pointed out that, rather than looking for a lightweight option, perhaps better route is to open another instance of X.

It’s something that I knew I could do, but didn’t really want — or need — to. After all, I’m normally I’m opposed to X in general, on account of the weight it has put on in recent months (years?). But something as quick and easy as this actually might prove … well, quicker and easier. :roll:

#!/bin/bash
DISPLAY=:1
X :1 -ac -terminate &
sleep 2
$*

Copy, paste, mark as executable. Call it from the terminal and suffix it with the name of the application you want to run. Switch between them by way of the CTRL+ALT+F# keys, with successive servers getting successive numbers.

Memorywise, I don’t know if it is a wise idea, or at least a wise idea for something as slow as this. On the other hand, it’s a dwindling population that uses machines with those specifications, so it might be perfectly acceptable for anyone using something built after 1999.

I gave it a try on a machine running Arch and had no real issues; whether or not you use it may depend on how practical it works out for you. After all, most window managers support multiple “desktops,” and so adding a whole different instance of X may be overcomplicating things to an unwieldy degree. You’re the best judge of that though. ;)

About these ads

12 thoughts on “An X for every application

  1. sigtermer

    you have a display error in your script. the & in the third line is displayed as is.

    by the way, try using newer hardware. i can see why you do this, but it comes to a point when it just isn’t practical anymore. just an opinion ;)

    Reply
    1. K.Mandla Post author

      Thanks, got it.

      Yes, I suppose its going to be practical or impractical, depending on the person. For me, it’s not something I would probably use often, regardless of the hardware.

      Reply
  2. Greg

    Extra X servers have their uses- for instance, trying out new WMs without closing out all your open applications, or running full screen games like World of Warcraft in Wine without having to close it every time you want to switch programs.

    Reply
  3. Jose Catre-Vandis

    Do you have to be root (or sudo) to do this? I tried it out from a terminal whilst in Xubuntu 9.04 and needed to sudo the command to get the new display. Cute trick though :)

    Reply
  4. LeoSolaris

    I’ve never had to be sudo to use it… but then again, I do not open a new X with the same user either. I have a few different users, and occasionally use this sort of thing to switch to them.

    Since startx doesn’t work for a second user, you could just use the command: xinit — :X

    (X= number of running X’s plus one. So xinit — :1 would be a second display, xinit — :2 would be the third and so on.)

    In theory you can make as many as you like, but switching between them with the Ctrl+Alt+Fn keys is limited. If you have F1-F6 as consoles, then you have F7-F12 left as easy switches. There is probably a way around this, but I don’t know it right off.

    Reply
    1. Jose Catre-Vandis

      xinit — :1 also requires sudo.

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

      When run as sudo, it fails

      Fatal server error:
      Server is already active for display 0
      	If this server is no longer running, remove /tmp/.X0-lock
      	and start again.
      
      
      Please consult the The X.Org Foundation support 
      	 at http://wiki.x.org
       for help. 
      
       ddxSigGiveUp: Closing log
      xinit:  Server error.

      This is on Xubuntu 9.04 – no funny business on the install :)

      Reply
        1. Stevko

          Look at file Xwrapper.config. You find allowed_users=console there. It means only users from console can run new X. You can chenge it to allow anyone to start X. I do not know if it is good or bad idea.

          Reply
  5. vespas

    this should be ok memory-wise since most of the memory should be in shared libs, so already loaded with the first instance of X. have a look at top’s SHR field.

    Reply
  6. Naib

    newx() { DISPLAY=:1.0; xinit $* — :1; };
    in your .bashrc

    then just: newx foo

    alot simpler

    Reply
  7. Jakob

    Really nice idea! Works fine. I use it to launch mplayer (playback in framebuffer doesn’t work with my setup).

    Reply
  8. Isengrin

    This is great for me since Awesome just can’t handle java apps (they look as an empty grey window).
    So, when I need one of them I call it this way. Thanks. :D

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s