Merge branch 'patch-1' of https://github.com/Siot/tigervnc
diff --git a/unix/vncserver b/unix/vncserver
index c7fdc65..d7cd711 100755
--- a/unix/vncserver
+++ b/unix/vncserver
@@ -53,6 +53,7 @@
                  ((-d "/usr/local/vnc/classes") && "/usr/local/vnc/classes"));
                  
 $vncUserDir = "$ENV{HOME}/.vnc";
+$skipxstartup = 0;
 $xauthorityFile = "$ENV{XAUTHORITY}" || "$ENV{HOME}/.Xauthority";
 
 $defaultXStartup
@@ -133,7 +134,7 @@
 # Check command line options
 
 &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
-	      "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0);
+	      "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0,"-noxstartup",0);
 
 &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});
 
@@ -155,6 +156,9 @@
 if ($opt{'-pixelformat'}) {
     $pixelformat = $opt{'-pixelformat'};
 }
+if ($opt{'-noxstartup'}) {
+    $skipxstartup = 1;
+}
 if ($opt{'-fp'}) {
     $fontPath = $opt{'-fp'};
     $fpArgSpecified = 1;
@@ -355,12 +359,14 @@
 
 # Create the user's xstartup script if necessary.
 
-if (!(-e "$vncUserDir/xstartup")) {
-    warn "Creating default startup script $vncUserDir/xstartup\n";
-    open(XSTARTUP, ">$vncUserDir/xstartup");
-    print XSTARTUP $defaultXStartup;
-    close(XSTARTUP);
-    chmod 0755, "$vncUserDir/xstartup";
+if (! $skipxstartup) {
+    if (!(-e "$vncUserDir/xstartup")) {
+        warn "Creating default startup script $vncUserDir/xstartup\n";
+        open(XSTARTUP, ">$vncUserDir/xstartup");
+        print XSTARTUP $defaultXStartup;
+        close(XSTARTUP);
+        chmod 0755, "$vncUserDir/xstartup";
+    }
 }
 
 # Create the user's config file if necessary.
@@ -375,7 +381,9 @@
 
 # Run the X startup script.
 
-warn "Starting applications specified in $vncUserDir/xstartup\n";
+if (! $skipxstartup) {
+    warn "Starting applications specified in $vncUserDir/xstartup\n";
+}
 warn "Log file is $desktopLog\n\n";
 
 # If the unix domain socket exists then use that (DISPLAY=:n) otherwise use
@@ -393,18 +401,24 @@
 system($exedir."vncconfig -nowin >> " . &quotedString($desktopLog) . " 2>&1 &");
 
 if ($opt{'-fg'}) {
-    system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 2>&1");
+    if (! $skipxstartup) {
+        system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 2>&1");
+    }
     if (kill 0, `cat $pidFile`) {
         $opt{'-kill'} = ':'.$displayNumber;
         &Kill();
     }
 } else {
     if ($opt{'-autokill'}) {
-        system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> "
-            . &quotedString($desktopLog) . " 2>&1 &");
+    	if (! $skipxstartup) {
+            system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> "
+             . &quotedString($desktopLog) . " 2>&1 &");
+    	}
     } else {
-        system("$vncUserDir/xstartup >> " . &quotedString($desktopLog)
-            . " 2>&1 &");
+    	if (! $skipxstartup) {
+            system("$vncUserDir/xstartup >> " . &quotedString($desktopLog)
+             . " 2>&1 &");
+    	}
     }
 }
 
@@ -621,6 +635,7 @@
 	"                 [-fp <font-path>]\n".
 	"                 [-fg]\n".
 	"                 [-autokill]\n".
+	"                 [-noxstartup]\n".
 	"                 <Xvnc-options>...\n\n".
 	"       $prog -kill <X-display>\n\n".
 	"       $prog -list\n\n");
diff --git a/unix/vncserver.man b/unix/vncserver.man
index 5ba6b8f..37fe315 100644
--- a/unix/vncserver.man
+++ b/unix/vncserver.man
@@ -16,6 +16,7 @@
 .IR font-path ]
 .RB [ \-fg ]
 .RB [ \-autokill ]
+.RB [ \-noxstartup ]
 .RI [ Xvnc-options... ]
 .br
 .BI "vncserver \-kill :" display#
@@ -123,6 +124,11 @@
 manager.
 .
 .TP
+.B \-noxstartup
+Do not run the %HOME/.vnc/xstartup script after launching Xvnc.  This
+option allows you to manually start a window manager in your TigerVNC session.
+.
+.TP
 .B \-list
 Lists all VNC desktops started by vncserver.