From 6181c249d7f96486fa397e8817646aba28b93868 Mon Sep 17 00:00:00 2001 From: Dmitry Maksyoma Date: Sun, 1 Aug 2021 21:57:36 +1200 Subject: [PATCH] vncserver: extract ConstructXvncCmd() --- unix/vncserver | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/unix/vncserver b/unix/vncserver index 2952456..b248cc3 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -107,24 +107,7 @@ unlink($desktopLog); # Now start the X VNC Server # We build up our Xvnc command with options -$cmd = $exedir."Xvnc :$displayNumber"; - -foreach my $k (sort keys %config) { - $cmd .= " -$k $config{$k}"; - delete $default_opts{$k}; # file options take precedence -} - -foreach my $k (sort keys %default_opts) { - $cmd .= " -$k $default_opts{$k}"; -} - -# Add color database stuff here, e.g.: -# $cmd .= " -co /usr/lib/X11/rgb"; - -foreach $arg (@ARGV) { - $cmd .= " " . "edString($arg); -} -$cmd .= " >> " . "edString($desktopLog) . " 2>&1"; +$cmd = &ConstructXvncCmd(); # Run $cmd and record the process ID. $pidFile = "$vncUserDir/$host:$displayNumber.pid"; @@ -933,3 +916,26 @@ sub SetupXauthorityFile { print XAUTH "add $host/unix:$displayNumber . $cookie\n"; close(XAUTH); } + +sub ConstructXvncCmd { + my $cmd = $exedir."Xvnc :$displayNumber"; + + foreach my $k (sort keys %config) { + $cmd .= " -$k $config{$k}"; + delete $default_opts{$k}; # file options take precedence + } + + foreach my $k (sort keys %default_opts) { + $cmd .= " -$k $default_opts{$k}"; + } + + # Add color database stuff here, e.g.: + # $cmd .= " -co /usr/lib/X11/rgb"; + + foreach $arg (@ARGV) { + $cmd .= " " . "edString($arg); + } + $cmd .= " >> " . "edString($desktopLog) . " 2>&1"; + + return $cmd; +}