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 <slavek.banko@axis.cz>
pull/20/head
Slávek Banko 3 years ago
parent e5903f8f6e
commit b0eb71dedf
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -8,7 +8,7 @@
if (NOT XSCREENSAVER_FOUND) if (NOT XSCREENSAVER_FOUND)
set(xscreensaver_alldirs) set(xscreensaver_alldirs)
set(xscreensaver_checkdirs ${TDE_INCLUDE_DIR} set(xscreensaver_checkdirs
/usr/ /usr/
/usr/local/ /usr/local/
/opt/local/ /opt/local/
@ -16,62 +16,65 @@ if (NOT XSCREENSAVER_FOUND)
/opt/kde/ /opt/kde/
/opt/kde3/ /opt/kde3/
/usr/kde/ /usr/kde/
/usr/share/xscreensaver/
/usr/local/kde/ /usr/local/kde/
/usr/local/xscreensaver/ /usr/local/xscreensaver/
/usr/local/share/xscreensaver/
/usr/openwin/lib/xscreensaver/ /usr/openwin/lib/xscreensaver/
/etc/ ) /etc/
foreach(suffix lib${LIB_SUFFIX}/xscreensaver lib${LIB_SUFFIX}/misc/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver )
foreach(suffix lib${LIB_SUFFIX}/xscreensaver lib${LIB_SUFFIX}/misc/xscreensaver
lib/xscreensaver lib64/xscreensaver libexec/xscreensaver
bin/xscreensaver-hacks hacks) bin/xscreensaver-hacks hacks)
foreach(xscreensaver_path ${xscreensaver_checkdirs} ) foreach(xscreensaver_path ${xscreensaver_checkdirs} )
set(xscreensaver_alldirs ${xscreensaver_alldirs} ${xscreensaver_path}/${suffix}) set(xscreensaver_alldirs ${xscreensaver_alldirs} ${xscreensaver_path}/${suffix})
endforeach(xscreensaver_path ${xscreensaver_checkdirs} ) endforeach(xscreensaver_path ${xscreensaver_checkdirs} )
endforeach(suffix lib${LIB_SUFFIX}/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver bin/xscreensaver-hacks hacks) endforeach()
FIND_PATH(XSCREENSAVER_DIR deco ${xscreensaver_alldirs})
set(XSCREENSAVER_CONFIG_DIR) set(XSCREENSAVER_DIRS)
FIND_PATH(XSCREENSAVER_CONFIG_DECO config/deco.xml FIND_PATH(XSCREENSAVER_DIR_DECO deco ${xscreensaver_alldirs})
${TDE_INCLUDE_DIR} FIND_PATH(XSCREENSAVER_DIR_FLUX flux ${xscreensaver_alldirs})
/usr/ if(XSCREENSAVER_DIR_DECO)
/usr/local/ list(APPEND XSCREENSAVER_DIRS ${XSCREENSAVER_DIR_DECO})
/opt/local/ endif(XSCREENSAVER_DIR_DECO)
/usr/X11R6/ if(XSCREENSAVER_DIR_FLUX)
/opt/kde/ list(APPEND XSCREENSAVER_DIRS ${XSCREENSAVER_DIR_FLUX})
/opt/kde3/ endif(XSCREENSAVER_DIR_FLUX)
/usr/kde/ list( REMOVE_DUPLICATES XSCREENSAVER_DIRS )
/usr/share/xscreensaver/ string( REPLACE ";" ":" XSCREENSAVER_DIRS "${XSCREENSAVER_DIRS}" )
/usr/local/kde/
/usr/local/xscreensaver/
/usr/local/share/xscreensaver/
/usr/openwin/lib/xscreensaver/
/etc/
)
#MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>")
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) if(XSCREENSAVER_CONFIG_DECO)
set(XSCREENSAVER_CONFIG_DIR "${XSCREENSAVER_CONFIG_DECO}/config/") list(APPEND XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DECO}/config/")
#MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR <${XSCREENSAVER_CONFIG_DIR}>")
endif(XSCREENSAVER_CONFIG_DECO) 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 # Try and locate XScreenSaver config when path doesn't include config
if(NOT XSCREENSAVER_CONFIG_DIR) if(NOT XSCREENSAVER_CONFIG_DIRS)
FIND_PATH(XSCREENSAVER_CONFIG_DIR deco.xml FIND_PATH(XSCREENSAVER_CONFIG_DIRS deco.xml
/etc/xscreensaver /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) endif(NOT XSCREENSAVER_FOUND)
#MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>") #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>")
#MESSAGE(STATUS "XSCREENSAVER_DIR :<${XSCREENSAVER_DIR}>") #MESSAGE(STATUS "XSCREENSAVER_DIR :<${XSCREENSAVER_DIR}>")
# Need to fix hack # Need to fix hack
if(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) if(XSCREENSAVER_DIRS AND XSCREENSAVER_CONFIG_DIRS)
set(XSCREENSAVER_FOUND TRUE) set(XSCREENSAVER_FOUND TRUE)
endif(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) endif(XSCREENSAVER_DIRS AND XSCREENSAVER_CONFIG_DIRS)
if (XSCREENSAVER_FOUND) if (XSCREENSAVER_FOUND)
if (NOT Xscreensaver_FIND_QUIETLY) 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) endif (NOT Xscreensaver_FIND_QUIETLY)
else (XSCREENSAVER_FOUND) else (XSCREENSAVER_FOUND)
if (Xscreensaver_FIND_REQUIRED) if (Xscreensaver_FIND_REQUIRED)
@ -79,5 +82,4 @@ else (XSCREENSAVER_FOUND)
endif (Xscreensaver_FIND_REQUIRED) endif (Xscreensaver_FIND_REQUIRED)
endif (XSCREENSAVER_FOUND) endif (XSCREENSAVER_FOUND)
MARK_AS_ADVANCED(XSCREENSAVER_DIRS XSCREENSAVER_CONFIG_DIRS)
MARK_AS_ADVANCED(XSCREENSAVER_DIR XSCREENSAVER_CONFIG_DIR)

