[PC-BSD Commits] r19031 - pcbsd-projects/PCDM

svn at pcbsd.org svn at pcbsd.org
Mon Sep 10 18:14:54 PDT 2012


Author: kenmoore
Date: 2012-09-11 01:14:54 +0000 (Tue, 11 Sep 2012)
New Revision: 19031

Removed:
   pcbsd-projects/PCDM/startPCDM
Modified:
   pcbsd-projects/PCDM/PCDM.pro
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-config.cpp
   pcbsd-projects/PCDM/pcdm-config.h
Log:
Add in the method to startup login scripts from any directory given in the configuration file (scripts must be executable to run)



Modified: pcbsd-projects/PCDM/PCDM.pro
===================================================================
--- pcbsd-projects/PCDM/PCDM.pro	2012-09-10 20:32:37 UTC (rev 19030)
+++ pcbsd-projects/PCDM/PCDM.pro	2012-09-11 01:14:54 UTC (rev 19031)
@@ -92,9 +92,6 @@
 dotrans.path=/usr/local/share/PCDM/i18n/
 dotrans.extra=cd i18n && lrelease-qt4 -nounfinished *.ts && cp *.qm /usr/local/share/pcbsd/i18n/
 
-scripts.path = /usr/local/bin
-scripts.files = startPCDM
+INSTALLS += dotrans target
 
-INSTALLS += scripts dotrans target
-
 RESOURCES += PCDM.qrc

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-10 20:32:37 UTC (rev 19030)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-11 01:14:54 UTC (rev 19031)
@@ -92,9 +92,12 @@
     return;
   }
   Backend::log("Starting up Desktop environment ("+saveX+") as user ("+saveUsername+")");
-  //Use the saved information and clear it
+  //Use the saved information
   QString username = saveUsername;
-  QString cmd = "su "+username+" -c /bin/sh"; //switch user command to start the DE
+  QString cmd = "su "+username+" -c "+saveX; //switch user command to start the DE
+  // Get any startup scripts 
+  QDir sdir(Config::loginScriptsDir());
+  QStringList child = sdir.entryList(QDir::Files | QDir::Executable | QDir::NoDotAndDotDot);
   
   // Get the user's home directory
   QString homeDir = getUserHomeDir(username);
@@ -123,11 +126,19 @@
   p->start(cmd);
   // Wait for the process to start before continuing
   p->waitForStarted();
-  p->write(saveX.toUtf8());
-  //Backend::log("Startup Environment: " + p->processEnvironment().toStringList().join(" ") );
+  Backend::log("Startup Environment: " + p->processEnvironment().toStringList().join(" ") );  
+  // Run any startup scripts as child processes
+  for(int i=0; i<child.length(); i++){
+    QProcess ch(p); // "p" is the parent of "ch", and inherits the same environment
+    ch.setStandardOutputFile("/usr/local/share/PCDM/PCDM.log",QIODevice::Append); //log any output
+    Backend::log("Starting script: "+child[i]);
+    Backend::log("Child Environment: "+ch.processEnvironment().toStringList().join(" "));
+    ch.start(child[i]); // As a child, it will close down once the parent closes
+  }
+
   // Now Wait for the process to finish
   p->waitForFinished(-1);  //do not time-out
-  //Clear the saved variables
+  //XSession stopped, now clean up
   saveUsername.clear(); 
   saveX.clear();
 }

Modified: pcbsd-projects/PCDM/pcdm-config.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.cpp	2012-09-10 20:32:37 UTC (rev 19030)
+++ pcbsd-projects/PCDM/pcdm-config.cpp	2012-09-11 01:14:54 UTC (rev 19031)
@@ -11,6 +11,7 @@
   confStruct << "/usr/local/share/PCDM/default.pcdm-theme";	// [0] Theme File Path
   confStruct << "/usr/local/share/xsessions";			// [1] *.desktop files directory
   confStruct << "/usr/local/share/pixmaps";			// [2] Images directory for *.desktop icons
+  confStruct << "/usr/local/share/pcbsd/xstartup";			// [3] Login Scripts Directory
   return;
 }
 
@@ -41,3 +42,6 @@
   return confStruct[2];
 }
 
+QString Config::loginScriptsDir(){
+  return confStruct[3];	
+}

Modified: pcbsd-projects/PCDM/pcdm-config.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.h	2012-09-10 20:32:37 UTC (rev 19030)
+++ pcbsd-projects/PCDM/pcdm-config.h	2012-09-11 01:14:54 UTC (rev 19031)
@@ -19,6 +19,7 @@
   static QString themeFile();
   static QString xSessionsDir();
   static QString xSessionsImageDir();
+  static QString loginScriptsDir();
   
 
 };



More information about the Commits mailing list