Search:  
Gentoo Wiki

NXClient_as_desktop_manager

Contents

Objective

To get NXClient launched solely on a full machine (full blown gentoo install, which in fact is running the nxserver).


Reasons


Ways to make it work

Config /etc/conf.d/xdm

  1. Description: Simply putting DISPLAYMANAGER="nxclient" in /etc/conf.d/xdm
  2. Source: According to http://www.nomachine.com/ar/view.php?ar_id=AR11B00078 nxclient is built to be used as a desktop manager
  3. Result: Doesn't work right out of the box. See below

edit the /etc/conf.d/xdm and set DISPLAYMANAGER="nx"

edit /etc/init.d/xdm and add

nx)
  NAME=bash
  EXE=/root/nxdesktop.sh
  PIDFILE=/var/run/nxdesktop.pid
  ;;

right above the default entry for xdm itself

the bash script /root/nxdesktop.sh looks like this :

#!/bin/bash
echo $$ > /var/run/nxdesktop.pid
X &
export DISPLAY=:0
echo "Starting NXClient..."
/usr/NX/bin/nxclient --session /root/.nx/config/localhost.nxs
sleep 40
while [[ `pidof nxssh | wc -w` > 0 ]]; do
   sleep 6
done
rm /var/run/nxdesktop.pid

some parts are kindly borrowed from SnEptUne and linuxquestions.org.

Creat the files nopassword, noexit and noconfig in /usr/NX/share as described in this document and set the localhost.nxs to run in fullscreen mode.

Running /etc/init.d/xdm start will fire up the X server and start nxclient.

Some notes:

Modifying Xservers file(s)

  1. Description: Either by modifying it in /etc/X11/xdm/ if you choose xdm, or usr/kde/3.5/share/config/kdm/ if you choose kdm (I dunno for gdm, don't use it), you should be able to replace /usr/bin/X by /usr/bin/nxclient.
  2. Source: This, according to http://www.weirdnet.nl/openbsd/xdm-xvnc/ which uses Xvnc and not X. However I later realized how stupid I was being, since doing that starts an Xvnc SERVER that listens for incoming connections.
  3. Result: Didn't work, just as expected

Using kdm, replacing kdm_greet

  1. Description: Replacing kdm_greet binary file with nxclient (or link) should do the work!
  2. Source: I thought about this one myself. ahhh that's why it didn't work!! ;)
  3. Result: It worked beautifully at first!!! The only problem was that, when nxclient got respawned (if you suspended the session or lost it, or signed out), you got presented with an nxclient login screen, but that didn't accept any input as username or password. Also, i didn't like it as it didn't feel "clean". I know, and you'll agree once you see it that the one I define as working is a blatant hack!, but still I prefer it and works as expected! :)

Using xinit and ion displaymanager

  1. Description: Starting nxclient using xinit. xinit starts the X server and then just launches nxclient!
  2. Source: I actually got the idea from here. However, it didn't work out of the box
  3. Result: Follows!

What happened was that nxclient login screen appeared correctly, but then after it connecting, just as it was about to show the session, it died!

So, I saw on the scripts from lessdisks that a minimal desktop manager is required to keep nxclient from dying. Therefore, I saw they used aewm, however it didn't work, just like with xinit by itself, nxclient died right at the moment it was about to show the session.

Then I tried twm (with the scripts from lessdisks) and it didn't work either.

Then I got a hang of all the window managers that appeared in x11-wm and felt like minimal and found one that worked: ion

Some others worked but, for example, a twm fork always placed a square on front of the nxclient session, so that was a no go. I wanted to see nothing but the nxclient session, and in fullscreen.

