add nxsession script

this is a lightly tweaked version of Lars' original script