Cooking with Linux - Can't Get Enough Desktops!

Explore new user interface ideas without leaving your regular desktop. Our chef shows you how to nest X sessions.

Ah, François, I see you have decided to run Window Maker—excellent. It's a great window manager, and I think you'll enjoy it. Two weeks ago, you were running GNOME; last week it was KDE, and now it's Window Maker. I'm glad you took my advice and decided to try other desktop window managers. Choice, after all, is one of the great joys of running Linux.

Quoi? Which one am I running? All of those and a half-dozen more, mon ami. François, I am not pulling your leg. My main desktop is KDE, but over here I have GNOME and over there XFCE, and in that virtual desktop, I have Window Maker. Furthermore, I have IceWM running in my Window Maker session. No, mon ami, it is not complicated at all, and I will show you how it is done as soon as our guests arrive. But they are already here! François! Vite! To the wine cellar. Given that today's menu is more dessert than meal, fetch the 2001 Niagara Peninsula Riesling ice wine and bring it back tout de suite!

Welcome, mes amis, to Chez Marcel. Please sit and make yourselves comfortable. I have been pushing my faithful waiter to experiment with different desktops. It's always nice to try something different, which is why we change the menu from time to time, non? The same is true for your desktop environment. KDE or GNOME may be your favorite, but why not try Window Maker, IceWM or XFCE for a change? A little visit to Matt Chapman's Window Managers for X Web site at www.plig.org/xwinman should whet your alternative window manager appetite. In fact, why not try them while you are still running your favorite desktop? Non, mes amis, I have not been oversampling the wine. It is possible to run multiple desktops simultaneously, and it is a lot of fun once you get the hang of it.

As with many things in the Open Source world, there is certainly more than one way to do it. The first involves jumping out of your current X session back to one of your virtual terminals. If you already are running an X session, press Ctrl-Alt-F1 and you should find yourself back at a text screen. Incidentally, F1 just as easily could be F2, F3, F4, F5 or F6. If you started X from the command line (as opposed to using a login manager like gdm or kdm), you should see the dialog for the session when you press Ctrl-Alt-F1 with the log output from X on your screen. Any of the other function keys, F2–F6, should provide you with a text-based login screen. Simply press Ctrl-Alt-F2 for virtual terminal two and so on.

Your graphical session is still active. It runs by default on what the system calls display :0, something you can verify by typing the command echo $DISPLAY at a shell prompt (inside your graphical session, of course). You should see your PC's hostname with the display suffix. Press Ctrl-Alt-F7 to go back to your KDE, GNOME or whatever session. Go ahead and try it, and then head on back to a text screen (Ctrl-Alt-F?). Your X session, then, is on virtual terminal seven. From the text screen, log in as yourself and type the following:

xinit /usr/X11R6/bin/xterm -- :1

Notice the -- :1 at the end of this line. Because X already is running on display :0, we need to run this X terminal on an alternate display, in this case, :1. Now a new X session begins, this one running on virtual terminal eight. It looks pretty boring because all you have is a simple X terminal running on a gray background. There isn't much to look at or even any way to move the X terminal window around, but you can execute commands and even start up other X programs, which you also won't be able to move around. To go from your new session to the old, press Ctrl-Alt-F7, then Ctrl-Alt-F8 to get back to your X terminal. Easy, non? Using this technique, you could start something more interesting, like another window manager, such as IceWM or XFCE, and happily switch back and forth from one virtual X session to another.

Figure 1. A Somewhat Dull and Bare X Display with a Single X Terminal

To get out of that X session, you should know about the classic X window escape hatch, what I call the “oh, mon Dieu, I've tried everything and I can't get out of X” escape clause. Simply press Ctrl-Alt-Backspace. This is, mes amis, a rather rude way to exit X and should be used only when no other options are available.

Switching from one X session to another is fine, but doing this makes it hard to continue working on two desktops. To avoid constantly switching back and forth, I have been running a program called Xnest. Xnest, part of the XFree86 distribution, is interesting because it is both an X client and server all in one. It literally is a nested X server. Before I continue, I probably should let you know that although it is part of X, it may not be installed already on your system; however, the package (XFree86-Xnest) is likely on your distribution CDs.

In order to start a nested server, you have to provide an alternative DISPLAY variable, as we did with the X terminal earlier. Because your own X server is probably running as :0, choose :1. To make sure you can connect to this new server from any of your applications, use the -ac option as well. This option disables access controls. The ampersand starts my new server as a background process:


Xnest :1 -ac &

Now, a blank window starts on your desktop with the basic X cursor in the center. On my Mandrake system, it was a dark-blue square. On another server running Red Hat, it was black. It doesn't look like much, so let's start an X application on our new server. We start with something simple like our venerable Xclock:

xclock -display :1

When you press Enter, the classic Xclock appears in your second X server window. This also is a great way to play with things like X resources. For instance, let's dress up that rather boring clock and move it to another part of the display:

xclock -foreground "Red" \
-geometry +450+250 -display :1

Figure 2. Populating Your Nested X Server

One by one, you could populate this new server with applications—the X logo here and an Eterm there. Of course, moving windows around isn't possible in this environment, thereby making this idea only so useful. To experience the flavor of desktop mania truly, you need the whole smörgåsbord, meaning a window manager and, of course, a little more wine to go with it.

