aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libLumina/LuminaXDG.cpp60
-rw-r--r--libLumina/LuminaXDG.h3
-rw-r--r--lumina-desktop/LSession.cpp12
3 files changed, 73 insertions, 2 deletions
diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp
index e4839480..dbf08b88 100644
--- a/libLumina/LuminaXDG.cpp
+++ b/libLumina/LuminaXDG.cpp
@@ -127,8 +127,8 @@ bool LXDG::checkValidity(XDGDesktop dFile, bool showAll){
if(DEBUG){ qDebug() << " - Unknown file type"; }
}
if(!showAll){
- if(!dFile.showInList.isEmpty()){ ok = dFile.showInList.contains("Lumina"); }
- else if(!dFile.notShowInList.isEmpty()){ ok = !dFile.notShowInList.contains("Lumina"); }
+ if(!dFile.showInList.isEmpty()){ ok = dFile.showInList.contains("Lumina", Qt::CaseInsensitive); }
+ else if(!dFile.notShowInList.isEmpty()){ ok = !dFile.notShowInList.contains("Lumina",Qt::CaseInsensitive); }
}
return ok;
}
@@ -665,3 +665,59 @@ QStringList LXDG::loadMimeFileGlobs2(){
return mimeglobs;
}
+//Find all the autostart *.desktop files
+QList<XDGDesktop> LXDG::findAutoStartFiles(bool includeInvalid){
+
+ //First get the list of directories to search (system first, user-provided files come later and overwrite sys files as needed)
+ QStringList paths = QString(getenv("XDG_CONFIG_DIRS")).split(":");
+ paths << QString(getenv("XDG_CONFIG_HOME")).split(":");
+ //Now go through them and find any valid *.desktop files
+ QList<XDGDesktop> files;
+ QStringList filenames; //make it easy to see if this filename is an override
+ QDir dir;
+ for(int i=0;i<paths.length(); i++){
+ if(!QFile::exists(paths[i]+"/autostart")){ continue; }
+ dir.cd(paths[i]+"/autostart");
+ QStringList tmp = dir.entryList(QStringList() << "*.desktop", QDir::Files, QDir::Name);
+ for(int t=0; t<tmp.length(); t++){
+ bool ok = false;
+ XDGDesktop desk = LXDG::loadDesktopFile(dir.absoluteFilePath(tmp[t]), ok);
+ if(!ok){ continue; } //could not read file
+ //Now figure out what to do with it
+ if(filenames.contains(tmp[t])){
+ //This is an overwrite of a lower-priority (system?) autostart file
+ // find the other file
+ int old = -1;
+ for(int o=0; o<files.length(); o++){
+ if(files[o].filePath.endsWith("/"+tmp[t])){ old = o; break; } //found it
+ }
+ if(LXDG::checkValidity(desk, false)){
+ //Full override of the lower-priority file (might be replacing exec/tryexec fields)
+ files[old] = desk;
+ }else{
+ //Small override file (only the "Hidden" field listed in spec)
+ files[old].isHidden = desk.isHidden; //replace this value with the override
+ files << desk; //still add this to the array (will be ignored/skipped later)
+ }
+ }else{
+ //This is a new autostart file
+ files << desk;
+ filenames << tmp[t];
+ }
+ }//end of loop over *.desktop files
+ } //end of loop over directories
+
+ //Now filter the results by validity if desired
+ if(!includeInvalid){
+ for(int i=0; i<files.length(); i++){
+ if( !LXDG::checkValidity(files[i], false) || files[i].isHidden ){
+ //Invalid file - go ahead and remove it from the output list
+ files.removeAt(i);
+ i--;
+ }
+ }
+ }
+
+ return files;
+}
+
diff --git a/libLumina/LuminaXDG.h b/libLumina/LuminaXDG.h
index fe44a4fd..e9a6081e 100644
--- a/libLumina/LuminaXDG.h
+++ b/libLumina/LuminaXDG.h
@@ -99,6 +99,9 @@ public:
static QStringList findAVFileExtensions();
//Load all the "globs2" mime database files
static QStringList loadMimeFileGlobs2();
+
+ //Find all the autostart *.desktop files
+ static QList<XDGDesktop> findAutoStartFiles(bool includeInvalid = false);
};
#endif
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp
index 6437524b..b472a60a 100644
--- a/lumina-desktop/LSession.cpp
+++ b/lumina-desktop/LSession.cpp
@@ -213,6 +213,18 @@ void LSession::launchStartupApps(){
if(sessionsettings->value("EnableNumlock",true).toBool()){
QProcess::startDetached("numlockx on");
}
+ //Now get any XDG startup applications and launch them
+ QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles();
+ for(int i=0; i<xdgapps.length(); i++){
+ qDebug() << " - Auto-Starting File:" << xdgapps[i].filePath;
+ if(xdgapps[i].startupNotify){
+ LSession::LaunchApplication("lumina-open \""+xdgapps[i].filePath+"\"");
+ }else{
+ //Don't update the mouse cursor
+ QProcess::startDetached("lumina-open \""+xdgapps[i].filePath+"\"");
+ }
+ }
+
}
void LSession::StartLogout(){
bgstack15