Added message boxes to notify user about accepted and terminated connections.
authorMarco Zanon <info@marcozanon.com>
Tue, 13 Mar 2012 22:13:32 +0000 (22:13 +0000)
committerMarco Zanon <info@marcozanon.com>
Tue, 13 Mar 2012 22:13:32 +0000 (22:13 +0000)
skeleton

index dd941f5f7487ce30f4a764439ed7df0bca7f95e3..854878210f808636715597d1db6752584b69488a 100644 (file)
--- a/skeleton
+++ b/skeleton
@@ -14,6 +14,7 @@
 ##   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"
@@ -23,8 +24,32 @@ 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,7 +79,7 @@ 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 [ "0" -ne "$?" ]; then
   echo "Temporary directory not created, exiting."
@@ -62,7 +87,7 @@ if [ "0" -ne "$?" ]; then
 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
@@ -77,15 +102,15 @@ 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