Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Xnest to run X11 sessions in a window UNIX
I've been holding onto this little secret for a long time; I've finally broken down. A search on google seems to imply that no one else is aware of this, or at least they aren't willing to spill the beans. So, here goes ... Apple's X11 and the XDarwin server both support running X11 full screen or rootless. Many people (including me) have been frustrated by the fact that when you run X11 full screen, you effectively lose OS X, but when you run Gnome or KDE in rootless mode, everything looks funny and you lose the X11 desktop. There is actually an in-between option.

Virtually every release of XFree86 includes a nest X server, called Xnest. This is simply an X server that is simultaneously an X client. In most instances, this is completely useless. Why would you want to run an X server inside of an X server on Linux? Debugging. Why would you do it in OS X? You do it so you can run KDE in a window.

Read the rest of the hint for the how-to...

For every window manager that you want to be able to run, you need a separate .xinitrc file. For KDE, I have a file in my home directory called .xinitrc.kde that only contains the following line:

exec /sw/bin/startkde
Note that I do not actually have a file in my home directory called .xinitrc, as I am using Apple's quartz-wm to control these windows. The tricky part is to get the new x-session open. The xinit script makes this quite simple:

xinit ~/.xinitrc.kde -- /usr/X11R6/bin/Xnest :3 -geometry 800x600
The ~/.xinitrc.kde represents the script we have written that launches kde. Anything that immediately follows this gets passed to the script.

The first item that follows -- represents the name of the X server. We want this to be /usr/X11R6/bin/Xnest because that's where Xnest should be. Everything after this counts as arguments to the Xnest command (man Xnest for more info).