Starting a full-blown window manager is a similar process, and for this next step we start with the basic Tabbed Window Manager (TWM). This is the most basic window manager you have and comes as part of XFree86. Begin by closing the applications in your Xnest so you can start clean. You should be looking at that blank square with the X cursor in the center. Now, from the command line, type:

twm -display :1

If nothing changes, press the left mouse button and TWM's menu should appear. I did say it was a basic window manager, non? Let's try running Window Maker this time:

wmaker -display :1

As you can see, the format essentially is the same, passing the -display parameter to the window manager's command name in each case. This is, of course, where I should tell you that not every window manager uses the same switch. Here's a list of the more popular window managers and what you need to start them:

  • Motif Window Manager: mwm -display :1

  • F Virtual Window Manager: fvwm2 -display :1

  • GNOME (note double hyphen): gnome-session --display :1

  • AfterStep: afterstep -d :1

In some cases, you won't be able to start a window manager using some kind of display redirect switch. This is true with KDE, AmiWM, XFCE and some others. To run these window managers, begin with a simple X terminal in your nested X server:

xterm -display :1

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Amazing!

Al Phi's picture

This is the first truly exciting article about the X Window System that I have read.

I'm relatively new to Linux, and I've been experimenting with different window managers. But I had been starting each in its own display, which was a bit limiting to me.

I haven't encountered any talk about replacing X (except for the fact that Mac OS X uses its own GUI system), if someone could point me in the general direction, it would be greatly appreciated.

Very good

Pranith's picture

thank you, thank you. thank you...........this was fantabulous....really
out of bounds...thnx for letting me into this.

Excelent!

WilsonGC's picture

Excellent article.
Simple and very very useful.
Just what I had looking for to
display my DECwindows session over IP in
my desktop without leaving my current KDE session.

Thanks.

starting default window manager

abcollier's picture

it is also possible to just start your default window manager in the xnest window:

$ startx -- /usr/X11R6/bin/Xnest :1

the -scrns option

abcollier's picture

and the -scrns option allows multiple windows to be opened:

$ Xnest -scrns 3 :1 -ac &
$ xclock -display :1.0 &

Re: Can't Get Enough Desktops!

aru's picture

Hi,

You say, in the article:

> In some cases, you won't be able to start a window manager
> using some kind of display redirect switch. This is true with
> KDE, AmiWM, XFCE and some others. To run these window
> managers, begin with a simple X terminal in your nested X
> server:

How about this?

DISPLAY=:1 startkde

Isn't this easier than the method you suggest?

Arvind

Re: Can't Get Enough Desktops!

Anonymous's picture

The thing is to start another wm inside another one and not just run another wm inside another display

Re: Can't Get Enough Desktops!

Anonymous's picture

Xnest won't run for me on Fedora Core 1.
I get:

#Xnest :1 -ac &

Fatal server error:
Unable to open display "".

Re: Can't Get Enough Desktops!

Anonymous's picture

export DISPLAY="0:1"
Xnest blah blah blah

Re: Can't Get Enough Desktops!

Anonymous's picture

Excellent article... Somehow I knew this must be possible, but I just didn't know how to do it!

Re: Can't Get Enough Desktops!

Anonymous's picture

Xnest won't run for me on Fedora Core 1.
I get:

#Xnest :1 -ac &

Fatal server error:
Unable to open display "".

Re: Can't Get Enough Desktops!

Anonymous's picture

It would appear that the author never heard of the command

gdmflexiserver

Try it. Beats the -- :1 stuff hands down in most cases.

This requires that you have

Anonymous's picture

This requires that you have Gnome installed, though, right?

Re: Can't Get Enough Desktops!

Anonymous's picture

Sweet! Thanks.

Re: Can't Get Enough Desktops!

Anonymous's picture

>> Issue 119: Can't Get Enough Desktops! <<
>> Posted on Monday, March 01, 2004 by Marcel Gagn

Re: Can't Get Enough Desktops!

Anonymous's picture

qoute:
unfortunately XP vs Win9x and SMB athentication has always been a mistery to me, I like to setup a printer under linux using CUPS and share it to Windows using the internet printing protocol (IPP), which bypasses the SMB/SAMBA authentication stuff completely and most every OS uses. But I don't even know if RH9 still uses the (now obsolete) crappy LPD printing system or the much better CUPSD printing stuff.([L=here is a little overview for the terms with CUPS]http://www.hlug.org/presentations/cups/printing.html[/L])

To see if you are using cups, cups has a web-based configuration setup you can access thru [L=https://127.0.0.1:631/]https://127.0.0.1:631[/L]. If you can access that from your linux machine then check out [L=here]http://mumford1.dyndns.org/~bs7452/linuxhelp/cups.html[/L] and skip down to the section "add a printer" in step 4 and follow the steps that follow that. See if that makes sense, hopefully that will bypass the RH9's "helpfull" printer setup application and configure the printer for you.

Then for specific applications you may still have to specify in their printing configs to use the command "lpr" or "lpr -P printernameyouchoosed"

/qoute

Your a idiot.

Thanks for a good X Window System article

Anonymous's picture

We need more of these. X is powerful. It is multi-user at the GUI level as Linux / UNIX is at the command line level.

With all the current noise about replacing X, articles like this go a long way toward educating people as to what X is really about. It is my belief, that once they actually understand what it is they would be giving up, some of this noise may go away for a while.

Good Stuff, thanks again!

lj@opengeek.org

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState