mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Only build display server code on linux
This commit is contained in:
+9
-6
@@ -185,11 +185,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/detection/cpu/cpu.c
|
||||
src/detection/gpu/gpu.c
|
||||
src/detection/memory/memory.c
|
||||
src/detection/displayserver/displayServer.c
|
||||
src/detection/displayserver/wayland.c
|
||||
src/detection/displayserver/xcb.c
|
||||
src/detection/displayserver/xlib.c
|
||||
src/detection/displayserver/wmde.c
|
||||
src/detection/displayserver/displayserver.c
|
||||
src/modules/break.c
|
||||
src/modules/custom.c
|
||||
src/modules/title.c
|
||||
@@ -238,6 +234,7 @@ if(APPLE)
|
||||
src/detection/cpu/cpu_apple.c
|
||||
src/detection/gpu/gpu_apple.c
|
||||
src/detection/memory/memory_apple.c
|
||||
src/detection/displayserver/displayserver_apple.c
|
||||
)
|
||||
elseif(ANDROID)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
@@ -246,6 +243,7 @@ elseif(ANDROID)
|
||||
src/detection/cpu/cpu_linux.c
|
||||
src/detection/gpu/gpu_android.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/displayserver/displayserver_android.c
|
||||
)
|
||||
else()
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
@@ -254,6 +252,11 @@ else()
|
||||
src/detection/cpu/cpu_linux.c
|
||||
src/detection/gpu/gpu_linux.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/wayland.c
|
||||
src/detection/displayserver/linux/xcb.c
|
||||
src/detection/displayserver/linux/xlib.c
|
||||
src/detection/displayserver/linux/wmde.c
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -289,7 +292,7 @@ ff_check_lib(VULKAN vulkan)
|
||||
ff_check_lib(WAYLAND wayland-client)
|
||||
ff_check_lib(XCB_RANDR xcb-randr)
|
||||
ff_check_lib(XCB xcb)
|
||||
ff_check_lib(XRAND xrandr)
|
||||
ff_check_lib(XRANDR xrandr)
|
||||
ff_check_lib(X11 x11)
|
||||
ff_check_lib(GIO gio-2.0)
|
||||
ff_check_lib(DCONF dconf)
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "detection/qt.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@@ -295,7 +295,7 @@ void startDetectionThreads(FFinstance* instance)
|
||||
//Android needs none of the things that are detected here
|
||||
//And using gsettings sometimes hangs the program in android for some unknown reason,
|
||||
//and since we don't need it we just never call it.
|
||||
#ifdef __ANDROID__
|
||||
#if defined(__ANDROID__) || defined(__APPLE__)
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "displayserver.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance);
|
||||
|
||||
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance)
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFDisplayServerResult,
|
||||
ffConnectDisplayServerImpl(&result, instance);
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "displayserver.h"
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
ffStrbufInitA(&ds->wmProcessName, 0);
|
||||
ffStrbufInitA(&ds->wmPrettyName, 0);
|
||||
ffStrbufInitA(&ds->wmProtocolName, 0);
|
||||
ffStrbufInitA(&ds->deProcessName, 0);
|
||||
ffStrbufInitA(&ds->dePrettyName, 0);
|
||||
ffStrbufInitA(&ds->deVersion, 0);
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "displayserver.h"
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
ffStrbufInitA(&ds->wmProcessName, 0);
|
||||
ffStrbufInitA(&ds->wmPrettyName, 0);
|
||||
ffStrbufInitA(&ds->wmProtocolName, 0);
|
||||
ffStrbufInitA(&ds->deProcessName, 0);
|
||||
ffStrbufInitA(&ds->dePrettyName, 0);
|
||||
ffStrbufInitA(&ds->deVersion, 0);
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 0);
|
||||
}
|
||||
+21
-37
@@ -1,6 +1,5 @@
|
||||
#include "displayServer.h"
|
||||
#include "displayserver_linux.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <dirent.h>
|
||||
|
||||
uint32_t ffdsParseRefreshRate(int32_t refreshRate)
|
||||
@@ -78,56 +77,41 @@ static void parseDRM(FFDisplayServerResult* result)
|
||||
ffStrbufDestroy(&drmDir);
|
||||
}
|
||||
|
||||
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance)
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
|
||||
{
|
||||
static FFDisplayServerResult result;
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static bool init = false;
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
}
|
||||
init = true;
|
||||
|
||||
ffStrbufInit(&result.wmProcessName);
|
||||
ffStrbufInit(&result.wmPrettyName);
|
||||
ffStrbufInit(&result.wmProtocolName);
|
||||
ffStrbufInit(&result.deProcessName);
|
||||
ffStrbufInit(&result.dePrettyName);
|
||||
ffStrbufInit(&result.deVersion);
|
||||
ffListInitA(&result.resolutions, sizeof(FFResolutionResult), 4);
|
||||
ffStrbufInit(&ds->wmProcessName);
|
||||
ffStrbufInit(&ds->wmPrettyName);
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffStrbufInit(&ds->deVersion);
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 4);
|
||||
|
||||
//We try wayland as our prefered display server, as it supports the most features.
|
||||
//This method can't detect the name of our WM / DE
|
||||
ffdsConnectWayland(instance, &result);
|
||||
ffdsConnectWayland(instance, ds);
|
||||
|
||||
//Try the x11 libs, from most feature rich to least.
|
||||
//We use the resolution list to detect if a connection is needed.
|
||||
//They respect wmProtocolName, and only detect resolution if it is set.
|
||||
|
||||
if(result.resolutions.length == 0)
|
||||
ffdsConnectXcbRandr(instance, &result);
|
||||
if(ds->resolutions.length == 0)
|
||||
ffdsConnectXcbRandr(instance, ds);
|
||||
|
||||
if(result.resolutions.length == 0)
|
||||
ffdsConnectXrandr(instance, &result);
|
||||
if(ds->resolutions.length == 0)
|
||||
ffdsConnectXrandr(instance, ds);
|
||||
|
||||
if(result.resolutions.length == 0)
|
||||
ffdsConnectXcb(instance, &result);
|
||||
if(ds->resolutions.length == 0)
|
||||
ffdsConnectXcb(instance, ds);
|
||||
|
||||
if(result.resolutions.length == 0)
|
||||
ffdsConnectXlib(instance, &result);
|
||||
if(ds->resolutions.length == 0)
|
||||
ffdsConnectXlib(instance, ds);
|
||||
|
||||
//This resolution detection method is display server independent.
|
||||
//Use it if all connections failed
|
||||
if(result.resolutions.length == 0)
|
||||
parseDRM(&result);
|
||||
if(ds->resolutions.length == 0)
|
||||
parseDRM(ds);
|
||||
|
||||
//This fills in missing information about WM / DE by using env vars and iterating processes
|
||||
ffdsDetectWMDE(instance, &result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
ffdsDetectWMDE(instance, ds);
|
||||
}
|
||||
+1
-2
@@ -3,8 +3,7 @@
|
||||
#ifndef FASTFETCH_INCLUDED_DISPLAYSERVER
|
||||
#define FASTFETCH_INCLUDED_DISPLAYSERVER
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_DISPLAYSERVER_PROTOCOL_WAYLAND "Wayland"
|
||||
#define FF_DISPLAYSERVER_PROTOCOL_X11 "X11"
|
||||
@@ -1,6 +1,6 @@
|
||||
#define _GNU_SOURCE //required for struct ucred
|
||||
|
||||
#include "displayServer.h"
|
||||
#include "displayserver_linux.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "displayServer.h"
|
||||
#include "displayserver_linux.h"
|
||||
#include "common/io.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/parsing.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "displayServer.h"
|
||||
#include "displayserver_linux.h"
|
||||
|
||||
#ifdef FF_HAVE_XCB
|
||||
#include "common/library.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "displayServer.h"
|
||||
#include "displayserver_linux.h"
|
||||
|
||||
#ifdef FF_HAVE_X11
|
||||
#include "common/library.h"
|
||||
@@ -8,7 +8,7 @@ void ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
void* iokit = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_LAZY);
|
||||
void* iokit = dlopen(FASTFETCH_TARGET_DIR_ROOT"/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_LAZY);
|
||||
if(iokit == NULL)
|
||||
return;
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "detection/gtk.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/settings.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/qt.h"
|
||||
#include "common/properties.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "common/settings.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_DE_MODULE_NAME "DE"
|
||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "detection/qt.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_FONT_MODULE_NAME "Font"
|
||||
#define FF_FONT_NUM_FORMAT_ARGS 21
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "detection/qt.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_ICONS_MODULE_NAME "Icons"
|
||||
#define FF_ICONS_NUM_FORMAT_ARGS 5
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/font.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/processing.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "detection/terminalshell.h"
|
||||
|
||||
#define FF_TERMFONT_MODULE_NAME "Terminal Font"
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "detection/qt.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_THEME_MODULE_NAME "Theme"
|
||||
#define FF_THEME_NUM_FORMAT_ARGS 7
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#define FF_WM_MODULE_NAME "WM"
|
||||
#define FF_WM_NUM_FORMAT_ARGS 3
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "common/settings.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "detection/displayserver.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Reference in New Issue
Block a user