Released version 0.2. 0.2
authorMarco Zanon <info@marcozanon.com>
Tue, 13 Mar 2012 22:14:14 +0000 (22:14 +0000)
committerMarco Zanon <info@marcozanon.com>
Tue, 13 Mar 2012 22:14:14 +0000 (22:14 +0000)
skeleton

index ab31e9c30df7f3a66a75cccef749710baaef21d8..854878210f808636715597d1db6752584b69488a 100644 (file)
--- a/skeleton
+++ b/skeleton
 ##   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="1.x"
+SINGLE_CLICK_REMOTE_HELP_VERSION="0.x"
 VNC_SERVER="x11vnc-0.9.13_i686-Linux"
 INPUT_BOX_TITLE="__YOUR_TEXT_HERE__"
 INPUT_BOX_MESSAGE="__YOUR_TEXT_HERE__"
 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"
@@ -54,38 +79,38 @@ VNC_SERVER_COMMAND_ARGUMENTS=${VV[1]}
 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 [ "$?" -ne "0" ]; then
+if [ "0" -ne "$?" ]; then
   echo "Temporary directory not created, exiting."
   exit 2
 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 [ "$?" -ne "0" ]; then
+if [ "0" -ne "$?" ]; then
   echo "Vnc server binary not extracted, exiting."
   exit 3
 fi
 echo "Vnc server binary extracted."
 chmod +x $TEMPORARY_DIRECTORY/vncserver
-if [ "$?" -ne "0" ]; then
+if [ "0" -ne "$?" ]; then
   echo "Execution permission not set, exiting."
   exit 4
 fi
 echo "Execution permission set."
 
-## 5. Run Vnc server.
+## 6. Run Vnc server.
 echo "Starting Vnc server."
-$TEMPORARY_DIRECTORY/vncserver $VNC_SERVER_COMMAND_ARGUMENTS
-if [ "$?" -ne "0" ]; then
+$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