Displaying an additional confirmation prompt with NX 3.5.0 when users terminate their sessions
This article applies to NX 3.5.0.
When terminating a NX session, users are prompted by default with a dialog which allows to choose among disconnect or terminate the session or cancel the operation.
When pressing the Terminate button, the session is terminated without giving the possibility of going back and cancel the operation. Even if this is the expected behaviour, it might be necessary to provide the user with an additional confirmation dialog. To do that it is possible to use a wrapper script for nxclient on server side. Sample below is using a wrapper script to provide an additional dialog to ask the user for confirmation when the user clicks on the terminate button.
Please note that this sample script is mostly suitable for a redhat distribution. Syntax of shell scripts may vary depending on the shell in use, for example you may have to change to #!/bin/bash on Ubuntu distributions.
1. Move /usr/NX/bin/nxclient to /usr/NX/bin/nxclient.orig
2. Save the following script as /usr/NX/bin/nxclient
#!/bin/sh
NX_CLIENT=/usr/NX/bin/nxclient.orig
ARGS=("$@")
c=0
for i in "$@"; do
case $i in
--dialog)
DIALOG=$ARGS[$c + 1]
;;
--display)
DISPLAY=$ARGS[$c + 1]
;;
--caption)
CAPTION=$ARGS[$c + 1]
;;
--message)
MESSAGE=$ARGS[$c + 1]
;;
--parent)
PARENT=$ARGS[$c + 1]
;;
esac
c=$((c + 1))
done
confirm()
trap 15
$NX_CLIENT --dialog yesno --caption "Please confirm" --message "
By clicking 'Yes' this session will terminate. No chance to reconnect later! " --class warning --parent $PARENT --display $DISPLAY
suspend()
kill -1 $PARENT
test -z "$DIALOG" && exec $NX_CLIENT "$@"
trap confirm 15
trap suspend 1
$NX_CLIENT --dialog $DIALOG --caption "$CAPTION" --message "$MESSAGE" --parent $ --display $DISPLAY
# End of file
3. Make nxclient executable: 'chmod a+x /usr/NX/bin/nxclient'.
