refactor(WMTheme): use ffSearchUserConfigFile

This commit is contained in:
apocelipes authored and Carter Li committed 2023-12-20 10:28:51 +00:00
1 parent b9368ac20d
commit 3040bc38cb
1 file changed
+10 -8
+10 -8
View File
@@ -133,15 +133,17 @@ static bool detectXFWM4(FFstrbuf* themeOrError)
static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError)
{
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(64);
ffStrbufAppend(&absolutePath, &instance.state.platform.homeDir);
const char *configFileSubpath = "openbox/rc.xml";
if (ffStrbufIgnCaseCompS(dePrettyName, "LXQT") == 0)
configFileSubpath = "openbox/lxqt-rc.xml";
else if (ffStrbufIgnCaseCompS(dePrettyName, "LXDE") == 0)
configFileSubpath = "openbox/lxde-rc.xml";
//TODO: use config dirs
if(ffStrbufIgnCaseCompS(dePrettyName, "LXQT") == 0)
ffStrbufAppendS(&absolutePath, ".config/openbox/lxqt-rc.xml");
else if(ffStrbufIgnCaseCompS(dePrettyName, "LXDE") == 0)
ffStrbufAppendS(&absolutePath, ".config/openbox/lxde-rc.xml");
else
ffStrbufAppendS(&absolutePath, ".config/openbox/rc.xml");
if (!ffSearchUserConfigFile(&instance.state.platform.configDirs, configFileSubpath, &absolutePath))
{
ffStrbufAppendF(themeOrError, "Couldn't find config file \"%s\"", configFileSubpath);
return false;
}
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
if (!ffReadFileBuffer(absolutePath.chars, &content))