No Machine Wrapper

The No Machine client allows you to choose between five types of UNIX session: KDE, GNOME, CDE, XDM and custom. In the first four cases the appropriate session startup is invoked (eg startkde) and the No Machine X server is destroyed when the session exits. In the case of a custom session, however, No Machine doesn't know when your program has finished (it may have put itself in the background) so the X server stays running and you have to terminate the No Machine session manually.

This simple wrapper script, placed in /usr/NX/bin, takes care of killing the X server after your session is completed.

#!/bin/bash
nxnode=$(ps -o ppid= -p $PPID)
nxagent=$(pgrep -P $nxnode -u $USER -x nxagent)
${1+"$@"}
exec kill $nxagent

To start an XFCE session, for example, you would use nxwrapper xfce4-session as the command to run.

nxwrapper