diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2022-03-28 23:34:29 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2022-03-29 00:15:35 +0200 |
commit | 58d7c360547e57857982fafd72b8a2086906c7d7 (patch) | |
tree | 47e7ff801b96321881836e881274138cf6242ffc | |
parent | 4974727d50923a4393e5f0daddf4694c6e082a84 (diff) | |
download | tdebase-58d7c360547e57857982fafd72b8a2086906c7d7.tar.gz tdebase-58d7c360547e57857982fafd72b8a2086906c7d7.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 TDE/tdeartwork#19.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | ConfigureChecks.cmake | 6 | ||||
-rw-r--r-- | FindXscreensaver.cmake | 72 | ||||
-rw-r--r-- | config.h.cmake | 2 | ||||
-rw-r--r-- | kcontrol/screensaver/scrnsave.cpp | 35 |
4 files changed, 64 insertions, 51 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index ddbd6025c..b60dd5dc0 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -309,10 +309,10 @@ if( WITH_XSCREENSAVER ) # where xscreensaver stores its executables. So give the user the possibility # to define XSCREENSAVER_DIR and speficy the location manually. include( FindXscreensaver.cmake ) # not really good practise - if( NOT XSCREENSAVER_DIR ) + if( NOT XSCREENSAVER_DIRS ) tde_message_fatal( - "xscreensaver is requested, but cmake can not determine the location of XSCREENSAVER_DIR - You have to either specify it manually with e.g. -DXSCREENSAVER_DIR=/usr/lib/misc/xscreensaver/ + "xscreensaver is requested, but cmake can not determine the location of XSCREENSAVER_DIRS + You have to either specify it manually with e.g. -DXSCREENSAVER_DIRS=/usr/lib/misc/xscreensaver/ or make sure that xscreensaver installed properly" ) endif( ) diff --git a/FindXscreensaver.cmake b/FindXscreensaver.cmake index 72ee19eda..93ca210ef 100644 --- a/FindXscreensaver.cmake +++ b/FindXscreensaver.cmake @@ -8,29 +8,7 @@ if (NOT XSCREENSAVER_FOUND) set(xscreensaver_alldirs) - set(xscreensaver_checkdirs ${TDE_INCLUDE_DIR} - /usr/ - /usr/local/ - /opt/local/ - /usr/X11R6/ - /opt/kde/ - /opt/kde3/ - /usr/kde/ - /usr/local/kde/ - /usr/local/xscreensaver/ - /usr/openwin/lib/xscreensaver/ - /etc/ ) - foreach(suffix lib${LIB_SUFFIX}/xscreensaver lib${LIB_SUFFIX}/misc/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver -bin/xscreensaver-hacks hacks) - foreach(xscreensaver_path ${xscreensaver_checkdirs} ) - set(xscreensaver_alldirs ${xscreensaver_alldirs} ${xscreensaver_path}/${suffix}) - endforeach(xscreensaver_path ${xscreensaver_checkdirs} ) - endforeach(suffix lib${LIB_SUFFIX}/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver bin/xscreensaver-hacks hacks) - FIND_PATH(XSCREENSAVER_DIR deco ${xscreensaver_alldirs}) - - set(XSCREENSAVER_CONFIG_DIR) - FIND_PATH(XSCREENSAVER_CONFIG_DECO config/deco.xml - ${TDE_INCLUDE_DIR} + set(xscreensaver_checkdirs /usr/ /usr/local/ /opt/local/ @@ -45,33 +23,58 @@ bin/xscreensaver-hacks hacks) /usr/openwin/lib/xscreensaver/ /etc/ ) - #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>") + foreach(suffix lib${LIB_SUFFIX}/xscreensaver lib${LIB_SUFFIX}/misc/xscreensaver + lib/xscreensaver lib64/xscreensaver libexec/xscreensaver + bin/xscreensaver-hacks hacks) + foreach(xscreensaver_path ${xscreensaver_checkdirs} ) + set(xscreensaver_alldirs ${xscreensaver_alldirs} ${xscreensaver_path}/${suffix}) + endforeach(xscreensaver_path ${xscreensaver_checkdirs} ) + endforeach() + + set(XSCREENSAVER_DIRS) + FIND_PATH(XSCREENSAVER_DIR_DECO deco ${xscreensaver_alldirs}) + FIND_PATH(XSCREENSAVER_DIR_FLUX flux ${xscreensaver_alldirs}) + if(XSCREENSAVER_DIR_DECO) + list(APPEND XSCREENSAVER_DIRS ${XSCREENSAVER_DIR_DECO}) + endif(XSCREENSAVER_DIR_DECO) + if(XSCREENSAVER_DIR_FLUX) + list(APPEND XSCREENSAVER_DIRS ${XSCREENSAVER_DIR_FLUX}) + endif(XSCREENSAVER_DIR_FLUX) + list( REMOVE_DUPLICATES XSCREENSAVER_DIRS ) + string( REPLACE ";" ":" XSCREENSAVER_DIRS "${XSCREENSAVER_DIRS}" ) + set(XSCREENSAVER_CONFIG_DIRS) + FIND_PATH(XSCREENSAVER_CONFIG_DECO config/deco.xml ${xscreensaver_checkdirs} ) + FIND_PATH(XSCREENSAVER_CONFIG_FLUX config/flux.xml ${xscreensaver_checkdirs} ) if(XSCREENSAVER_CONFIG_DECO) - set(XSCREENSAVER_CONFIG_DIR "${XSCREENSAVER_CONFIG_DECO}/config/") - #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR <${XSCREENSAVER_CONFIG_DIR}>") + list(APPEND XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DECO}/config/") endif(XSCREENSAVER_CONFIG_DECO) - + if(XSCREENSAVER_CONFIG_FLUX) + list(APPEND XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_FLUX}/config/") + endif(XSCREENSAVER_CONFIG_FLUX) # Try and locate XScreenSaver config when path doesn't include config - if(NOT XSCREENSAVER_CONFIG_DIR) - FIND_PATH(XSCREENSAVER_CONFIG_DIR deco.xml + if(NOT XSCREENSAVER_CONFIG_DIRS) + FIND_PATH(XSCREENSAVER_CONFIG_DIRS deco.xml /etc/xscreensaver ) - endif(NOT XSCREENSAVER_CONFIG_DIR) + endif(NOT XSCREENSAVER_CONFIG_DIRS) + + list( REMOVE_DUPLICATES XSCREENSAVER_CONFIG_DIRS ) + string( REPLACE ";" ":" XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" ) endif(NOT XSCREENSAVER_FOUND) #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>") #MESSAGE(STATUS "XSCREENSAVER_DIR :<${XSCREENSAVER_DIR}>") # Need to fix hack -if(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) +if(XSCREENSAVER_DIRS AND XSCREENSAVER_CONFIG_DIRS) set(XSCREENSAVER_FOUND TRUE) -endif(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) +endif(XSCREENSAVER_DIRS AND XSCREENSAVER_CONFIG_DIRS) if (XSCREENSAVER_FOUND) if (NOT Xscreensaver_FIND_QUIETLY) - message(STATUS "Found SCREENSAVER_CONFIG_DIR <${XSCREENSAVER_CONFIG_DIR}>") + message(STATUS "Found SCREENSAVER_CONFIG_DIRS <${XSCREENSAVER_CONFIG_DIRS}>") endif (NOT Xscreensaver_FIND_QUIETLY) else (XSCREENSAVER_FOUND) if (Xscreensaver_FIND_REQUIRED) @@ -79,5 +82,4 @@ else (XSCREENSAVER_FOUND) endif (Xscreensaver_FIND_REQUIRED) endif (XSCREENSAVER_FOUND) - -MARK_AS_ADVANCED(XSCREENSAVER_DIR XSCREENSAVER_CONFIG_DIR) +MARK_AS_ADVANCED(XSCREENSAVER_DIRS XSCREENSAVER_CONFIG_DIRS) diff --git a/config.h.cmake b/config.h.cmake index 82b16c44f..d174283a0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -35,7 +35,7 @@ #cmakedefine HAVE_XSCREENSAVER 1 /* Defines where xscreensaver stores its graphic hacks */ -#define XSCREENSAVER_HACKS_DIR "@XSCREENSAVER_DIR@" +#define XSCREENSAVER_HACKS_DIRS "@XSCREENSAVER_DIRS@" // libart #cmakedefine HAVE_LIBART 1 diff --git a/kcontrol/screensaver/scrnsave.cpp b/kcontrol/screensaver/scrnsave.cpp index b66f7bbd6..cd30fa1a1 100644 --- a/kcontrol/screensaver/scrnsave.cpp +++ b/kcontrol/screensaver/scrnsave.cpp @@ -523,28 +523,39 @@ void KScreenSaver::findSavers() i++, mNumLoaded++ ) { TQString file = mSaverFileList[mNumLoaded]; SaverConfig *saver = new SaverConfig; - if (saver->read(file)) { - TQString saverexec = TQString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(saver->exec()); + bool saverFound = false; + if (saver->read(file)) + { // find the xscreensaver executable //work around a TDEStandardDirs::findExe() "feature" where it looks in $TDEDIR/bin first no matter what and sometimes finds the wrong executable TQFileInfo checkExe; - checkExe.setFile(saverexec); - if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) { - mSaverList.append(saver); + TQStringList saverPaths = TQStringList::split(':', XSCREENSAVER_HACKS_DIRS); + for (TQStringList::ConstIterator it = saverPaths.begin(); it != saverPaths.end(); ++it) + { + checkExe.setFile((*it) + "/" + saver->exec()); + if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) + { + mSaverList.append(saver); + saverFound = true; + break; + } } - else { + + if (!saverFound) + { // Executable not present in XScreenSaver directory! // Try standard paths - if (TDEStandardDirs::findExe(saver->exec()) != TQString::null) { + if (TDEStandardDirs::findExe(saver->exec()) != TQString::null) + { mSaverList.append(saver); - } - else { - delete saver; + saverFound = true; } } } - else { - delete saver; + + if (!saverFound) + { + delete saver; } } |