## 3 Vnc server binary not extracted.
## 4 Execution permission not set.
## 5 Vnc connection error.
+## 6 Invalid command line argument.
## 1. Define constants.
SINGLE_CLICK_REMOTE_HELP_VERSION="0.x"
LABEL_COLUMN_TITLE="__YOUR_TEXT_HERE__"
CONNECTIONS[0]="__YOUR_LABEL_HERE__|__YOUR_VNC_SERVER_COMMAND_ARGUMENTS_HERE__"
CONNECTIONS[1]="__YOUR_LABEL_HERE__|__YOUR_VNC_SERVER_COMMAND_ARGUMENTS_HERE__"
+CLIENT_CONNECTED_MESSAGE="__YOUR_TEXT_HERE__"
+CLIENT_GONE_MESSAGE="__YOUR_TEXT_HERE__"
-## 2. Get Vnc server command arguments, or terminate.
+## 2. Evaluate command line arguments.
+if [ -n "$1" ]; then
+ if [ "client_connected" == "$1" ]; then
+ M="$CLIENT_CONNECTED_MESSAGE"
+ elif [ "client_gone" == "$1" ]; then
+ M="$CLIENT_GONE_MESSAGE"
+ fi
+ if [ -z "$M" ]; then
+ echo "Invalid command line argument, exiting."
+ exit 6
+ fi
+ if [ -x /usr/bin/zenity ]; then
+ N=`eval $"zenity --title=\"$INPUT_BOX_TITLE\" --info --text=\"$M\""`
+ elif [ -x /usr/bin/kdialog ]; then
+ N=`eval $"kdialog --title \"$INPUT_BOX_TITLE\" --msgbox \"$M\""`
+ else
+ echo "Gui scripting tool not found, exiting."
+ exit 1
+ fi
+ exit 0
+fi
+
+## 3. Get Vnc server command arguments, or terminate.
echo "single_click_remote_help $SINGLE_CLICK_REMOTE_HELP_VERSION (bundled with $VNC_SERVER as Vnc server)"
VALUES=""
OLD_IFS="$IFS"
IFS="$OLD_IFS"
echo "Vnc server command arguments: $VNC_SERVER_COMMAND_ARGUMENTS."
-## 3. Create temporary directory.
+## 4. Create temporary directory.
TEMPORARY_DIRECTORY=`mktemp -d /tmp/single_click_remote_help.XXXXXXXXXX`
if [ "0" -ne "$?" ]; then
echo "Temporary directory not created, exiting."
fi
echo "Temporary directory created: $TMP_DIR."
-## 4. Extract Vnc server binary and make it executable.
+## 5. Extract Vnc server binary and make it executable.
BINARY_LINES=`awk '/^__BINARY_BELOW__/ { print NR + 1; exit 0; }' $0`
tail -n+$BINARY_LINES $0 > $TEMPORARY_DIRECTORY/vncserver
if [ "0" -ne "$?" ]; then
fi
echo "Execution permission set."
-## 5. Run Vnc server.
+## 6. Run Vnc server.
echo "Starting Vnc server."
-$TEMPORARY_DIRECTORY/vncserver $VNC_SERVER_COMMAND_ARGUMENTS
+$TEMPORARY_DIRECTORY/vncserver $VNC_SERVER_COMMAND_ARGUMENTS -afteraccept "$0 client_connected" -gone "$0 client_gone"
if [ "0" -ne "$?" ]; then
echo "Vnc connection error, exiting."
exit 5
fi
-## 6. Remove temporary directory and terminate.
+## 7. Remove temporary directory and terminate.
rm -rf $TEMPORARY_DIRECTORY
echo "Removed temporary directory."
exit 0