@ -3,10 +3,10 @@
#cmakedefine HAVE_NUMERIC_LIMITS 1 #cmakedefine HAVE_NUMERIC_LIMITS 1
/* Defines where xscreensaver stores it's config files */ /* 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 */ /* 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, ...) */ /* Defines if you have GL (Mesa, OpenGL, ...) */
#cmakedefine HAVE_GL 1 #cmakedefine HAVE_GL 1

@ -16,8 +16,10 @@ endif( )
message( STATUS "Prepare to extract strings from xscreensaver data files..." ) message( STATUS "Prepare to extract strings from xscreensaver data files..." )
include( ${CMAKE_SOURCE_DIR}/FindXscreensaver.cmake ) include( ${CMAKE_SOURCE_DIR}/FindXscreensaver.cmake )
string( REPLACE ":" ";" SEARCH_XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" )
unset( _xsavers_l10n ) unset( _xsavers_l10n )
foreach( XSCREENSAVER_CONFIG_DIR IN LISTS SEARCH_XSCREENSAVER_CONFIG_DIRS )
file( GLOB _xsaver_files file( GLOB _xsaver_files
RELATIVE "${XSCREENSAVER_CONFIG_DIR}" RELATIVE "${XSCREENSAVER_CONFIG_DIR}"
${XSCREENSAVER_CONFIG_DIR}*.xml ) ${XSCREENSAVER_CONFIG_DIR}*.xml )
@ -61,6 +63,7 @@ foreach( _xsaver_file ${_xsaver_files} )
"${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h.tde_l10n" ) "${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h.tde_l10n" )
list( APPEND _xsavers_l10n "ScreenSavers/${_xsaver_file}.h.tde_l10n" ) list( APPEND _xsavers_l10n "ScreenSavers/${_xsaver_file}.h.tde_l10n" )
endforeach( ) endforeach( )
endforeach( )
##### create translation templates ############## ##### create translation templates ##############