With that decided, I modified the script and it ended up like this (it's called nxwm): (This is a blatant hack.. I know.. Not pretty at all, but works) #!/bin/sh

#/usr/bin/nxwm
# Copyright 2004 under the terms of the GNU General Public
# License, version 2 or any later version. -schweer
# based upon the script sdm by vagrant
# based on all of those scripts, modified by Mede
ARG=$1
if [ "$ARG" = "xinitrc" ]
then
       shift
       echo -e $$ > /var/run/nxwm.pid
       exec /usr/bin/nxclient &
       ion
else
       PATH=/usr/local/sbin:/usr/bin/X11/:/usr/X11R6/bin/:$PATH
       
       rm /.nx/config/*.*
       cp /root/.nx/config/protected/* /.nx/config/
       exec xinit /usr/bin/nxwm xinitrc &
fi

How it works.

You put DISPLAYMANAGER="nxwm" in /etc/conf.d/xdm

When the program is called, it's called with no arguments and therefore the first if block is skipped.

Some Paths are set (those inherited from lessdisks' conf, maybe could be skipped, hehe). Then, for some reason or another (again, don't ask me why), the nxclient will read it's configuration from /.nx/ . You can call it with a --config argument that changes the dir to /usr/NX/.nx or whatever.. HOWEVER!! What I want is that nxclient respawns itself if it's closed, giving the feeling of a real window manager. Therefore, when nxclient is respawned, it is called WITHOUT ARGUMENTS, so for the best sake, it's better to just call it with no arguments just the way it will be called when it is respawned and handle it that way from the beginning.

Ok, being that is, when nxclient is run, it is run as root! (I don't know how to change that either) and as a result, it will be able to modify your files in /.nx/config Mainly the nxclient.cfg and Whatever.nxs, which is the name of a session. Therefore, what I've done is that I placed a copy of those files in some other folder and copy them over everytime the xdm server restarts.

Then xinit is run, and I tried running it with something like: xinit /usr/bin/nxclient -- ion or something like that but I think that's not the way it's supposed to work. As I said before, I needed to start nxclient alongside with a display-manager. Therefore, I had to create a script. Initially it was nxwm-xinitrc but then for some reasons (described below), I merged it to this file putting it inside an if block.

As you can see the xinit command has an & at the end, because, when run with the xinitrc argument, ion will hold the script, and will not return to console, therefore, won't indicate that it's done running.

Same goes for nxclient.

There is one other way of doing this:

{ xinit ion & } ; /usr/bin/nxclient

Runs the ion DM and then nxclient therefore showing somehow what I wanted. However, there's also a login request from ion (You could change ion to twm, for instance, and it would work). And that's not what I wanted. Running first nxclient through xinit and after that running the DM worked by giving nothing but the nxclient login window (No login request from the DM)

Reversing the order to something like

{ xinit /usr/bin/nxclient & } ; ion

sounds reasonable, but doesn't work. Apparently the DM never starts and nxclient fails right before starting the session.

Right now, with that simple script, NXClient should work as a DM (I know, I know... it's actually an ion session with NXClient, but try it and you'll know what I'm talking about: - Nothing but nxclient running and also, when you start, it goes fullscreen, ion doesn't "catch" any keystrokes or combinations.. beautiful!)

For the fullscreen part, of course the session file from nx (that one ending in .nxs) has to have that option set, look somewhere else for directions.

Now for some details..

NXClient config In order for nxclient to respawn itself, you have to create a file in /usr/NX/share called 'noexit' a touch command should suffice. Also good would be a file called 'nopasswd' in the same dir, so usernames and passwords are forgotten and not kept in memory

XDM scripts As you may have seen from the script itself, this becomes a real PITA to track the successfulness of the service. I've added a few hacks to the XDM scripts here they go:

/etc/init.d/xdm

in the case ${MY_XDM} add the following option

               nxwm)
                       EXE=/usr/bin/nxwm
                       PIDFILE=/var/run/nxwm.pid
                       ;;

Then in the stop() function, start-stop-daemon will never work, since it will look for nxwm and the one actually running is /bin/bash/nxwm!.. (At first i thought it was because the one I was running was nxwm-xinitrc, and that's the reason I merged the two files... Still didn't work).

There's an if with start-stop-daemon --stop --test which will return 1, since it won't find nxwm as a running process..

I added an elif as follows:

       if start-stop-daemon --quiet --test --stop --exec "${myexe}" ; then
               start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
                       ${mypidfile:+--pidfile} ${mypidfile} \
                       ${myname:+--name} ${myname}
               retval=$?
       elif [ "${myexe}" = "/usr/bin/nxwm" ]; then
               if start-stop-daemon --quiet --test --stop --pidfile ${mypidfile}; then
                       start-stop-daemon --stop --retry TERM/5/TERM/5 \
                       --pidfile ${mypidfile}
                       sleep 3
                       retval=$?
               fi
       fi

What it does: If the test failed, check if it's an nxwm service and base your decision solely on pidfile (which was set by the nxwm script, remember?). If it now doesn't fail, the stop it. The sleep 3 is because it takes some time to actually finish. Remember all the '&'s?? /etc/init.d/xdm will not wait!

then on:

/etc/X11/startDM.sh

we add another sleep command for the same reason as mentioned above (almost at the end, and only sleep if it's nxwm):

${NAME:+--name} ${NAME} ${PIDFILE:+--pidfile} ${PIDFILE} || \
eerror "ERROR: could not start the Display Manager"
[[ "${EXEC}" = "/usr/bin/nxwm" ]] && sleep 5
# vim:ts=4

Ok, that's it... I didn't find much info on the net about this, so decided to post it here.. It's not the prettiest of formats, i know, but hopefully it will help someone out.

There seems to be another option. Damn! I lost the link and google isn't helping me right now. There's someone on a mailing list who said that just by replacing nxclient as the desktop manager worked for their company. Just that I was too lazy to drop him an e-mail and it was back-dated, so didn't know if he would actually answer..

Hehe.. Have just right now found some info: http://mail.kde.org/pipermail/freenx-knx/2007-April/005038.html

They came to the same conclussion of ion as me :)

This feels good :)) PS. I put all the 'non-working' stuff in too because I took this as a learning experience. Therefore, maybe there are some other ways of doing it, and I wanted to expose what I found.


Last modified: Sat, 27 Sep 2008 00:11:00 +0000 Hits: 1,846