diff options
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaXDG.cpp | 60 | ||||
-rw-r--r-- | libLumina/LuminaXDG.h | 3 |
2 files changed, 61 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 |