diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2022-03-29 02:53:16 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2022-03-29 09:50:36 +0200 |
commit | 2988432a72a28f15a292d79f3c6b6d11b294899c (patch) | |
tree | 076d291f80748cf39ae9ffa6c0f457da959659cc | |
parent | cf8c057b08d378085d81c4c6f39eb3a7cdb1c299 (diff) | |
download | tdeartwork-2988432a72a28f15a292d79f3c6b6d11b294899c.tar.gz tdeartwork-2988432a72a28f15a292d79f3c6b6d11b294899c.zip |
Modify screen savers detection that the XSCREENSAVER_DIRSr14.0.12
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 <slavek.banko@axis.cz>
(cherry picked from commit b0eb71dedfc68ca5ce981b2853af9a64b2c2e67f)
-rw-r--r-- | FindXscreensaver.cmake | 72 | ||||
-rw-r--r-- | config.h.cmake | 4 | ||||
-rw-r--r-- | tdescreensaver/kxsconfig/CMakeL10n.txt | 13 | ||||
-rw-r--r-- | tdescreensaver/kxsconfig/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tdescreensaver/kxsconfig/kxsconfig.cpp | 42 | ||||
-rw-r--r-- | tdescreensaver/kxsconfig/kxsrun.cpp | 38 |
6 files changed, 111 insertions, 61 deletions
diff --git a/FindXscreensaver.cmake b/FindXscreensaver.cmake index 72ee19ed..93ca210e 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 1749551e..241c562d 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -3,10 +3,10 @@ #cmakedefine HAVE_NUMERIC_LIMITS 1 /* Defines where xscreensaver stores it's config files */ -#define XSCREENSAVER_CONFIG_DIR "@XSCREENSAVER_CONFIG_DIR@" +#define XSCREENSAVER_CONFIG_DIRS "@XSCREENSAVER_CONFIG_DIRS@" /* Defines where xscreensaver stores its graphic hacks */ -#define XSCREENSAVER_HACKS_DIR "@XSCREENSAVER_DIR@" +#define XSCREENSAVER_HACKS_DIRS "@XSCREENSAVER_DIRS@" /* Defines if you have GL (Mesa, OpenGL, ...) */ #cmakedefine HAVE_GL 1 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]; |