From unknown Sat Apr 04 13:19:36 2026
X-Loop: owner@bugs.x2go.org
Subject: Bug#1024: Refreshed x2goclient autostart multiple app patch with bug fix
Reply-To: Jason Alavaliant <alavaliant@ra09.com>, 1024@bugs.x2go.org
Resent-From: Jason Alavaliant <alavaliant@ra09.com>
Resent-To: x2go-dev@lists.x2go.org
Resent-CC: X2Go Developers <x2go-dev@lists.x2go.org>
X-Loop: owner@bugs.x2go.org
Resent-Date: Sun, 25 Sep 2016 08:00:02 +0000
Resent-Message-ID: <handler.1024.B1024.147479033826205@bugs.x2go.org>
Resent-Sender: owner@bugs.x2go.org
X-X2Go-PR-Message: followup 1024
X-X2Go-PR-Package: x2goclient
X-X2Go-PR-Keywords: patch
Received: via spool by 1024-submit@bugs.x2go.org id=B1024.147479033826205
          (code B ref 1024); Sun, 25 Sep 2016 08:00:02 +0000
Received: (at 1024) by bugs.x2go.org; 25 Sep 2016 07:58:58 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,URIBL_BLOCKED
	autolearn=ham version=3.3.2
Received: from localhost (localhost [127.0.0.1])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id 471F35DA95
	for <1024@bugs.x2go.org>; Sun, 25 Sep 2016 09:58:55 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at ymir.das-netzwerkteam.de
X-Amavis-Alert: BAD HEADER SECTION, Improper folded header field made up
	entirely of whitespace (char 20 hex): X-Spam-report: ...that system
	for details.\n \n Content previ[...]