@ -49,12 +49,13 @@ tde_add_executable( ${target} AUTOMOC
##### install desktops ########################## ##### install desktops ##########################
# code from kde4 # code from kde4
FILE(GLOB _desktopfiles "ScreenSavers/*.desktop" ) FILE(GLOB _desktopfiles "ScreenSavers/*.desktop" )
string( REPLACE ":" ";" SEARCH_XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" )
foreach(_currentdesktopfile ${_desktopfiles}) foreach(_currentdesktopfile ${_desktopfiles})
STRING(REGEX REPLACE ".desktop" "" _newitem "${_currentdesktopfile}" ) STRING(REGEX REPLACE ".desktop" "" _newitem "${_currentdesktopfile}" )
#MESSAGE(STATUS "newItem <${_newitem}>") #MESSAGE(STATUS "newItem <${_newitem}>")
GET_FILENAME_COMPONENT(_screensaverName ${_newitem} NAME_WE) GET_FILENAME_COMPONENT(_screensaverName ${_newitem} NAME_WE)
#MESSAGE(STATUS "name without extension <${_screensaverName}>") #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) if(XSCREENSAVER_FILE_FOUND)
MESSAGE(STATUS "xscreensaver name ${_screensaverName} found") MESSAGE(STATUS "xscreensaver name ${_screensaverName} found")
else(XSCREENSAVER_FILE_FOUND) else(XSCREENSAVER_FILE_FOUND)

@ -101,11 +101,21 @@ bool KXSConfigDialog::create()
TDEConfig config(mConfigFile); TDEConfig config(mConfigFile);
TQString xmlFile = "/doesntexist"; TQString xmlFile = "/doesntexist";
#ifdef XSCREENSAVER_CONFIG_DIR xmlFile += "/" + mExeName + ".xml";
xmlFile = XSCREENSAVER_CONFIG_DIR; #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 #endif
xmlFile += "/" + mExeName + ".xml";
if ( TQFile::exists( xmlFile ) ) { if ( TQFile::exists( xmlFile ) ) {
// We can use the xscreensaver xml config files. // We can use the xscreensaver xml config files.
KXSXml xmlParser(controlLayout); KXSXml xmlParser(controlLayout);
@ -227,15 +237,29 @@ void KXSConfigDialog::slotPreviewExited(TDEProcess *)
TQString word; TQString word;
saver = saver.stripWhiteSpace(); saver = saver.stripWhiteSpace();
while ( !saver[i].isSpace() ) word += saver[i++]; 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 //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; TQString path;
checkExe.setFile(saverdir); 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()) if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
{ {
path = saverdir; path = checkExe.absFilePath();
break;
}
}
if (path.isEmpty())
{
// Executable not present in XScreenSaver directory!
// Try standard paths
path = TDEStandardDirs::findExe(word);
} }
if (!path.isEmpty()) { if (!path.isEmpty()) {
(*mPreviewProc) << path; (*mPreviewProc) << path;
@ -260,7 +284,7 @@ void KXSConfigDialog::slotPreviewExited(TDEProcess *)
} }
} else { } else {
// stops us from spawning the hack really fast, but still not the best // 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) ) { if ( TQFile::exists(path) ) {
mKilled = true; mKilled = true;
slotChanged(); slotChanged();

@ -88,10 +88,20 @@ int main(int argc, char *argv[])
TQPtrList<KXSConfigItem> configItemList; TQPtrList<KXSConfigItem> configItemList;
TQString xmlFile = "/doesntexist"; TQString xmlFile = "/doesntexist";
#ifdef XSCREENSAVER_CONFIG_DIR
xmlFile = XSCREENSAVER_CONFIG_DIR;
#endif
xmlFile += "/" + exeName + ".xml"; 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 ) ) { if ( TQFile::exists( xmlFile ) ) {
// We can use the xscreensaver xml config files. // We can use the xscreensaver xml config files.
KXSXml xmlParser(0); KXSXml xmlParser(0);
@ -134,16 +144,26 @@ int main(int argc, char *argv[])
// find the xscreensaver executable // 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 //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; TQString exeFile;
checkExe.setFile(saverdir); TQFileInfo checkExe;
TQStringList saverPaths = TQStringList::split(':', XSCREENSAVER_HACKS_DIRS);
for (TQStringList::ConstIterator it = saverPaths.begin(); it != saverPaths.end(); ++it)
{
checkExe.setFile((*it) + "/" + filename);
if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
{ {
exeFile = saverdir; 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()) { if (!exeFile.isEmpty()) {
char *sargs[MAX_ARGS]; char *sargs[MAX_ARGS];

Loading…
Cancel
Save