The default X server (XDarwin or Apple's X11) uses display :0 as the default, so you must pick a number higher than that. Also, if you want to be able to launch more than one Xnest session, each of these will need to have a different display number. The -geometry argument just tells Xnest how big of a window you want.

Give it a shot as described above. If you like being able to run KDE or other window managers in a window, you can set them up for easy launching as aliases in your .tcshrc file or as applications in the X11 "Applications" menu.

For extra fun, you can also launch these Xnest sessions on remote machines through ssh (HOWTOs available elsewhere). Have fun!
    •    
  • Currently 3.67 / 5
  You rated: 5 / 5 (6 votes cast)
 
[77,174 views]  

Use Xnest to run X11 sessions in a window | 31 comments | Create New Account
Click here to return to the 'Use Xnest to run X11 sessions in a window' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Xnest to run X11 sessions in a window
Authored by: zedwards on Feb 06, '04 12:01:54PM

Thank you! This is very helpful!



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: shoaiby on Feb 06, '04 03:24:03PM

So I have to have Apple's X11 running before I can issue the following command?

xinit ~/.xinitrc.kde -- /usr/X11R6/bin/Xnest :3 -geometry 800x600



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: zedwards on Feb 06, '04 03:29:39PM

Yes. I'm thinking you also have to have the DISPLAY set to run X commands in Terminal.



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: jambiscuit on Feb 06, '04 01:52:10PM
This is a very cool hint--thanks for deciding to share!! It's especially useful if you want to run an XWindows session in a second monitor. If you don't want the Xnest session to start everytime you start X11, add the following line to your X11 Applications menu (replace wmaker with whatever window manager you like):
Xnest :1 | wmaker --display :1
When you select it, it will open up your window manager of choice in an Xnest session that fills 2/3 of the screen (that's the Xnest default).

[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: Detrius on Feb 07, '04 10:01:26AM
Actually not every window manager supports the --display :1 argument. fvwm, for example, has the -d :1 argument to set the display number.

This is, however, a much simpler method of launching just a window manager in an Xnest server. The xinit method gives more options, as it executes an xinitrc script for you (if you want to use twm and launch several applications, for example).



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: dhrakar on Feb 06, '04 01:53:01PM

Another option for this is to use the enlightenment window manager instead of the QuartzWM. If you enable the multiple desktops in enlightenment, all of the secondary desktops behave as if they were rootless. That is, the desktop background is set by enlightenment and desktop clicks go to X11 (and enlightenment) instead of the Finder. This means that the root menus finally work (yeah!). The best part is that when you use the pager widget in enlightenment, all of the Aqua apps swoop out of the way (even in 10.2.8 -- which I run at work) -- but you still have your normal OS X Menu bar :-). Enlightenment is available via Fink. You might be able to do this with FVWM or IceWM, but I have not tried them.



[ Reply to This | # ]
Please expand on this!!!!
Authored by: ktohg on Feb 11, '04 12:08:00AM

Please can you elaberate on this. I really would like to hear more on this idea. I've wanted to use Enlightenment for quite some time but couldn't ever get it to mesh well with Aqua.

How do you accomplish the virtual desktops to sync with Aqua and/or Quartz-wm? How do you set up the scrupts to do this? Do you run X11.app first then the xinit command with Enlightenment? Is Xnest in a window or fullscreen? Do you run X11.app with Enlightenment and then Xnest? Are these rootless or not?

Please help it sounds like what I want but can't postulate how to do this from your post. Thank you so much.



[ Reply to This | # ]
Problems with Xnest and Gnome.
Authored by: elmlish on Feb 06, '04 04:17:05PM

This is very cool, but I'm having some trouble with getting gnome to work.

I've tried setting the ~/.xinitrc.gnome file I've created to use gnome-session, but there seems to be some problems with Gnome actually starting up. For one, the Xnest window that I should have created is nowhere to be seen and a gnome dialogue box pops up and tells me that Gnome can't figure out my internet address or some craziness like that. I'm then booted to my normal Apple X11 setup whereupon I see another message telling me that gnome-session has crapped out and will try again next time.

Any clues on what I might have wrong? I can create a windowed X session using Xnest so long as I don't include an xinitrc file.

---


~elmlish~



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: kcamera on Feb 06, '04 09:42:12PM

I am running Apple's built-in X11 with Panther, and the name of my executable is '/usr/X11R6/bin/Xnest'... note the capital "X". Probably most people interested in this hint just figured that out and moved on, but for those who tried and failed, don't worry -- xnest is there but you need to adjust the case.



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: nobody on Feb 07, '04 02:39:35AM
You can have a double-clickable command on your desktop to start X11 and then the Window-manager:
make a shell script like:

#!/bin/sh
open /Applications/Utilities/X11.app
xinit ~/.xinitrc.wmaker -- /usr/X11R6/bin/Xnest :3 -geometry 1280x1024 &
and name it "X11.command".
Of course, this only works if you have to set the DISPLAY variable in your .cshrc file:

if ${?REMOTEHOST} == "1" then
        setenv DISPLAY {$REMOTEHOST}:0.0
 else
        setenv DISPLAY :0.0
        setenv TERM vt100
endif
I have no shortcuts in the Applications Menu of Apples X11 installed, so no annoying terminal window opens after X11 starts.
This way X11 launches "fullscreen" on my second monitor.


[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: PubGuy on Feb 08, '04 11:29:51PM

QUESTION: I've got a G4 iMac LCD that has a maximum resolution of 1024 x 768 and need to run an xsession on it that is designed for 1280 x 1024. Will Xnest allow me to either (1) run the program in a scaled window or (2) provide me with a scollable window?

Anyone know? Thanks!



[ Reply to This | # ]
How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: by on Feb 08, '04 04:49:50AM
This is a truely magnificent hint, thank you very much!!!

Here's what I did to be able to run a normal X11 in rootless mode as well as rooted KDE and GNOME (applies to other window manager as well; source /sw/bin/init.sh stems from fink):

First I created a .xinitrc with this content:


source /sw/bin/init.sh
/usr/X11R6/bin/quartz-wm
This starts Apple's Quartz-WM and stops the annoying termnal session when launching X11.

Next I created a .xinitrc.kde for KDE:


source /sw/bin/init.sh
export KDEWM=kwin
/sw/bin/startkde >/tmp/kde.log 2>&1
(sets KDE's window manager to the standard kwin, otherwise you are running without any wm, which is not a good idea...)

and a .xinitrc.gnome for GNOME:


source /sw/bin/init.sh
exec gnome-session

In Apple's X11, I created these menu entries within 'Applications/Customize...':

KDE: xinit ~/.xinitrc.kde -- /usr/X11R6/bin/Xnest :3 -geometry 1000x650

GNOME: xinit ~/.xinitrc.gnome -- /usr/X11R6/bin/Xnest :3 -geometry 1000x650

Now I can call up KDE as well as GNOME, each within its own rooted window, great!

Best regards,

Michael

[ Reply to This | # ]

How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: ScienceMan on Feb 12, '04 10:48:23AM
I cannot get this to work with gnome. To be sure I had a current installation, I used fink to do a full recomplilation of the latest cvs version of the gnome convenience package. In X11, if I select the GNOME application after following this hint, the XNest window appears, the gnome startup spash screen for 2.4 comes up, and then the XNest window exits and disappears. In the console, I have the following log:
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Error:            Can't find file "unknown" for geometry include
>                   Exiting
>                   Abandoning geometry file "default"
Errors from xkbcomp are not fatal to the X server
Couldn't get keyboard.
_IceTransmkdir: Owner of /tmp/.ICE-unix should be set to root
SESSION_MANAGER=local/My-Computer.local:/tmp/.ICE-unix/1715
Xlib:  extension "RENDER" missing on display ":3.0".

** (gnome-session:1715): WARNING **: Cannot open font file for font Verdana 10

** (gnome-session:1715): WARNING **: Cannot open fallback font, nothing to do

waiting for X server to shut down 
What could be wrong here?

[ Reply to This | # ]
How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: nobody on Feb 12, '04 12:21:18PM

Try to deactivate Font smoothing in your Window Manager.
Does it work then ?



[ Reply to This | # ]
How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: ScienceMan on Feb 14, '04 01:40:45PM

Hmm. There is a font smoothing option in the Mac OS X System Preferences Appearance panel, but it does not appear to have any setting that allows "off". Note the error says it cannot find the Verdana font -- where would this be?



[ Reply to This | # ]
How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: nobody on Feb 14, '04 07:46:43PM

I meant to disable the font smoothing in gnome - this is not related to MacOSX.
I am not familiar with gnome, so I cant tell you where to search for, but there should be a an option to decativate it.
Launch Gnome in a normal rootless session and look for a way to disable font smoothing, save. Then quit X11 and start Xnest



[ Reply to This | # ]
How to run rootless X11 and rooted KDE and GNOme at once...
Authored by: by on Feb 16, '04 01:53:43PM

It's a problem with fink/Gnome and I found a solution here:
http://article.gmane.org/gmane.os.apple.fink.gnome/343

Hope this help.

Best regards,
Michael



[ Reply to This | # ]
Great!
Authored by: Anonymous on Feb 09, '04 10:34:41AM

Definitely the X11 hint of the month.

---
Salmon, the other pink meat.



[ Reply to This | # ]
What about an xdm session?
Authored by: cynikal on Feb 09, '04 03:12:28PM

Got this Sun box that I'd like to be presented the xdm-style login on my mac system. I can't for the life of me figure out how to do this.

Pretty sure it has something to do with the XDMCP protocol, but the Apple X11 doesn't seem to have any option on which host to query.

I used to be able to do this back on windows with any competant X server such as Exodus or X-Win32. There was an option on which xdmcp server to query but i'm lost with Apple's X11.app

This has to be possible somehow, but i'm not sure. I guess there's that price to be paid for having a rootless x server, but this hint breathes new hope for this desire of mine to not need one of those annoying sun monitors :)



[ Reply to This | # ]
What about an xdm session?
Authored by: heather1001 on Feb 10, '04 05:15:10AM

Check out these options to Xnest ...

-query host-name contact named host for XDMCP
-broadcast broadcast for XDMCP
-indirect host-name contact named host for indirect XDMCP

If you do 'Xnest -h', you'll see that there's heaps of options, many of which aren't in the man page.



[ Reply to This | # ]
What about an xdm session?
Authored by: aquin43 on Mar 30, '04 10:27:46AM

I have an old Sun sparc5 that is already set up running xdm.
I set up my 17 inch powerbook to communicate with the sparc by adding the following line to the mac X11 Applications menu:

/usr/X11R6/bin/Xnest :1 -geometry 1420x860 -query 192.0.0.1

where 192.0.0.1 is the local network address of the sparc.
This gives me an xdm login window in a mac window.

I set X11 to 256 colours to match the requirements of the legacy programs running on the sparc.

The arrangement works well but is not absolutely reliable. The worst thing it has done is to scramble the powerbook keyboard completely so that nothing less than a power down would restore it. I have only had this working for a day, so I haven't worked out the exact circumsances that cause this problem.




[ Reply to This | # ]
What about an xdm session?
Authored by: rbbhghs on Apr 18, '04 05:40:55AM
simply type (in the terminal.app, not the XTerm as that is display :0)

X -query 192.168.1.1

or

/usr/X11R6/bin/X -query 192.168.1.1

if your path isn't set up right.

if you are running X11 already, use this:

/usr/X11R6/bin/X :1 -query 192.168.1.1

to send the query to DISPLAY=1. easy as pie. Not sure how I stumbled upon that, but it's very useful for me and my Fedora Box.

[ Reply to This | # ]

What about an xdm session?
Authored by: bluehz on Apr 18, '04 09:38:21AM

I have a headless (no monitor) linux server (slackware) on our lan that I occasionally like to run some gui app from. How can I use this technique to do this sort of thing? I am currently launching Apple X11, then from Apple X11 I ssh -X user@linux into the linux box, then I can launch gui apps that show up on the OS X box monitor. That works fine - but I would like to streamline the process and do it all in one step if possible.



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: vikingshelmut on Feb 10, '04 12:57:40AM

Ok, I'm lost. I don't understand exactly how to execute the xinit script. You say:
The xinit script makes this quite simple:

xinit ~/.xinitrc.kde -- /usr/X11R6/bin/Xnest :3 -geometry 800x600

But how is this run from the command line? if I type the line, bash complains that the xinit command is not found. Can somebody please explain what I am missing? do I add this line to my .xinitrc file? Do I run this some other way?

HELP!!!



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: jimhill on Feb 10, '04 05:56:58AM
vikingshelmut:

It's likely that xinit is not in your PATH. Type echo $PATH at the prompt and see if /usr/X11R6/bin is in there. If not, you'll need to add it or specify the path explicitly. If that sounds like gibberish, you really need to read a basic unix tutorial because you're getting into waters that are over your head. (However, it's easy to learn to swim!) I'm sure Rob has some hints that point to such tutorials...

---
Mac OS X: Because making UNIX simple is easier than debugging Windows.

[ Reply to This | # ]

PATH doesn't seem to be an issue for me
Authored by: vikingshelmut on Feb 10, '04 11:18:04AM

I am familiar with adding directories to my path, however if I just cd into the /usr/X11R6/bin directory and try to execute the command, bash says xinit is not a command. This is what I don't understand. Again, my previous post has what was originally listed as a script:

xinit ~/.xinitrc.kde -- /usr/X11R6/bin/Xnest :3 -geometry 800x600

If bash won't let me execute this command from within /usr/X11R6/bin, then what is wrong?



[ Reply to This | # ]
PATH doesn't seem to be an issue for me
Authored by: nobody on Feb 10, '04 12:19:31PM
the more modern unix variants wont execute a file if its in your current working directory ( because its not in your PATH by default ). Only commands which are in your PATH are searched and executed. You have to explicitly tell the system where it is:

./xinit ......
You can, however add the current directory to your PATH. Then it will work like you expected, example for tcsh:

setenv PATH {$PATH}:./


[ Reply to This | # ]
PATH doesn't seem to be an issue for me
Authored by: Detrius on Feb 15, '04 12:18:37PM

Take note, however, that adding the current working directory to your $PATH is a serious security risk. If someone finds a way to put a file named 'ls' somewhere on your drive (maybe through guest access/file sharing), and you type ls in that folder as root, then you have excecuted their script as root. This is not a good idea. Just put ./ in front of the filename if you want to run something in the local directory.



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: heather1001 on Feb 10, '04 05:18:03AM

If you do 'Xnest -h', you'll see that there are lots of options that can be passed to Xnest which aren't in the man page.

I found '-ac' useful, to allow remote connections.

Also, '-query' to use XDMCP



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: chmeee on Feb 14, '04 03:13:14PM

I want to put my Sun's monitor away to free up room on my desk, so am playing with the XDMCP stuff. However, I seem to have a problem: I can login from my linux machine at the command prompt using X -query <hostname>, but Xnest won't allow me, I get connection refused. Anyone with experience with this, and willing to help me? I've checked all the manpages I could find to be related, but can't find any help.



[ Reply to This | # ]
Use Xnest to run X11 sessions in a window
Authored by: palahala on Jan 07, '09 03:11:35PM