Received: from ymir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (ymir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id N0iwcaQNnZre for <1024@bugs.x2go.org>;
	Sun, 25 Sep 2016 09:58:37 +0200 (CEST)
X-Greylist: delayed 1517 seconds by postgrey-1.34 at ymir.das-netzwerkteam.de; Sun, 25 Sep 2016 09:58:36 CEST
Received: from thetower.ra09.com (ra09.com [202.124.104.240])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id DA1495DA94
	for <1024@bugs.x2go.org>; Sun, 25 Sep 2016 09:58:36 +0200 (CEST)
Received: from grigorig.ra09.com ([10.1.1.8])
	by thetower.ra09.com with esmtp (Exim 4.84_2)
	(envelope-from <alavaliant@ra09.com>)
	id 1bo3w3-0002DS-3H
	for 1024@bugs.x2go.org; Sun, 25 Sep 2016 20:33:15 +1300
To: "1024@bugs.x2go.org" <1024@bugs.x2go.org>
From: Jason Alavaliant <alavaliant@ra09.com>
Message-ID: <22e80dab-3ef6-70f4-4313-1ad328ba1fc8@ra09.com>
Date: Sun, 25 Sep 2016 20:33:15 +1300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Icedove/45.2.0
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------8EF980A84DD99024D91A38C7"

This is a multi-part message in MIME format.
--------------8EF980A84DD99024D91A38C7
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

It's been a while since I submitted the original proposed patches for 
the x2goclient to allow it to support autostarting multiple 
applications.    I note the original patches no longer applied to git 
master so I've refreshed them in git format-patch format and also fixed 
an off by one error that stopped the autostart option working when only 
one app was specified.

Thanks

Jason


--------------8EF980A84DD99024D91A38C7
Content-Type: text/x-patch;
 name="x2goclient-add-multiple-autostart-app-support.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="x2goclient-add-multiple-autostart-app-support.patch"

>From 836f8f7423ee9699c0c307754f52d412c70a91e9 Mon Sep 17 00:00:00 2001
From: Jason Alavaliant <alavaliant@ra09.com>
Date: Sun, 25 Sep 2016 20:17:17 +1300
Subject: [PATCH] Patch autostart option to support multiple autostart app at
 the same time

---
 src/help.cpp         |  2 +-
 src/onmainwindow.cpp | 48 +++++++++++++++++++++++++++++++++---------------
 src/onmainwindow.h   |  2 +-
 3 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/src/help.cpp b/src/help.cpp
index a708d81..5da345b 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -139,7 +139,7 @@ help::params_t help::build_params () {
   ADD_OPT ("--kbd-type=<type>", QT_TRANSLATE_NOOP ("Help", "Sets the default keyboard type."));
   ADD_OPT ("--home=<dir>", QT_TRANSLATE_NOOP ("Help", "Sets the user's home directory."));
   ADD_OPT ("--set-kbd=<0|1>", QT_TRANSLATE_NOOP ("Help", "Enables or disables overwriting the current keyboard settings."));
-  ADD_OPT ("--autostart=<app>", QT_TRANSLATE_NOOP ("Help", "Automatically launches the application \"app\" on session start in Published Applications mode."));
+  ADD_OPT ("--autostart=<app>,<app2>", QT_TRANSLATE_NOOP ("Help", "Automatically launches the application(s) \"app\" on session start in Published Applications mode."));
   ADD_OPT ("--session-conf=<file>", QT_TRANSLATE_NOOP ("Help", "Defines an alternative session config file path."));
   ADD_OPT ("--tray-icon", QT_TRANSLATE_NOOP ("Help", "Force-enables session system tray icon."));
   ADD_OPT ("--close-disconnect", QT_TRANSLATE_NOOP ("Help", "Automatically closes X2Go Client after a disconnect."));
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 4b3fb05..5f77c0d 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -6747,7 +6747,7 @@ void ONMainWindow::slotReadApplications(bool result, QString output,
     applications.clear();
     QString locallong=QLocale::system().name();
     QString localshort=QLocale::system().name().split("_")[0];
-    bool startAppFound=false;
+    QStringList startAppsFound;
 
     foreach(QString appstr, output.split("</desktop>",QString::SkipEmptyParts))
     {
@@ -6776,9 +6776,12 @@ void ONMainWindow::slotReadApplications(bool result, QString output,
             if (line.indexOf("Name=")!=-1 && !localname)
             {
                 app.name=line.split("=")[1];
-                if (app.name==autostartApp)
-                    startAppFound=true;
-                //                 x2goDebug<<"name: "<<app.name<<endl;
+                for (int i=0; i<autostartApps.length(); ++i)
+                {
+                    if (app.name==autostartApps[i])
+                        startAppsFound.append(app.name);
+                    //                 x2goDebug<<"name: "<<app.name<<endl;
+                }
             }
             if (line.indexOf("Comment=")!=-1 && !localcomment)
             {
@@ -6794,9 +6797,12 @@ void ONMainWindow::slotReadApplications(bool result, QString output,
                 app.exec.replace("%u","",Qt::CaseInsensitive);
                 app.exec.replace("%i","",Qt::CaseInsensitive);
                 app.exec.replace("%c",app.name,Qt::CaseInsensitive);
-                if (app.exec==autostartApp)
-                    startAppFound=true;
-                //                 x2goDebug<<"exec: "<<app.exec<<endl;
+                for (int i=0; i<autostartApps.length(); ++i)
+                {
+                    if (app.exec==autostartApps[i])
+                        startAppsFound.append(app.exec);
+                    //                 x2goDebug<<"exec: "<<app.exec<<endl;
+                }
             }
             if (line.indexOf("Categories=")!=-1)
             {
@@ -6861,14 +6867,26 @@ void ONMainWindow::slotReadApplications(bool result, QString output,
 
     qSort(applications.begin(), applications.end(),Application::lessThen);
     plugAppsInTray();
-    if (runStartApp && autostartApp.length()>1)
-    {
-        if (!startAppFound) {
-            x2goDebug<<"Autostart application "<<autostartApp<< " not found in desktop files.";
-        }
-        else
+    if (runStartApp && autostartApps.length()>0)
+    {   
+        for (int i=0; i<autostartApps.length(); ++i)
         {
-            runApplication(autostartApp);
+            bool startAppFound = False;
+            for (int j=0; j<startAppsFound.length(); ++j)
+            {
+                if (startAppsFound[j] == autostartApps[i]) 
+                {
+                    startAppFound = True;
+                }
+            }
+            if (!startAppFound) {
+                x2goDebug<<"Autostart application "<<autostartApps[i]<< " not found in desktop files.";
+            }
+            else
+            {
+                runApplication(autostartApps[i]);
+            }
+            
         }
     }
     else
@@ -7233,7 +7251,7 @@ bool ONMainWindow::parseParameter ( QString param )
     }
     if ( setting == "--autostart")
     {
-        autostartApp=value;
+        autostartApps.append(value.split(','));
         return true;
     }
     if ( setting == "--auth-id")
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 344f7d1..e0e4d26 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -624,7 +624,7 @@ private:
     bool embedMode;
     bool thinMode;
     QString statusString;
-    QString autostartApp;
+    QStringList autostartApps;
     bool cmdAutologin;
     int defaultLink;
     int defaultQuality;
-- 
2.9.3


--------------8EF980A84DD99024D91A38C7--
