mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Merge branch 'LinusDierheimer:master' into master
This commit is contained in:
@@ -48,18 +48,18 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0)
|
||||
{
|
||||
themeName = ffSettingsGetStr(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme");
|
||||
iconsName = ffSettingsGetStr(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme");
|
||||
fontName = ffSettingsGetStr(instance, "/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name");
|
||||
themeName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
iconsName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
fontName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
}
|
||||
|
||||
//Fallback + Gnome impl
|
||||
if(themeName == NULL)
|
||||
themeName = ffSettingsGetStr(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme");
|
||||
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if(iconsName == NULL)
|
||||
iconsName = ffSettingsGetStr(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme");
|
||||
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
if(fontName == NULL)
|
||||
fontName = ffSettingsGetStr(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name");
|
||||
fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
applyGTKDConfSettings(result, themeName, iconsName, fontName);
|
||||
|
||||
+38
-10
@@ -17,7 +17,8 @@ typedef enum DEHint
|
||||
FF_DE_HINT_UNKNOWN = 0,
|
||||
FF_DE_HINT_PLASMA,
|
||||
FF_DE_HINT_GNOME,
|
||||
FF_DE_HINT_CINNAMON
|
||||
FF_DE_HINT_CINNAMON,
|
||||
FF_DE_HINT_XFCE4
|
||||
} DEHint;
|
||||
|
||||
typedef struct ProcData
|
||||
@@ -114,7 +115,7 @@ static bool applyPrettyNameIfWM(FFWMDEResult* result, const FFstrbuf* processNam
|
||||
}
|
||||
else if(ffStrbufIgnCaseCompS(processName, "xfwm4") == 0)
|
||||
{
|
||||
ffStrbufSetS(&result->wmPrettyName, "XFWM");
|
||||
ffStrbufSetS(&result->wmPrettyName, "Xfwm4");
|
||||
*protocolHint = FF_PROTOCOL_HINT_X11;
|
||||
}
|
||||
else if(ffStrbufIgnCaseCompS(processName, "gnome-session-binary") == 0)
|
||||
@@ -139,6 +140,8 @@ static bool applyDEHintIfDE(const FFstrbuf* processName, DEHint* deHint)
|
||||
*deHint = FF_DE_HINT_GNOME;
|
||||
else if(ffStrbufIgnCaseCompS(processName, "cinnamon") == 0)
|
||||
*deHint = FF_DE_HINT_CINNAMON;
|
||||
else if(ffStrbufIgnCaseCompS(processName, "xfce4-session") == 0)
|
||||
*deHint = FF_DE_HINT_XFCE4;
|
||||
|
||||
return *deHint != FF_DE_HINT_UNKNOWN;
|
||||
}
|
||||
@@ -224,7 +227,30 @@ static void getCinnamon(FFWMDEResult* result)
|
||||
ffStrbufRecalculateLength(&result->deVersion);
|
||||
}
|
||||
|
||||
static inline void getDEFromHint(FFWMDEResult* result, ProcData* procData)
|
||||
static void getXFCE4(FFinstance* instance, FFWMDEResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, "xfce4-session");
|
||||
ffStrbufSetS(&result->dePrettyName, "Xfce4");
|
||||
|
||||
ffParsePropFile("/usr/share/gtk-doc/html/libxfce4ui/index.html", "<div><p class=\"releaseinfo\">Version %[^\n]", result->deVersion.chars);
|
||||
ffStrbufRecalculateLength(&result->deVersion);
|
||||
|
||||
if(result->deVersion.length == 0 && instance->config.allowSlowOperations)
|
||||
{
|
||||
//This is really, really slow. Thank you, XFCE developers
|
||||
ffProcessAppendStdOut(&result->deVersion, (char* const[]){
|
||||
"xfce4-session",
|
||||
"--version",
|
||||
NULL
|
||||
});
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(&result->deVersion, '(');
|
||||
ffStrbufSubstrAfterFirstC(&result->deVersion, ' ');
|
||||
ffStrbufTrim(&result->deVersion, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
static inline void getDEFromHint(FFinstance* instance, FFWMDEResult* result, ProcData* procData)
|
||||
{
|
||||
getFromProcDir(result, procData, false);
|
||||
|
||||
@@ -237,9 +263,11 @@ static inline void getDEFromHint(FFWMDEResult* result, ProcData* procData)
|
||||
getGnome(result);
|
||||
else if(procData->deHint == FF_DE_HINT_CINNAMON)
|
||||
getCinnamon(result);
|
||||
else if(procData->deHint == FF_DE_HINT_XFCE4)
|
||||
getXFCE4(instance, result);
|
||||
}
|
||||
|
||||
static inline void getDE(FFWMDEResult* result, ProcData* procData)
|
||||
static inline void getDE(FFinstance* instance, FFWMDEResult* result, ProcData* procData)
|
||||
{
|
||||
// if sessionDesktop is not set or sessionDesktiop == WM, try finding DE via /proc
|
||||
if(
|
||||
@@ -248,7 +276,7 @@ static inline void getDE(FFWMDEResult* result, ProcData* procData)
|
||||
ffStrbufIgnCaseCompS(&result->wmProcessName, result->sessionDesktop) == 0 ||
|
||||
ffStrbufIgnCaseCompS(&result->wmPrettyName, result->sessionDesktop) == 0
|
||||
) {
|
||||
getDEFromHint(result, procData);
|
||||
getDEFromHint(instance, result, procData);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,6 +286,8 @@ static inline void getDE(FFWMDEResult* result, ProcData* procData)
|
||||
getGnome(result);
|
||||
else if(strcasecmp(result->sessionDesktop, "X-Cinnamon") == 0 || strcasecmp(result->sessionDesktop, "Cinnamon") == 0)
|
||||
getCinnamon(result);
|
||||
else if(strcasecmp(result->sessionDesktop, "XFCE") == 0 || strcasecmp(result->sessionDesktop, "X-XFCE") == 0 || strcasecmp(result->sessionDesktop, "XFCE4") == 0 || strcasecmp(result->sessionDesktop, "X-XFCE4") == 0)
|
||||
getXFCE4(instance, result);
|
||||
else
|
||||
{
|
||||
ffStrbufSetS(&result->deProcessName, result->sessionDesktop);
|
||||
@@ -304,7 +334,7 @@ static inline void getSessionType(FFWMDEResult* result, ProtocolHint protocolHin
|
||||
getSessionTypeFallback(result, protocolHint);
|
||||
}
|
||||
|
||||
static inline void getWMDE(FFWMDEResult* result)
|
||||
static inline void getWMDE(FFinstance* instance, FFWMDEResult* result)
|
||||
{
|
||||
ProcData procData;
|
||||
procData.proc = opendir("/proc");
|
||||
@@ -314,7 +344,7 @@ static inline void getWMDE(FFWMDEResult* result)
|
||||
|
||||
getSessionDesktop(result);
|
||||
getWM(result, &procData);
|
||||
getDE(result, &procData);
|
||||
getDE(instance, result, &procData);
|
||||
|
||||
if(result->wmProtocolName.length == 0 && procData.protocolHint != FF_PROTOCOL_HINT_UNKNOWN)
|
||||
getSessionTypeFallback(result, procData.protocolHint);
|
||||
@@ -325,8 +355,6 @@ static inline void getWMDE(FFWMDEResult* result)
|
||||
|
||||
const FFWMDEResult* ffDetectWMDE(FFinstance* instance)
|
||||
{
|
||||
UNUSED(instance);
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFWMDEResult result;
|
||||
static bool init = false;
|
||||
@@ -349,7 +377,7 @@ const FFWMDEResult* ffDetectWMDE(FFinstance* instance)
|
||||
|
||||
//Don't run anyting when on TTY. This prevents us to catch process from other users in at least that case.
|
||||
if(ffStrbufIgnCaseCompS(&result.wmProtocolName, "TTY") != 0)
|
||||
getWMDE(&result);
|
||||
getWMDE(instance, &result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ static void defaultConfig(FFconfig* config)
|
||||
config->recache = false;
|
||||
config->cacheSave = true;
|
||||
config->printRemainingLogo = true;
|
||||
config->allowSlowOperations = false;
|
||||
|
||||
//Since most of these properties are unlikely to be used at once, give them minimal heap space (the \0 character)
|
||||
ffStrbufInitA(&config->osFormat, 1);
|
||||
@@ -159,6 +160,7 @@ static void defaultConfig(FFconfig* config)
|
||||
ffStrbufInitA(&config->libGIO, 1);
|
||||
ffStrbufInitA(&config->libDConf, 1);
|
||||
ffStrbufInitA(&config->libWayland, 1);
|
||||
ffStrbufInitA(&config->libXFConf, 1);
|
||||
|
||||
ffStrbufInitA(&config->diskFolders, 1);
|
||||
|
||||
|
||||
+118
-72
@@ -2,8 +2,30 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <gio/gio.h>
|
||||
#include <dconf.h>
|
||||
#include <dconf.h> // Also included gio/gio.h
|
||||
|
||||
typedef void* DynamicLibrary;
|
||||
|
||||
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
|
||||
|
||||
#define FF_LIBRARY_LOAD(libraryNameUser, libraryNameDefault, mutex) dlopen(libraryNameUser.length == 0 ? libraryNameDefault : libraryNameUser.chars, RTLD_LAZY); \
|
||||
if(dlerror() != NULL) { \
|
||||
pthread_mutex_unlock(&mutex); \
|
||||
return FF_VARIANT_NULL; \
|
||||
}
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, mutex) dlsym(library, symbolName); \
|
||||
if(dlerror() != NULL) { \
|
||||
pthread_mutex_unlock(&mutex); \
|
||||
dlclose(library); \
|
||||
return FF_VARIANT_NULL; \
|
||||
}
|
||||
|
||||
#define FF_LIBRARY_ERROR_RETURN(library, mutex) { \
|
||||
pthread_mutex_unlock(&mutex); \
|
||||
dlclose(library); \
|
||||
return FF_VARIANT_NULL; \
|
||||
}
|
||||
|
||||
typedef struct GVariantGetters
|
||||
{
|
||||
@@ -11,23 +33,19 @@ typedef struct GVariantGetters
|
||||
gboolean(*ffg_variant_get_boolean)(GVariant*);
|
||||
} GVariantGetters;
|
||||
|
||||
static inline void initGVariantGetters(void* library, GVariantGetters* variantGetters)
|
||||
{
|
||||
variantGetters->ffg_variant_get_string = dlsym(library, "g_variant_get_string");
|
||||
variantGetters->ffg_variant_get_boolean = dlsym(library, "g_variant_get_boolean");
|
||||
}
|
||||
|
||||
#define FF_VARIANT_NULL (FFvariant)(const char*)NULL
|
||||
#define FF_LIBRARY_GVARIANT_GETTERS_INIT(library, object, mutex) \
|
||||
object.ffg_variant_get_string = FF_LIBRARY_LOAD_SYMBOL(library, "g_variant_get_string", mutex); \
|
||||
object.ffg_variant_get_boolean = FF_LIBRARY_LOAD_SYMBOL(library, "g_variant_get_boolean", mutex);
|
||||
|
||||
static FFvariant getGVariantValue(GVariant* variant, FFvarianttype type, GVariantGetters* variantGetters)
|
||||
{
|
||||
if(variant == NULL)
|
||||
return FF_VARIANT_NULL;
|
||||
|
||||
if(type == FF_VARIANT_TYPE_STRING && variantGetters->ffg_variant_get_string != NULL)
|
||||
if(type == FF_VARIANT_TYPE_STRING)
|
||||
return (FFvariant) variantGetters->ffg_variant_get_string(variant, NULL);
|
||||
|
||||
if(type == FF_VARIANT_TYPE_BOOL && variantGetters->ffg_variant_get_boolean != NULL)
|
||||
if(type == FF_VARIANT_TYPE_BOOL)
|
||||
return (FFvariant) { .boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true};
|
||||
|
||||
return FF_VARIANT_NULL;
|
||||
@@ -46,13 +64,14 @@ static FFvariant getDConfValue(DConfData* data, const char* key, FFvarianttype t
|
||||
return FF_VARIANT_NULL;
|
||||
|
||||
GVariant* variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_FLAGS_NONE, NULL);
|
||||
if(variant != NULL)
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
|
||||
if(variant == NULL)
|
||||
variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_USER_VALUE, NULL);
|
||||
|
||||
if(variant == NULL)
|
||||
variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_DEFAULT_VALUE, NULL);
|
||||
variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_USER_VALUE, NULL);
|
||||
if(variant != NULL)
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
|
||||
variant = data->ffdconf_client_read_full(data->client, key, DCONF_READ_DEFAULT_VALUE, NULL);
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
}
|
||||
|
||||
@@ -70,31 +89,18 @@ FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttyp
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getDConfValue(&data, key, type);
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
data.client = NULL; //error indicator
|
||||
|
||||
void* library = dlopen(instance->config.libDConf.length == 0 ? "libdconf.so" : instance->config.libDConf.chars, RTLD_LAZY);
|
||||
if(library == NULL)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
DynamicLibrary library = FF_LIBRARY_LOAD(instance->config.libDConf, "libdocnf.so", mutex);
|
||||
|
||||
data.ffdconf_client_read_full = dlsym(library, "dconf_client_read_full");
|
||||
initGVariantGetters(library, &data.variantGetters);
|
||||
data.ffdconf_client_read_full = FF_LIBRARY_LOAD_SYMBOL(library, "dconf_client_read_full", mutex);
|
||||
FF_LIBRARY_GVARIANT_GETTERS_INIT(library, data.variantGetters, mutex);
|
||||
|
||||
DConfClient*(*ffdconf_client_new)(void) = dlsym(library, "dconf_client_new");
|
||||
|
||||
if(
|
||||
data.ffdconf_client_read_full == NULL ||
|
||||
(data.client = ffdconf_client_new()) == NULL
|
||||
) {
|
||||
pthread_mutex_unlock(&mutex);
|
||||
dlclose(library);
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
DConfClient*(*ffdconf_client_new)(void) = FF_LIBRARY_LOAD_SYMBOL(library, "dconf_client_new", mutex);
|
||||
if((data.client = ffdconf_client_new()) == NULL)
|
||||
FF_LIBRARY_ERROR_RETURN(library, mutex);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getDConfValue(&data, key, type);
|
||||
@@ -129,13 +135,14 @@ static FFvariant getGSettingsValue(GSettingsData* data, const char* schemaName,
|
||||
return FF_VARIANT_NULL;
|
||||
|
||||
GVariant* variant = data->ffg_settings_get_value(settings, key);
|
||||
if(variant != NULL)
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
|
||||
if(variant == NULL)
|
||||
variant = data->ffg_settings_get_user_value(settings, key);
|
||||
|
||||
if(variant == NULL)
|
||||
variant = data->ffg_settings_get_default_value(settings, key);
|
||||
variant = data->ffg_settings_get_user_value(settings, key);
|
||||
if(variant != NULL)
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
|
||||
variant = data->ffg_settings_get_default_value(settings, key);
|
||||
return getGVariantValue(variant, type, &data->variantGetters);
|
||||
}
|
||||
|
||||
@@ -153,42 +160,23 @@ FFvariant ffSettingsGetGsettings(FFinstance* instance, const char* schemaName, c
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getGSettingsValue(&data, schemaName, path, key, type);
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
data.schemaSource = NULL; //error indicator
|
||||
|
||||
void* library = dlopen(instance->config.libGIO.length == 0 ? "libgio-2.0.so" : instance->config.libGIO.chars, RTLD_LAZY);
|
||||
if(library == NULL)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
DynamicLibrary library = FF_LIBRARY_LOAD(instance->config.libGIO, "libgio-2.0.so", mutex);
|
||||
|
||||
data.ffg_settings_schema_source_lookup = dlsym(library, "g_settings_schema_source_lookup");
|
||||
data.ffg_settings_schema_has_key = dlsym(library, "g_settings_schema_has_key");
|
||||
data.ffg_settings_new_full = dlsym(library, "g_settings_new_full");
|
||||
data.ffg_settings_get_value = dlsym(library, "g_settings_get_value");
|
||||
data.ffg_settings_get_user_value = dlsym(library, "g_settings_get_user_value");
|
||||
data.ffg_settings_get_default_value = dlsym(library, "g_settings_get_default_value");
|
||||
initGVariantGetters(library, &data.variantGetters);
|
||||
data.ffg_settings_schema_source_lookup = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_schema_source_lookup", mutex);
|
||||
data.ffg_settings_schema_has_key = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_schema_has_key", mutex);
|
||||
data.ffg_settings_new_full = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_new_full", mutex);
|
||||
data.ffg_settings_get_value = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_get_value", mutex);
|
||||
data.ffg_settings_get_user_value = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_get_user_value", mutex);
|
||||
data.ffg_settings_get_default_value = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_get_default_value", mutex);
|
||||
FF_LIBRARY_GVARIANT_GETTERS_INIT(library, data.variantGetters, mutex);
|
||||
|
||||
GSettingsSchemaSource*(*ffg_settings_schema_source_get_default)(void) = dlsym(library, "g_settings_schema_source_get_default");
|
||||
|
||||
if(
|
||||
data.ffg_settings_schema_source_lookup == NULL ||
|
||||
data.ffg_settings_schema_has_key == NULL ||
|
||||
data.ffg_settings_new_full == NULL ||
|
||||
data.ffg_settings_get_value == NULL ||
|
||||
data.ffg_settings_get_user_value == NULL ||
|
||||
data.ffg_settings_get_default_value == NULL ||
|
||||
ffg_settings_schema_source_get_default == NULL ||
|
||||
(data.schemaSource = ffg_settings_schema_source_get_default()) == NULL
|
||||
) {
|
||||
pthread_mutex_unlock(&mutex);
|
||||
dlclose(library);
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
GSettingsSchemaSource*(*ffg_settings_schema_source_get_default)(void) = FF_LIBRARY_LOAD_SYMBOL(library, "g_settings_schema_source_get_default", mutex);
|
||||
if((data.schemaSource = ffg_settings_schema_source_get_default()) == NULL)
|
||||
FF_LIBRARY_ERROR_RETURN(library, mutex);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getGSettingsValue(&data, schemaName, path, key, type);
|
||||
@@ -203,9 +191,67 @@ FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char*
|
||||
return ffSettingsGetGsettings(instance, gsettingsSchemaName, gsettingsPath, gsettingsKey, FF_VARIANT_TYPE_STRING);
|
||||
}
|
||||
|
||||
const char* ffSettingsGetStr(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey)
|
||||
typedef struct _XfconfChannel XfconfChannel; // /usr/include/xfce4/xfconf-0/xfconf/xfconf-channel.h#L39
|
||||
|
||||
typedef struct XFConfData
|
||||
{
|
||||
return ffSettingsGet(instance, dconfKey, gsettingsSchemaName, gsettingsPath, gsettingsKey, FF_VARIANT_TYPE_STRING).strValue;
|
||||
bool init;
|
||||
XfconfChannel*(*ffxfconf_channel_get)(const gchar*);
|
||||
gboolean(*ffxfconf_channel_has_property)(XfconfChannel*, const gchar*);
|
||||
gchar*(*ffxfconf_channel_get_string)(XfconfChannel*, const gchar*, const gchar*);
|
||||
gboolean(*ffxfconf_channel_get_bool)(XfconfChannel*, const gchar*, gboolean);
|
||||
} XFConfData;
|
||||
|
||||
static FFvariant getXFConfValue(XFConfData* data, const char* channelName, const char* propertyName, FFvarianttype type)
|
||||
{
|
||||
if(!data->init)
|
||||
return FF_VARIANT_NULL;
|
||||
|
||||
XfconfChannel* channel = data->ffxfconf_channel_get(channelName); // Never fails according to documentation but rather returns an empty channel
|
||||
|
||||
if(!data->ffxfconf_channel_has_property(channel, propertyName))
|
||||
return FF_VARIANT_NULL;
|
||||
|
||||
if(type == FF_VARIANT_TYPE_STRING)
|
||||
return (FFvariant) {.strValue = data->ffxfconf_channel_get_string(channel, propertyName, NULL)};
|
||||
|
||||
if(type == FF_VARIANT_TYPE_BOOL)
|
||||
return (FFvariant) {.boolValue = data->ffxfconf_channel_get_bool(channel, propertyName, false), .boolValueSet = true};
|
||||
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
|
||||
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static bool init = false;
|
||||
|
||||
static XFConfData data;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getXFConfValue(&data, channelName, propertyName, type);
|
||||
}
|
||||
init = true;
|
||||
|
||||
data.init = false; //error indicator
|
||||
|
||||
DynamicLibrary library = FF_LIBRARY_LOAD(instance->config.libXFConf, "libxfconf-0.so", mutex);
|
||||
|
||||
data.ffxfconf_channel_get = FF_LIBRARY_LOAD_SYMBOL(library, "xfconf_channel_get", mutex);
|
||||
data.ffxfconf_channel_has_property = FF_LIBRARY_LOAD_SYMBOL(library, "xfconf_channel_has_property", mutex);
|
||||
data.ffxfconf_channel_get_string = FF_LIBRARY_LOAD_SYMBOL(library, "xfconf_channel_get_string", mutex);
|
||||
data.ffxfconf_channel_get_bool = FF_LIBRARY_LOAD_SYMBOL(library, "xfconf_channel_get_bool", mutex);
|
||||
|
||||
gboolean(*ffxfconf_init)(GError **) = FF_LIBRARY_LOAD_SYMBOL(library, "xfconf_init", mutex);
|
||||
if((data.init = ffxfconf_init(NULL)) == FALSE)
|
||||
FF_LIBRARY_ERROR_RETURN(library, mutex);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getXFConfValue(&data, channelName, propertyName, type);
|
||||
}
|
||||
|
||||
#undef FF_VARIANT_NULL
|
||||
|
||||
+20
-15
@@ -46,18 +46,19 @@ static inline void printHelp()
|
||||
" --print-available-presets: list presets fastfetch knows about. They can be loaded with --load-config. (+)\n"
|
||||
"\n"
|
||||
"General options:\n"
|
||||
" --structure <structure>: sets the structure of the fetch. Must be a colon seperated list of keys. Use --print-available-modules to show the default\n"
|
||||
" --set <key=value>: hard set the value of an key\n"
|
||||
" -c <color>, --color <color>: sets the color of the keys. Must be a linux console color code (+)\n"
|
||||
" --spacing <width>: sets the distance between logo and text\n"
|
||||
" -s <str>, --seperator <str>: sets the seperator between key and value. Default is a colon with a space\n"
|
||||
" -x <offset>, --offsetx <offset>: sets the x offset. Can be negative to cut the logo, but no more than logo width.\n"
|
||||
" --show-errors <?value>: print occuring errors\n"
|
||||
" -r <?value> --recache <?value>: generate new cached values\n"
|
||||
" --nocache <?value>: dont use cached values, but also dont overwrite existing ones\n"
|
||||
" --print-remaining-logo <?value>: print the remaining logo, if it is higher than the number of lines shown\n"
|
||||
" --multithreading <?value>: use multiple threads to detect values\n"
|
||||
" --load-config <file>: load a config file (+)\n"
|
||||
" --structure <structure>: sets the structure of the fetch. Must be a colon seperated list of keys. Use --print-available-modules to show the default\n"
|
||||
" --set <key=value>: hard set the value of an key\n"
|
||||
" -c <color>, --color <color>: sets the color of the keys. Must be a linux console color code (+)\n"
|
||||
" --spacing <width>: sets the distance between logo and text\n"
|
||||
" -s <str>, --seperator <str>: sets the seperator between key and value. Default is a colon with a space\n"
|
||||
" -x <offset>, --offsetx <offset>: sets the x offset. Can be negative to cut the logo, but no more than logo width.\n"
|
||||
" --show-errors <?value>: print occuring errors\n"
|
||||
" -r <?value> --recache <?value>: generate new cached values\n"
|
||||
" --nocache <?value>: dont use cached values, but also dont overwrite existing ones\n"
|
||||
" --print-remaining-logo <?value>: print the remaining logo, if it is higher than the number of lines shown\n"
|
||||
" --multithreading <?value>: use multiple threads to detect values\n"
|
||||
" --load-config <file>: load a config file (+)\n"
|
||||
" --allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output\n"
|
||||
"\n"
|
||||
"Logo options:\n"
|
||||
" -l <name>, --logo <name>: sets the shown logo. Also changes the main color accordingly\n"
|
||||
@@ -116,6 +117,7 @@ static inline void printHelp()
|
||||
" --lib-gio <path>\n"
|
||||
" --lib-DConf <path>\n"
|
||||
" --lib-wayland <path>\n"
|
||||
" --lib-XFConf <path>\n"
|
||||
"\n"
|
||||
"Module specific options:\n"
|
||||
" --disk-folders <folders>: A colon seperated list of folder paths for the disk output. Default is \"/:/home\"\n"
|
||||
@@ -643,10 +645,9 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char
|
||||
|
||||
static inline bool optionParseBoolean(const char* str)
|
||||
{
|
||||
if(str == NULL)
|
||||
return true;
|
||||
|
||||
return (
|
||||
str == NULL ||
|
||||
*str == '\0' ||
|
||||
strcasecmp(str, "true") == 0 ||
|
||||
strcasecmp(str, "yes") == 0 ||
|
||||
strcasecmp(str, "on") == 0 ||
|
||||
@@ -778,6 +779,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
instance->config.printRemainingLogo = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--multithreading") == 0)
|
||||
data->multithreading = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--allow-slow-operations") == 0)
|
||||
instance->config.allowSlowOperations = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--structure") == 0)
|
||||
optionParseString(key, value, &data->structure);
|
||||
else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0)
|
||||
@@ -882,6 +885,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
optionParseString(key, value, &instance->config.libDConf);
|
||||
else if(strcasecmp(key, "--lib-wayland") == 0)
|
||||
optionParseString(key, value, &instance->config.libWayland);
|
||||
else if(strcasecmp(key, "--lib-XFConf") == 0)
|
||||
optionParseString(key, value, &instance->config.libXFConf);
|
||||
else if(strcasecmp(key, "--disk-folders") == 0)
|
||||
optionParseString(key, value, &instance->config.diskFolders);
|
||||
else if(strcasecmp(key, "--battery-dir") == 0)
|
||||
|
||||
+3
-1
@@ -46,6 +46,7 @@ typedef struct FFconfig
|
||||
bool recache;
|
||||
bool cacheSave;
|
||||
bool printRemainingLogo;
|
||||
bool allowSlowOperations;
|
||||
|
||||
FFstrbuf osFormat;
|
||||
FFstrbuf osKey;
|
||||
@@ -96,6 +97,7 @@ typedef struct FFconfig
|
||||
FFstrbuf libWayland;
|
||||
FFstrbuf libGIO;
|
||||
FFstrbuf libDConf;
|
||||
FFstrbuf libXFConf;
|
||||
|
||||
FFstrbuf diskFolders;
|
||||
|
||||
@@ -274,7 +276,7 @@ void ffGetFontPretty(FFstrbuf* buffer, const FFstrbuf* name, double size);
|
||||
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
|
||||
FFvariant ffSettingsGetGsettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
|
||||
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
|
||||
const char* ffSettingsGetStr(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey);
|
||||
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
|
||||
|
||||
//common/detectPlasma.c
|
||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance);
|
||||
|
||||
+31
-10
@@ -19,20 +19,26 @@ static void printWMTheme(FFinstance* instance, const char* theme)
|
||||
}
|
||||
}
|
||||
|
||||
static void printKWin(FFinstance* instance)
|
||||
static void printWMThemeFromConfigFile(FFinstance* instance, const char* configFile, const char* themeRegex, const char* defaultValue)
|
||||
{
|
||||
char theme[256];
|
||||
bool fileFound = ffParsePropFileConfig(instance, "kwinrc", "theme=%s", theme);
|
||||
|
||||
if(!ffParsePropFileConfig(instance, configFile, themeRegex, theme))
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Config file %s doesn't exist", configFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if(*theme == '\0')
|
||||
{
|
||||
if(!fileFound)
|
||||
if(defaultValue == NULL)
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find \"theme=\" in \".config/kwinrc\"");
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find theme in %s", configFile);
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(theme, "Breeze");
|
||||
printWMTheme(instance, defaultValue);
|
||||
return;
|
||||
}
|
||||
|
||||
printWMTheme(instance, theme);
|
||||
@@ -40,10 +46,10 @@ static void printKWin(FFinstance* instance)
|
||||
|
||||
static void printMutter(FFinstance* instance)
|
||||
{
|
||||
const char* theme = ffSettingsGetStr(instance, "/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", NULL, "name");
|
||||
const char* theme = ffSettingsGet(instance, "/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(theme == NULL)
|
||||
theme = ffSettingsGetStr(instance, "/org/gnome/desktop/wm/preferences/theme", "org.gnome.desktop.wm.preferences", NULL, "theme");
|
||||
theme = ffSettingsGet(instance, "/org/gnome/desktop/wm/preferences/theme", "org.gnome.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(theme == NULL)
|
||||
{
|
||||
@@ -56,8 +62,8 @@ static void printMutter(FFinstance* instance)
|
||||
|
||||
static void printMuffin(FFinstance* instance)
|
||||
{
|
||||
const char* name = ffSettingsGetStr(instance, "/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name");
|
||||
const char* theme = ffSettingsGetStr(instance, "/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme");
|
||||
const char* name = ffSettingsGet(instance, "/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue;
|
||||
const char* theme = ffSettingsGet(instance, "/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(name == NULL && theme == NULL)
|
||||
{
|
||||
@@ -84,6 +90,19 @@ static void printMuffin(FFinstance* instance)
|
||||
}
|
||||
}
|
||||
|
||||
static void printXFWM4(FFinstance* instance)
|
||||
{
|
||||
const char* theme = ffSettingsGetXFConf(instance, "xfwm4", "/general/theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||
|
||||
if(theme == NULL)
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find xfwm4::/general/theme in XFConf");
|
||||
return;
|
||||
}
|
||||
|
||||
printWMTheme(instance, theme);
|
||||
}
|
||||
|
||||
static void printOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName)
|
||||
{
|
||||
FFstrbuf absolutePath;
|
||||
@@ -159,7 +178,9 @@ void ffPrintWMTheme(FFinstance* instance)
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "KWin") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "KDE") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Plasma") == 0)
|
||||
printKWin(instance);
|
||||
printWMThemeFromConfigFile(instance, "kwinrc", " theme=%s", "Breeze");
|
||||
else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Xfwm4") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Xfwm") == 0)
|
||||
printXFWM4(instance);
|
||||
else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Mutter") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Ubuntu") == 0)
|
||||
printMutter(instance);
|
||||
else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Muffin") == 0)
|
||||
|
||||
Reference in New Issue
Block a user