summaryrefslogtreecommitdiffstats
path: root/tdescreensaver
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2022-03-29 02:53:16 +0200
committerSlávek Banko <[email protected]>2022-03-29 02:53:16 +0200
commitb0eb71dedfc68ca5ce981b2853af9a64b2c2e67f (patch)
tree8734f4b2c86a22c8aa0945816102969dda4ce01f /tdescreensaver
parente5903f8f6e3d5cec0934a62040fe5a95179e2bb0 (diff)
downloadtdeartwork-b0eb71dedfc68ca5ce981b2853af9a64b2c2e67f.tar.gz
tdeartwork-b0eb71dedfc68ca5ce981b2853af9a64b2c2e67f.zip
Modify screen savers detection that the XSCREENSAVER_DIRS
and XSCREENSAVER_CONFIG_DIRS variables allow multiple paths. Likewise, the XSCREENSAVER HACKS DIRS variable used to search for an screen saver executable can contain multiple paths. This relates to #19. Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'tdescreensaver')
-rw-r--r--tdescreensaver/kxsconfig/CMakeL10n.txt13
-rw-r--r--tdescreensaver/kxsconfig/CMakeLists.txt3
-rw-r--r--tdescreensaver/kxsconfig/kxsconfig.cpp42
-rw-r--r--tdescreensaver/kxsconfig/kxsrun.cpp38
4 files changed, 72 insertions, 24 deletions
diff --git a/tdescreensaver/kxsconfig/CMakeL10n.txt b/tdescreensaver/kxsconfig/CMakeL10n.txt
index a3a99e44..b7099c1b 100644
--- a/tdescreensaver/kxsconfig/CMakeL10n.txt
+++ b/tdescreensaver/kxsconfig/CMakeL10n.txt
@@ -16,13 +16,15 @@ endif( )
message( STATUS "Prepare to extract strings from xscreensaver data files..." )
include( ${CMAKE_SOURCE_DIR}/FindXscreensaver.cmake )
+string( REPLACE ":" ";" SEARCH_XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" )
unset( _xsavers_l10n )
-file( GLOB _xsaver_files
- RELATIVE "${XSCREENSAVER_CONFIG_DIR}"
- ${XSCREENSAVER_CONFIG_DIR}*.xml )
-list( SORT _xsaver_files )
-foreach( _xsaver_file ${_xsaver_files} )
+foreach( XSCREENSAVER_CONFIG_DIR IN LISTS SEARCH_XSCREENSAVER_CONFIG_DIRS )
+ file( GLOB _xsaver_files
+ RELATIVE "${XSCREENSAVER_CONFIG_DIR}"
+ ${XSCREENSAVER_CONFIG_DIR}*.xml )
+ list( SORT _xsaver_files )
+ foreach( _xsaver_file ${_xsaver_files} )
string( REGEX REPLACE "\\.xml\$" "" _xsaver_name "${_xsaver_file}" )
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_name}.desktop" )
file( READ "${XSCREENSAVER_CONFIG_DIR}${_xsaver_file}" _xsaver_xml )
@@ -60,6 +62,7 @@ foreach( _xsaver_file ${_xsaver_files} )
"${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h"
"${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h.tde_l10n" )
list( APPEND _xsavers_l10n "ScreenSavers/${_xsaver_file}.h.tde_l10n" )
+ endforeach( )
endforeach( )
diff --git a/tdescreensaver/kxsconfig/CMakeLists.txt b/tdescreensaver/kxsconfig/CMakeLists.txt
index 05c0d6b5..103203db 100644
--- a/tdescreensaver/kxsconfig/CMakeLists.txt
+++ b/tdescreensaver/kxsconfig/CMakeLists.txt
@@ -49,12 +49,13 @@ tde_add_executable( ${target} AUTOMOC
##### install desktops ##########################
# code from kde4
FILE(GLOB _desktopfiles "ScreenSavers/*.desktop" )
+string( REPLACE ":" ";" SEARCH_XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" )
foreach(_currentdesktopfile ${_desktopfiles})
STRING(REGEX REPLACE ".desktop" "" _newitem "${_currentdesktopfile}" )
#MESSAGE(STATUS "newItem <${_newitem}>")
GET_FILENAME_COMPONENT(_screensaverName ${_newitem} NAME_WE)
#MESSAGE(STATUS "name without extension <${_screensaverName}>")
- find_file(XSCREENSAVER_FILE_FOUND ${_screensaverName}.xml PATHS ${XSCREENSAVER_CONFIG_DIR} )
+ find_file(XSCREENSAVER_FILE_FOUND ${_screensaverName}.xml PATHS ${SEARCH_XSCREENSAVER_CONFIG_DIRS} )
if(XSCREENSAVER_FILE_FOUND)
MESSAGE(STATUS "xscreensaver name ${_screensaverName} found")
else(XSCREENSAVER_FILE_FOUND)
diff --git a/tdescreensaver/kxsconfig/kxsconfig.cpp b/tdescreensaver/kxsconfig/kxsconfig.cpp
index 28e9d112..f91b0321 100644
--- a/tdescreensaver/kxsconfig/kxsconfig.cpp
+++ b/tdescreensaver/kxsconfig/kxsconfig.cpp
@@ -101,11 +101,21 @@ bool KXSConfigDialog::create()
TDEConfig config(mConfigFile);
TQString xmlFile = "/doesntexist";
-#ifdef XSCREENSAVER_CONFIG_DIR
- xmlFile = XSCREENSAVER_CONFIG_DIR;
+ xmlFile += "/" + mExeName + ".xml";
+#ifdef XSCREENSAVER_CONFIG_DIRS
+ TQFileInfo checkXml;
+ TQStringList saverConfigPaths = TQStringList::split(':', XSCREENSAVER_CONFIG_DIRS);
+ for (TQStringList::ConstIterator it = saverConfigPaths.begin(); it != saverConfigPaths.end(); ++it)
+ {
+ checkXml.setFile((*it) + "/" + mExeName + ".xml");
+ if (checkXml.exists())
+ {
+ xmlFile = checkXml.absFilePath();
+ break;
+ }
+ }
#endif
- xmlFile += "/" + mExeName + ".xml";
if ( TQFile::exists( xmlFile ) ) {
// We can use the xscreensaver xml config files.
KXSXml xmlParser(controlLayout);
@@ -227,15 +237,29 @@ void KXSConfigDialog::slotPreviewExited(TDEProcess *)
TQString word;
saver = saver.stripWhiteSpace();
while ( !saver[i].isSpace() ) word += saver[i++];
+
+ // find the xscreensaver executable
//work around a KStandarDirs::findExe() "feature" where it looks in $TDEDIR/bin first no matter what and sometimes finds the wrong executable
- TQFileInfo checkExe;
- TQString saverdir = TQString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(word);
TQString path;
- checkExe.setFile(saverdir);
- if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
+ TQFileInfo checkExe;
+ TQStringList saverPaths = TQStringList::split(':', XSCREENSAVER_HACKS_DIRS);
+ for (TQStringList::ConstIterator it = saverPaths.begin(); it != saverPaths.end(); ++it)
+ {
+ checkExe.setFile((*it) + "/" + word);
+ if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
+ {
+ path = checkExe.absFilePath();
+ break;
+ }
+ }
+
+ if (path.isEmpty())
{
- path = saverdir;
+ // Executable not present in XScreenSaver directory!
+ // Try standard paths
+ path = TDEStandardDirs::findExe(word);
}
+
if (!path.isEmpty()) {
(*mPreviewProc) << path;
@@ -260,7 +284,7 @@ void KXSConfigDialog::slotPreviewExited(TDEProcess *)
}
} else {
// stops us from spawning the hack really fast, but still not the best
- TQString path = TDEStandardDirs::findExe(mFilename, XSCREENSAVER_HACKS_DIR);
+ TQString path = TDEStandardDirs::findExe(mFilename, XSCREENSAVER_HACKS_DIRS);
if ( TQFile::exists(path) ) {
mKilled = true;
slotChanged();
diff --git a/tdescreensaver/kxsconfig/kxsrun.cpp b/tdescreensaver/kxsconfig/kxsrun.cpp
index cb9cc20b..8c144c67 100644
--- a/tdescreensaver/kxsconfig/kxsrun.cpp
+++ b/tdescreensaver/kxsconfig/kxsrun.cpp
@@ -88,10 +88,20 @@ int main(int argc, char *argv[])
TQPtrList<KXSConfigItem> configItemList;
TQString xmlFile = "/doesntexist";
-#ifdef XSCREENSAVER_CONFIG_DIR
- xmlFile = XSCREENSAVER_CONFIG_DIR;
-#endif
xmlFile += "/" + exeName + ".xml";
+#ifdef XSCREENSAVER_CONFIG_DIRS
+ TQFileInfo checkXml;
+ TQStringList saverConfigPaths = TQStringList::split(':', XSCREENSAVER_CONFIG_DIRS);
+ for (TQStringList::ConstIterator it = saverConfigPaths.begin(); it != saverConfigPaths.end(); ++it)
+ {
+ checkXml.setFile((*it) + "/" + exeName + ".xml");
+ if (checkXml.exists())
+ {
+ xmlFile = checkXml.absFilePath();
+ break;
+ }
+ }
+#endif
if ( TQFile::exists( xmlFile ) ) {
// We can use the xscreensaver xml config files.
KXSXml xmlParser(0);
@@ -134,16 +144,26 @@ int main(int argc, char *argv[])
// find the xscreensaver executable
//work around a KStandarDirs::findExe() "feature" where it looks in $TDEDIR/bin first no matter what and sometimes finds the wrong executable
- TQFileInfo checkExe;
- TQString saverdir = TQString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(filename);
- kdDebug() << "saverdir is" << saverdir << endl;
TQString exeFile;
- checkExe.setFile(saverdir);
- if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
+ TQFileInfo checkExe;
+ TQStringList saverPaths = TQStringList::split(':', XSCREENSAVER_HACKS_DIRS);
+ for (TQStringList::ConstIterator it = saverPaths.begin(); it != saverPaths.end(); ++it)
{
- exeFile = saverdir;
+ checkExe.setFile((*it) + "/" + filename);
+ if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
+ {
+ exeFile = checkExe.absFilePath();
+ kdDebug() << "saverdir is" << exeFile << endl;
+ break;
+ }
}
+ if (exeFile.isEmpty())
+ {
+ // Executable not present in XScreenSaver directory!
+ // Try standard paths
+ exeFile = TDEStandardDirs::findExe(filename);
+ }
if (!exeFile.isEmpty()) {
char *sargs[MAX_ARGS];