mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Make it possible to build without optional dependencies
This commit is contained in:
+27
-3
@@ -2,8 +2,12 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <dconf.h> // Also included gio/gio.h
|
||||
#include <sqlite3.h>
|
||||
#if FF_HAS_DCONF
|
||||
# include <dconf.h> // Also included gio/gio.h
|
||||
#endif
|
||||
#if FF_HAS_SQLITE3
|
||||
# include <sqlite3.h>
|
||||
#endif
|
||||
|
||||
typedef void* DynamicLibrary;
|
||||
|
||||
@@ -25,6 +29,7 @@ typedef void* DynamicLibrary;
|
||||
if(dlerror() != NULL) \
|
||||
FF_LIBRARY_ERROR_RETURN(library, mutex, returnValue)
|
||||
|
||||
#if FF_HAS_DCONF
|
||||
typedef struct GVariantGetters
|
||||
{
|
||||
const gchar*(*ffg_variant_get_string)(GVariant*, gsize*);
|
||||
@@ -261,9 +266,23 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getXFConfValue(&data, channelName, propertyName, type);
|
||||
}
|
||||
|
||||
#else
|
||||
FFvariant ffSettingsGet(FFinstance*, const char*, const char*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetDConf(FFinstance*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetXFConf(FFinstance*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
FFvariant ffSettingsGetGSettings(FFinstance*, const char*, const char*, const char*, FFvarianttype) {
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
#endif // FF_HAS_DCONF
|
||||
#undef FF_VARIANT_NULL
|
||||
|
||||
#if FF_HAS_SQLITE3
|
||||
typedef struct SQLiteData
|
||||
{
|
||||
int(*ffsqlite3_open_v2)(const char* filename, sqlite3** ppDb, int flags, const char* zVfs);
|
||||
@@ -355,3 +374,8 @@ uint32_t ffSettingsGetSQLiteColumnCount(FFinstance* instance, const char* fileNa
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return getSQLiteColumnCount(&data, fileName, tableName);
|
||||
}
|
||||
#else
|
||||
uint32_t ffSettingsGetSQLiteColumnCount(FFinstance*, const char*, const char*) {
|
||||
return 0;
|
||||
}
|
||||
#endif // FF_HAS_SQLITE3
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#if FF_HAS_X11
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
#if FF_HAS_WAYLAND
|
||||
# include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||
@@ -61,6 +69,7 @@ static bool printResolutionResultList(FFinstance* instance, FFlist* results)
|
||||
return res;
|
||||
}
|
||||
|
||||
#if FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
static int parseRefreshRate(int32_t refreshRate)
|
||||
{
|
||||
if(refreshRate <= 0)
|
||||
@@ -78,6 +87,7 @@ static int parseRefreshRate(int32_t refreshRate)
|
||||
|
||||
return refreshRate;
|
||||
}
|
||||
#endif // FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
|
||||
static void printResolutionDRMBackend(FFinstance* instance)
|
||||
{
|
||||
@@ -139,6 +149,7 @@ static void printResolutionDRMBackend(FFinstance* instance)
|
||||
printResolutionResultList(instance, &modes);
|
||||
}
|
||||
|
||||
#if FF_HAS_X11
|
||||
static void x11AddScreenAsResult(FFlist* results, Screen* screen, int refreshRate)
|
||||
{
|
||||
if(WidthOfScreen(screen) == 0 || HeightOfScreen(screen) == 0)
|
||||
@@ -175,7 +186,9 @@ static bool printResolutionX11Backend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &results);
|
||||
}
|
||||
#endif // FF_HAS_XLIB
|
||||
|
||||
#if FF_HAS_XRANDR
|
||||
typedef struct XrandrData
|
||||
{
|
||||
XRRScreenConfiguration*(*ffXRRGetScreenInfo)(Display* display, Window window);
|
||||
@@ -357,7 +370,9 @@ static bool printResolutionXrandrBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_XRANDR
|
||||
|
||||
#if FF_HAS_WAYLAND
|
||||
typedef struct WaylandData
|
||||
{
|
||||
FFinstance* instance;
|
||||
@@ -502,13 +517,21 @@ static bool printResolutionWaylandBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_WAYLAND
|
||||
|
||||
void ffPrintResolution(FFinstance* instance)
|
||||
{
|
||||
if(
|
||||
#if FF_HAS_WAYLAND
|
||||
printResolutionWaylandBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
printResolutionXrandrBackend(instance) ||
|
||||
printResolutionX11Backend(instance)
|
||||
#endif
|
||||
#if FF_HAS_X11
|
||||
printResolutionX11Backend(instance) ||
|
||||
#endif
|
||||
false
|
||||
) return;
|
||||
|
||||
printResolutionDRMBackend(instance);
|
||||
|
||||
Reference in New Issue
Block a user