From 8b285af2764beeda32cb562a36d17fb2d1d7c56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 Jun 2023 22:38:55 +0800 Subject: [PATCH 001/493] CMake: build with debug info --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94f68f62e..a5ae85629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by gith #################### if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") From de2a3466016499179c3c96619395313e6fbc1ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 25 Mar 2023 14:46:47 +0800 Subject: [PATCH 002/493] Revert "Deps: revert changes of JSON parse library" This reverts commit ccb0f853db6974212776f4654893b240d95b71ac. --- .github/workflows/push.yml | 12 +- CHANGELOG.md | 3 + CMakeLists.txt | 8 +- README.md | 6 +- src/common/init.c | 8 +- src/data/config_user.txt | 2 +- src/data/help.txt | 2 +- src/detection/terminalfont/terminalfont.c | 142 ++++++++++++---------- src/fastfetch.c | 4 +- src/fastfetch.h | 2 +- 10 files changed, 101 insertions(+), 88 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 26b197503..cb4355dc6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libcjson-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev - name: configure project env: @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libcjson-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev - name: Initialize CodeQL uses: github/codeql-action/init@v2 @@ -183,7 +183,7 @@ jobs: with: msystem: CLANG64 update: true - install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-cjson + install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-json-c - name: print msys version run: uname -a @@ -203,7 +203,7 @@ jobs: uses: github/codeql-action/analyze@v2 - name: copy necessary dlls - run: cp /clang64/bin/{libcjson,OpenCL,vulkan-1}.dll . + run: cp /clang64/bin/{libjson-c*,OpenCL,vulkan-1}.dll . - name: list features run: ./fastfetch --list-features @@ -244,7 +244,7 @@ jobs: with: msystem: CLANG32 update: true - install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd mingw-w64-clang-i686-cjson + install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd mingw-w64-clang-i686-json-c - name: print msys version run: uname -a @@ -264,7 +264,7 @@ jobs: uses: github/codeql-action/analyze@v2 - name: copy necessary dlls - run: cp /clang32/bin/{libcjson,OpenCL,vulkan-1}.dll . + run: cp /clang32/bin/{libjson-c*,OpenCL,vulkan-1}.dll . - name: run fastfetch run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b99eba1f..fb38752aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,9 @@ Bugfixes: * Don't exit if libpci is failed to init (GPU, Linux, #433) * Names of most well-known gamepads are correctly printed instead of `Wireless Controller` on Windows +Changes: +* Use json-c to parse JSON strings for comments support, instead of using unmaintained cJSON + Logo: * Small update for nobara logo (#435, @regulargvy13) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5ae85629..df1a1da32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,7 @@ cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) -cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN32" OFF) +cmake_dependent_option(ENABLE_JSONC "Enable json-c" ON "LINUX OR WIN32" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) @@ -700,9 +700,9 @@ ff_lib_enable(PULSE "libpulse" "Pulse" ) -ff_lib_enable(LIBCJSON - "libcjson" - "CJson" +ff_lib_enable(JSONC + "json-c" + "json-c" ) if(ENABLE_THREADS) diff --git a/README.md b/README.md index ef9536c06..a5a153ee8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ The following libraries are used if present at runtime: * [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font. * [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count. * [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE. -* [`libcJSON`](https://github.com/DaveGamble/cJSON): Needed for Windows Terminal font ( WSL ). +* [`json-c`](https://github.com/json-c/json-c): Needed for Windows Terminal font ( WSL ). * [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection. * [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection. @@ -71,7 +71,7 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal ### Windows * [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection. -* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection. [`cjson`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-cjson) +* [`json-c`](https://github.com/json-c/json-c): Used for Windows Terminal font detection. [`json-c`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-json-c) * [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers) * [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd) @@ -138,7 +138,7 @@ Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 s 1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime) 1. Install dependencies ```bash -pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd +pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-json-c mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd ``` Follow the building instructions of Linux next. diff --git a/src/common/init.c b/src/common/init.c index 372b2dd8f..5f6ee43db 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -137,7 +137,7 @@ static void defaultConfig(FFinstance* instance) ffStrbufInitA(&instance->config.libGLX, 0); ffStrbufInitA(&instance->config.libOSMesa, 0); ffStrbufInitA(&instance->config.libOpenCL, 0); - ffStrbufInitA(&instance->config.libcJSON, 0); + ffStrbufInitA(&instance->config.libJSONC, 0); ffStrbufInitA(&instance->config.libfreetype, 0); ffStrbufInit(&instance->config.libPulse); ffStrbufInit(&instance->config.libwlanapi); @@ -400,7 +400,7 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libGLX); ffStrbufDestroy(&instance->config.libOSMesa); ffStrbufDestroy(&instance->config.libOpenCL); - ffStrbufDestroy(&instance->config.libcJSON); + ffStrbufDestroy(&instance->config.libJSONC); ffStrbufDestroy(&instance->config.libfreetype); ffStrbufDestroy(&instance->config.libPulse); ffStrbufDestroy(&instance->config.libwlanapi); @@ -505,8 +505,8 @@ void ffListFeatures() #ifdef FF_HAVE_OPENCL "opencl\n" #endif - #ifdef FF_HAVE_LIBCJSON - "libcjson\n" + #ifdef FF_HAVE_LIBJSONC + "json-c\n" #endif #ifdef FF_HAVE_FREETYPE "freetype\n" diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 0ade6d30b..a0b91d92f 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -456,6 +456,6 @@ #--lib-glx /usr/lib/libGLX.so #--lib-osmesa /usr/lib/libOSMesa.so #--lib-opencl /usr/lib/libOpenCL.so -#--lib-cjson /usr/lib/libcjson.so +#--lib-jsonc /usr/lib/libjson-c.so #--lib-freetype /data/data/com.termux/files/usr/lib #--lib-pulse /usr/lib/libpulse.so diff --git a/src/data/help.txt b/src/data/help.txt index 83428e0da..30fedcdfd 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -97,7 +97,7 @@ Library options: Set the path of a library to load --lib-glx --lib-osmesa --lib-opencl - --lib-cjson + --lib-jsonc --lib-pulse --lib-freetype diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 1c2a4be9b..d9693f637 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -67,110 +67,115 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) #if defined(_WIN32) || defined(__linux__) -#ifdef FF_HAVE_LIBCJSON +#ifdef FF_HAVE_JSONC #include "common/library.h" #include "common/processing.h" -#include #include +#include -typedef struct CJSONData +typedef struct JSONCData { - FF_LIBRARY_SYMBOL(cJSON_Parse) - FF_LIBRARY_SYMBOL(cJSON_IsObject) - FF_LIBRARY_SYMBOL(cJSON_GetObjectItemCaseSensitive) - FF_LIBRARY_SYMBOL(cJSON_IsString) - FF_LIBRARY_SYMBOL(cJSON_GetStringValue) - FF_LIBRARY_SYMBOL(cJSON_IsNumber) - FF_LIBRARY_SYMBOL(cJSON_GetNumberValue) - FF_LIBRARY_SYMBOL(cJSON_IsArray) - FF_LIBRARY_SYMBOL(cJSON_Delete) + FF_LIBRARY_SYMBOL(json_tokener_parse) + FF_LIBRARY_SYMBOL(json_object_get_array) + FF_LIBRARY_SYMBOL(json_object_is_type) + FF_LIBRARY_SYMBOL(json_object_get_double) + FF_LIBRARY_SYMBOL(json_object_get_string_len) + FF_LIBRARY_SYMBOL(json_object_get_string) + FF_LIBRARY_SYMBOL(json_object_object_get) + FF_LIBRARY_SYMBOL(json_object_put) - cJSON* root; -} CJSONData; + json_object* root; +} JSONCData; -static const char* detectWTProfile(CJSONData* cjsonData, cJSON* profile, FFstrbuf* name, double* size) +static const char* detectWTProfile(JSONCData* data, json_object* profile, FFstrbuf* name, double* size) { - if(!cjsonData->ffcJSON_IsObject(profile)) - return "cJSON_IsObject(profile) returns false"; + json_object* font = data->ffjson_object_object_get(profile, "font"); + if (!font) + return "json_object_object_get(profile, \"font\"); failed"; - cJSON* font = cjsonData->ffcJSON_GetObjectItemCaseSensitive(profile, "font"); - if(!cjsonData->ffcJSON_IsObject(font)) - return "cJSON_IsObject(font) returns false"; + if (!data->ffjson_object_is_type(font, json_type_object)) + return "json_object_is_type(font, json_type_object) returns false"; - if(name->length == 0) + if (name->length == 0) { - cJSON* pface = cjsonData->ffcJSON_GetObjectItemCaseSensitive(font, "face"); - if(cjsonData->ffcJSON_IsString(pface)) - ffStrbufAppendS(name, cjsonData->ffcJSON_GetStringValue(pface)); + json_object* pface = data->ffjson_object_object_get(font, "face"); + if(data->ffjson_object_is_type(pface, json_type_string)) + ffStrbufAppendNS(name, (uint32_t) data->ffjson_object_get_string_len(pface), data->ffjson_object_get_string(pface)); } - if(*size < 0) + + if (*size < 0) { - cJSON* psize = cjsonData->ffcJSON_GetObjectItemCaseSensitive(font, "size"); - if(cjsonData->ffcJSON_IsNumber(psize)) - *size = cjsonData->ffcJSON_GetNumberValue(psize); + json_object* psize = data->ffjson_object_object_get(font, "size"); + if (data->ffjson_object_is_type(psize, json_type_int) || data->ffjson_object_is_type(psize, json_type_double)) + *size = data->ffjson_object_get_double(psize); } return NULL; } -static inline void wrapCjsonFree(CJSONData* data) +static inline void wrapJsoncFree(JSONCData* data) { assert(data); if (data->root) - data->ffcJSON_Delete(data->root); + data->ffjson_object_put(data->root); } static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, double* size) { - FF_LIBRARY_LOAD(libcjson, &instance->config.libcJSON, "dlopen libcjson" FF_LIBRARY_EXTENSION " failed", "libcjson"FF_LIBRARY_EXTENSION, 1) - CJSONData __attribute__((__cleanup__(wrapCjsonFree))) cjsonData = {}; // Make sure cjsonData is destroyed before libcjson is dlclosed - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_Parse, cJSON_Parse@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsObject, cJSON_IsObject@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_GetObjectItemCaseSensitive, cJSON_GetObjectItemCaseSensitive@8) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsString, cJSON_IsString@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_GetStringValue, cJSON_GetStringValue@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsNumber, cJSON_IsNumber@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_GetNumberValue, cJSON_GetNumberValue@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsArray, cJSON_IsArray@4) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_Delete, cJSON_Delete@4) + FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", + #ifdef _WIN32 + "libjson-c-5" FF_LIBRARY_EXTENSION, -1 + #else + "libjson-c" FF_LIBRARY_EXTENSION, 5 + #endif + ) + JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) - cJSON* root = cjsonData.root = cjsonData.ffcJSON_Parse(content->chars); - if(!cjsonData.ffcJSON_IsObject(root)) - return "cJSON_Parse() failed"; + data.root = data.ffjson_tokener_parse(content->chars); + if (!data.root) + return "Failed to parse WT JSON config file"; - cJSON* profiles = cjsonData.ffcJSON_GetObjectItemCaseSensitive(root, "profiles"); - if(!cjsonData.ffcJSON_IsObject(profiles)) - return "cJSON_GetObjectItemCaseSensitive(root, \"profiles\") failed"; + json_object* profiles = data.ffjson_object_object_get(data.root, "profiles"); + if (!profiles) + return "json_object_object_get(root, \"profiles\") failed"; FF_STRBUF_AUTO_DESTROY wtProfileId; ffStrbufInitS(&wtProfileId, getenv("WT_PROFILE_ID")); ffStrbufTrim(&wtProfileId, '\''); - if(wtProfileId.length > 0) + if (wtProfileId.length > 0) { - cJSON* list = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profiles, "list"); - if(cjsonData.ffcJSON_IsArray(list)) + array_list* list = data.ffjson_object_get_array(data.ffjson_object_object_get(profiles, "list")); + if (list) { - cJSON* profile; - cJSON_ArrayForEach(profile, list) + for (size_t idx = 0; idx < list->length; ++idx) { - if(!cjsonData.ffcJSON_IsObject(profile)) + json_object* profile = (json_object*) list->array[idx]; + json_object* guid = data.ffjson_object_object_get(profile, "guid"); + + if (!data.ffjson_object_is_type(guid, json_type_string)) continue; - cJSON* guid = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profile, "guid"); - if(!cjsonData.ffcJSON_IsString(guid)) - continue; - if(ffStrbufCompS(&wtProfileId, cjsonData.ffcJSON_GetStringValue(guid)) == 0) + + if(ffStrbufEqualS(&wtProfileId, data.ffjson_object_get_string(guid))) { - detectWTProfile(&cjsonData, profile, name, size); + detectWTProfile(&data, profile, name, size); break; } } } } - cJSON* defaults = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profiles, "defaults"); - if(defaults) - detectWTProfile(&cjsonData, defaults, name, size); + json_object* defaults = data.ffjson_object_object_get(profiles, "defaults"); + if (defaults) + detectWTProfile(&data, defaults, name, size); if(name->length == 0) ffStrbufSetS(name, "Cascadia Mono"); @@ -188,7 +193,7 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) { //https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file - FF_STRBUF_AUTO_DESTROY json; + FFstrbuf json; ffStrbufInit(&json); const char* error = NULL; @@ -249,19 +254,22 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu if(error) { ffStrbufAppendS(&terminalFont->error, error); + ffStrbufDestroy(&json); return; } ffStrbufTrimRight(&json, '\n'); if(json.length == 0) { ffStrbufAppendS(&terminalFont->error, "Cannot find file \"settings.json\""); + ffStrbufDestroy(&json); return; } - FF_STRBUF_AUTO_DESTROY name; + FFstrbuf name; ffStrbufInit(&name); double size = -1; error = detectFromWTImpl(instance, &json, &name, &size); + ffStrbufDestroy(&json); if(error) ffStrbufAppendS(&terminalFont->error, error); @@ -271,17 +279,19 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu snprintf(sizeStr, sizeof(sizeStr), "%g", size); ffFontInitValues(&terminalFont->font, name.chars, sizeStr); } + + ffStrbufDestroy(&name); } -#else //FF_HAVE_CJSON +#else //FF_HAVE_JSONC static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) { FF_UNUSED(instance, terminalExe, terminalFont); - ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without libcJSON support"); + ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without json-c support"); } -#endif //FF_HAVE_CJSON +#endif //FF_HAVE_JSONC #endif //defined(_WIN32) || defined(__linux__) diff --git a/src/fastfetch.c b/src/fastfetch.c index 63480f514..fd60176b8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1226,8 +1226,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseString(key, value, &instance->config.libOSMesa); else if(strcasecmp(subkey, "-opencl") == 0) optionParseString(key, value, &instance->config.libOpenCL); - else if(strcasecmp(subkey, "-cjson") == 0) - optionParseString(key, value, &instance->config.libcJSON); + else if(strcasecmp(subkey, "-jsonc") == 0) + optionParseString(key, value, &instance->config.libJSONC); else if(strcasecmp(subkey, "-wlanapi") == 0) optionParseString(key, value, &instance->config.libwlanapi); else if(strcasecmp(key, "-pulse") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 8c1114cef..407c34f20 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -206,7 +206,7 @@ typedef struct FFconfig FFstrbuf libGLX; FFstrbuf libOSMesa; FFstrbuf libOpenCL; - FFstrbuf libcJSON; + FFstrbuf libJSONC; FFstrbuf libfreetype; FFstrbuf libPulse; FFstrbuf libwlanapi; From 6cb073e6a5e824c1723e703918e4152293c8db12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 7 Mar 2023 14:56:13 +0800 Subject: [PATCH 003/493] OS: major code refactoring Split `fastfetch.h` to make it possible to print OS module with different options --- CMakeLists.txt | 3 +- src/common/init.c | 9 ++- src/common/option.c | 120 ++++++++++++++++++++++++++++++++++++ src/common/option.h | 18 ++++++ src/detection/os/os_linux.c | 4 +- src/fastfetch.c | 8 +-- src/fastfetch.h | 14 +---- src/flashfetch.c | 4 +- src/modules/os/option.h | 15 +++++ src/modules/{ => os}/os.c | 48 +++++++++++++-- src/modules/os/os.h | 9 +++ 11 files changed, 223 insertions(+), 29 deletions(-) create mode 100644 src/common/option.c create mode 100644 src/common/option.h create mode 100644 src/modules/os/option.h rename src/modules/{ => os}/os.c (74%) create mode 100644 src/modules/os/os.h diff --git a/CMakeLists.txt b/CMakeLists.txt index df1a1da32..2ffb5de72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,7 @@ set(LIBFASTFETCH_SRC src/common/format.c src/common/init.c src/common/library.c + src/common/option.c src/common/parsing.c src/common/printing.c src/common/properties.c @@ -286,7 +287,7 @@ set(LIBFASTFETCH_SRC src/modules/memory.c src/modules/opencl.c src/modules/opengl.c - src/modules/os.c + src/modules/os/os.c src/modules/packages.c src/modules/player.c src/modules/poweradapter.c diff --git a/src/common/init.c b/src/common/init.c index 5f6ee43db..fd67ee70c 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -15,6 +15,8 @@ #include #endif +#include "modules/os/os.h" + static void initState(FFstate* state) { state->logoWidth = 0; @@ -69,7 +71,7 @@ static void defaultConfig(FFinstance* instance) instance->config.multithreading = true; instance->config.stat = false; - initModuleArg(&instance->config.os); + ffInitOSOptions(&instance->config.os); initModuleArg(&instance->config.host); initModuleArg(&instance->config.bios); initModuleArg(&instance->config.board); @@ -180,8 +182,6 @@ static void defaultConfig(FFinstance* instance) instance->config.weatherTimeout = 0; ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)"); - ffStrbufInitA(&instance->config.osFile, 0); - ffStrbufInitA(&instance->config.playerName, 0); instance->config.percentType = 1; @@ -333,7 +333,7 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.colorTitle); ffStrbufDestroy(&instance->config.separator); - destroyModuleArg(&instance->config.os); + ffDestroyOSOptions(&instance->config.os); destroyModuleArg(&instance->config.host); destroyModuleArg(&instance->config.bios); destroyModuleArg(&instance->config.board); @@ -412,7 +412,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.localIpNamePrefix); ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); - ffStrbufDestroy(&instance->config.osFile); ffStrbufDestroy(&instance->config.playerName); ffStrbufDestroy(&instance->config.commandShell); diff --git a/src/common/option.c b/src/common/option.c new file mode 100644 index 000000000..08c990632 --- /dev/null +++ b/src/common/option.c @@ -0,0 +1,120 @@ +#include "common/option.h" +#include "util/stringUtils.h" + +// Return start position of the inner key if the argument key belongs to the module specified, NULL otherwise +const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) +{ + const char* subKey = argumentKey; + if(!(subKey[0] == '-' && subKey[1] == '-')) + return NULL; + + subKey += 2; + uint32_t moduleNameLen = (uint32_t)strlen(moduleName); + if(strncasecmp(subKey, moduleName, moduleNameLen) != 0) + return NULL; + + subKey += moduleNameLen; + if(subKey[0] != '-') + return NULL; + + subKey += 1; + + return subKey; +} + +bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const char* value, FFModuleArgs* result) +{ + if(strcasecmp(subKey, "key") == 0) + { + ffOptionParseString(argumentKey, value, &result->key); + return true; + } + else if(strcasecmp(subKey, "format") == 0) + { + ffOptionParseString(argumentKey, value, &result->outputFormat); + return true; + } + else if(strcasecmp(subKey, "error") == 0) + { + ffOptionParseString(argumentKey, value, &result->errorFormat); + return true; + } + return false; +} + +void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer) +{ + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(477); + } + + ffStrbufSetS(buffer, value); +} + +uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value) +{ + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(480); + } + + char* end; + uint32_t num = (uint32_t) strtoul(value, &end, 10); + if(*end != '\0') + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(479); + } + + return num; +} + +void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...) +{ + if(requestedKey == NULL) + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(476); + } + + va_list args; + va_start(args, result); + + while(true) + { + const char* key = va_arg(args, const char*); + if(key == NULL) + break; + + int value = va_arg(args, int); //C standard guarantees that enumeration constants are presented as ints + + if(strcasecmp(requestedKey, key) == 0) + { + *(int*)result = value; + va_end(args); + return; + } + } + + va_end(args); + + fprintf(stderr, "Error: unknown %s value: %s\n", argumentKey, requestedKey); + exit(478); +} + +void ffOptionInitModuleArg(FFModuleArgs* args) +{ + ffStrbufInit(&args->key); + ffStrbufInit(&args->outputFormat); + ffStrbufInit(&args->errorFormat); +} + +void ffOptionDestroyModuleArg(FFModuleArgs* args) +{ + ffStrbufDestroy(&args->key); + ffStrbufDestroy(&args->outputFormat); + ffStrbufDestroy(&args->errorFormat); +} diff --git a/src/common/option.h b/src/common/option.h new file mode 100644 index 000000000..339a44009 --- /dev/null +++ b/src/common/option.h @@ -0,0 +1,18 @@ +#pragma once + +#include "util/FFstrbuf.h" + +typedef struct FFModuleArgs +{ + FFstrbuf key; + FFstrbuf outputFormat; + FFstrbuf errorFormat; +} FFModuleArgs; + +const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName); +bool ffOptionParseModuleArgs(const char* argumentKey, const char* pkey, const char* value, FFModuleArgs* result); +void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); +uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); +void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...); +void ffOptionInitModuleArg(FFModuleArgs* args); +void ffOptionDestroyModuleArg(FFModuleArgs* args); diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 063e8455b..a9db735db 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -96,9 +96,9 @@ static void getUbuntuFlavour(FFOSResult* result) static void detectOS(FFOSResult* os, const FFinstance* instance) { - if(instance->config.osFile.length > 0) + if(instance->config.os.file.length > 0) { - parseFile(instance->config.osFile.chars, os); + parseFile(instance->config.os.file.chars, os); return; } diff --git a/src/fastfetch.c b/src/fastfetch.c index fd60176b8..e6da44aad 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -17,6 +17,8 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" +#include "modules/os/os.h" + typedef struct CustomValue { bool printKey; @@ -1129,7 +1131,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module args options// /////////////////////// - else if(optionParseModuleArgs(key, value, "os", &instance->config.os)) {} + else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(optionParseModuleArgs(key, value, "host", &instance->config.host)) {} else if(optionParseModuleArgs(key, value, "bios", &instance->config.bios)) {} else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} @@ -1311,8 +1313,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_COMPACT_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_COMPACT_BIT); else if(strcasecmp(key, "--localip-name-prefix") == 0) optionParseString(key, value, &instance->config.localIpNamePrefix); - else if(strcasecmp(key, "--os-file") == 0) - optionParseString(key, value, &instance->config.osFile); else if(strcasecmp(key, "--player-name") == 0) optionParseString(key, value, &instance->config.playerName); else if(strcasecmp(key, "--publicip-url") == 0) @@ -1415,7 +1415,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "separator") == 0) ffPrintSeparator(instance); else if(strcasecmp(line, "os") == 0) - ffPrintOS(instance); + ffPrintOS(instance, &instance->config.os); else if(strcasecmp(line, "host") == 0) ffPrintHost(instance); else if(strcasecmp(line, "bios") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 407c34f20..3125cc0b4 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -18,6 +18,8 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) +#include "modules/os/option.h" + typedef enum FFLogoType { FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo @@ -80,13 +82,6 @@ typedef enum FFGLType FF_GL_TYPE_OSMESA } FFGLType; -typedef struct FFModuleArgs -{ - FFstrbuf key; - FFstrbuf outputFormat; - FFstrbuf errorFormat; -} FFModuleArgs; - typedef enum FFLocalIpType { FF_LOCALIP_TYPE_NONE, @@ -138,7 +133,7 @@ typedef struct FFconfig bool multithreading; bool stat; - FFModuleArgs os; + FFOSOptions os; FFModuleArgs host; FFModuleArgs bios; FFModuleArgs board; @@ -249,8 +244,6 @@ typedef struct FFconfig FFSoundType soundType; - FFstrbuf osFile; - FFstrbuf playerName; uint32_t percentType; @@ -316,7 +309,6 @@ void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); void ffPrintTitle(FFinstance* instance); void ffPrintSeparator(FFinstance* instance); -void ffPrintOS(FFinstance* instance); void ffPrintHost(FFinstance* instance); void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 8737c8fcf..447cdd269 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -1,5 +1,7 @@ #include "fastfetch.h" +#include "modules/os/os.h" + int main(int argc, char** argv) { //Disable compiler warnings @@ -20,7 +22,7 @@ int main(int argc, char** argv) //Printing ffPrintTitle(&instance); ffPrintSeparator(&instance); - ffPrintOS(&instance); + ffPrintOS(&instance, &instance.config.os); ffPrintHost(&instance); //ffPrintBios(&instance); //ffPrintBoard(&instance); diff --git a/src/modules/os/option.h b/src/modules/os/option.h new file mode 100644 index 000000000..7d6b4d082 --- /dev/null +++ b/src/modules/os/option.h @@ -0,0 +1,15 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFOSOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + #if defined(__linux__) || defined(__FreeBSD__) + FFstrbuf file; + #endif +} FFOSOptions; diff --git a/src/modules/os.c b/src/modules/os/os.c similarity index 74% rename from src/modules/os.c rename to src/modules/os/os.c index 140cfdbbe..f202e6e4e 100644 --- a/src/modules/os.c +++ b/src/modules/os/os.c @@ -1,6 +1,8 @@ #include "fastfetch.h" #include "common/printing.h" +#include "common/option.h" #include "detection/os/os.h" +#include "modules/os/os.h" #include @@ -94,17 +96,17 @@ static void buildOutputNixOS(const FFinstance* instance, const FFOSResult* os, F } } -void ffPrintOS(FFinstance* instance) +void ffPrintOS(FFinstance* instance, FFOSOptions* options) { const FFOSResult* os = ffDetectOS(instance); if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) { - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, "Could not detect OS"); + ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS"); return; } - if(instance->config.os.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { FFstrbuf result; ffStrbufInit(&result); @@ -114,13 +116,13 @@ void ffPrintOS(FFinstance* instance) else buildOutputDefault(instance, os, &result); - ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &instance->config.os.key); + ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key); ffStrbufPutTo(&result, stdout); ffStrbufDestroy(&result); } else { - ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName}, @@ -136,3 +138,39 @@ void ffPrintOS(FFinstance* instance) }); } } + +void ffInitOSOptions(FFOSOptions* options) +{ + options->moduleName = FF_OS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + #if defined(__linux__) || defined(__FreeBSD__) + ffStrbufInit(&options->file); + #endif +} + +bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_OS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + #if defined(__linux__) || defined(__FreeBSD__) + if (strcasecmp(subKey, "file") == 0) + { + ffOptionParseString(key, value, &options->file); + return true; + } + #endif + + return false; +} + +void ffDestroyOSOptions(FFOSOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + #if defined(__linux__) || defined(__FreeBSD__) + ffStrbufDestroy(&options->file); + #endif +} diff --git a/src/modules/os/os.h b/src/modules/os/os.h new file mode 100644 index 000000000..bf6572291 --- /dev/null +++ b/src/modules/os/os.h @@ -0,0 +1,9 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/os/option.h" + +void ffPrintOS(FFinstance* instance, FFOSOptions* options); +void ffInitOSOptions(FFOSOptions* options); +bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value); +void ffDestroyOSOptions(FFOSOptions* options); From 4e3e469ba877248f623b065cf0851ffde41c7be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 7 Mar 2023 16:13:53 +0800 Subject: [PATCH 004/493] Battery: major code refactoring ditto --- CMakeLists.txt | 2 +- src/common/init.c | 10 ++--- src/common/option.c | 11 +++++ src/common/option.h | 1 + src/detection/battery/battery_android.c | 4 +- src/detection/battery/battery_apple.c | 4 +- src/detection/battery/battery_linux.c | 7 +-- src/detection/battery/battery_windows.c | 2 +- src/fastfetch.c | 9 ++-- src/fastfetch.h | 8 +--- src/flashfetch.c | 4 +- src/modules/{ => battery}/battery.c | 60 +++++++++++++++++++++---- src/modules/battery/battery.h | 10 +++++ src/modules/battery/option.h | 17 +++++++ src/modules/modules.h | 6 +++ src/modules/options.h | 6 +++ 16 files changed, 122 insertions(+), 39 deletions(-) rename src/modules/{ => battery}/battery.c (63%) create mode 100644 src/modules/battery/battery.h create mode 100644 src/modules/battery/option.h create mode 100644 src/modules/modules.h create mode 100644 src/modules/options.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ffb5de72..d8cb8ffc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,7 +259,7 @@ set(LIBFASTFETCH_SRC src/logo/image/im7.c src/logo/image/image.c src/logo/logo.c - src/modules/battery.c + src/modules/battery/battery.c src/modules/bios.c src/modules/bluetooth.c src/modules/board.c diff --git a/src/common/init.c b/src/common/init.c index fd67ee70c..54a9e128b 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -15,7 +15,7 @@ #include #endif -#include "modules/os/os.h" +#include "modules/modules.h" static void initState(FFstate* state) { @@ -98,7 +98,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.memory); initModuleArg(&instance->config.swap); initModuleArg(&instance->config.disk); - initModuleArg(&instance->config.battery); + ffInitBatteryOptions(&instance->config.battery); initModuleArg(&instance->config.powerAdapter); initModuleArg(&instance->config.locale); initModuleArg(&instance->config.localIP); @@ -148,7 +148,6 @@ static void defaultConfig(FFinstance* instance) instance->config.cpuTemp = false; instance->config.gpuTemp = false; instance->config.gpuForceVulkan = false; - instance->config.batteryTemp = false; instance->config.gpuHideIntegrated = false; instance->config.gpuHideDiscrete = false; @@ -169,8 +168,6 @@ static void defaultConfig(FFinstance* instance) instance->config.soundType = FF_SOUND_TYPE_MAIN; - ffStrbufInitA(&instance->config.batteryDir, 0); - ffStrbufInitA(&instance->config.separatorString, 0); instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT; @@ -359,7 +356,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.memory); destroyModuleArg(&instance->config.swap); destroyModuleArg(&instance->config.disk); - destroyModuleArg(&instance->config.battery); + ffDestroyBatteryOptions(&instance->config.battery); destroyModuleArg(&instance->config.powerAdapter); destroyModuleArg(&instance->config.locale); destroyModuleArg(&instance->config.localIP); @@ -407,7 +404,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libnm); ffStrbufDestroy(&instance->config.diskFolders); - ffStrbufDestroy(&instance->config.batteryDir); ffStrbufDestroy(&instance->config.separatorString); ffStrbufDestroy(&instance->config.localIpNamePrefix); ffStrbufDestroy(&instance->config.publicIpUrl); diff --git a/src/common/option.c b/src/common/option.c index 08c990632..81e54c532 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -105,6 +105,17 @@ void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* exit(478); } +bool ffOptionParseBoolean(const char* str) +{ + return ( + !ffStrSet(str) || + strcasecmp(str, "true") == 0 || + strcasecmp(str, "yes") == 0 || + strcasecmp(str, "on") == 0 || + strcasecmp(str, "1") == 0 + ); +} + void ffOptionInitModuleArg(FFModuleArgs* args) { ffStrbufInit(&args->key); diff --git a/src/common/option.h b/src/common/option.h index 339a44009..b24c278b8 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -14,5 +14,6 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* pkey, const ch void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...); +bool ffOptionParseBoolean(const char* str); void ffOptionInitModuleArg(FFModuleArgs* args); void ffOptionDestroyModuleArg(FFModuleArgs* args); diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index 1a783e595..1bcb48db7 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -7,7 +7,7 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "BatteryStatus" -const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* results) +const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer; ffStrbufInit(&buffer); @@ -35,7 +35,7 @@ const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* re ffStrbufClear(&battery->status); } - if(instance->config.batteryTemp) + if(instance->config.battery.temp) { if(ffParsePropLines(buffer.chars, "\"temperature\": ", &battery->status)) { diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index 7244a89a1..8a4214180 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -30,8 +30,6 @@ static double detectBatteryTemp() const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { - FF_UNUSED(instance); - CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery"); if (matchDict == NULL) return "IOServiceMatching(\"AppleSmartBattery\") failed"; @@ -93,7 +91,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) else ffStrbufAppendS(&battery->status, ""); - if(instance->config.batteryTemp) + if(instance->config.battery.temp) battery->temperature = detectBatteryTemp(); else battery->temperature = FF_BATTERY_TEMP_UNSET; diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index b78a6cf7f..7ae4a3639 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -74,12 +74,13 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) result->temperature = FF_BATTERY_TEMP_UNSET; } -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { +const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +{ FFstrbuf baseDir; ffStrbufInitA(&baseDir, 64); - if(instance->config.batteryDir.length > 0) + if(instance->config.battery.dir.length > 0) { - ffStrbufAppend(&baseDir, &instance->config.batteryDir); + ffStrbufAppend(&baseDir, &instance->config.battery.dir); ffStrbufEnsureEndsWithC(&baseDir, '/'); } else diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index fc89a335a..9268362fd 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -111,7 +111,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) } battery->temperature = 0.0/0.0; - if(instance->config.batteryTemp) + if(instance->config.battery.temp) { bqi.InformationLevel = BatteryTemperature; ULONG temp; diff --git a/src/fastfetch.c b/src/fastfetch.c index e6da44aad..7050a61df 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -18,6 +18,7 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #include "modules/os/os.h" +#include "modules/modules.h" typedef struct CustomValue { @@ -1160,7 +1161,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {} else if(optionParseModuleArgs(key, value, "disk", &instance->config.disk)) {} - else if(optionParseModuleArgs(key, value, "battery", &instance->config.battery)) {} + else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} else if(optionParseModuleArgs(key, value, "locale", &instance->config.locale)) {} else if(optionParseModuleArgs(key, value, "localip", &instance->config.localIP)) {} @@ -1250,8 +1251,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.gpuTemp = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-force-vulkan") == 0) instance->config.gpuForceVulkan = optionParseBoolean(value); - else if(strcasecmp(key, "--battery-temp") == 0) - instance->config.batteryTemp = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-hide-integrated") == 0) instance->config.gpuHideIntegrated = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-hide-discrete") == 0) @@ -1297,8 +1296,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con NULL ); } - else if(strcasecmp(key, "--battery-dir") == 0) - optionParseString(key, value, &instance->config.batteryDir); else if(strcasecmp(key, "--separator-string") == 0) optionParseString(key, value, &instance->config.separatorString); else if(strcasecmp(key, "--localip-show-ipv4") == 0) @@ -1471,7 +1468,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "disk") == 0) ffPrintDisk(instance); else if(strcasecmp(line, "battery") == 0) - ffPrintBattery(instance); + ffPrintBattery(instance, &instance->config.battery); else if(strcasecmp(line, "poweradapter") == 0) ffPrintPowerAdapter(instance); else if(strcasecmp(line, "locale") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3125cc0b4..a58cea0ae 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -18,7 +18,7 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) -#include "modules/os/option.h" +#include "modules/options.h" typedef enum FFLogoType { @@ -162,7 +162,7 @@ typedef struct FFconfig FFModuleArgs memory; FFModuleArgs swap; FFModuleArgs disk; - FFModuleArgs battery; + FFBatteryOptions battery; FFModuleArgs powerAdapter; FFModuleArgs locale; FFModuleArgs localIP; @@ -210,7 +210,6 @@ typedef struct FFconfig bool cpuTemp; bool gpuTemp; bool gpuForceVulkan; - bool batteryTemp; bool gpuHideIntegrated; bool gpuHideDiscrete; @@ -229,8 +228,6 @@ typedef struct FFconfig bool bluetoothShowDisconnected; - FFstrbuf batteryDir; - FFstrbuf separatorString; FFstrbuf localIpNamePrefix; @@ -336,7 +333,6 @@ void ffPrintGPU(FFinstance* instance); void ffPrintMemory(FFinstance* instance); void ffPrintSwap(FFinstance* instance); void ffPrintDisk(FFinstance* instance); -void ffPrintBattery(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintLocale(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 447cdd269..e6bdba2bd 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -1,6 +1,6 @@ #include "fastfetch.h" -#include "modules/os/os.h" +#include "modules/modules.h" int main(int argc, char** argv) { @@ -48,7 +48,7 @@ int main(int argc, char** argv) ffPrintMemory(&instance); //ffPrintSwap(&instance); ffPrintDisk(&instance); - ffPrintBattery(&instance); + ffPrintBattery(&instance, &instance.config.battery); ffPrintPowerAdapter(&instance); //ffPrintPlayer(&instance); //ffPrintMedia(&instance); diff --git a/src/modules/battery.c b/src/modules/battery/battery.c similarity index 63% rename from src/modules/battery.c rename to src/modules/battery/battery.c index 6bafb0ee7..4ba93c49d 100644 --- a/src/modules/battery.c +++ b/src/modules/battery/battery.c @@ -2,15 +2,16 @@ #include "common/printing.h" #include "common/bar.h" #include "detection/battery/battery.h" +#include "modules/battery/battery.h" #define FF_BATTERY_MODULE_NAME "Battery" #define FF_BATTERY_NUM_FORMAT_ARGS 5 -static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t index) +static void printBattery(FFinstance* instance, FFBatteryOptions* options, BatteryResult* result, uint8_t index) { - if(instance->config.battery.outputFormat.length == 0) + if(instance->config.battery.moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.battery.key); + ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key); bool showStatus = !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && @@ -62,7 +63,7 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in } else { - ffPrintFormat(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.battery, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->technology}, @@ -73,7 +74,7 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in } } -void ffPrintBattery(FFinstance* instance) +void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options) { FFlist results; ffListInitA(&results, sizeof(BatteryResult), 0); @@ -82,14 +83,14 @@ void ffPrintBattery(FFinstance* instance) if (error) { - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.battery, "%s", error); + ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else { for(uint8_t i = 0; i < (uint8_t) results.length; i++) { BatteryResult* result = ffListGet(&results, i); - printBattery(instance, result, i); + printBattery(instance, options, result, i); ffStrbufDestroy(&result->manufacturer); ffStrbufDestroy(&result->modelName); @@ -97,8 +98,51 @@ void ffPrintBattery(FFinstance* instance) ffStrbufDestroy(&result->status); } if(results.length == 0) - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.battery, "No batteries found"); + ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found"); } ffListDestroy(&results); } + +void ffInitBatteryOptions(FFBatteryOptions* options) +{ + options->moduleName = FF_BATTERY_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + options->temp = false; + + #ifdef __linux__ + ffStrbufInit(&options->dir); + #endif +} + +bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_BATTERY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "temp") == 0) + { + options->temp = ffOptionParseBoolean(value); + return true; + } + + #ifdef __linux__ + if (strcasecmp(subKey, "dir") == 0) + { + ffOptionParseString(key, value, &options->dir); + return true; + } + #endif + + return false; +} + +void ffDestroyBatteryOptions(FFBatteryOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + #ifdef __linux__ + ffStrbufDestroy(&options->dir); + #endif +} diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h new file mode 100644 index 000000000..c6eb2951f --- /dev/null +++ b/src/modules/battery/battery.h @@ -0,0 +1,10 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/battery/option.h" + +void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); + +void ffInitBatteryOptions(FFBatteryOptions* options); +bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value); +void ffDestroyBatteryOptions(FFBatteryOptions* options); diff --git a/src/modules/battery/option.h b/src/modules/battery/option.h new file mode 100644 index 000000000..73632b9c6 --- /dev/null +++ b/src/modules/battery/option.h @@ -0,0 +1,17 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFBatteryOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + bool temp; + + #ifdef __linux__ + FFstrbuf dir; + #endif +} FFBatteryOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h new file mode 100644 index 000000000..eb72482af --- /dev/null +++ b/src/modules/modules.h @@ -0,0 +1,6 @@ +#pragma once + +// For "fastfetch.c" and "flashfetch.c" + +#include "modules/os/os.h" +#include "modules/battery/battery.h" diff --git a/src/modules/options.h b/src/modules/options.h new file mode 100644 index 000000000..8d22da1d1 --- /dev/null +++ b/src/modules/options.h @@ -0,0 +1,6 @@ +#pragma once + +// For "fastfetch.h" + +#include "modules/battery/option.h" +#include "modules/os/option.h" From cbaeed7e8ea984fa87cca883a835c0c848eff67e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 7 Mar 2023 19:27:49 +0800 Subject: [PATCH 005/493] Command: major code refactoring ditto; and multi-command support was removed in favor of JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 22 +-------- src/fastfetch.c | 17 +------ src/fastfetch.h | 6 +-- src/modules/command.c | 67 --------------------------- src/modules/command/command.c | 85 +++++++++++++++++++++++++++++++++++ src/modules/command/command.h | 9 ++++ src/modules/command/option.h | 14 ++++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/os/os.c | 3 +- 11 files changed, 117 insertions(+), 110 deletions(-) delete mode 100644 src/modules/command.c create mode 100644 src/modules/command/command.c create mode 100644 src/modules/command/command.h create mode 100644 src/modules/command/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d8cb8ffc1..b6b9dee1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,7 +271,7 @@ set(LIBFASTFETCH_SRC src/modules/cpuUsage.c src/modules/cursor.c src/modules/custom.c - src/modules/command.c + src/modules/command/command.c src/modules/date.c src/modules/datetime.c src/modules/de.c diff --git a/src/common/init.c b/src/common/init.c index 54a9e128b..dbe5899f8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -77,6 +77,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.board); initModuleArg(&instance->config.brightness); initModuleArg(&instance->config.chassis); + ffInitCommandOptions(&instance->config.command); initModuleArg(&instance->config.kernel); initModuleArg(&instance->config.uptime); initModuleArg(&instance->config.processes); @@ -182,18 +183,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInitA(&instance->config.playerName, 0); instance->config.percentType = 1; - - ffStrbufInitS(&instance->config.commandShell, - #ifdef _WIN32 - "cmd" - #elif defined(__FreeBSD__) - "csh" - #else - "bash" - #endif - ); - ffListInit(&instance->config.commandKeys, sizeof(FFstrbuf)); - ffListInit(&instance->config.commandTexts, sizeof(FFstrbuf)); } void ffInitInstance(FFinstance* instance) @@ -335,6 +324,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.bios); destroyModuleArg(&instance->config.board); destroyModuleArg(&instance->config.chassis); + ffDestroyCommandOptions(&instance->config.command); destroyModuleArg(&instance->config.kernel); destroyModuleArg(&instance->config.uptime); destroyModuleArg(&instance->config.processes); @@ -409,14 +399,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); ffStrbufDestroy(&instance->config.playerName); - - ffStrbufDestroy(&instance->config.commandShell); - FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandKeys) - ffStrbufDestroy(item); - ffListDestroy(&instance->config.commandKeys); - FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandTexts) - ffStrbufDestroy(item); - ffListDestroy(&instance->config.commandTexts); } static void destroyState(FFinstance* instance) diff --git a/src/fastfetch.c b/src/fastfetch.c index 7050a61df..a838592ff 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1137,6 +1137,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "bios", &instance->config.bios)) {} else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} + else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} else if(optionParseModuleArgs(key, value, "kernel", &instance->config.kernel)) {} else if(optionParseModuleArgs(key, value, "uptime", &instance->config.uptime)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} @@ -1332,20 +1333,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(strcasecmp(key, "--percent-type") == 0) instance->config.percentType = optionParseUInt32(key, value); - else if(strcasecmp(key, "--command-shell") == 0) - optionParseString(key, value, &instance->config.commandShell); - else if(strcasecmp(key, "--command-key") == 0) - { - FFstrbuf* result = (FFstrbuf*) ffListAdd(&instance->config.commandKeys); - ffStrbufInit(result); - optionParseString(key, value, result); - } - else if(strcasecmp(key, "--command-text") == 0) - { - FFstrbuf* result = (FFstrbuf*) ffListAdd(&instance->config.commandTexts); - ffStrbufInit(result); - optionParseString(key, value, result); - } ////////////////// //Unknown option// @@ -1502,7 +1489,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "users") == 0) ffPrintUsers(instance); else if(strcasecmp(line, "command") == 0) - ffPrintCommand(instance); + ffPrintCommand(instance, &instance->config.command); else if(strcasecmp(line, "bluetooth") == 0) ffPrintBluetooth(instance); else if(strcasecmp(line, "sound") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index a58cea0ae..c0d76d313 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -139,6 +139,7 @@ typedef struct FFconfig FFModuleArgs board; FFModuleArgs brightness; FFModuleArgs chassis; + FFCommandOptions command; FFModuleArgs kernel; FFModuleArgs uptime; FFModuleArgs processes; @@ -244,10 +245,6 @@ typedef struct FFconfig FFstrbuf playerName; uint32_t percentType; - - FFstrbuf commandShell; - FFlist commandKeys; - FFlist commandTexts; } FFconfig; typedef struct FFstate @@ -349,7 +346,6 @@ void ffPrintVulkan(FFinstance* instance); void ffPrintOpenGL(FFinstance* instance); void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); -void ffPrintCommand(FFinstance* instance); void ffPrintBluetooth(FFinstance* instance); void ffPrintSound(FFinstance* instance); void ffPrintGamepad(FFinstance* instance); diff --git a/src/modules/command.c b/src/modules/command.c deleted file mode 100644 index 1b767013b..000000000 --- a/src/modules/command.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "fastfetch.h" - -#include "common/printing.h" -#include "common/processing.h" -#include "util/textModifier.h" - -#define FF_COMMAND_MODULE_NAME "Command" - -static void printError(FFinstance* instance, const char* key, const char* error) -{ - ffPrintLogoAndKey(instance, key, 0, NULL); - - if(instance->config.pipe) - fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); - - fputs(error, stdout); - - if(!instance->config.pipe) - fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); - - putchar('\n'); -} - -void ffPrintCommand(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); - - if(!ffListShift(&instance->config.commandKeys, &key)) - ffStrbufInitS(&key, FF_COMMAND_MODULE_NAME); - - FF_STRBUF_AUTO_DESTROY text; - ffStrbufInit(&text); - if(!ffListShift(&instance->config.commandTexts, &text)) - { - printError(instance, key.chars, "No command text left"); - return; - } - - FF_STRBUF_AUTO_DESTROY result; - ffStrbufInit(&result); - const char* error = ffProcessAppendStdOut(&result, (char* const[]){ - instance->config.commandShell.chars, - #ifdef _WIN32 - "/c", - #else - "-c", - #endif - text.chars, - NULL - }); - - if(error) - { - printError(instance, key.chars, error); - return; - } - - if(!result.length) - { - printError(instance, key.chars, "No result printed"); - return; - } - - ffPrintLogoAndKey(instance, key.chars, 0, NULL); - puts(result.chars); -} diff --git a/src/modules/command/command.c b/src/modules/command/command.c new file mode 100644 index 000000000..c523095e2 --- /dev/null +++ b/src/modules/command/command.c @@ -0,0 +1,85 @@ +#include "fastfetch.h" + +#include "common/printing.h" +#include "common/processing.h" +#include "modules/command/command.h" + +#define FF_COMMAND_MODULE_NAME "Command" + +void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) +{ + FF_STRBUF_AUTO_DESTROY result; + ffStrbufInit(&result); + const char* error = ffProcessAppendStdOut(&result, (char* const[]){ + options->shell.chars, + #ifdef _WIN32 + "/c", + #else + "-c", + #endif + options->text.chars, + NULL + }); + + if(error) + { + ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(!result.length) + { + ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed"); + return; + } + + ffPrintLogoAndKey(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&result, stdout); +} + +void ffInitCommandOptions(FFCommandOptions* options) +{ + options->moduleName = FF_COMMAND_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + ffStrbufInitS(&options->shell, + #ifdef _WIN32 + "cmd" + #elif defined(__FreeBSD__) + "csh" + #else + "bash" + #endif + ); + + ffStrbufInit(&options->text); +} + +bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_COMMAND_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if(strcasecmp(subKey, "shell") == 0) + { + ffOptionParseString(key, value, &options->shell); + return true; + } + + if(strcasecmp(subKey, "text") == 0) + { + ffOptionParseString(key, value, &options->text); + return true; + } + + return false; +} + +void ffDestroyCommandOptions(FFCommandOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + ffStrbufDestroy(&options->shell); + ffStrbufDestroy(&options->text); +} diff --git a/src/modules/command/command.h b/src/modules/command/command.h new file mode 100644 index 000000000..069e423e4 --- /dev/null +++ b/src/modules/command/command.h @@ -0,0 +1,9 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/command/option.h" + +void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); +void ffInitCommandOptions(FFCommandOptions* options); +bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value); +void ffDestroyCommandOptions(FFCommandOptions* options); diff --git a/src/modules/command/option.h b/src/modules/command/option.h new file mode 100644 index 000000000..41d3408a4 --- /dev/null +++ b/src/modules/command/option.h @@ -0,0 +1,14 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFCommandOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFstrbuf shell; + FFstrbuf text; +} FFCommandOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index eb72482af..7afac8950 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -4,3 +4,4 @@ #include "modules/os/os.h" #include "modules/battery/battery.h" +#include "modules/command/command.h" diff --git a/src/modules/options.h b/src/modules/options.h index 8d22da1d1..61a78b57b 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -4,3 +4,4 @@ #include "modules/battery/option.h" #include "modules/os/option.h" +#include "modules/command/option.h" diff --git a/src/modules/os/os.c b/src/modules/os/os.c index f202e6e4e..767e57166 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -108,7 +108,7 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - FFstrbuf result; + FF_STRBUF_AUTO_DESTROY result; ffStrbufInit(&result); if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0) @@ -118,7 +118,6 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key); ffStrbufPutTo(&result, stdout); - ffStrbufDestroy(&result); } else { From 790ca460d4c501ac2aab7dd969fe8689fdfe8ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 16:01:18 +0800 Subject: [PATCH 006/493] Battery: init support of JSON config --- CMakeLists.txt | 3 +- src/common/config.c | 132 ++++++++++++++++++++++++++++++++++ src/common/config.h | 29 ++++++++ src/fastfetch.c | 58 ++++++++------- src/modules/battery/battery.c | 45 ++++++++++++ src/modules/battery/battery.h | 5 ++ 6 files changed, 246 insertions(+), 26 deletions(-) create mode 100644 src/common/config.c create mode 100644 src/common/config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b6b9dee1e..bd302d562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,7 @@ cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) -cmake_dependent_option(ENABLE_JSONC "Enable json-c" ON "LINUX OR WIN32" OFF) +cmake_dependent_option(ENABLE_JSONC "Enable json-c" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) @@ -228,6 +228,7 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h) set(LIBFASTFETCH_SRC src/common/bar.c + src/common/config.c src/common/font.c src/common/format.c src/common/init.c diff --git a/src/common/config.c b/src/common/config.c new file mode 100644 index 000000000..75af071c8 --- /dev/null +++ b/src/common/config.c @@ -0,0 +1,132 @@ +#include "fastfetch.h" +#include "common/config.h" + +#ifdef FF_HAVE_JSONC + +#include "common/io/io.h" +#include "modules/modules.h" + +#include + +static inline void wrapJsoncFree(JSONCData* data) +{ + assert(data); + if (data->root) + data->ffjson_object_put(data->root); +} + +static const char* parseModules(FFinstance* instance, JSONCData* data, json_object* modules) +{ + array_list* list = data->ffjson_object_get_array(modules); + if (!list) return "modules must be an array of strings or objects"; + + for (size_t idx = 0; idx < list->length; ++idx) + { + json_object* module = (json_object*) list->array[idx]; + const char* type = NULL; + if (data->ffjson_object_is_type(module, json_type_string)) + { + type = data->ffjson_object_get_string(module); + module = NULL; + } + else if (data->ffjson_object_is_type(module, json_type_object)) + { + type = data->ffjson_object_get_string(data->ffjson_object_object_get(module, "type")); + if (!type) return "module object must contain a type key"; + } + else + return "modules must be an array of strings or objects"; + + if(!ffParseBatteryJsonObject(instance, type, data, module)) + return "Unknown module type"; + } + + return NULL; +} + +const char* ffJsonConfigParse(FFinstance* instance) +{ + FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", + #ifdef _WIN32 + "libjson-c-5" FF_LIBRARY_EXTENSION, -1 + #else + "libjson-c" FF_LIBRARY_EXTENSION, 5 + #endif + ) + JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_boolean) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_object) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) + + FF_STRBUF_AUTO_DESTROY content; + ffStrbufInit(&content); + FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) + { + uint32_t oldLength = filename->length; + ffStrbufAppendS(filename, "fastfetch/config.json"); + bool success = ffAppendFileBuffer(filename->chars, &content); + ffStrbufSubstrBefore(filename, oldLength); + if (success) break; + } + + data.root = data.ffjson_tokener_parse(content.chars); + if (!data.root) + return "Failed to parse JSON config file"; + + lh_table* rootObject = data.ffjson_object_get_object(data.root); + if (!rootObject) + return "Invalid JSON config format. Root value must be an object"; + + struct lh_entry* entry; + lh_foreach(rootObject, entry) + { + const char* key = (const char *)lh_entry_k(entry); + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (strcmp(key, "modules") == 0) + { + const char* error = parseModules(instance, &data, val); + if (error) return error; + } + else + return "Unknown JSON config key in root object"; + } + + return NULL; +} + +bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs) +{ + if(strcasecmp(key, "key") == 0) + { + ffStrbufSetNS(&moduleArgs->key, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + return true; + } + else if(strcasecmp(key, "format") == 0) + { + ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + return true; + } + else if(strcasecmp(key, "error") == 0) + { + ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + return true; + } + return false; +} + +#else + +const char* ffParseJsonConfig(FF_MAYBE_UNUSED FFinstance* instance) +{ + return "Fastfetch was compiled without json-c support"; +} + +#endif diff --git a/src/common/config.h b/src/common/config.h new file mode 100644 index 000000000..23e597af4 --- /dev/null +++ b/src/common/config.h @@ -0,0 +1,29 @@ +#pragma once + +#ifdef FF_HAVE_JSONC + +#include + +#include "common/library.h" + +typedef struct JSONCData +{ + FF_LIBRARY_SYMBOL(json_tokener_parse) + FF_LIBRARY_SYMBOL(json_object_is_type) + FF_LIBRARY_SYMBOL(json_object_get_array) + FF_LIBRARY_SYMBOL(json_object_get_boolean) + FF_LIBRARY_SYMBOL(json_object_get_double) + FF_LIBRARY_SYMBOL(json_object_get_string_len) + FF_LIBRARY_SYMBOL(json_object_get_string) + FF_LIBRARY_SYMBOL(json_object_get_object) + FF_LIBRARY_SYMBOL(json_object_object_get) + FF_LIBRARY_SYMBOL(json_object_put) + + json_object* root; +} JSONCData; + +bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs); + +#endif + +const char* ffJsonConfigParse(FFinstance* instance); diff --git a/src/fastfetch.c b/src/fastfetch.c index a838592ff..ade8d4d35 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -18,6 +18,7 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #include "modules/os/os.h" +#include "common/config.h" #include "modules/modules.h" typedef struct CustomValue @@ -1537,34 +1538,41 @@ int main(int argc, const char** argv) fflush(stdout); #endif - //Parse the structure and call the modules - uint32_t startIndex = 0; - while (startIndex < data.structure.length) + if (ffStrbufIgnCaseEqualS(&data.structure, "Config")) { - uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); - data.structure.chars[colonIndex] = '\0'; - - uint64_t ms = 0; - if(__builtin_expect(instance.config.stat, false)) - ms = ffTimeGetTick(); - - parseStructureCommand(&instance, &data, data.structure.chars + startIndex); - - if(__builtin_expect(instance.config.stat, false)) + ffJsonConfigParse(&instance); + } + else + { + //Parse the structure and call the modules + uint32_t startIndex = 0; + while (startIndex < data.structure.length) { - char str[32]; - int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); - if(instance.config.pipe) - puts(str); - else - printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); + data.structure.chars[colonIndex] = '\0'; + + uint64_t ms = 0; + if(__builtin_expect(instance.config.stat, false)) + ms = ffTimeGetTick(); + + parseStructureCommand(&instance, &data, data.structure.chars + startIndex); + + if(__builtin_expect(instance.config.stat, false)) + { + char str[32]; + int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); + if(instance.config.pipe) + puts(str); + else + printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + } + + #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + fflush(stdout); + #endif + + startIndex = colonIndex + 1; } - - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); - #endif - - startIndex = colonIndex + 1; } ffFinish(&instance); diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 4ba93c49d..f76f67797 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -146,3 +146,48 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options) ffStrbufDestroy(&options->dir); #endif } + +#ifdef FF_HAVE_JSONC +bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_BATTERY_MODULE_NAME) != 0) + return false; + + FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; + ffInitBatteryOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + #ifdef __linux__ + if (strcasecmp(key, "dir") == 0) + { + ffStrbufSetS(&options.dir, data->ffjson_object_get_string(val)); + continue; + } + #endif + + if (strcasecmp(key, "temp") == 0) + { + options.temp = (bool) data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintBattery(instance, &options); + return true; +} +#endif diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index c6eb2951f..14d31c3f0 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -8,3 +8,8 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); void ffInitBatteryOptions(FFBatteryOptions* options); bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value); void ffDestroyBatteryOptions(FFBatteryOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif From d4549d68499260452c8df8c7f14056d575db823a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 16:10:46 +0800 Subject: [PATCH 007/493] Command: init support of JSON config --- src/common/config.c | 1 + src/modules/command/command.c | 43 +++++++++++++++++++++++++++++++++++ src/modules/command/command.h | 5 ++++ 3 files changed, 49 insertions(+) diff --git a/src/common/config.c b/src/common/config.c index 75af071c8..09f7d5073 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -38,6 +38,7 @@ static const char* parseModules(FFinstance* instance, JSONCData* data, json_obje return "modules must be an array of strings or objects"; if(!ffParseBatteryJsonObject(instance, type, data, module)) + if(!ffParseCommandJsonObject(instance, type, data, module)) return "Unknown module type"; } diff --git a/src/modules/command/command.c b/src/modules/command/command.c index c523095e2..43143fb5f 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -83,3 +83,46 @@ void ffDestroyCommandOptions(FFCommandOptions* options) ffStrbufDestroy(&options->shell); ffStrbufDestroy(&options->text); } + +#ifdef FF_HAVE_JSONC +bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_COMMAND_MODULE_NAME) != 0) + return false; + + FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; + ffInitCommandOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "shell") == 0) + { + ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val)); + continue; + } + + if (strcasecmp(key, "text") == 0) + { + ffStrbufSetS(&options.text, data->ffjson_object_get_string(val)); + continue; + } + + ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintCommand(instance, &options); + return true; +} +#endif diff --git a/src/modules/command/command.h b/src/modules/command/command.h index 069e423e4..adbf29d04 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -7,3 +7,8 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); void ffInitCommandOptions(FFCommandOptions* options); bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value); void ffDestroyCommandOptions(FFCommandOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif From 161c4ac028e99bbd0e62261fb92a49f8851dec4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 16:14:08 +0800 Subject: [PATCH 008/493] OS: init support of JSON config --- src/common/config.c | 1 + src/modules/os/os.c | 39 +++++++++++++++++++++++++++++++++++++++ src/modules/os/os.h | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/src/common/config.c b/src/common/config.c index 09f7d5073..bfa2e5c43 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -39,6 +39,7 @@ static const char* parseModules(FFinstance* instance, JSONCData* data, json_obje if(!ffParseBatteryJsonObject(instance, type, data, module)) if(!ffParseCommandJsonObject(instance, type, data, module)) + if(!ffParseOSJsonObject(instance, type, data, module)) return "Unknown module type"; } diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 767e57166..e87488ded 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -173,3 +173,42 @@ void ffDestroyOSOptions(FFOSOptions* options) ffStrbufDestroy(&options->file); #endif } + +#ifdef FF_HAVE_JSONC +bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_OS_MODULE_NAME) != 0) + return false; + + FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; + ffInitOSOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + #if defined(__linux__) || defined(__FreeBSD__) + if (strcasecmp(key, "file") == 0) + { + ffStrbufSetS(&options.file, data->ffjson_object_get_string(val)); + continue; + } + #endif + + ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintOS(instance, &options); + return true; +} +#endif diff --git a/src/modules/os/os.h b/src/modules/os/os.h index bf6572291..9d66a32d4 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -7,3 +7,8 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options); void ffInitOSOptions(FFOSOptions* options); bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value); void ffDestroyOSOptions(FFOSOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif From 4cf130bd07b4d31d1329d518dfdae8740b288cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 16:43:43 +0800 Subject: [PATCH 009/493] Fastfetch: rename FFinstance::`separator` to `keyValueSeparator`, because it's conflicted against Separator module --- src/common/init.c | 6 +++--- src/common/printing.c | 2 +- src/fastfetch.c | 2 +- src/fastfetch.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index dbe5899f8..fb49c41e9 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -56,8 +56,8 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.colorKeys); ffStrbufInit(&instance->config.colorTitle); - ffStrbufInit(&instance->config.separator); - ffStrbufAppendS(&instance->config.separator, ": "); + ffStrbufInit(&instance->config.keyValueSeparator); + ffStrbufAppendS(&instance->config.keyValueSeparator, ": "); instance->config.showErrors = false; instance->config.recache = false; @@ -317,7 +317,7 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.logo.colors[i]); ffStrbufDestroy(&instance->config.colorKeys); ffStrbufDestroy(&instance->config.colorTitle); - ffStrbufDestroy(&instance->config.separator); + ffStrbufDestroy(&instance->config.keyValueSeparator); ffDestroyOSOptions(&instance->config.os); destroyModuleArg(&instance->config.host); diff --git a/src/common/printing.c b/src/common/printing.c index f33d5cf33..95350e09e 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -38,7 +38,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod if(!instance->config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); - ffStrbufWriteTo(&instance->config.separator, stdout); + ffStrbufWriteTo(&instance->config.keyValueSeparator, stdout); if(!instance->config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); diff --git a/src/fastfetch.c b/src/fastfetch.c index ade8d4d35..081b9470a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1105,7 +1105,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "-s") == 0 || strcasecmp(key, "--structure") == 0) optionParseString(key, value, &data->structure); else if(strcasecmp(key, "--separator") == 0) - optionParseString(key, value, &instance->config.separator); + optionParseString(key, value, &instance->config.keyValueSeparator); else if(strcasecmp(key, "--color-keys") == 0) optionParseColor(key, value, &instance->config.colorKeys); else if(strcasecmp(key, "--color-title") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index c0d76d313..d20827315 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -119,7 +119,7 @@ typedef struct FFconfig FFstrbuf colorKeys; FFstrbuf colorTitle; - FFstrbuf separator; + FFstrbuf keyValueSeparator; bool showErrors; bool recache; From 0ab2eda0aef406c4eca88c6feca157fcd7b2a31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 17:00:37 +0800 Subject: [PATCH 010/493] Separator: init support of JSON config --- CMakeLists.txt | 2 +- src/common/config.c | 14 +++-- src/common/init.c | 5 +- src/fastfetch.c | 5 +- src/fastfetch.h | 4 +- src/flashfetch.c | 2 +- src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/separator.c | 29 ---------- src/modules/separator/option.h | 12 +++++ src/modules/separator/separator.c | 90 +++++++++++++++++++++++++++++++ src/modules/separator/separator.h | 14 +++++ 12 files changed, 136 insertions(+), 43 deletions(-) delete mode 100644 src/modules/separator.c create mode 100644 src/modules/separator/option.h create mode 100644 src/modules/separator/separator.c create mode 100644 src/modules/separator/separator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bd302d562..1b2fc440f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -295,7 +295,7 @@ set(LIBFASTFETCH_SRC src/modules/processes.c src/modules/publicip.c src/modules/display.c - src/modules/separator.c + src/modules/separator/separator.c src/modules/shell.c src/modules/sound.c src/modules/swap.c diff --git a/src/common/config.c b/src/common/config.c index bfa2e5c43..aff9e73c3 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -8,6 +8,16 @@ #include +static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + return + ffParseBatteryJsonObject(instance, type, data, module) || + ffParseCommandJsonObject(instance, type, data, module) || + ffParseOSJsonObject(instance, type, data, module) || + ffParseSeparatorJsonObject(instance, type, data, module) || + false; +} + static inline void wrapJsoncFree(JSONCData* data) { assert(data); @@ -37,9 +47,7 @@ static const char* parseModules(FFinstance* instance, JSONCData* data, json_obje else return "modules must be an array of strings or objects"; - if(!ffParseBatteryJsonObject(instance, type, data, module)) - if(!ffParseCommandJsonObject(instance, type, data, module)) - if(!ffParseOSJsonObject(instance, type, data, module)) + if(!parseModuleJsonObject(instance, type, data, module)) return "Unknown module type"; } diff --git a/src/common/init.c b/src/common/init.c index fb49c41e9..012b7e788 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -118,6 +118,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.users); initModuleArg(&instance->config.bluetooth); initModuleArg(&instance->config.sound); + ffInitSeparatorOptions(&instance->config.separator); initModuleArg(&instance->config.gamepad); ffStrbufInitA(&instance->config.libPCI, 0); @@ -169,8 +170,6 @@ static void defaultConfig(FFinstance* instance) instance->config.soundType = FF_SOUND_TYPE_MAIN; - ffStrbufInitA(&instance->config.separatorString, 0); - instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT; ffStrbufInit(&instance->config.localIpNamePrefix); @@ -364,6 +363,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.openCL); destroyModuleArg(&instance->config.users); destroyModuleArg(&instance->config.bluetooth); + ffDestroySeparatorOptions(&instance->config.separator); destroyModuleArg(&instance->config.sound); destroyModuleArg(&instance->config.gamepad); @@ -394,7 +394,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libnm); ffStrbufDestroy(&instance->config.diskFolders); - ffStrbufDestroy(&instance->config.separatorString); ffStrbufDestroy(&instance->config.localIpNamePrefix); ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); diff --git a/src/fastfetch.c b/src/fastfetch.c index 081b9470a..935200ea8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1179,6 +1179,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "opencl", &instance->config.openCL)) {} else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} else if(optionParseModuleArgs(key, value, "bluetooth", &instance->config.bluetooth)) {} + else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(optionParseModuleArgs(key, value, "sound", &instance->config.sound)) {} else if(optionParseModuleArgs(key, value, "gamepad", &instance->config.gamepad)) {} @@ -1298,8 +1299,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con NULL ); } - else if(strcasecmp(key, "--separator-string") == 0) - optionParseString(key, value, &instance->config.separatorString); else if(strcasecmp(key, "--localip-show-ipv4") == 0) optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_IPV4_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_IPV4_BIT); else if(strcasecmp(key, "--localip-show-ipv6") == 0) @@ -1398,7 +1397,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "title") == 0) ffPrintTitle(instance); else if(strcasecmp(line, "separator") == 0) - ffPrintSeparator(instance); + ffPrintSeparator(instance, &instance->config.separator); else if(strcasecmp(line, "os") == 0) ffPrintOS(instance, &instance->config.os); else if(strcasecmp(line, "host") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index d20827315..7123082a9 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -179,6 +179,7 @@ typedef struct FFconfig FFModuleArgs openCL; FFModuleArgs users; FFModuleArgs bluetooth; + FFSeparatorOptions separator; FFModuleArgs sound; FFModuleArgs gamepad; @@ -229,8 +230,6 @@ typedef struct FFconfig bool bluetoothShowDisconnected; - FFstrbuf separatorString; - FFstrbuf localIpNamePrefix; FFLocalIpType localIpShowType; @@ -302,7 +301,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); void ffPrintTitle(FFinstance* instance); -void ffPrintSeparator(FFinstance* instance); void ffPrintHost(FFinstance* instance); void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index e6bdba2bd..48a0e0c94 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -21,7 +21,7 @@ int main(int argc, char** argv) //Printing ffPrintTitle(&instance); - ffPrintSeparator(&instance); + ffPrintSeparator(&instance, &instance.config.separator); ffPrintOS(&instance, &instance.config.os); ffPrintHost(&instance); //ffPrintBios(&instance); diff --git a/src/modules/modules.h b/src/modules/modules.h index 7afac8950..ee76d794c 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -5,3 +5,4 @@ #include "modules/os/os.h" #include "modules/battery/battery.h" #include "modules/command/command.h" +#include "modules/separator/separator.h" diff --git a/src/modules/options.h b/src/modules/options.h index 61a78b57b..7e25edd1b 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -5,3 +5,4 @@ #include "modules/battery/option.h" #include "modules/os/option.h" #include "modules/command/option.h" +#include "modules/separator/option.h" diff --git a/src/modules/separator.c b/src/modules/separator.c deleted file mode 100644 index 879bc5bb8..000000000 --- a/src/modules/separator.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" - -void ffPrintSeparator(FFinstance* instance) -{ - uint32_t titleLength = instance->state.platform.userName.length + 1 + (instance->config.titleFQDN ? - instance->state.platform.domainName.length : - instance->state.platform.hostName.length - ); - - ffLogoPrintLine(instance); - - if(instance->config.separatorString.length == 0) - { - for(uint32_t i = 0; i < titleLength; i++) - putchar('-'); - } - else - { - //Write the whole separator as often as it fits fully into titleLength - for(uint32_t i = 0; i < titleLength / instance->config.separatorString.length; i++) - ffStrbufWriteTo(&instance->config.separatorString, stdout); - - //Write as much of the separator as needed to fill titleLength - for(uint32_t i = 0; i < titleLength % instance->config.separatorString.length; i++) - putchar(instance->config.separatorString.chars[i]); - } - putchar('\n'); -} diff --git a/src/modules/separator/option.h b/src/modules/separator/option.h new file mode 100644 index 000000000..10f5effdf --- /dev/null +++ b/src/modules/separator/option.h @@ -0,0 +1,12 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFSeparatorOptions +{ + const char* moduleName; + + FFstrbuf string; +} FFSeparatorOptions; diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c new file mode 100644 index 000000000..a25c04021 --- /dev/null +++ b/src/modules/separator/separator.c @@ -0,0 +1,90 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "modules/separator/separator.h" + +#define FF_SEPARATOR_MODULE_NAME "Separator" + +void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) +{ + uint32_t titleLength = instance->state.platform.userName.length + 1 + (instance->config.titleFQDN ? + instance->state.platform.domainName.length : + instance->state.platform.hostName.length + ); + + ffLogoPrintLine(instance); + + if(options->string.length == 0) + { + ffPrintCharTimes('-', titleLength); + } + else + { + //Write the whole separator as often as it fits fully into titleLength + for(uint32_t i = 0; i < titleLength / options->string.length; i++) + ffStrbufWriteTo(&options->string, stdout); + + //Write as much of the separator as needed to fill titleLength + for(uint32_t i = 0; i < titleLength % options->string.length; i++) + putchar(options->string.chars[i]); + } + putchar('\n'); +} + +void ffInitSeparatorOptions(FFSeparatorOptions* options) +{ + options->moduleName = FF_SEPARATOR_MODULE_NAME; + ffStrbufInit(&options->string); +} + +bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_SEPARATOR_MODULE_NAME); + if (!subKey) return false; + + if (strcasecmp(subKey, "string") == 0) + { + ffOptionParseString(key, value, &options->string); + return true; + } + + return false; +} + +void ffDestroySeparatorOptions(FFSeparatorOptions* options) +{ + ffStrbufDestroy(&options->string); +} + +#ifdef FF_HAVE_JSONC +bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_SEPARATOR_MODULE_NAME) != 0) + return false; + + FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; + ffInitSeparatorOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (strcasecmp(key, "string") == 0) + { + ffStrbufSetS(&options.string, data->ffjson_object_get_string(val)); + continue; + } + + ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + } + } + + ffPrintSeparator(instance, &options); + return true; +} +#endif diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h new file mode 100644 index 000000000..295afa215 --- /dev/null +++ b/src/modules/separator/separator.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/separator/option.h" + +void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options); +void ffInitSeparatorOptions(FFSeparatorOptions* options); +bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value); +void ffDestroySeparatorOptions(FFSeparatorOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif From da5da85c0725fd1c709fa58242f8fffa1edf6a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 18:11:03 +0800 Subject: [PATCH 011/493] Title: init support of JSON config --- CMakeLists.txt | 2 +- src/common/config.c | 1 + src/common/init.c | 5 +- src/fastfetch.c | 4 +- src/fastfetch.h | 5 +- src/flashfetch.c | 2 +- src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/separator/separator.c | 13 +++-- src/modules/title.c | 30 ---------- src/modules/title/option.h | 12 ++++ src/modules/title/title.c | 95 +++++++++++++++++++++++++++++++ src/modules/title/title.h | 14 +++++ 13 files changed, 141 insertions(+), 44 deletions(-) delete mode 100644 src/modules/title.c create mode 100644 src/modules/title/option.h create mode 100644 src/modules/title/title.c create mode 100644 src/modules/title/title.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b2fc440f..99ae9e3e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,7 +304,7 @@ set(LIBFASTFETCH_SRC src/modules/terminalfont.c src/modules/theme.c src/modules/time.c - src/modules/title.c + src/modules/title/title.c src/modules/uptime.c src/modules/users.c src/modules/vulkan.c diff --git a/src/common/config.c b/src/common/config.c index aff9e73c3..2b9f9045c 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -11,6 +11,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) { return + ffParseTitleJsonObject(instance, type, data, module) || ffParseBatteryJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseOSJsonObject(instance, type, data, module) || diff --git a/src/common/init.c b/src/common/init.c index 012b7e788..b27c17a12 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -22,6 +22,7 @@ static void initState(FFstate* state) state->logoWidth = 0; state->logoHeight = 0; state->keysHeight = 0; + state->titleLength = 0; ffPlatformInit(&state->platform); } @@ -71,6 +72,7 @@ static void defaultConfig(FFinstance* instance) instance->config.multithreading = true; instance->config.stat = false; + ffInitTitleOptions(&instance->config.title); ffInitOSOptions(&instance->config.os); initModuleArg(&instance->config.host); initModuleArg(&instance->config.bios); @@ -157,8 +159,6 @@ static void defaultConfig(FFinstance* instance) instance->config.shellVersion = true; instance->config.terminalVersion = true; - instance->config.titleFQDN = false; - ffStrbufInitA(&instance->config.diskFolders, 0); instance->config.diskShowTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; @@ -318,6 +318,7 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.colorTitle); ffStrbufDestroy(&instance->config.keyValueSeparator); + ffDestroyTitleOptions(&instance->config.title); ffDestroyOSOptions(&instance->config.os); destroyModuleArg(&instance->config.host); destroyModuleArg(&instance->config.bios); diff --git a/src/fastfetch.c b/src/fastfetch.c index 935200ea8..bfff141e9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1258,8 +1258,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.gpuHideIntegrated = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-hide-discrete") == 0) instance->config.gpuHideDiscrete = optionParseBoolean(value); - else if(strcasecmp(key, "--title-fqdn") == 0) - instance->config.titleFQDN = optionParseBoolean(value); else if(strcasecmp(key, "--shell-version") == 0) instance->config.shellVersion = optionParseBoolean(value); else if(strcasecmp(key, "--terminal-version") == 0) @@ -1395,7 +1393,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char if(strcasecmp(line, "break") == 0) ffPrintBreak(instance); else if(strcasecmp(line, "title") == 0) - ffPrintTitle(instance); + ffPrintTitle(instance, &instance->config.title); else if(strcasecmp(line, "separator") == 0) ffPrintSeparator(instance, &instance->config.separator); else if(strcasecmp(line, "os") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 7123082a9..805a9b46c 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -133,6 +133,7 @@ typedef struct FFconfig bool multithreading; bool stat; + FFTitleOptions title; FFOSOptions os; FFModuleArgs host; FFModuleArgs bios; @@ -216,8 +217,6 @@ typedef struct FFconfig bool gpuHideIntegrated; bool gpuHideDiscrete; - bool titleFQDN; - bool shellVersion; bool terminalVersion; @@ -251,6 +250,7 @@ typedef struct FFstate uint32_t logoWidth; uint32_t logoHeight; uint32_t keysHeight; + uint32_t titleLength; FFPlatform platform; } FFstate; @@ -300,7 +300,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); -void ffPrintTitle(FFinstance* instance); void ffPrintHost(FFinstance* instance); void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 48a0e0c94..6b961e04a 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -20,7 +20,7 @@ int main(int argc, char** argv) ffStart(&instance); //Printing - ffPrintTitle(&instance); + ffPrintTitle(&instance, &instance.config.title); ffPrintSeparator(&instance, &instance.config.separator); ffPrintOS(&instance, &instance.config.os); ffPrintHost(&instance); diff --git a/src/modules/modules.h b/src/modules/modules.h index ee76d794c..f407e92d2 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -6,3 +6,4 @@ #include "modules/battery/battery.h" #include "modules/command/command.h" #include "modules/separator/separator.h" +#include "modules/title/title.h" diff --git a/src/modules/options.h b/src/modules/options.h index 7e25edd1b..faf052800 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -6,3 +6,4 @@ #include "modules/os/option.h" #include "modules/command/option.h" #include "modules/separator/option.h" +#include "modules/title/option.h" diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index a25c04021..1c6b92bc9 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -6,10 +6,15 @@ void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) { - uint32_t titleLength = instance->state.platform.userName.length + 1 + (instance->config.titleFQDN ? - instance->state.platform.domainName.length : - instance->state.platform.hostName.length - ); + uint32_t titleLength = instance->state.titleLength; + if (titleLength == 0) + { + // Title was not printed, should we support this case? + titleLength = instance->state.platform.userName.length + 1 + (instance->config.title.fdqn ? + instance->state.platform.domainName.length : + instance->state.platform.hostName.length + ); + } ffLogoPrintLine(instance); diff --git a/src/modules/title.c b/src/modules/title.c deleted file mode 100644 index 4e509fbe5..000000000 --- a/src/modules/title.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "util/textModifier.h" - -static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) -{ - if(!instance->config.pipe) - { - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance->config.colorTitle); - } - - ffStrbufWriteTo(content, stdout); - - if(!instance->config.pipe) - fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); -} - -void ffPrintTitle(FFinstance* instance) -{ - ffLogoPrintLine(instance); - - printTitlePart(instance, &instance->state.platform.userName); - putchar('@'); - printTitlePart(instance, instance->config.titleFQDN ? - &instance->state.platform.domainName : - &instance->state.platform.hostName - ); - putchar('\n'); -} diff --git a/src/modules/title/option.h b/src/modules/title/option.h new file mode 100644 index 000000000..1faa59ea4 --- /dev/null +++ b/src/modules/title/option.h @@ -0,0 +1,12 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFTitleOptions +{ + const char* moduleName; + + bool fdqn; +} FFTitleOptions; diff --git a/src/modules/title/title.c b/src/modules/title/title.c new file mode 100644 index 000000000..3503d01b3 --- /dev/null +++ b/src/modules/title/title.c @@ -0,0 +1,95 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "util/textModifier.h" +#include "modules/title/title.h" + +#define FF_TITLE_MODULE_NAME "Title" + +static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) +{ + if(!instance->config.pipe) + { + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + ffPrintColor(&instance->config.colorTitle); + } + + ffStrbufWriteTo(content, stdout); + + if(!instance->config.pipe) + fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); +} + +void ffPrintTitle(FFinstance* instance, FFTitleOptions* options) +{ + ffLogoPrintLine(instance); + + printTitlePart(instance, &instance->state.platform.userName); + putchar('@'); + FFstrbuf* host = options->fdqn ? + &instance->state.platform.domainName : + &instance->state.platform.hostName; + printTitlePart(instance, host); + + instance->state.titleLength = instance->state.platform.userName.length + host->length + 1; + + putchar('\n'); +} + +void ffInitTitleOptions(FFTitleOptions* options) +{ + options->moduleName = FF_TITLE_MODULE_NAME; + options->fdqn = false; +} + +bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_TITLE_MODULE_NAME); + if (!subKey) return false; + + if (strcasecmp(subKey, "fdqn") == 0) + { + options->fdqn = ffOptionParseBoolean(value); + return true; + } + + return false; +} + +void ffDestroyTitleOptions(FFTitleOptions* options) +{ + FF_UNUSED(options); +} + +#ifdef FF_HAVE_JSONC +bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_TITLE_MODULE_NAME) != 0) + return false; + + FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; + ffInitTitleOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (strcasecmp(key, "fdqn") == 0) + { + options.fdqn = data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + } + } + + ffPrintTitle(instance, &options); + return true; +} +#endif diff --git a/src/modules/title/title.h b/src/modules/title/title.h new file mode 100644 index 000000000..b361e72c7 --- /dev/null +++ b/src/modules/title/title.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/title/option.h" + +void ffPrintTitle(FFinstance* instance, FFTitleOptions* options); +void ffInitTitleOptions(FFTitleOptions* options); +bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value); +void ffDestroyTitleOptions(FFTitleOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif From c5dcf522c408c1d7fb8e96d38bbaff99e3d63f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 18:57:57 +0800 Subject: [PATCH 012/493] JsonConfig: make it a special module --- CMakeLists.txt | 1 + src/common/config.c | 117 ------------------------- src/common/config.h | 2 - src/fastfetch.c | 59 ++++++------- src/modules/jsonconfig/jsonconfig.c | 131 ++++++++++++++++++++++++++++ src/modules/jsonconfig/jsonconfig.h | 5 ++ src/modules/modules.h | 1 + 7 files changed, 165 insertions(+), 151 deletions(-) create mode 100644 src/modules/jsonconfig/jsonconfig.c create mode 100644 src/modules/jsonconfig/jsonconfig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 99ae9e3e4..5fac1e924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,7 @@ set(LIBFASTFETCH_SRC src/modules/wifi.c src/modules/wm.c src/modules/wmtheme.c + src/modules/jsonconfig/jsonconfig.c src/util/FFlist.c src/util/FFstrbuf.c src/util/FFvaluestore.c diff --git a/src/common/config.c b/src/common/config.c index 2b9f9045c..f7d124fce 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -3,116 +3,6 @@ #ifdef FF_HAVE_JSONC -#include "common/io/io.h" -#include "modules/modules.h" - -#include - -static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) -{ - return - ffParseTitleJsonObject(instance, type, data, module) || - ffParseBatteryJsonObject(instance, type, data, module) || - ffParseCommandJsonObject(instance, type, data, module) || - ffParseOSJsonObject(instance, type, data, module) || - ffParseSeparatorJsonObject(instance, type, data, module) || - false; -} - -static inline void wrapJsoncFree(JSONCData* data) -{ - assert(data); - if (data->root) - data->ffjson_object_put(data->root); -} - -static const char* parseModules(FFinstance* instance, JSONCData* data, json_object* modules) -{ - array_list* list = data->ffjson_object_get_array(modules); - if (!list) return "modules must be an array of strings or objects"; - - for (size_t idx = 0; idx < list->length; ++idx) - { - json_object* module = (json_object*) list->array[idx]; - const char* type = NULL; - if (data->ffjson_object_is_type(module, json_type_string)) - { - type = data->ffjson_object_get_string(module); - module = NULL; - } - else if (data->ffjson_object_is_type(module, json_type_object)) - { - type = data->ffjson_object_get_string(data->ffjson_object_object_get(module, "type")); - if (!type) return "module object must contain a type key"; - } - else - return "modules must be an array of strings or objects"; - - if(!parseModuleJsonObject(instance, type, data, module)) - return "Unknown module type"; - } - - return NULL; -} - -const char* ffJsonConfigParse(FFinstance* instance) -{ - FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", - #ifdef _WIN32 - "libjson-c-5" FF_LIBRARY_EXTENSION, -1 - #else - "libjson-c" FF_LIBRARY_EXTENSION, 5 - #endif - ) - JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_boolean) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_object) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) - - FF_STRBUF_AUTO_DESTROY content; - ffStrbufInit(&content); - FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) - { - uint32_t oldLength = filename->length; - ffStrbufAppendS(filename, "fastfetch/config.json"); - bool success = ffAppendFileBuffer(filename->chars, &content); - ffStrbufSubstrBefore(filename, oldLength); - if (success) break; - } - - data.root = data.ffjson_tokener_parse(content.chars); - if (!data.root) - return "Failed to parse JSON config file"; - - lh_table* rootObject = data.ffjson_object_get_object(data.root); - if (!rootObject) - return "Invalid JSON config format. Root value must be an object"; - - struct lh_entry* entry; - lh_foreach(rootObject, entry) - { - const char* key = (const char *)lh_entry_k(entry); - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (strcmp(key, "modules") == 0) - { - const char* error = parseModules(instance, &data, val); - if (error) return error; - } - else - return "Unknown JSON config key in root object"; - } - - return NULL; -} - bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs) { if(strcasecmp(key, "key") == 0) @@ -133,11 +23,4 @@ bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* return false; } -#else - -const char* ffParseJsonConfig(FF_MAYBE_UNUSED FFinstance* instance) -{ - return "Fastfetch was compiled without json-c support"; -} - #endif diff --git a/src/common/config.h b/src/common/config.h index 23e597af4..81dd9c011 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -25,5 +25,3 @@ typedef struct JSONCData bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs); #endif - -const char* ffJsonConfigParse(FFinstance* instance); diff --git a/src/fastfetch.c b/src/fastfetch.c index bfff141e9..a8fe3357e 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1494,6 +1494,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintSound(instance); else if(strcasecmp(line, "gamepad") == 0) ffPrintGamepad(instance); + else if(strcasecmp(line, "jsonconfig") == 0) + ffPrintJsonConfig(instance); else ffPrintErrorString(instance, line, 0, NULL, NULL, ""); } @@ -1535,41 +1537,34 @@ int main(int argc, const char** argv) fflush(stdout); #endif - if (ffStrbufIgnCaseEqualS(&data.structure, "Config")) + //Parse the structure and call the modules + uint32_t startIndex = 0; + while (startIndex < data.structure.length) { - ffJsonConfigParse(&instance); - } - else - { - //Parse the structure and call the modules - uint32_t startIndex = 0; - while (startIndex < data.structure.length) + uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); + data.structure.chars[colonIndex] = '\0'; + + uint64_t ms = 0; + if(__builtin_expect(instance.config.stat, false)) + ms = ffTimeGetTick(); + + parseStructureCommand(&instance, &data, data.structure.chars + startIndex); + + if(__builtin_expect(instance.config.stat, false)) { - uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); - data.structure.chars[colonIndex] = '\0'; - - uint64_t ms = 0; - if(__builtin_expect(instance.config.stat, false)) - ms = ffTimeGetTick(); - - parseStructureCommand(&instance, &data, data.structure.chars + startIndex); - - if(__builtin_expect(instance.config.stat, false)) - { - char str[32]; - int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); - if(instance.config.pipe) - puts(str); - else - printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load - } - - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); - #endif - - startIndex = colonIndex + 1; + char str[32]; + int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); + if(instance.config.pipe) + puts(str); + else + printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } + + #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + fflush(stdout); + #endif + + startIndex = colonIndex + 1; } ffFinish(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c new file mode 100644 index 000000000..893972315 --- /dev/null +++ b/src/modules/jsonconfig/jsonconfig.c @@ -0,0 +1,131 @@ +#include "modules/jsonconfig/jsonconfig.h" +#include "common/config.h" +#include "common/printing.h" + +#ifdef FF_HAVE_JSONC + +#include "common/io/io.h" +#include "modules/modules.h" + +#include + +static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + return + ffParseTitleJsonObject(instance, type, data, module) || + ffParseBatteryJsonObject(instance, type, data, module) || + ffParseCommandJsonObject(instance, type, data, module) || + ffParseOSJsonObject(instance, type, data, module) || + ffParseSeparatorJsonObject(instance, type, data, module) || + false; +} + +static inline void wrapJsoncFree(JSONCData* data) +{ + assert(data); + if (data->root) + data->ffjson_object_put(data->root); +} + +static const char* parseModules(FFinstance* instance, JSONCData* data, json_object* modules) +{ + array_list* list = data->ffjson_object_get_array(modules); + if (!list) return "modules must be an array of strings or objects"; + + for (size_t idx = 0; idx < list->length; ++idx) + { + json_object* module = (json_object*) list->array[idx]; + const char* type = NULL; + if (data->ffjson_object_is_type(module, json_type_string)) + { + type = data->ffjson_object_get_string(module); + module = NULL; + } + else if (data->ffjson_object_is_type(module, json_type_object)) + { + type = data->ffjson_object_get_string(data->ffjson_object_object_get(module, "type")); + if (!type) return "module object must contain a type key"; + } + else + return "modules must be an array of strings or objects"; + + if(!parseModuleJsonObject(instance, type, data, module)) + return "Unknown module type"; + } + + return NULL; +} + +static const char* printJsonConfig(FFinstance* instance) +{ + FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", + #ifdef _WIN32 + "libjson-c-5" FF_LIBRARY_EXTENSION, -1 + #else + "libjson-c" FF_LIBRARY_EXTENSION, 5 + #endif + ) + JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_boolean) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_object) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) + + FF_STRBUF_AUTO_DESTROY content; + ffStrbufInit(&content); + FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) + { + uint32_t oldLength = filename->length; + ffStrbufAppendS(filename, "fastfetch/config.json"); + bool success = ffAppendFileBuffer(filename->chars, &content); + ffStrbufSubstrBefore(filename, oldLength); + if (success) break; + } + + data.root = data.ffjson_tokener_parse(content.chars); + if (!data.root) + return "Failed to parse JSON config file"; + + lh_table* rootObject = data.ffjson_object_get_object(data.root); + if (!rootObject) + return "Invalid JSON config format. Root value must be an object"; + + struct lh_entry* entry; + lh_foreach(rootObject, entry) + { + const char* key = (const char *)lh_entry_k(entry); + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (strcmp(key, "modules") == 0) + { + const char* error = parseModules(instance, &data, val); + if (error) return error; + } + else + return "Unknown JSON config key in root object"; + } + + return NULL; +} + +#else + +static const char* printJsonConfig(FF_MAYBE_UNUSED FFinstance* instance) +{ + return "Fastfetch was compiled without json-c support"; +} + +#endif + +void ffPrintJsonConfig(FFinstance* instance) +{ + const char* error = printJsonConfig(instance); + if (error) + ffPrintErrorString(instance, "JsonConfig", 0, NULL, NULL, "%s", error); +} diff --git a/src/modules/jsonconfig/jsonconfig.h b/src/modules/jsonconfig/jsonconfig.h new file mode 100644 index 000000000..a29f7bda5 --- /dev/null +++ b/src/modules/jsonconfig/jsonconfig.h @@ -0,0 +1,5 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintJsonConfig(FFinstance* instance); diff --git a/src/modules/modules.h b/src/modules/modules.h index f407e92d2..e2a2b672a 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -7,3 +7,4 @@ #include "modules/command/command.h" #include "modules/separator/separator.h" #include "modules/title/title.h" +#include "modules/jsonconfig/jsonconfig.h" From da81111575f9855e34294b73ebec1d95e4ffab36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Mar 2023 19:38:03 +0800 Subject: [PATCH 013/493] DateTime: init support of JSON config Redundant modules `Date` and `Time` are removed --- CMakeLists.txt | 4 +- src/common/init.c | 8 +-- src/fastfetch.c | 10 +-- src/fastfetch.h | 7 +- src/modules/date.c | 20 ------ src/modules/datetime.c | 48 ------------- src/modules/datetime/datetime.c | 102 ++++++++++++++++++++++++++++ src/modules/datetime/datetime.h | 14 ++++ src/modules/datetime/option.h | 11 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 3 +- src/modules/time.c | 20 ------ 13 files changed, 138 insertions(+), 111 deletions(-) delete mode 100644 src/modules/date.c delete mode 100644 src/modules/datetime.c create mode 100644 src/modules/datetime/datetime.c create mode 100644 src/modules/datetime/datetime.h create mode 100644 src/modules/datetime/option.h delete mode 100644 src/modules/time.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fac1e924..19a202bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,8 +273,7 @@ set(LIBFASTFETCH_SRC src/modules/cursor.c src/modules/custom.c src/modules/command/command.c - src/modules/date.c - src/modules/datetime.c + src/modules/datetime/datetime.c src/modules/de.c src/modules/disk.c src/modules/font.c @@ -303,7 +302,6 @@ set(LIBFASTFETCH_SRC src/modules/terminal.c src/modules/terminalfont.c src/modules/theme.c - src/modules/time.c src/modules/title/title.c src/modules/uptime.c src/modules/users.c diff --git a/src/common/init.c b/src/common/init.c index b27c17a12..39d840869 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -110,9 +110,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.wifi); initModuleArg(&instance->config.player); initModuleArg(&instance->config.media); - initModuleArg(&instance->config.dateTime); - initModuleArg(&instance->config.date); - initModuleArg(&instance->config.time); + ffInitDateTimeOptions(&instance->config.dateTime); initModuleArg(&instance->config.vulkan); initModuleArg(&instance->config.wallpaper); initModuleArg(&instance->config.openGL); @@ -356,9 +354,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.wifi); destroyModuleArg(&instance->config.player); destroyModuleArg(&instance->config.media); - destroyModuleArg(&instance->config.dateTime); - destroyModuleArg(&instance->config.date); - destroyModuleArg(&instance->config.time); + ffDestroyDateTimeOptions(&instance->config.dateTime); destroyModuleArg(&instance->config.vulkan); destroyModuleArg(&instance->config.openGL); destroyModuleArg(&instance->config.openCL); diff --git a/src/fastfetch.c b/src/fastfetch.c index a8fe3357e..23e06fa39 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1171,9 +1171,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {} else if(optionParseModuleArgs(key, value, "media", &instance->config.media)) {} - else if(optionParseModuleArgs(key, value, "datetime", &instance->config.dateTime)) {} - else if(optionParseModuleArgs(key, value, "date", &instance->config.date)) {} - else if(optionParseModuleArgs(key, value, "time", &instance->config.time)) {} + else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} else if(optionParseModuleArgs(key, value, "vulkan", &instance->config.vulkan)) {} else if(optionParseModuleArgs(key, value, "opengl", &instance->config.openGL)) {} else if(optionParseModuleArgs(key, value, "opencl", &instance->config.openCL)) {} @@ -1471,11 +1469,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "media") == 0) ffPrintMedia(instance); else if(strcasecmp(line, "datetime") == 0) - ffPrintDateTime(instance); - else if(strcasecmp(line, "date") == 0) - ffPrintDate(instance); - else if(strcasecmp(line, "time") == 0) - ffPrintTime(instance); + ffPrintDateTime(instance, &instance->config.dateTime); else if(strcasecmp(line, "colors") == 0) ffPrintColors(instance); else if(strcasecmp(line, "vulkan") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 805a9b46c..c889f8cf7 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -172,9 +172,7 @@ typedef struct FFconfig FFModuleArgs weather; FFModuleArgs player; FFModuleArgs media; - FFModuleArgs dateTime; - FFModuleArgs date; - FFModuleArgs time; + FFDateTimeOptions dateTime; FFModuleArgs vulkan; FFModuleArgs openGL; FFModuleArgs openCL; @@ -291,7 +289,6 @@ void ffLogoBuiltinListAutocompletion(); //Common -void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs); void ffPrepareCPUUsage(); void ffPreparePublicIp(FFinstance* instance); void ffPrepareWeather(FFinstance* instance); @@ -331,7 +328,7 @@ void ffPrintPowerAdapter(FFinstance* instance); void ffPrintLocale(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); -void ffPrintDateTime(FFinstance* instance); +void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); void ffPrintDate(FFinstance* instance); void ffPrintTime(FFinstance* instance); void ffPrintLocalIp(FFinstance* instance); diff --git a/src/modules/date.c b/src/modules/date.c deleted file mode 100644 index a92209ed0..000000000 --- a/src/modules/date.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/datetime/datetime.h" - -#define FF_DATE_MODULE_NAME "Date" - -void ffPrintDate(FFinstance* instance) -{ - if(instance->config.date.outputFormat.length > 0) - { - ffPrintDateTimeFormat(instance, FF_DATE_MODULE_NAME, &instance->config.date); - return; - } - - const FFDateTimeResult* datetime = ffDetectDateTime(instance); - ffPrintLogoAndKey(instance, FF_DATE_MODULE_NAME, 0, &instance->config.date.key); - - //yyyy-mm-dd - printf("%u-%s-%u\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth); -} diff --git a/src/modules/datetime.c b/src/modules/datetime.c deleted file mode 100644 index 968d17725..000000000 --- a/src/modules/datetime.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/datetime/datetime.h" - -#define FF_DATETIME_MODULE_NAME "Date & Time" -#define FF_DATETIME_NUM_FORMAT_ARGS 20 - -void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs) -{ - const FFDateTimeResult* result = ffDetectDateTime(instance); - ffPrintFormat(instance, moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_UINT16, &result->year}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->yearShort}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->month}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthPretty}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthNameShort}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->week}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->weekday}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->weekdayShort}, - {FF_FORMAT_ARG_TYPE_UINT16, &result->dayInYear}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->dayInMonth}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->dayInWeek}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->hour}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->hourPretty}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->hour12}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->hour12Pretty}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->minute}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->minutePretty}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->second}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->secondPretty} - }); -} - -void ffPrintDateTime(FFinstance* instance) -{ - if(instance->config.dateTime.outputFormat.length > 0) - { - ffPrintDateTimeFormat(instance, FF_DATETIME_MODULE_NAME, &instance->config.dateTime); - return; - } - - const FFDateTimeResult* datetime = ffDetectDateTime(instance); - ffPrintLogoAndKey(instance, FF_DATETIME_MODULE_NAME, 0, &instance->config.dateTime.key); - - //yyyy-MM-dd HH:mm:ss - printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); -} diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c new file mode 100644 index 000000000..40d09b851 --- /dev/null +++ b/src/modules/datetime/datetime.c @@ -0,0 +1,102 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/datetime/datetime.h" +#include "modules/datetime/datetime.h" + +#define FF_DATETIME_MODULE_NAME "DateTime" +#define FF_DATETIME_DISPLAY_NAME "Date & Time" +#define FF_DATETIME_NUM_FORMAT_ARGS 20 + +void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs) +{ + const FFDateTimeResult* result = ffDetectDateTime(instance); + ffPrintFormat(instance, moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_UINT16, &result->year}, // 1 + {FF_FORMAT_ARG_TYPE_UINT8, &result->yearShort}, // 2 + {FF_FORMAT_ARG_TYPE_UINT8, &result->month}, // 3 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthPretty}, // 4 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthName}, // 5 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->monthNameShort}, // 6 + {FF_FORMAT_ARG_TYPE_UINT8, &result->week}, // 7 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->weekday}, // 8 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->weekdayShort}, // 9 + {FF_FORMAT_ARG_TYPE_UINT16, &result->dayInYear}, // 10 + {FF_FORMAT_ARG_TYPE_UINT8, &result->dayInMonth}, // 11 + {FF_FORMAT_ARG_TYPE_UINT8, &result->dayInWeek}, // 12 + {FF_FORMAT_ARG_TYPE_UINT8, &result->hour}, // 13 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->hourPretty}, // 14 + {FF_FORMAT_ARG_TYPE_UINT8, &result->hour12}, // 15 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->hour12Pretty}, // 16 + {FF_FORMAT_ARG_TYPE_UINT8, &result->minute}, // 17 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->minutePretty}, // 18 + {FF_FORMAT_ARG_TYPE_UINT8, &result->second}, // 19 + {FF_FORMAT_ARG_TYPE_STRBUF, &result->secondPretty} // 20 + }); +} + +void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options) +{ + if(options->moduleArgs.outputFormat.length > 0) + { + ffPrintDateTimeFormat(instance, FF_DATETIME_DISPLAY_NAME, &options->moduleArgs); + return; + } + + const FFDateTimeResult* datetime = ffDetectDateTime(instance); + ffPrintLogoAndKey(instance, FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key); + + //yyyy-MM-dd HH:mm:ss + printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); +} + +void ffInitDateTimeOptions(FFDateTimeOptions* options) +{ + options->moduleName = FF_DATETIME_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_DATETIME_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyDateTimeOptions(FFDateTimeOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_DATETIME_MODULE_NAME) != 0) + return false; + + FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; + ffInitDateTimeOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintDateTime(instance, &options); + return true; +} +#endif diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h new file mode 100644 index 000000000..aba103d77 --- /dev/null +++ b/src/modules/datetime/datetime.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/datetime/option.h" + +void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); +void ffInitDateTimeOptions(FFDateTimeOptions* options); +bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value); +void ffDestroyDateTimeOptions(FFDateTimeOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/datetime/option.h b/src/modules/datetime/option.h new file mode 100644 index 000000000..1c32501e6 --- /dev/null +++ b/src/modules/datetime/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFDateTimeOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFDateTimeOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 893972315..2f0309d2a 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -15,6 +15,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseTitleJsonObject(instance, type, data, module) || ffParseBatteryJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || + ffParseDateTimeJsonObject(instance, type, data, module) || ffParseOSJsonObject(instance, type, data, module) || ffParseSeparatorJsonObject(instance, type, data, module) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index e2a2b672a..4bd1a79e3 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -5,6 +5,7 @@ #include "modules/os/os.h" #include "modules/battery/battery.h" #include "modules/command/command.h" +#include "modules/datetime/datetime.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index faf052800..157c34cb2 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -3,7 +3,8 @@ // For "fastfetch.h" #include "modules/battery/option.h" -#include "modules/os/option.h" #include "modules/command/option.h" +#include "modules/datetime/option.h" +#include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" diff --git a/src/modules/time.c b/src/modules/time.c deleted file mode 100644 index 523e4fa19..000000000 --- a/src/modules/time.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/datetime/datetime.h" - -#define FF_TIME_MODULE_NAME "Time" - -void ffPrintTime(FFinstance* instance) -{ - if(instance->config.time.outputFormat.length > 0) - { - ffPrintDateTimeFormat(instance, FF_TIME_MODULE_NAME, &instance->config.time); - return; - } - - const FFDateTimeResult* datetime = ffDetectDateTime(instance); - ffPrintLogoAndKey(instance, FF_TIME_MODULE_NAME, 0, &instance->config.time.key); - - //hh:mm:ss - printf("%s:%s:%s\n", datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); -} From 04180a73893775d6e13a1f87cf8dbd9bd63badf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 10:56:36 +0800 Subject: [PATCH 014/493] Display: init support of JSON config --- CMakeLists.txt | 2 +- src/common/config.c | 35 +++ src/common/config.h | 2 + src/common/init.c | 8 +- src/common/option.c | 23 +- src/common/option.h | 12 +- .../displayserver/displayserver_apple.c | 2 +- .../displayserver/displayserver_windows.c | 2 +- src/detection/displayserver/linux/wayland.c | 2 +- src/fastfetch.c | 16 +- src/fastfetch.h | 14 +- src/flashfetch.c | 2 +- src/modules/display.c | 108 --------- src/modules/display/display.c | 218 ++++++++++++++++++ src/modules/display/display.h | 14 ++ src/modules/display/option.h | 22 ++ src/modules/jsonconfig/jsonconfig.c | 2 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 19 files changed, 318 insertions(+), 168 deletions(-) delete mode 100644 src/modules/display.c create mode 100644 src/modules/display/display.c create mode 100644 src/modules/display/display.h create mode 100644 src/modules/display/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 19a202bed..2faf326fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,7 +293,7 @@ set(LIBFASTFETCH_SRC src/modules/poweradapter.c src/modules/processes.c src/modules/publicip.c - src/modules/display.c + src/modules/display/display.c src/modules/separator/separator.c src/modules/shell.c src/modules/sound.c diff --git a/src/common/config.c b/src/common/config.c index f7d124fce..c154583c9 100644 --- a/src/common/config.c +++ b/src/common/config.c @@ -23,4 +23,39 @@ bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* return false; } +const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result, FFKeyValuePair pairs[]) +{ + if (data->ffjson_object_is_type(val, json_type_int)) + { + int intVal = data->ffjson_object_get_int(val); + + for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) + { + if (intVal == pPair->value) + { + *result = pPair->value; + return NULL; + } + } + + return "Invalid enum integer"; + } + else if (data->ffjson_object_is_type(val, json_type_string)) + { + const char* strVal = data->ffjson_object_get_string(val); + for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) + { + if (strcasecmp(strVal, pPair->key) == 0) + { + *result = pPair->value; + return NULL; + } + } + + return "Invalid enum string"; + } + else + return "Invalid enum value type; must be a string or integer"; +} + #endif diff --git a/src/common/config.h b/src/common/config.h index 81dd9c011..d52b88440 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -13,6 +13,7 @@ typedef struct JSONCData FF_LIBRARY_SYMBOL(json_object_get_array) FF_LIBRARY_SYMBOL(json_object_get_boolean) FF_LIBRARY_SYMBOL(json_object_get_double) + FF_LIBRARY_SYMBOL(json_object_get_int) FF_LIBRARY_SYMBOL(json_object_get_string_len) FF_LIBRARY_SYMBOL(json_object_get_string) FF_LIBRARY_SYMBOL(json_object_get_object) @@ -23,5 +24,6 @@ typedef struct JSONCData } JSONCData; bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs); +const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result, FFKeyValuePair pairs[]); #endif diff --git a/src/common/init.c b/src/common/init.c index 39d840869..950f30c1b 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -85,7 +85,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.processes); initModuleArg(&instance->config.packages); initModuleArg(&instance->config.shell); - initModuleArg(&instance->config.display); + ffInitDisplayOptions(&instance->config.display); initModuleArg(&instance->config.de); initModuleArg(&instance->config.wm); initModuleArg(&instance->config.wmTheme); @@ -160,10 +160,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInitA(&instance->config.diskFolders, 0); instance->config.diskShowTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; - instance->config.displayCompactType = FF_DISPLAY_COMPACT_TYPE_NONE; - instance->config.displayDetectName = false; - instance->config.displayPreciseRefreshRate = false; - instance->config.bluetoothShowDisconnected = false; instance->config.soundType = FF_SOUND_TYPE_MAIN; @@ -328,7 +324,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.processes); destroyModuleArg(&instance->config.packages); destroyModuleArg(&instance->config.shell); - destroyModuleArg(&instance->config.display); + ffDestroyDisplayOptions(&instance->config.display); destroyModuleArg(&instance->config.de); destroyModuleArg(&instance->config.wm); destroyModuleArg(&instance->config.wmTheme); diff --git a/src/common/option.c b/src/common/option.c index 81e54c532..3f6c360e4 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -72,7 +72,7 @@ uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value) return num; } -void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...) +int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]) { if(requestedKey == NULL) { @@ -80,27 +80,12 @@ void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* exit(476); } - va_list args; - va_start(args, result); - - while(true) + for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { - const char* key = va_arg(args, const char*); - if(key == NULL) - break; - - int value = va_arg(args, int); //C standard guarantees that enumeration constants are presented as ints - - if(strcasecmp(requestedKey, key) == 0) - { - *(int*)result = value; - va_end(args); - return; - } + if(strcasecmp(requestedKey, pPair->key) == 0) + return pPair->value; } - va_end(args); - fprintf(stderr, "Error: unknown %s value: %s\n", argumentKey, requestedKey); exit(478); } diff --git a/src/common/option.h b/src/common/option.h index b24c278b8..1c56de4d3 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -9,11 +9,17 @@ typedef struct FFModuleArgs FFstrbuf errorFormat; } FFModuleArgs; +typedef struct FFKeyValuePair +{ + const char* key; + int value; +} FFKeyValuePair; + const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName); bool ffOptionParseModuleArgs(const char* argumentKey, const char* pkey, const char* value, FFModuleArgs* result); void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); -uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); -void ffOptionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...); -bool ffOptionParseBoolean(const char* str); +FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); +FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); +FF_C_NODISCARD bool ffOptionParseBoolean(const char* str); void ffOptionInitModuleArg(FFModuleArgs* args); void ffOptionDestroyModuleArg(FFModuleArgs* args); diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index f2d2447aa..05c017a49 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -121,5 +121,5 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufAppendS(&ds->dePrettyName, "Aqua"); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); - detectDisplays(ds, instance->config.displayDetectName); + detectDisplays(ds, instance->config.display.detectName); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 5d93746f5..1ee86ef5d 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -113,7 +113,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufInit(&ds->deVersion); ffListInit(&ds->displays, sizeof(FFDisplayResult)); - detectDisplays(ds, instance->config.displayDetectName); + detectDisplays(ds, instance->config.display.detectName); //https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067 const FFOSResult* os = ffDetectOS(instance); diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 7e7f98fb5..d65fa70a5 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -225,7 +225,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) if(data.display == NULL) return false; - data.detectName = instance->config.displayDetectName; + data.detectName = instance->config.display.detectName; waylandDetectWM(ffwl_display_get_fd(data.display), result); diff --git a/src/fastfetch.c b/src/fastfetch.c index 23e06fa39..071e947a5 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1144,7 +1144,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} else if(optionParseModuleArgs(key, value, "packages", &instance->config.packages)) {} else if(optionParseModuleArgs(key, value, "shell", &instance->config.shell)) {} - else if(optionParseModuleArgs(key, value, "display", &instance->config.display)) {} + else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} else if(optionParseModuleArgs(key, value, "brightness", &instance->config.brightness)) {} else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} else if(optionParseModuleArgs(key, value, "wifi", &instance->config.wifi)) {} @@ -1272,18 +1272,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_SUBVOLUME_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT); else if(strcasecmp(key, "--disk-show-unknown") == 0) optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_UNKNOWN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT); - else if(strcasecmp(key, "--display-compact-type") == 0) - { - optionParseEnum(key, value, &instance->config.displayCompactType, - "none", FF_DISPLAY_COMPACT_TYPE_NONE, - "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT, - "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT, - NULL); - } - else if(strcasecmp(key, "--display-precise-refresh-rate") == 0) - instance->config.displayPreciseRefreshRate = optionParseBoolean(value); - else if(strcasecmp(key, "--display-detect-name") == 0) - instance->config.displayDetectName = optionParseBoolean(value); else if(strcasecmp(key, "--bluetooth-show-disconnected") == 0) instance->config.bluetoothShowDisconnected = optionParseBoolean(value); else if(strcasecmp(key, "--sound-type") == 0) @@ -1417,7 +1405,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "shell") == 0) ffPrintShell(instance); else if(strcasecmp(line, "display") == 0) - ffPrintDisplay(instance); + ffPrintDisplay(instance, &instance->config.display); else if(strcasecmp(line, "desktopenvironment") == 0 || strcasecmp(line, "de") == 0) ffPrintDesktopEnvironment(instance); else if(strcasecmp(line, "windowmanager") == 0 || strcasecmp(line, "wm") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index c889f8cf7..7c1ecf1f2 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -43,13 +43,6 @@ typedef enum FFSoundType FF_SOUND_TYPE_ALL, } FFSoundType; -typedef enum FFDisplayCompactType -{ - FF_DISPLAY_COMPACT_TYPE_NONE = 0, - FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT = 1 << 0, - FF_DISPLAY_COMPACT_TYPE_SCALED_BIT = 1 << 1, -} FFDisplayCompactType; - typedef enum FFLocalIpCompactType { FF_LOCALIP_COMPACT_TYPE_NONE, @@ -146,7 +139,7 @@ typedef struct FFconfig FFModuleArgs processes; FFModuleArgs packages; FFModuleArgs shell; - FFModuleArgs display; + FFDisplayOptions display; FFModuleArgs de; FFModuleArgs wallpaper; FFModuleArgs wifi; @@ -221,10 +214,6 @@ typedef struct FFconfig FFstrbuf diskFolders; FFDiskType diskShowTypes; - FFDisplayCompactType displayCompactType; - bool displayDetectName; - bool displayPreciseRefreshRate; - bool bluetoothShowDisconnected; FFstrbuf localIpNamePrefix; @@ -306,7 +295,6 @@ void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintPackages(FFinstance* instance); void ffPrintShell(FFinstance* instance); -void ffPrintDisplay(FFinstance* instance); void ffPrintBrightness(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 6b961e04a..4ababc3a7 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -32,7 +32,7 @@ int main(int argc, char** argv) //ffPrintProcesses(&instance); ffPrintPackages(&instance); ffPrintShell(&instance); - ffPrintDisplay(&instance); + ffPrintDisplay(&instance, &instance.config.display); // ffPrintBrightness(&instance); ffPrintDesktopEnvironment(&instance); ffPrintWM(&instance); diff --git a/src/modules/display.c b/src/modules/display.c deleted file mode 100644 index f4dddbe1f..000000000 --- a/src/modules/display.c +++ /dev/null @@ -1,108 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/displayserver/displayserver.h" - -#define FF_DISPLAY_MODULE_NAME "Display" -#define FF_DISPLAY_NUM_FORMAT_ARGS 7 - -void ffPrintDisplay(FFinstance* instance) -{ - #ifdef __ANDROID__ - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display, "Display detection is not supported on Android"); - return; - #endif - - const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance); - - if (instance->config.displayCompactType != FF_DISPLAY_COMPACT_TYPE_NONE) - { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.key); - - int index = 0; - FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays) - { - if (instance->config.displayCompactType & FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT) - { - if (index++) putchar(' '); - printf("%ix%i", result->width, result->height); - } - if (instance->config.displayCompactType & FF_DISPLAY_COMPACT_TYPE_SCALED_BIT) - { - if (index++) putchar(' '); - printf("%ix%i", result->scaledWidth, result->scaledHeight); - } - ffStrbufDestroy(&result->name); - } - putchar('\n'); - return; - } - - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); - - for(uint32_t i = 0; i < dsResult->displays.length; i++) - { - FFDisplayResult* result = ffListGet(&dsResult->displays, i); - uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1); - const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external"; - - if(instance->config.display.outputFormat.length == 0) - { - if(result->name.length || (moduleIndex > 0 && displayType)) - { - ffStrbufClear(&key); - if(instance->config.display.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); - } - else - { - ffParseFormatString(&key, &instance->config.display.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &i}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, - {FF_FORMAT_ARG_TYPE_STRING, displayType}, - }); - } - ffPrintLogoAndKey(instance, key.chars, 0, NULL); - } - else - { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &instance->config.display.key); - } - - printf("%ix%i", result->width, result->height); - - if(result->refreshRate > 0) - { - if(instance->config.displayPreciseRefreshRate) - printf(" @ %gHz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0); - else - printf(" @ %iHz", (uint32_t) (result->refreshRate + 0.5)); - } - - if( - result->scaledWidth > 0 && result->scaledWidth != result->width && - result->scaledHeight > 0 && result->scaledHeight != result->height) - printf(" (as %ix%i)", result->scaledWidth, result->scaledHeight); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &instance->config.display, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_UINT, &result->width}, - {FF_FORMAT_ARG_TYPE_UINT, &result->height}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate}, - {FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth}, - {FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, - {FF_FORMAT_ARG_TYPE_STRING, displayType}, - }); - } - - ffStrbufDestroy(&result->name); - } - - if(dsResult->displays.length == 0) - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display, "Couldn't detect display"); -} diff --git a/src/modules/display/display.c b/src/modules/display/display.c new file mode 100644 index 000000000..72330878c --- /dev/null +++ b/src/modules/display/display.c @@ -0,0 +1,218 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/displayserver/displayserver.h" +#include "modules/display/display.h" + +#define FF_DISPLAY_MODULE_NAME "Display" +#define FF_DISPLAY_NUM_FORMAT_ARGS 7 + +void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) +{ + #ifdef __ANDROID__ + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Display detection is not supported on Android"); + return; + #endif + + const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance); + + if(dsResult->displays.length == 0) + { + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Couldn't detect display"); + return; + } + + if (options->compactType != FF_DISPLAY_COMPACT_TYPE_NONE) + { + ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key); + + int index = 0; + FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays) + { + if (options->compactType & FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT) + { + if (index++) putchar(' '); + printf("%ix%i", result->width, result->height); + } + if (options->compactType & FF_DISPLAY_COMPACT_TYPE_SCALED_BIT) + { + if (index++) putchar(' '); + printf("%ix%i", result->scaledWidth, result->scaledHeight); + } + ffStrbufDestroy(&result->name); + } + putchar('\n'); + return; + } + + FF_STRBUF_AUTO_DESTROY key; + ffStrbufInit(&key); + + for(uint32_t i = 0; i < dsResult->displays.length; i++) + { + FFDisplayResult* result = ffListGet(&dsResult->displays, i); + uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1); + const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external"; + + if(options->moduleArgs.outputFormat.length == 0) + { + if(result->name.length || (moduleIndex > 0 && displayType)) + { + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &i}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, + }); + } + ffPrintLogoAndKey(instance, key.chars, 0, NULL); + } + else + { + ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs.key); + } + + printf("%ix%i", result->width, result->height); + + if(result->refreshRate > 0) + { + if(options->preciseRefreshRate) + printf(" @ %gHz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0); + else + printf(" @ %iHz", (uint32_t) (result->refreshRate + 0.5)); + } + + if( + result->scaledWidth > 0 && result->scaledWidth != result->width && + result->scaledHeight > 0 && result->scaledHeight != result->height) + printf(" (as %ix%i)", result->scaledWidth, result->scaledHeight); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_UINT, &result->width}, + {FF_FORMAT_ARG_TYPE_UINT, &result->height}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate}, + {FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth}, + {FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, + }); + } + + ffStrbufDestroy(&result->name); + } +} + +void ffInitDisplayOptions(FFDisplayOptions* options) +{ + options->moduleName = FF_DISPLAY_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE; + options->detectName = false; + options->preciseRefreshRate = false; +} + +bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_DISPLAY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "compact-type") == 0) + { + options->compactType = (FFDisplayCompactType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, + { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, + { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, + {}, + }); + return true; + } + + if (strcasecmp(subKey, "detect-name") == 0) + { + options->detectName = ffOptionParseBoolean(value); + return true; + } + + if (strcasecmp(subKey, "precise-refresh-rate") == 0) + { + options->preciseRefreshRate = ffOptionParseBoolean(value); + return true; + } + + return false; +} + +void ffDestroyDisplayOptions(FFDisplayOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_DISPLAY_MODULE_NAME) != 0) + return false; + + FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; + ffInitDisplayOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "compactType") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(data, val, &value, (FFKeyValuePair[]) { + { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, + { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, + { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, + {}, + }); + if (error) + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.compactType = (FFDisplayCompactType) value; + continue; + } + + if (strcasecmp(key, "detectName") == 0) + { + options.detectName = data->ffjson_object_get_boolean(val); + continue; + } + + if (strcasecmp(key, "preciseRefreshRate") == 0) + { + options.preciseRefreshRate = data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintDisplay(instance, &options); + return true; +} +#endif diff --git a/src/modules/display/display.h b/src/modules/display/display.h new file mode 100644 index 000000000..7ee6d65d1 --- /dev/null +++ b/src/modules/display/display.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/display/option.h" + +void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options); +void ffInitDisplayOptions(FFDisplayOptions* options); +bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value); +void ffDestroyDisplayOptions(FFDisplayOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/display/option.h b/src/modules/display/option.h new file mode 100644 index 000000000..4e47b1bee --- /dev/null +++ b/src/modules/display/option.h @@ -0,0 +1,22 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFDisplayCompactType +{ + FF_DISPLAY_COMPACT_TYPE_NONE = 0, + FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT = 1 << 0, + FF_DISPLAY_COMPACT_TYPE_SCALED_BIT = 1 << 1, +} FFDisplayCompactType; + +typedef struct FFDisplayOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFDisplayCompactType compactType; + bool detectName; + bool preciseRefreshRate; +} FFDisplayOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 2f0309d2a..c7a4aec6f 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -16,6 +16,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseBatteryJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || + ffParseDisplayJsonObject(instance, type, data, module) || ffParseOSJsonObject(instance, type, data, module) || ffParseSeparatorJsonObject(instance, type, data, module) || false; @@ -72,6 +73,7 @@ static const char* printJsonConfig(FFinstance* instance) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_boolean) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_int) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_object) diff --git a/src/modules/modules.h b/src/modules/modules.h index 4bd1a79e3..5235729f4 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -6,6 +6,7 @@ #include "modules/battery/battery.h" #include "modules/command/command.h" #include "modules/datetime/datetime.h" +#include "modules/display/display.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index 157c34cb2..a929492cb 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -5,6 +5,7 @@ #include "modules/battery/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" +#include "modules/display/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" From 9c066e94948b08a8a1f36502645c3379d1df168f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 11:26:53 +0800 Subject: [PATCH 015/493] Host: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 4 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/host.c | 55 -------------- src/modules/host/host.c | 108 ++++++++++++++++++++++++++++ src/modules/host/host.h | 14 ++++ src/modules/host/option.h | 11 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 143 insertions(+), 63 deletions(-) delete mode 100644 src/modules/host.c create mode 100644 src/modules/host/host.c create mode 100644 src/modules/host/host.h create mode 100644 src/modules/host/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2faf326fe..60acb6ca4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,7 @@ set(LIBFASTFETCH_SRC src/modules/disk.c src/modules/font.c src/modules/gpu.c - src/modules/host.c + src/modules/host/host.c src/modules/icons.c src/modules/gamepad.c src/modules/kernel.c diff --git a/src/common/init.c b/src/common/init.c index 950f30c1b..1441b84c8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -74,7 +74,7 @@ static void defaultConfig(FFinstance* instance) ffInitTitleOptions(&instance->config.title); ffInitOSOptions(&instance->config.os); - initModuleArg(&instance->config.host); + ffInitHostOptions(&instance->config.host); initModuleArg(&instance->config.bios); initModuleArg(&instance->config.board); initModuleArg(&instance->config.brightness); @@ -314,7 +314,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyTitleOptions(&instance->config.title); ffDestroyOSOptions(&instance->config.os); - destroyModuleArg(&instance->config.host); + ffDestroyHostOptions(&instance->config.host); destroyModuleArg(&instance->config.bios); destroyModuleArg(&instance->config.board); destroyModuleArg(&instance->config.chassis); diff --git a/src/fastfetch.c b/src/fastfetch.c index 071e947a5..d6a31b5a4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1134,7 +1134,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con /////////////////////// else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} - else if(optionParseModuleArgs(key, value, "host", &instance->config.host)) {} + else if(ffParseHostCommandOptions(&instance->config.host, key, value)) {} else if(optionParseModuleArgs(key, value, "bios", &instance->config.bios)) {} else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} @@ -1385,7 +1385,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "os") == 0) ffPrintOS(instance, &instance->config.os); else if(strcasecmp(line, "host") == 0) - ffPrintHost(instance); + ffPrintHost(instance, &instance->config.host); else if(strcasecmp(line, "bios") == 0) ffPrintBios(instance); else if(strcasecmp(line, "board") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 7c1ecf1f2..3f405892b 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -128,7 +128,7 @@ typedef struct FFconfig FFTitleOptions title; FFOSOptions os; - FFModuleArgs host; + FFHostOptions host; FFModuleArgs bios; FFModuleArgs board; FFModuleArgs brightness; @@ -286,7 +286,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); -void ffPrintHost(FFinstance* instance); void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); void ffPrintChassis(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 4ababc3a7..8942113d9 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) ffPrintTitle(&instance, &instance.config.title); ffPrintSeparator(&instance, &instance.config.separator); ffPrintOS(&instance, &instance.config.os); - ffPrintHost(&instance); + ffPrintHost(&instance, &instance.config.host); //ffPrintBios(&instance); //ffPrintBoard(&instance); //ffPrintChassis(&instance); diff --git a/src/modules/host.c b/src/modules/host.c deleted file mode 100644 index 9fa3bafee..000000000 --- a/src/modules/host.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/host/host.h" - -#define FF_HOST_MODULE_NAME "Host" -#define FF_HOST_NUM_FORMAT_ARGS 5 - -void ffPrintHost(FFinstance* instance) -{ - const FFHostResult* host = ffDetectHost(); - - if(host->error.length > 0) - { - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, "%*s", host->error.length, host->error.chars); - return; - } - - if(host->productFamily.length == 0 && host->productName.length == 0) - { - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, "neither product_family nor product_name is set by O.E.M."); - return; - } - - if(instance->config.host.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host.key); - - FFstrbuf output; - ffStrbufInit(&output); - - if(host->productName.length > 0) - ffStrbufAppend(&output, &host->productName); - else - ffStrbufAppend(&output, &host->productFamily); - - if(host->productVersion.length > 0 && !ffStrbufIgnCaseEqualS(&host->productVersion, "none")) - { - ffStrbufAppendF(&output, " (%s)", host->productVersion.chars); - } - - ffStrbufPutTo(&output, stdout); - - ffStrbufDestroy(&output); - } - else - { - ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor} - }); - } -} diff --git a/src/modules/host/host.c b/src/modules/host/host.c new file mode 100644 index 000000000..d4a498c13 --- /dev/null +++ b/src/modules/host/host.c @@ -0,0 +1,108 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/host/host.h" +#include "modules/host/host.h" + +#define FF_HOST_MODULE_NAME "Host" +#define FF_HOST_NUM_FORMAT_ARGS 5 + +void ffPrintHost(FFinstance* instance, FFHostOptions* options) +{ + const FFHostResult* host = ffDetectHost(); + + if(host->error.length > 0) + { + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%*s", host->error.length, host->error.chars); + return; + } + + if(host->productFamily.length == 0 && host->productName.length == 0) + { + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "neither product_family nor product_name is set by O.E.M."); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key); + + FFstrbuf output; + ffStrbufInit(&output); + + if(host->productName.length > 0) + ffStrbufAppend(&output, &host->productName); + else + ffStrbufAppend(&output, &host->productFamily); + + if(host->productVersion.length > 0 && !ffStrbufIgnCaseEqualS(&host->productVersion, "none")) + { + ffStrbufAppendF(&output, " (%s)", host->productVersion.chars); + } + + ffStrbufPutTo(&output, stdout); + + ffStrbufDestroy(&output); + } + else + { + ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host->productName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor} + }); + } +} + +void ffInitHostOptions(FFHostOptions* options) +{ + options->moduleName = FF_HOST_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_HOST_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyHostOptions(FFHostOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_HOST_MODULE_NAME) != 0) + return false; + + FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; + ffInitHostOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintHost(instance, &options); + return true; +} +#endif diff --git a/src/modules/host/host.h b/src/modules/host/host.h new file mode 100644 index 000000000..05b06d422 --- /dev/null +++ b/src/modules/host/host.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/host/option.h" + +void ffPrintHost(FFinstance* instance, FFHostOptions* options); +void ffInitHostOptions(FFHostOptions* options); +bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value); +void ffDestroyHostOptions(FFHostOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/host/option.h b/src/modules/host/option.h new file mode 100644 index 000000000..59073e934 --- /dev/null +++ b/src/modules/host/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFHostOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFHostOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index c7a4aec6f..55d9df3b6 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -17,6 +17,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || + ffParseHostJsonObject(instance, type, data, module) || ffParseOSJsonObject(instance, type, data, module) || ffParseSeparatorJsonObject(instance, type, data, module) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index 5235729f4..4bbddcb83 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -7,6 +7,7 @@ #include "modules/command/command.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" +#include "modules/host/host.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index a929492cb..7a2509aa5 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -6,6 +6,7 @@ #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" +#include "modules/host/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" From 169785a8bb426dc9b672bdbb5f45a1bb8a4b3641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 14:14:32 +0800 Subject: [PATCH 016/493] Kernel: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 4 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/kernel.c | 30 ----------- src/modules/kernel/kernel.c | 83 +++++++++++++++++++++++++++++ src/modules/kernel/kernel.h | 14 +++++ src/modules/kernel/option.h | 11 ++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 118 insertions(+), 38 deletions(-) delete mode 100644 src/modules/kernel.c create mode 100644 src/modules/kernel/kernel.c create mode 100644 src/modules/kernel/kernel.h create mode 100644 src/modules/kernel/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 60acb6ca4..a3f582051 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,7 +281,7 @@ set(LIBFASTFETCH_SRC src/modules/host/host.c src/modules/icons.c src/modules/gamepad.c - src/modules/kernel.c + src/modules/kernel/kernel.c src/modules/locale.c src/modules/localip.c src/modules/memory.c diff --git a/src/common/init.c b/src/common/init.c index 1441b84c8..4dace7205 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -80,7 +80,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.brightness); initModuleArg(&instance->config.chassis); ffInitCommandOptions(&instance->config.command); - initModuleArg(&instance->config.kernel); + ffInitKernelOptions(&instance->config.kernel); initModuleArg(&instance->config.uptime); initModuleArg(&instance->config.processes); initModuleArg(&instance->config.packages); @@ -319,7 +319,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.board); destroyModuleArg(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); - destroyModuleArg(&instance->config.kernel); + ffDestroyKernelOptions(&instance->config.kernel); destroyModuleArg(&instance->config.uptime); destroyModuleArg(&instance->config.processes); destroyModuleArg(&instance->config.packages); diff --git a/src/fastfetch.c b/src/fastfetch.c index d6a31b5a4..2c1582950 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1139,7 +1139,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} - else if(optionParseModuleArgs(key, value, "kernel", &instance->config.kernel)) {} + else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} else if(optionParseModuleArgs(key, value, "uptime", &instance->config.uptime)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} else if(optionParseModuleArgs(key, value, "packages", &instance->config.packages)) {} @@ -1395,7 +1395,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "chassis") == 0) ffPrintChassis(instance); else if(strcasecmp(line, "kernel") == 0) - ffPrintKernel(instance); + ffPrintKernel(instance, &instance->config.kernel); else if(strcasecmp(line, "uptime") == 0) ffPrintUptime(instance); else if(strcasecmp(line, "processes") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3f405892b..c91395b06 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -134,7 +134,7 @@ typedef struct FFconfig FFModuleArgs brightness; FFModuleArgs chassis; FFCommandOptions command; - FFModuleArgs kernel; + FFKernelOptions kernel; FFModuleArgs uptime; FFModuleArgs processes; FFModuleArgs packages; @@ -289,7 +289,6 @@ void ffPrintBreak(FFinstance* instance); void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); void ffPrintChassis(FFinstance* instance); -void ffPrintKernel(FFinstance* instance); void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintPackages(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 8942113d9..034fea0ff 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -27,7 +27,7 @@ int main(int argc, char** argv) //ffPrintBios(&instance); //ffPrintBoard(&instance); //ffPrintChassis(&instance); - ffPrintKernel(&instance); + ffPrintKernel(&instance, &instance.config.kernel); ffPrintUptime(&instance); //ffPrintProcesses(&instance); ffPrintPackages(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 55d9df3b6..8b2876db3 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -18,6 +18,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || ffParseHostJsonObject(instance, type, data, module) || + ffParseKernelJsonObject(instance, type, data, module) || ffParseOSJsonObject(instance, type, data, module) || ffParseSeparatorJsonObject(instance, type, data, module) || false; diff --git a/src/modules/kernel.c b/src/modules/kernel.c deleted file mode 100644 index bc1139833..000000000 --- a/src/modules/kernel.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" - -#define FF_KERNEL_MODULE_NAME "Kernel" -#define FF_KERNEL_NUM_FORMAT_ARGS 4 - -void ffPrintKernel(FFinstance* instance) -{ - if(instance->config.kernel.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel.key); - ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout); - - #ifdef _WIN32 - if(instance->state.platform.systemVersion.length > 0) - printf(" (%s)", instance->state.platform.systemVersion.chars); - #endif - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemRelease}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture} - }); - } -} diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c new file mode 100644 index 000000000..31f206581 --- /dev/null +++ b/src/modules/kernel/kernel.c @@ -0,0 +1,83 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "modules/kernel/kernel.h" + +#define FF_KERNEL_MODULE_NAME "Kernel" +#define FF_KERNEL_NUM_FORMAT_ARGS 4 + +void ffPrintKernel(FFinstance* instance, FFKernelOptions* options) +{ + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout); + + #ifdef _WIN32 + if(instance->state.platform.systemVersion.length > 0) + printf(" (%s)", instance->state.platform.systemVersion.chars); + #endif + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemRelease}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture} + }); + } +} + +void ffInitKernelOptions(FFKernelOptions* options) +{ + options->moduleName = FF_KERNEL_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_KERNEL_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyKernelOptions(FFKernelOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_KERNEL_MODULE_NAME) != 0) + return false; + + FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; + ffInitKernelOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintKernel(instance, &options); + return true; +} +#endif diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h new file mode 100644 index 000000000..7d3b55b35 --- /dev/null +++ b/src/modules/kernel/kernel.h @@ -0,0 +1,14 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/kernel/option.h" + +void ffPrintKernel(FFinstance* instance, FFKernelOptions* options); +void ffInitKernelOptions(FFKernelOptions* options); +bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value); +void ffDestroyKernelOptions(FFKernelOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/kernel/option.h b/src/modules/kernel/option.h new file mode 100644 index 000000000..434c3069d --- /dev/null +++ b/src/modules/kernel/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFKernelOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFKernelOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index 4bbddcb83..cbfdc0ca6 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -8,6 +8,7 @@ #include "modules/datetime/datetime.h" #include "modules/display/display.h" #include "modules/host/host.h" +#include "modules/kernel/kernel.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index 7a2509aa5..2bf008d66 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -7,6 +7,7 @@ #include "modules/datetime/option.h" #include "modules/display/option.h" #include "modules/host/option.h" +#include "modules/kernel/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" From 0377793102e3cc78eb358859bd8988ea03e5e236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 14:17:46 +0800 Subject: [PATCH 017/493] JsonConfig: use `.jsonc` as config file extension to prevent text editors from confusing --- src/modules/jsonconfig/jsonconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 8b2876db3..e4037cc17 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -87,7 +87,7 @@ static const char* printJsonConfig(FFinstance* instance) FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) { uint32_t oldLength = filename->length; - ffStrbufAppendS(filename, "fastfetch/config.json"); + ffStrbufAppendS(filename, "fastfetch/config.jsonc"); bool success = ffAppendFileBuffer(filename->chars, &content); ffStrbufSubstrBefore(filename, oldLength); if (success) break; From 76da3d811c04dc25f9d2e140b948ef03bf9f3690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 14:38:49 +0800 Subject: [PATCH 018/493] Modules: remove unnecessary `#include` --- src/modules/battery/battery.h | 1 - src/modules/command/command.h | 1 - src/modules/datetime/datetime.h | 1 - src/modules/display/display.h | 1 - src/modules/host/host.h | 1 - 5 files changed, 5 deletions(-) diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index 14d31c3f0..20d76a50b 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include "modules/battery/option.h" void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); diff --git a/src/modules/command/command.h b/src/modules/command/command.h index adbf29d04..de894975b 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include "modules/command/option.h" void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); void ffInitCommandOptions(FFCommandOptions* options); diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index aba103d77..7536e3da7 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include "modules/datetime/option.h" void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); void ffInitDateTimeOptions(FFDateTimeOptions* options); diff --git a/src/modules/display/display.h b/src/modules/display/display.h index 7ee6d65d1..bb09d0e5f 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include "modules/display/option.h" void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options); void ffInitDisplayOptions(FFDisplayOptions* options); diff --git a/src/modules/host/host.h b/src/modules/host/host.h index 05b06d422..c2a0ca695 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include "modules/host/option.h" void ffPrintHost(FFinstance* instance, FFHostOptions* options); void ffInitHostOptions(FFHostOptions* options); From ae08966d40c7c0e52ab4fe67d53bcb0465c24070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 14:48:09 +0800 Subject: [PATCH 019/493] Bios: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 4 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/bios.c | 46 -------------- src/modules/bios/bios.c | 99 +++++++++++++++++++++++++++++ src/modules/bios/bios.h | 13 ++++ src/modules/bios/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 133 insertions(+), 54 deletions(-) delete mode 100644 src/modules/bios.c create mode 100644 src/modules/bios/bios.c create mode 100644 src/modules/bios/bios.h create mode 100644 src/modules/bios/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a3f582051..7663965af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,7 +261,7 @@ set(LIBFASTFETCH_SRC src/logo/image/image.c src/logo/logo.c src/modules/battery/battery.c - src/modules/bios.c + src/modules/bios/bios.c src/modules/bluetooth.c src/modules/board.c src/modules/brightness.c diff --git a/src/common/init.c b/src/common/init.c index 4dace7205..aa427b2d0 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -75,7 +75,7 @@ static void defaultConfig(FFinstance* instance) ffInitTitleOptions(&instance->config.title); ffInitOSOptions(&instance->config.os); ffInitHostOptions(&instance->config.host); - initModuleArg(&instance->config.bios); + ffInitBiosOptions(&instance->config.bios); initModuleArg(&instance->config.board); initModuleArg(&instance->config.brightness); initModuleArg(&instance->config.chassis); @@ -315,7 +315,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyTitleOptions(&instance->config.title); ffDestroyOSOptions(&instance->config.os); ffDestroyHostOptions(&instance->config.host); - destroyModuleArg(&instance->config.bios); + ffDestroyBiosOptions(&instance->config.bios); destroyModuleArg(&instance->config.board); destroyModuleArg(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); diff --git a/src/fastfetch.c b/src/fastfetch.c index 2c1582950..bc6528567 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1135,7 +1135,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(ffParseHostCommandOptions(&instance->config.host, key, value)) {} - else if(optionParseModuleArgs(key, value, "bios", &instance->config.bios)) {} + else if(ffParseBiosCommandOptions(&instance->config.bios, key, value)) {} else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} @@ -1387,7 +1387,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "host") == 0) ffPrintHost(instance, &instance->config.host); else if(strcasecmp(line, "bios") == 0) - ffPrintBios(instance); + ffPrintBios(instance, &instance->config.bios); else if(strcasecmp(line, "board") == 0) ffPrintBoard(instance); else if(strcasecmp(line, "brightness") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index c91395b06..79dd8a0f3 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -129,7 +129,7 @@ typedef struct FFconfig FFTitleOptions title; FFOSOptions os; FFHostOptions host; - FFModuleArgs bios; + FFBiosOptions bios; FFModuleArgs board; FFModuleArgs brightness; FFModuleArgs chassis; @@ -286,7 +286,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); -void ffPrintBios(FFinstance* instance); void ffPrintBoard(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintUptime(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 034fea0ff..9c24a9ee8 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) ffPrintSeparator(&instance, &instance.config.separator); ffPrintOS(&instance, &instance.config.os); ffPrintHost(&instance, &instance.config.host); - //ffPrintBios(&instance); + //ffPrintBios(&instance, &instance.config.bios); //ffPrintBoard(&instance); //ffPrintChassis(&instance); ffPrintKernel(&instance, &instance.config.kernel); diff --git a/src/modules/bios.c b/src/modules/bios.c deleted file mode 100644 index 7b3853355..000000000 --- a/src/modules/bios.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/bios/bios.h" - -#define FF_BIOS_MODULE_NAME "Bios" -#define FF_BIOS_NUM_FORMAT_ARGS 4 - -void ffPrintBios(FFinstance* instance) -{ - FFBiosResult result; - ffDetectBios(&result); - - if(result.error.length > 0) - { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios, "%*s", result.error.length, result.error.chars); - goto exit; - } - - if(result.biosRelease.length == 0) - { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios, "bios_release is not set."); - goto exit; - } - - if(instance->config.bios.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios.key); - puts(result.biosRelease.chars); - } - else - { - ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosDate}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosRelease}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVersion}, - }); - } - -exit: - ffStrbufDestroy(&result.biosDate); - ffStrbufDestroy(&result.biosRelease); - ffStrbufDestroy(&result.biosVendor); - ffStrbufDestroy(&result.biosVersion); - ffStrbufDestroy(&result.error); -} diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c new file mode 100644 index 000000000..718e404a9 --- /dev/null +++ b/src/modules/bios/bios.c @@ -0,0 +1,99 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/bios/bios.h" +#include "modules/bios/bios.h" + +#define FF_BIOS_MODULE_NAME "Bios" +#define FF_BIOS_NUM_FORMAT_ARGS 4 + +void ffPrintBios(FFinstance* instance, FFBiosOptions* options) +{ + FFBiosResult result; + ffDetectBios(&result); + + if(result.error.length > 0) + { + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + goto exit; + } + + if(result.biosRelease.length == 0) + { + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_release is not set."); + goto exit; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key); + puts(result.biosRelease.chars); + } + else + { + ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosDate}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosRelease}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVersion}, + }); + } + +exit: + ffStrbufDestroy(&result.biosDate); + ffStrbufDestroy(&result.biosRelease); + ffStrbufDestroy(&result.biosVendor); + ffStrbufDestroy(&result.biosVersion); + ffStrbufDestroy(&result.error); +} + +void ffInitBiosOptions(FFBiosOptions* options) +{ + options->moduleName = FF_BIOS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_BIOS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyBiosOptions(FFBiosOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_BIOS_MODULE_NAME) != 0) + return false; + + FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; + ffInitBiosOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintBios(instance, &options); + return true; +} +#endif diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h new file mode 100644 index 000000000..c751285c5 --- /dev/null +++ b/src/modules/bios/bios.h @@ -0,0 +1,13 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintBios(FFinstance* instance, FFBiosOptions* options); +void ffInitBiosOptions(FFBiosOptions* options); +bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value); +void ffDestroyBiosOptions(FFBiosOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/bios/option.h b/src/modules/bios/option.h new file mode 100644 index 000000000..6c0f67420 --- /dev/null +++ b/src/modules/bios/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFBiosOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFBiosOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index e4037cc17..bd062ae7d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -14,6 +14,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, return ffParseTitleJsonObject(instance, type, data, module) || ffParseBatteryJsonObject(instance, type, data, module) || + ffParseBiosJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || diff --git a/src/modules/modules.h b/src/modules/modules.h index cbfdc0ca6..be6bac672 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -4,6 +4,7 @@ #include "modules/os/os.h" #include "modules/battery/battery.h" +#include "modules/bios/bios.h" #include "modules/command/command.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" diff --git a/src/modules/options.h b/src/modules/options.h index 2bf008d66..1b7502204 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -3,6 +3,7 @@ // For "fastfetch.h" #include "modules/battery/option.h" +#include "modules/bios/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From e812380f20b0c77e4aa444705c41bd2f82bf491d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Mar 2023 17:49:03 +0800 Subject: [PATCH 020/493] Logo: move logo command line option parser to a separate file Prepare for JSON config support --- CMakeLists.txt | 1 + src/common/init.c | 25 +----- src/common/option.c | 38 +++++++++ src/common/option.h | 1 + src/fastfetch.c | 128 +------------------------------ src/fastfetch.h | 41 +--------- src/logo/logo.c | 90 +++++++++++++--------- src/logo/logo.h | 5 ++ src/logo/option.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ src/logo/option.h | 41 ++++++++++ 10 files changed, 331 insertions(+), 222 deletions(-) create mode 100644 src/logo/option.c create mode 100644 src/logo/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7663965af..b3b487584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,6 +260,7 @@ set(LIBFASTFETCH_SRC src/logo/image/im7.c src/logo/image/image.c src/logo/logo.c + src/logo/option.c src/modules/battery/battery.c src/modules/bios/bios.c src/modules/bluetooth.c diff --git a/src/common/init.c b/src/common/init.c index aa427b2d0..8d2e7a48f 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -3,6 +3,7 @@ #include "common/thread.h" #include "detection/displayserver/displayserver.h" #include "util/textModifier.h" +#include "logo/logo.h" #include #include @@ -36,23 +37,7 @@ static void initModuleArg(FFModuleArgs* args) static void defaultConfig(FFinstance* instance) { - ffStrbufInitA(&instance->config.logo.source, 0); - instance->config.logo.type = FF_LOGO_TYPE_AUTO; - for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i) - ffStrbufInit(&instance->config.logo.colors[i]); - instance->config.logo.width = 0; - instance->config.logo.height = 0; //preserve aspect ratio - instance->config.logo.paddingTop = 0; - instance->config.logo.paddingLeft = 0; - instance->config.logo.paddingRight = 4; - instance->config.logo.printRemaining = true; - instance->config.logo.preserveAspectRadio = false; - - instance->config.logo.chafaFgOnly = false; - ffStrbufInitS(&instance->config.logo.chafaSymbols, "block+border+space-wide-inverted"); // Chafa default - instance->config.logo.chafaCanvasMode = UINT32_MAX; - instance->config.logo.chafaColorSpace = UINT32_MAX; - instance->config.logo.chafaDitherMode = UINT32_MAX; + ffInitLogoOptions(&instance->config.logo); ffStrbufInit(&instance->config.colorKeys); ffStrbufInit(&instance->config.colorTitle); @@ -304,10 +289,8 @@ static void destroyModuleArg(FFModuleArgs* args) static void destroyConfig(FFinstance* instance) { - ffStrbufDestroy(&instance->config.logo.source); - ffStrbufDestroy(&instance->config.logo.chafaSymbols); - for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i) - ffStrbufDestroy(&instance->config.logo.colors[i]); + ffDestroyLogoOptions(&instance->config.logo); + ffStrbufDestroy(&instance->config.colorKeys); ffStrbufDestroy(&instance->config.colorTitle); ffStrbufDestroy(&instance->config.keyValueSeparator); diff --git a/src/common/option.c b/src/common/option.c index 3f6c360e4..e151788be 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -14,6 +14,10 @@ const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) return NULL; subKey += moduleNameLen; + + if(subKey[0] == '\0') + return subKey; + if(subKey[0] != '-') return NULL; @@ -101,6 +105,40 @@ bool ffOptionParseBoolean(const char* str) ); } +void ffOptionParseColor(const char* key, const char* value, FFstrbuf* buffer) +{ + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", key); + exit(477); + } + ffStrbufEnsureFree(buffer, 63); + + while(*value != '\0') + { + #define FF_APPEND_COLOR_CODE_COND(prefix, code) \ + if(strncasecmp(value, #prefix, strlen(#prefix))) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); } + + FF_APPEND_COLOR_CODE_COND(reset_, "0;") + else FF_APPEND_COLOR_CODE_COND(bright_, "1;") + else FF_APPEND_COLOR_CODE_COND(black, "30") + else FF_APPEND_COLOR_CODE_COND(red, "31") + else FF_APPEND_COLOR_CODE_COND(green, "32") + else FF_APPEND_COLOR_CODE_COND(yellow, "33") + else FF_APPEND_COLOR_CODE_COND(blue, "34") + else FF_APPEND_COLOR_CODE_COND(magenta, "35") + else FF_APPEND_COLOR_CODE_COND(cyan, "36") + else FF_APPEND_COLOR_CODE_COND(white, "37") + else + { + ffStrbufAppendC(buffer, *value); + ++value; + } + + #undef FF_APPEND_COLOR_CODE_COND + } +} + void ffOptionInitModuleArg(FFModuleArgs* args) { ffStrbufInit(&args->key); diff --git a/src/common/option.h b/src/common/option.h index 1c56de4d3..0c8d29b1b 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -21,5 +21,6 @@ void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* b FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); FF_C_NODISCARD bool ffOptionParseBoolean(const char* str); +void ffOptionParseColor(const char* key, const char* value, FFstrbuf* buffer); void ffOptionInitModuleArg(FFModuleArgs* args); void ffOptionDestroyModuleArg(FFModuleArgs* args); diff --git a/src/fastfetch.c b/src/fastfetch.c index bc6528567..eb9ab31c9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -5,6 +5,7 @@ #include "common/time.h" #include "util/FFvaluestore.h" #include "util/stringUtils.h" +#include "logo/logo.h" #include #include @@ -965,132 +966,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Logo options// //////////////// - else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - - //this is usally wanted when using the none logo - if(strcasecmp(value, "none") == 0) - { - instance->config.logo.paddingTop = 0; - instance->config.logo.paddingRight = 0; - instance->config.logo.paddingLeft = 0; - instance->config.logo.type = FF_LOGO_TYPE_NONE; - } - } - else if(startsWith(key, "--logo")) - { - const char* subkey = key + strlen("--logo"); - if(strcasecmp(subkey, "-type") == 0) - { - optionParseEnum(key, value, &instance->config.logo.type, - "auto", FF_LOGO_TYPE_AUTO, - "builtin", FF_LOGO_TYPE_BUILTIN, - "file", FF_LOGO_TYPE_FILE, - "file-raw", FF_LOGO_TYPE_FILE_RAW, - "data", FF_LOGO_TYPE_DATA, - "data-raw", FF_LOGO_TYPE_DATA_RAW, - "sixel", FF_LOGO_TYPE_IMAGE_SIXEL, - "kitty", FF_LOGO_TYPE_IMAGE_KITTY, - "iterm", FF_LOGO_TYPE_IMAGE_ITERM, - "chafa", FF_LOGO_TYPE_IMAGE_CHAFA, - "raw", FF_LOGO_TYPE_IMAGE_RAW, - "none", FF_LOGO_TYPE_NONE, - NULL - ); - } - else if(startsWith(subkey, "-color-") && key[13] != '\0' && key[14] == '\0') // matches "--logo-color-*" - { - //Map the number to an array index, so that '1' -> 0, '2' -> 1, etc. - int index = (int)key[13] - 49; - - //Match only --logo-color-[1-9] - if(index < 0 || index >= FASTFETCH_LOGO_MAX_COLORS) - { - fprintf(stderr, "Error: invalid --color-[1-9] index: %c\n", key[13]); - exit(472); - } - - optionParseColor(key, value, &instance->config.logo.colors[index]); - } - else if(strcasecmp(subkey, "-width") == 0) - instance->config.logo.width = optionParseUInt32(key, value); - else if(strcasecmp(subkey, "-height") == 0) - instance->config.logo.height = optionParseUInt32(key, value); - else if(strcasecmp(subkey, "-padding") == 0) - { - uint32_t padding = optionParseUInt32(key, value); - instance->config.logo.paddingLeft = padding; - instance->config.logo.paddingRight = padding; - } - else if(strcasecmp(subkey, "-padding-top") == 0) - instance->config.logo.paddingTop = optionParseUInt32(key, value); - else if(strcasecmp(subkey, "-padding-left") == 0) - instance->config.logo.paddingLeft = optionParseUInt32(key, value); - else if(strcasecmp(subkey, "-padding-right") == 0) - instance->config.logo.paddingRight = optionParseUInt32(key, value); - else if(strcasecmp(subkey, "-print-remaining") == 0) - instance->config.logo.printRemaining = optionParseBoolean(value); - else if(strcasecmp(subkey, "-preserve-aspect-radio") == 0) - instance->config.logo.preserveAspectRadio = optionParseBoolean(value); - else - goto error; - } - else if(strcasecmp(key, "--file") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_FILE; - } - else if(strcasecmp(key, "--file-raw") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_FILE_RAW; - } - else if(strcasecmp(key, "--data") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_DATA; - } - else if(strcasecmp(key, "--data-raw") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_DATA_RAW; - } - else if(strcasecmp(key, "--sixel") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_IMAGE_SIXEL; - } - else if(strcasecmp(key, "--kitty") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_IMAGE_KITTY; - } - else if(strcasecmp(key, "--chafa") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_IMAGE_CHAFA; - } - else if(strcasecmp(key, "--iterm") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_IMAGE_ITERM; - } - else if(strcasecmp(key, "--raw") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_IMAGE_RAW; - } - else if(strcasecmp(key, "--chafa-fg-only") == 0) - instance->config.logo.chafaFgOnly = optionParseBoolean(value); - else if(strcasecmp(key, "--chafa-symbols") == 0) - optionParseString(key, value, &instance->config.logo.chafaSymbols); - else if(strcasecmp(key, "--chafa-canvas-mode") == 0) - instance->config.logo.chafaCanvasMode = optionParseUInt32(key, value); - else if(strcasecmp(key, "--chafa-color-space") == 0) - instance->config.logo.chafaColorSpace = optionParseUInt32(key, value); - else if(strcasecmp(key, "--chafa-dither-mode") == 0) - instance->config.logo.chafaDitherMode = optionParseUInt32(key, value); + else if(ffParseLogoCommandOptions(&instance->config.logo, key, value)) {} /////////////////// //Display options// diff --git a/src/fastfetch.h b/src/fastfetch.h index 79dd8a0f3..3453f3bd5 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -16,25 +16,8 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #define FF_UNUSED(...) ffUnused(0, __VA_ARGS__); #define FF_MAYBE_UNUSED __attribute__ ((__unused__)) -#define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) - #include "modules/options.h" - -typedef enum FFLogoType -{ - FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo - FF_LOGO_TYPE_BUILTIN, //builtin ascii art - FF_LOGO_TYPE_FILE, //text file, printed with color code replacement - FF_LOGO_TYPE_FILE_RAW, //text file, printed as is - FF_LOGO_TYPE_DATA, //text data, printed with color code replacement - FF_LOGO_TYPE_DATA_RAW, //text data, printed as is - FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes. - FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol - FF_LOGO_TYPE_IMAGE_ITERM, //image file, printed as iterm graphics protocol - FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa - FF_LOGO_TYPE_IMAGE_RAW, //image file, printed as raw binary string - FF_LOGO_TYPE_NONE, //--logo none -} FFLogoType; +#include "logo/option.h" typedef enum FFSoundType { @@ -88,25 +71,7 @@ typedef enum FFLocalIpType typedef struct FFconfig { - struct - { - FFstrbuf source; - FFLogoType type; - FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS]; - uint32_t width; - uint32_t height; - uint32_t paddingTop; - uint32_t paddingLeft; - uint32_t paddingRight; - bool printRemaining; - bool preserveAspectRadio; - - bool chafaFgOnly; - FFstrbuf chafaSymbols; - uint32_t chafaCanvasMode; - uint32_t chafaColorSpace; - uint32_t chafaDitherMode; - } logo; + FFLogoOptions logo; //If one of those is empty, ffLogoPrint will set them FFstrbuf colorKeys; @@ -230,6 +195,8 @@ typedef struct FFconfig FFstrbuf playerName; uint32_t percentType; + + bool jsonConfig; } FFconfig; typedef struct FFstate diff --git a/src/logo/logo.c b/src/logo/logo.c index 43d39bc97..4b7fa2124 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -1,4 +1,4 @@ -#include "logo.h" +#include "logo/logo.h" #include "common/io/io.h" #include "common/printing.h" #include "detection/os/os.h" @@ -10,35 +10,38 @@ static void ffLogoPrintCharsRaw(FFinstance* instance, const char* data, size_t length) { + FFLogoOptions* options = &instance->config.logo; fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes('\n', options->paddingTop); + ffPrintCharTimes(' ', options->paddingLeft); fwrite(data, length, 1, stdout); - instance->state.logoHeight = instance->config.logo.paddingTop + instance->config.logo.height; - instance->state.logoWidth = instance->config.logo.paddingLeft + instance->config.logo.width + instance->config.logo.paddingRight; + instance->state.logoHeight = options->paddingTop + options->height; + instance->state.logoWidth = options->paddingLeft + options->width + options->paddingRight; printf("\033[9999999D\n\033[%uA", instance->state.logoHeight); } void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplacement) { + FFLogoOptions* options = &instance->config.logo; + uint32_t currentlineLength = 0; fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes('\n', options->paddingTop); + ffPrintCharTimes(' ', options->paddingLeft); - instance->state.logoHeight = instance->config.logo.paddingTop; + instance->state.logoHeight = options->paddingTop; //Use logoColor[0] as the default color if(doColorReplacement) - ffPrintColor(&instance->config.logo.colors[0]); + ffPrintColor(&options->colors[0]); while(*data != '\0') { //We are at the end of a line. Print paddings and update max line length if(*data == '\n' || (*data == '\r' && *(data + 1) == '\n')) { - ffPrintCharTimes(' ', instance->config.logo.paddingRight); + ffPrintCharTimes(' ', options->paddingRight); //We have \r\n, skip the \r if(*data == '\r') @@ -47,7 +50,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac putchar('\n'); ++data; - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes(' ', options->paddingLeft); if(currentlineLength > instance->state.logoWidth) instance->state.logoWidth = currentlineLength; @@ -115,7 +118,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac } else { - ffPrintColor(&instance->config.logo.colors[index]); + ffPrintColor(&options->colors[index]); ++data; continue; } @@ -148,14 +151,14 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac } } - ffPrintCharTimes(' ', instance->config.logo.paddingRight); + ffPrintCharTimes(' ', options->paddingRight); fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); //Happens if the last line is the longest if(currentlineLength > instance->state.logoWidth) instance->state.logoWidth = currentlineLength; - instance->state.logoWidth += instance->config.logo.paddingLeft + instance->config.logo.paddingRight; + instance->state.logoWidth += options->paddingLeft + options->paddingRight; //Go to the leftmost position fputs("\033[9999999D", stdout); @@ -241,11 +244,13 @@ static void logoPrintStruct(FFinstance* instance, const FFlogo* logo) { logoApplyColors(instance, logo); + FFLogoOptions* options = &instance->config.logo; + const char** colors = logo->builtinColors; for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) { - if(instance->config.logo.colors[i].length == 0) - ffStrbufAppendS(&instance->config.logo.colors[i], *colors); + if(options->colors[i].length == 0) + ffStrbufAppendS(&options->colors[i], *colors); } ffLogoPrintChars(instance, logo->data, true); @@ -281,17 +286,20 @@ static inline void logoPrintDetected(FFinstance* instance) } static bool logoPrintData(FFinstance* instance, bool doColorReplacement) { - if(instance->config.logo.source.length == 0) + FFLogoOptions* options = &instance->config.logo; + if(options->source.length == 0) return false; - ffLogoPrintChars(instance, instance->config.logo.source.chars, doColorReplacement); + ffLogoPrintChars(instance, options->source.chars, doColorReplacement); logoApplyColorsDetected(instance); return true; } static void updateLogoPath(FFinstance* instance) { - if(ffPathExists(instance->config.logo.source.chars, FF_PATHTYPE_FILE)) + FFLogoOptions* options = &instance->config.logo; + + if(ffPathExists(options->source.chars, FF_PATHTYPE_FILE)) return; FFstrbuf fullPath; @@ -302,11 +310,11 @@ static void updateLogoPath(FFinstance* instance) //We need to copy it, because multiple threads might be using dataDirs at the same time ffStrbufSet(&fullPath, dataDir); ffStrbufAppendS(&fullPath, "fastfetch/logos/"); - ffStrbufAppend(&fullPath, &instance->config.logo.source); + ffStrbufAppend(&fullPath, &options->source); if(ffPathExists(fullPath.chars, FF_PATHTYPE_FILE)) { - ffStrbufSet(&instance->config.logo.source, &fullPath); + ffStrbufSet(&options->source, &fullPath); break; } } @@ -316,10 +324,12 @@ static void updateLogoPath(FFinstance* instance) static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, bool raw) { - FFstrbuf content; + FFLogoOptions* options = &instance->config.logo; + + FF_STRBUF_AUTO_DESTROY content; ffStrbufInit(&content); - if(!ffAppendFileBuffer(instance->config.logo.source.chars, &content)) + if(!ffAppendFileBuffer(options->source.chars, &content)) { ffStrbufDestroy(&content); fputs("Logo: Failed to load file content from logo source\n", stderr); @@ -331,7 +341,6 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, ffLogoPrintCharsRaw(instance, content.chars, content.length); else ffLogoPrintChars(instance, content.chars, doColorReplacement); - ffStrbufDestroy(&content); return true; } @@ -346,32 +355,34 @@ static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo, bool p static bool logoTryKnownType(FFinstance* instance) { - if(instance->config.logo.type == FF_LOGO_TYPE_NONE) + FFLogoOptions* options = &instance->config.logo; + + if(options->type == FF_LOGO_TYPE_NONE) { logoApplyColorsDetected(instance); return true; } - if(instance->config.logo.type == FF_LOGO_TYPE_BUILTIN) - return logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars); + if(options->type == FF_LOGO_TYPE_BUILTIN) + return logoPrintBuiltinIfExists(instance, options->source.chars); - if(instance->config.logo.type == FF_LOGO_TYPE_DATA) + if(options->type == FF_LOGO_TYPE_DATA) return logoPrintData(instance, true); - if(instance->config.logo.type == FF_LOGO_TYPE_DATA_RAW) + if(options->type == FF_LOGO_TYPE_DATA_RAW) return logoPrintData(instance, false); updateLogoPath(instance); //We sure have a file, resolve relative paths - if(instance->config.logo.type == FF_LOGO_TYPE_FILE) + if(options->type == FF_LOGO_TYPE_FILE) return logoPrintFileIfExists(instance, true, false); - if(instance->config.logo.type == FF_LOGO_TYPE_FILE_RAW) + if(options->type == FF_LOGO_TYPE_FILE_RAW) return logoPrintFileIfExists(instance, false, false); - if(instance->config.logo.type == FF_LOGO_TYPE_IMAGE_RAW) + if(options->type == FF_LOGO_TYPE_IMAGE_RAW) { - if(instance->config.logo.width == 0 || instance->config.logo.height == 0) + if(options->width == 0 || options->height == 0) { fputs("both `--logo-width` and `--logo-height` must be specified\n", stderr); return false; @@ -380,7 +391,7 @@ static bool logoTryKnownType(FFinstance* instance) return logoPrintFileIfExists(instance, false, true); } - return logoPrintImageIfExists(instance, instance->config.logo.type, true); + return logoPrintImageIfExists(instance, options->type, true); } static void logoPrintKnownType(FFinstance* instance) @@ -401,22 +412,24 @@ void ffLogoPrint(FFinstance* instance) return; } + const FFLogoOptions* options = &instance->config.logo; + //If the source is not set, we can directly print the detected logo. - if(instance->config.logo.source.length == 0) + if(options->source.length == 0) { logoPrintDetected(instance); return; } //If the source and source type is set to something else than auto, always print with the set type. - if(instance->config.logo.source.length > 0 && instance->config.logo.type != FF_LOGO_TYPE_AUTO) + if(options->source.length > 0 && options->type != FF_LOGO_TYPE_AUTO) { logoPrintKnownType(instance); return; } //If source matches the name of a builtin logo, print it and return. - if(logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars)) + if(logoPrintBuiltinIfExists(instance, options->source.chars)) return; //Make sure the logo path is set correctly. @@ -462,6 +475,7 @@ void ffLogoPrintRemaining(FFinstance* instance) void ffLogoBuiltinPrint(FFinstance* instance) { GetLogoMethod* methods = ffLogoBuiltinGetAll(); + FFLogoOptions* options = &instance->config.logo; while(*methods != NULL) { @@ -474,7 +488,7 @@ void ffLogoBuiltinPrint(FFinstance* instance) instance->state.logoHeight = 0; instance->state.keysHeight = 0; for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) - ffStrbufClear(&instance->config.logo.colors[i]); + ffStrbufClear(&options->colors[i]); puts("\n"); ++methods; diff --git a/src/logo/logo.h b/src/logo/logo.h index 0664f6f98..9d3878c66 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -26,4 +26,9 @@ GetLogoMethod* ffLogoBuiltinGetAll(); //image/image.c bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type, bool printError); +//option.c +void ffInitLogoOptions(FFLogoOptions* options); +bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const char* value); +void ffDestroyLogoOptions(FFLogoOptions* options); + #endif diff --git a/src/logo/option.c b/src/logo/option.c new file mode 100644 index 000000000..033885635 --- /dev/null +++ b/src/logo/option.c @@ -0,0 +1,183 @@ +#include "logo/logo.h" + +void ffInitLogoOptions(FFLogoOptions* options) +{ + ffStrbufInit(&options->source); + options->type = FF_LOGO_TYPE_AUTO; + for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i) + ffStrbufInit(&options->colors[i]); + options->width = 0; + options->height = 0; //preserve aspect ratio + options->paddingTop = 0; + options->paddingLeft = 0; + options->paddingRight = 4; + options->printRemaining = true; + options->preserveAspectRadio = false; + + options->chafaFgOnly = false; + ffStrbufInitS(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default + options->chafaCanvasMode = UINT32_MAX; + options->chafaColorSpace = UINT32_MAX; + options->chafaDitherMode = UINT32_MAX; +} + +bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const char* value) +{ + if (strcasecmp(key, "-l") == 0) + goto logoType; + + const char* subKey = ffOptionTestPrefix(key, "logo"); + if(subKey) + { + if (subKey[0] == '\0') + { +logoType: + ffOptionParseString(key, value, &options->source); + + //this is usally wanted when using the none logo + if(strcasecmp(value, "none") == 0) + { + options->paddingTop = 0; + options->paddingRight = 0; + options->paddingLeft = 0; + options->type = FF_LOGO_TYPE_NONE; + } + } + else if(strcasecmp(subKey, "type") == 0) + { + options->type = (FFLogoType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "auto", FF_LOGO_TYPE_AUTO }, + { "builtin", FF_LOGO_TYPE_BUILTIN }, + { "file", FF_LOGO_TYPE_FILE }, + { "file-raw", FF_LOGO_TYPE_FILE_RAW }, + { "data", FF_LOGO_TYPE_DATA }, + { "data-raw", FF_LOGO_TYPE_DATA_RAW }, + { "sixel", FF_LOGO_TYPE_IMAGE_SIXEL }, + { "kitty", FF_LOGO_TYPE_IMAGE_KITTY }, + { "iterm", FF_LOGO_TYPE_IMAGE_ITERM }, + { "chafa", FF_LOGO_TYPE_IMAGE_CHAFA }, + { "raw", FF_LOGO_TYPE_IMAGE_RAW }, + { "none", FF_LOGO_TYPE_NONE }, + {}, + }); + } + else if(strncasecmp(subKey, "color-", strlen("color-")) && key[13] != '\0' && key[14] == '\0') // matches "--logo-color-*" + { + //Map the number to an array index, so that '1' -> 0, '2' -> 1, etc. + int index = (int)key[13] - 49; + + //Match only --logo-color-[1-9] + if(index < 0 || index >= FASTFETCH_LOGO_MAX_COLORS) + { + fprintf(stderr, "Error: invalid --color-[1-9] index: %c\n", key[13]); + exit(472); + } + + ffOptionParseColor(key, value, &options->colors[index]); + } + else if(strcasecmp(subKey, "width") == 0) + options->width = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "height") == 0) + options->height = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "padding") == 0) + { + uint32_t padding = ffOptionParseUInt32(key, value); + options->paddingLeft = padding; + options->paddingRight = padding; + } + else if(strcasecmp(subKey, "padding-top") == 0) + options->paddingTop = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "padding-left") == 0) + options->paddingLeft = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "padding-right") == 0) + options->paddingRight = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "print-remaining") == 0) + options->printRemaining = ffOptionParseBoolean(value); + else if(strcasecmp(subKey, "preserve-aspect-radio") == 0) + options->preserveAspectRadio = ffOptionParseBoolean(value); + else + return false; + } + else if((subKey = ffOptionTestPrefix(key, "file"))) + { + if(subKey[0] == '\0') + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_FILE; + } + else if(strcasecmp(key, "raw") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_FILE_RAW; + } + else + return false; + } + else if((subKey = ffOptionTestPrefix(key, "data"))) + { + if(subKey[0] == '\0') + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_DATA; + } + else if(strcasecmp(subKey, "raw") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_DATA_RAW; + } + else + return false; + } + else if(strcasecmp(key, "--sixel") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_SIXEL; + } + else if(strcasecmp(key, "--kitty") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_KITTY; + } + else if(strcasecmp(key, "--iterm") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_ITERM; + } + else if(strcasecmp(key, "--raw") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_RAW; + } + else if((subKey = ffOptionTestPrefix(key, "chafa"))) + { + if(subKey[0] == '\0') + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_CHAFA; + } + else if(strcasecmp(subKey, "fg-only") == 0) + options->chafaFgOnly = ffOptionParseBoolean(value); + else if(strcasecmp(subKey, "symbols") == 0) + ffOptionParseString(key, value, &options->chafaSymbols); + else if(strcasecmp(subKey, "canvas-mode") == 0) + options->chafaCanvasMode = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "color-space") == 0) + options->chafaColorSpace = ffOptionParseUInt32(key, value); + else if(strcasecmp(subKey, "dither-mode") == 0) + options->chafaDitherMode = ffOptionParseUInt32(key, value); + else + return false; + } + else + return false; + + return true; +} + +void ffDestroyLogoOptions(FFLogoOptions* options) +{ + ffStrbufDestroy(&options->source); + ffStrbufDestroy(&options->chafaSymbols); + for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i) + ffStrbufDestroy(&options->colors[i]); +} diff --git a/src/logo/option.h b/src/logo/option.h new file mode 100644 index 000000000..09f7822d1 --- /dev/null +++ b/src/logo/option.h @@ -0,0 +1,41 @@ +#pragma once + +#include "util/FFstrbuf.h" + +#define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) + +typedef enum FFLogoType +{ + FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo + FF_LOGO_TYPE_BUILTIN, //builtin ascii art + FF_LOGO_TYPE_FILE, //text file, printed with color code replacement + FF_LOGO_TYPE_FILE_RAW, //text file, printed as is + FF_LOGO_TYPE_DATA, //text data, printed with color code replacement + FF_LOGO_TYPE_DATA_RAW, //text data, printed as is + FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes. + FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol + FF_LOGO_TYPE_IMAGE_ITERM, //image file, printed as iterm graphics protocol + FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa + FF_LOGO_TYPE_IMAGE_RAW, //image file, printed as raw binary string + FF_LOGO_TYPE_NONE, //--logo none +} FFLogoType; + +typedef struct FFLogoOptions +{ + FFstrbuf source; + FFLogoType type; + FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS]; + uint32_t width; + uint32_t height; + uint32_t paddingTop; + uint32_t paddingLeft; + uint32_t paddingRight; + bool printRemaining; + bool preserveAspectRadio; + + bool chafaFgOnly; + FFstrbuf chafaSymbols; + uint32_t chafaCanvasMode; + uint32_t chafaColorSpace; + uint32_t chafaDitherMode; +} FFLogoOptions; From fb2004a6f9222d6bb6e8338e6e3e62bf1371efd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 13 Mar 2023 17:36:48 +0800 Subject: [PATCH 021/493] Bluetooth: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 6 +- src/fastfetch.c | 6 +- src/fastfetch.h | 5 +- src/modules/bluetooth.c | 64 -------------- src/modules/bluetooth/bluetooth.c | 126 ++++++++++++++++++++++++++++ src/modules/bluetooth/bluetooth.h | 13 +++ src/modules/bluetooth/option.h | 13 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 11 files changed, 161 insertions(+), 77 deletions(-) delete mode 100644 src/modules/bluetooth.c create mode 100644 src/modules/bluetooth/bluetooth.c create mode 100644 src/modules/bluetooth/bluetooth.h create mode 100644 src/modules/bluetooth/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b3b487584..e58949ddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,7 +263,7 @@ set(LIBFASTFETCH_SRC src/logo/option.c src/modules/battery/battery.c src/modules/bios/bios.c - src/modules/bluetooth.c + src/modules/bluetooth/bluetooth.c src/modules/board.c src/modules/brightness.c src/modules/break.c diff --git a/src/common/init.c b/src/common/init.c index 8d2e7a48f..62a877fba 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -101,7 +101,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.openGL); initModuleArg(&instance->config.openCL); initModuleArg(&instance->config.users); - initModuleArg(&instance->config.bluetooth); + ffInitBluetoothOptions(&instance->config.bluetooth); initModuleArg(&instance->config.sound); ffInitSeparatorOptions(&instance->config.separator); initModuleArg(&instance->config.gamepad); @@ -145,8 +145,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInitA(&instance->config.diskFolders, 0); instance->config.diskShowTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; - instance->config.bluetoothShowDisconnected = false; - instance->config.soundType = FF_SOUND_TYPE_MAIN; instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT; @@ -338,7 +336,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.openGL); destroyModuleArg(&instance->config.openCL); destroyModuleArg(&instance->config.users); - destroyModuleArg(&instance->config.bluetooth); + ffDestroyBluetoothOptions(&instance->config.bluetooth); ffDestroySeparatorOptions(&instance->config.separator); destroyModuleArg(&instance->config.sound); destroyModuleArg(&instance->config.gamepad); diff --git a/src/fastfetch.c b/src/fastfetch.c index eb9ab31c9..89c54fbbb 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1052,7 +1052,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "opengl", &instance->config.openGL)) {} else if(optionParseModuleArgs(key, value, "opencl", &instance->config.openCL)) {} else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} - else if(optionParseModuleArgs(key, value, "bluetooth", &instance->config.bluetooth)) {} + else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(optionParseModuleArgs(key, value, "sound", &instance->config.sound)) {} else if(optionParseModuleArgs(key, value, "gamepad", &instance->config.gamepad)) {} @@ -1148,8 +1148,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_SUBVOLUME_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT); else if(strcasecmp(key, "--disk-show-unknown") == 0) optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_UNKNOWN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT); - else if(strcasecmp(key, "--bluetooth-show-disconnected") == 0) - instance->config.bluetoothShowDisconnected = optionParseBoolean(value); else if(strcasecmp(key, "--sound-type") == 0) { optionParseEnum(key, value, &instance->config.soundType, @@ -1347,7 +1345,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "command") == 0) ffPrintCommand(instance, &instance->config.command); else if(strcasecmp(line, "bluetooth") == 0) - ffPrintBluetooth(instance); + ffPrintBluetooth(instance, &instance->config.bluetooth); else if(strcasecmp(line, "sound") == 0) ffPrintSound(instance); else if(strcasecmp(line, "gamepad") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3453f3bd5..8001cdf5d 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -135,7 +135,7 @@ typedef struct FFconfig FFModuleArgs openGL; FFModuleArgs openCL; FFModuleArgs users; - FFModuleArgs bluetooth; + FFBluetoothOptions bluetooth; FFSeparatorOptions separator; FFModuleArgs sound; FFModuleArgs gamepad; @@ -179,8 +179,6 @@ typedef struct FFconfig FFstrbuf diskFolders; FFDiskType diskShowTypes; - bool bluetoothShowDisconnected; - FFstrbuf localIpNamePrefix; FFLocalIpType localIpShowType; @@ -292,7 +290,6 @@ void ffPrintVulkan(FFinstance* instance); void ffPrintOpenGL(FFinstance* instance); void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); -void ffPrintBluetooth(FFinstance* instance); void ffPrintSound(FFinstance* instance); void ffPrintGamepad(FFinstance* instance); diff --git a/src/modules/bluetooth.c b/src/modules/bluetooth.c deleted file mode 100644 index 6038acf01..000000000 --- a/src/modules/bluetooth.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "common/printing.h" -#include "detection/bluetooth/bluetooth.h" - -#define FF_BLUETOOTH_MODULE_NAME "Bluetooth" -#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4 - -static void printDevice(FFinstance* instance, const FFBluetoothDevice* device, uint8_t index) -{ - if(instance->config.bluetooth.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &instance->config.bluetooth.key); - ffStrbufWriteTo(&device->name, stdout); - - if(device->battery > 0) - printf(" (%d%%)", device->battery); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_BLUETOOTH_MODULE_NAME, index, &instance->config.bluetooth, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->address}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, - {FF_FORMAT_ARG_TYPE_UINT8, &device->battery} - }); - } -} - -void ffPrintBluetooth(FFinstance* instance) -{ - const FFBluetoothResult* bluetooth = ffDetectBluetooth(instance); - - if(bluetooth->error.length > 0) - { - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &instance->config.bluetooth, "%s", bluetooth->error.chars); - return; - } - - FFlist filtered; - ffListInit(&filtered, sizeof(FFBluetoothDevice*)); - - FF_LIST_FOR_EACH(FFBluetoothDevice, device, bluetooth->devices) - { - if(!device->connected && !instance->config.bluetoothShowDisconnected) - continue; - - *(FFBluetoothDevice**)ffListAdd(&filtered) = device; - } - - if(filtered.length == 0) - { - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &instance->config.bluetooth, "No bluetooth devices found"); - return; - } - - for(uint32_t i = 0; i < filtered.length; i++) - { - uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); - printDevice(instance, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); - } - - ffListDestroy(&filtered); -} diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c new file mode 100644 index 000000000..90d5c2f4d --- /dev/null +++ b/src/modules/bluetooth/bluetooth.c @@ -0,0 +1,126 @@ +#include "common/printing.h" +#include "detection/bluetooth/bluetooth.h" +#include "modules/bluetooth/bluetooth.h" + +#define FF_BLUETOOTH_MODULE_NAME "Bluetooth" +#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4 + +static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index) +{ + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key); + ffStrbufWriteTo(&device->name, stdout); + + if(device->battery > 0) + printf(" (%d%%)", device->battery); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->address}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, + {FF_FORMAT_ARG_TYPE_UINT8, &device->battery} + }); + } +} + +void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) +{ + const FFBluetoothResult* bluetooth = ffDetectBluetooth(instance); + + if(bluetooth->error.length > 0) + { + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", bluetooth->error.chars); + return; + } + + FFlist filtered; + ffListInit(&filtered, sizeof(FFBluetoothDevice*)); + + FF_LIST_FOR_EACH(FFBluetoothDevice, device, bluetooth->devices) + { + if(!device->connected && !options->showDisconnected) + continue; + + *(FFBluetoothDevice**)ffListAdd(&filtered) = device; + } + + if(filtered.length == 0) + { + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); + return; + } + + for(uint32_t i = 0; i < filtered.length; i++) + { + uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); + printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); + } + + ffListDestroy(&filtered); +} + +void ffInitBluetoothOptions(FFBluetoothOptions* options) +{ + options->moduleName = FF_BLUETOOTH_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + options->showDisconnected = false; +} + +bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_BLUETOOTH_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "show-disconnected") == 0) + options->showDisconnected = ffOptionParseBoolean(value); + return false; +} + +void ffDestroyBluetoothOptions(FFBluetoothOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_BLUETOOTH_MODULE_NAME) != 0) + return false; + + FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; + ffInitBluetoothOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "showConnected") == 0) + { + options.showDisconnected = data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintBluetooth(instance, &options); + return true; +} +#endif diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h new file mode 100644 index 000000000..500d39290 --- /dev/null +++ b/src/modules/bluetooth/bluetooth.h @@ -0,0 +1,13 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options); +void ffInitBluetoothOptions(FFBluetoothOptions* options); +bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value); +void ffDestroyBluetoothOptions(FFBluetoothOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/bluetooth/option.h b/src/modules/bluetooth/option.h new file mode 100644 index 000000000..b347dc466 --- /dev/null +++ b/src/modules/bluetooth/option.h @@ -0,0 +1,13 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFBluetoothOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + bool showDisconnected; +} FFBluetoothOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index bd062ae7d..bcfd07f7c 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -15,6 +15,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseTitleJsonObject(instance, type, data, module) || ffParseBatteryJsonObject(instance, type, data, module) || ffParseBiosJsonObject(instance, type, data, module) || + ffParseBluetoothJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || diff --git a/src/modules/modules.h b/src/modules/modules.h index be6bac672..19a6414c7 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -5,6 +5,7 @@ #include "modules/os/os.h" #include "modules/battery/battery.h" #include "modules/bios/bios.h" +#include "modules/bluetooth/bluetooth.h" #include "modules/command/command.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" diff --git a/src/modules/options.h b/src/modules/options.h index 1b7502204..9f992996a 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -4,6 +4,7 @@ #include "modules/battery/option.h" #include "modules/bios/option.h" +#include "modules/bluetooth/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From 5f3154acc6bee085f6af0deb7b7d424f74146e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 13 Mar 2023 18:54:57 +0800 Subject: [PATCH 022/493] Board: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 4 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/board.c | 44 ------------- src/modules/board/board.c | 97 +++++++++++++++++++++++++++++ src/modules/board/board.h | 13 ++++ src/modules/board/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 131 insertions(+), 52 deletions(-) delete mode 100644 src/modules/board.c create mode 100644 src/modules/board/board.c create mode 100644 src/modules/board/board.h create mode 100644 src/modules/board/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e58949ddc..d423e07f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,7 +264,7 @@ set(LIBFASTFETCH_SRC src/modules/battery/battery.c src/modules/bios/bios.c src/modules/bluetooth/bluetooth.c - src/modules/board.c + src/modules/board/board.c src/modules/brightness.c src/modules/break.c src/modules/chassis.c diff --git a/src/common/init.c b/src/common/init.c index 62a877fba..0bfbeb164 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -61,7 +61,7 @@ static void defaultConfig(FFinstance* instance) ffInitOSOptions(&instance->config.os); ffInitHostOptions(&instance->config.host); ffInitBiosOptions(&instance->config.bios); - initModuleArg(&instance->config.board); + ffInitBoardOptions(&instance->config.board); initModuleArg(&instance->config.brightness); initModuleArg(&instance->config.chassis); ffInitCommandOptions(&instance->config.command); @@ -297,7 +297,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyOSOptions(&instance->config.os); ffDestroyHostOptions(&instance->config.host); ffDestroyBiosOptions(&instance->config.bios); - destroyModuleArg(&instance->config.board); + ffDestroyBoardOptions(&instance->config.board); destroyModuleArg(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); ffDestroyKernelOptions(&instance->config.kernel); diff --git a/src/fastfetch.c b/src/fastfetch.c index 89c54fbbb..650a30923 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1012,7 +1012,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(ffParseHostCommandOptions(&instance->config.host, key, value)) {} else if(ffParseBiosCommandOptions(&instance->config.bios, key, value)) {} - else if(optionParseModuleArgs(key, value, "board", &instance->config.board)) {} + else if(ffParseBoardCommandOptions(&instance->config.board, key, value)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} @@ -1263,7 +1263,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "bios") == 0) ffPrintBios(instance, &instance->config.bios); else if(strcasecmp(line, "board") == 0) - ffPrintBoard(instance); + ffPrintBoard(instance, &instance->config.board); else if(strcasecmp(line, "brightness") == 0) ffPrintBrightness(instance); else if(strcasecmp(line, "chassis") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 8001cdf5d..bd6e4ee72 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -95,7 +95,7 @@ typedef struct FFconfig FFOSOptions os; FFHostOptions host; FFBiosOptions bios; - FFModuleArgs board; + FFBoardOptions board; FFModuleArgs brightness; FFModuleArgs chassis; FFCommandOptions command; @@ -251,7 +251,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintBreak(FFinstance* instance); -void ffPrintBoard(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 9c24a9ee8..ef097343e 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -25,7 +25,7 @@ int main(int argc, char** argv) ffPrintOS(&instance, &instance.config.os); ffPrintHost(&instance, &instance.config.host); //ffPrintBios(&instance, &instance.config.bios); - //ffPrintBoard(&instance); + //ffPrintBoard(&instance, &instance.config.board); //ffPrintChassis(&instance); ffPrintKernel(&instance, &instance.config.kernel); ffPrintUptime(&instance); diff --git a/src/modules/board.c b/src/modules/board.c deleted file mode 100644 index 558653892..000000000 --- a/src/modules/board.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/board/board.h" - -#define FF_BOARD_MODULE_NAME "Board" -#define FF_BOARD_NUM_FORMAT_ARGS 3 - -void ffPrintBoard(FFinstance* instance) -{ - FFBoardResult result; - ffDetectBoard(&result); - - if(result.error.length > 0) - { - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board, "%*s", result.error.length, result.error.chars); - goto exit; - } - - if(result.boardName.length == 0) - { - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board, "board_name is not set."); - goto exit; - } - - if(instance->config.board.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board.key); - puts(result.boardName.chars); - } - else - { - ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVersion}, - }); - } - -exit: - ffStrbufDestroy(&result.boardName); - ffStrbufDestroy(&result.boardVendor); - ffStrbufDestroy(&result.boardVersion); - ffStrbufDestroy(&result.error); -} diff --git a/src/modules/board/board.c b/src/modules/board/board.c new file mode 100644 index 000000000..6f41aa76e --- /dev/null +++ b/src/modules/board/board.c @@ -0,0 +1,97 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/board/board.h" +#include "modules/board/board.h" + +#define FF_BOARD_MODULE_NAME "Board" +#define FF_BOARD_NUM_FORMAT_ARGS 3 + +void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) +{ + FFBoardResult result; + ffDetectBoard(&result); + + if(result.error.length > 0) + { + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + goto exit; + } + + if(result.boardName.length == 0) + { + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set."); + goto exit; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key); + puts(result.boardName.chars); + } + else + { + ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVersion}, + }); + } + +exit: + ffStrbufDestroy(&result.boardName); + ffStrbufDestroy(&result.boardVendor); + ffStrbufDestroy(&result.boardVersion); + ffStrbufDestroy(&result.error); +} + +void ffInitBoardOptions(FFBoardOptions* options) +{ + options->moduleName = FF_BOARD_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_BOARD_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyBoardOptions(FFBoardOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_BOARD_MODULE_NAME) != 0) + return false; + + FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; + ffInitBoardOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintBoard(instance, &options); + return true; +} +#endif diff --git a/src/modules/board/board.h b/src/modules/board/board.h new file mode 100644 index 000000000..2027baf4b --- /dev/null +++ b/src/modules/board/board.h @@ -0,0 +1,13 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintBoard(FFinstance* instance, FFBoardOptions* options); +void ffInitBoardOptions(FFBoardOptions* options); +bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value); +void ffDestroyBoardOptions(FFBoardOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/board/option.h b/src/modules/board/option.h new file mode 100644 index 000000000..582854d23 --- /dev/null +++ b/src/modules/board/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFBoardOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFBoardOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index bcfd07f7c..221c1050a 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -16,6 +16,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseBatteryJsonObject(instance, type, data, module) || ffParseBiosJsonObject(instance, type, data, module) || ffParseBluetoothJsonObject(instance, type, data, module) || + ffParseBoardJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 19a6414c7..846b18b08 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -6,6 +6,7 @@ #include "modules/battery/battery.h" #include "modules/bios/bios.h" #include "modules/bluetooth/bluetooth.h" +#include "modules/board/board.h" #include "modules/command/command.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" diff --git a/src/modules/options.h b/src/modules/options.h index 9f992996a..3872909fb 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -5,6 +5,7 @@ #include "modules/battery/option.h" #include "modules/bios/option.h" #include "modules/bluetooth/option.h" +#include "modules/board/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From 010330ac90aed80dbc60f6f1e0747d250e621cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 13 Mar 2023 19:01:08 +0800 Subject: [PATCH 023/493] Break: support JSON config --- CMakeLists.txt | 2 +- src/fastfetch.h | 1 - src/modules/break.c | 8 -------- src/modules/break/break.c | 22 ++++++++++++++++++++++ src/modules/break/break.h | 10 ++++++++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + 7 files changed, 35 insertions(+), 10 deletions(-) delete mode 100644 src/modules/break.c create mode 100644 src/modules/break/break.c create mode 100644 src/modules/break/break.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d423e07f6..920f98d72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,7 +266,7 @@ set(LIBFASTFETCH_SRC src/modules/bluetooth/bluetooth.c src/modules/board/board.c src/modules/brightness.c - src/modules/break.c + src/modules/break/break.c src/modules/chassis.c src/modules/colors.c src/modules/cpu.c diff --git a/src/fastfetch.h b/src/fastfetch.h index bd6e4ee72..16975ef34 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -250,7 +250,6 @@ void ffPrepareWeather(FFinstance* instance); //Printing void ffPrintCustom(FFinstance* instance, const char* key, const char* value); -void ffPrintBreak(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); diff --git a/src/modules/break.c b/src/modules/break.c deleted file mode 100644 index 45b09e5fd..000000000 --- a/src/modules/break.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" - -void ffPrintBreak(FFinstance* instance) -{ - ffLogoPrintLine(instance); - putchar('\n'); -} diff --git a/src/modules/break/break.c b/src/modules/break/break.c new file mode 100644 index 000000000..05587a6fd --- /dev/null +++ b/src/modules/break/break.c @@ -0,0 +1,22 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "modules/break/break.h" + +#define FF_BREAK_MODULE_NAME "Break" + +void ffPrintBreak(FFinstance* instance) +{ + ffLogoPrintLine(instance); + putchar('\n'); +} + +#ifdef FF_HAVE_JSONC +bool ffParseBreakJsonObject(FFinstance* instance, const char* type, FF_MAYBE_UNUSED JSONCData* data, FF_MAYBE_UNUSED json_object* module) +{ + if (strcasecmp(type, FF_BREAK_MODULE_NAME) != 0) + return false; + + ffPrintBreak(instance); + return true; +} +#endif diff --git a/src/modules/break/break.h b/src/modules/break/break.h new file mode 100644 index 000000000..81e40f5c8 --- /dev/null +++ b/src/modules/break/break.h @@ -0,0 +1,10 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintBreak(FFinstance* instance); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBreakJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 221c1050a..30c0f2451 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -17,6 +17,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseBiosJsonObject(instance, type, data, module) || ffParseBluetoothJsonObject(instance, type, data, module) || ffParseBoardJsonObject(instance, type, data, module) || + ffParseBreakJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 846b18b08..bd5a75acf 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -7,6 +7,7 @@ #include "modules/bios/bios.h" #include "modules/bluetooth/bluetooth.h" #include "modules/board/board.h" +#include "modules/break/break.h" #include "modules/command/command.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" From 5da3127344a17d771f3c0035d8e948579f0f2772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 14 Mar 2023 15:29:47 +0800 Subject: [PATCH 024/493] Brightness: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 3 +- src/fastfetch.c | 4 +- src/fastfetch.h | 3 +- src/modules/brightness.c | 58 --------------- src/modules/brightness/brightness.c | 111 ++++++++++++++++++++++++++++ src/modules/brightness/brightness.h | 13 ++++ src/modules/brightness/option.h | 11 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 11 files changed, 144 insertions(+), 64 deletions(-) delete mode 100644 src/modules/brightness.c create mode 100644 src/modules/brightness/brightness.c create mode 100644 src/modules/brightness/brightness.h create mode 100644 src/modules/brightness/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 920f98d72..e85996d78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,7 +265,7 @@ set(LIBFASTFETCH_SRC src/modules/bios/bios.c src/modules/bluetooth/bluetooth.c src/modules/board/board.c - src/modules/brightness.c + src/modules/brightness/brightness.c src/modules/break/break.c src/modules/chassis.c src/modules/colors.c diff --git a/src/common/init.c b/src/common/init.c index 0bfbeb164..a09e34fa8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -62,7 +62,7 @@ static void defaultConfig(FFinstance* instance) ffInitHostOptions(&instance->config.host); ffInitBiosOptions(&instance->config.bios); ffInitBoardOptions(&instance->config.board); - initModuleArg(&instance->config.brightness); + ffInitBrightnessOptions(&instance->config.brightness); initModuleArg(&instance->config.chassis); ffInitCommandOptions(&instance->config.command); ffInitKernelOptions(&instance->config.kernel); @@ -298,6 +298,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyHostOptions(&instance->config.host); ffDestroyBiosOptions(&instance->config.bios); ffDestroyBoardOptions(&instance->config.board); + ffDestroyBrightnessOptions(&instance->config.brightness); destroyModuleArg(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); ffDestroyKernelOptions(&instance->config.kernel); diff --git a/src/fastfetch.c b/src/fastfetch.c index 650a30923..6f28ca97c 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1021,7 +1021,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "packages", &instance->config.packages)) {} else if(optionParseModuleArgs(key, value, "shell", &instance->config.shell)) {} else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} - else if(optionParseModuleArgs(key, value, "brightness", &instance->config.brightness)) {} + else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} else if(optionParseModuleArgs(key, value, "wifi", &instance->config.wifi)) {} else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} @@ -1265,7 +1265,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char else if(strcasecmp(line, "board") == 0) ffPrintBoard(instance, &instance->config.board); else if(strcasecmp(line, "brightness") == 0) - ffPrintBrightness(instance); + ffPrintBrightness(instance, &instance->config.brightness); else if(strcasecmp(line, "chassis") == 0) ffPrintChassis(instance); else if(strcasecmp(line, "kernel") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 16975ef34..3fe6d3f54 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -96,7 +96,7 @@ typedef struct FFconfig FFHostOptions host; FFBiosOptions bios; FFBoardOptions board; - FFModuleArgs brightness; + FFBrightnessOptions brightness; FFModuleArgs chassis; FFCommandOptions command; FFKernelOptions kernel; @@ -255,7 +255,6 @@ void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintPackages(FFinstance* instance); void ffPrintShell(FFinstance* instance); -void ffPrintBrightness(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); void ffPrintWMTheme(FFinstance* instance); diff --git a/src/modules/brightness.c b/src/modules/brightness.c deleted file mode 100644 index 9c1cde499..000000000 --- a/src/modules/brightness.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/brightness/brightness.h" - -#define FF_BRIGHTNESS_MODULE_NAME "Brightness" -#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2 - -void ffPrintBrightness(FFinstance* instance) -{ - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFBrightnessResult)); - const char* error = ffDetectBrightness(&result); - - if(error) - { - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &instance->config.brightness, "%s", error); - return; - } - - if(result.length == 0) - { - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &instance->config.brightness, "No result is detected."); - return; - } - - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); - - FF_LIST_FOR_EACH(FFBrightnessResult, item, result) - { - if(instance->config.brightness.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars); - } - else - { - ffParseFormatString(&key, &instance->config.brightness.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &item->name} - }); - } - - if(instance->config.brightness.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); - printf("%.0f%%\n", item->value); - } - else - { - ffPrintFormatString(instance, key.chars, 0, NULL, &instance->config.brightness.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &item->value}, - {FF_FORMAT_ARG_TYPE_FLOAT, &item->name} - }); - } - - ffStrbufClear(&key); - ffStrbufDestroy(&item->name); - } -} diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c new file mode 100644 index 000000000..fd85ea459 --- /dev/null +++ b/src/modules/brightness/brightness.c @@ -0,0 +1,111 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/brightness/brightness.h" +#include "modules/brightness/brightness.h" + +#define FF_BRIGHTNESS_MODULE_NAME "Brightness" +#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2 + +void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) +{ + FF_LIST_AUTO_DESTROY result; + ffListInit(&result, sizeof(FFBrightnessResult)); + const char* error = ffDetectBrightness(&result); + + if(error) + { + ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(result.length == 0) + { + ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected."); + return; + } + + FF_STRBUF_AUTO_DESTROY key; + ffStrbufInit(&key); + + FF_LIST_FOR_EACH(FFBrightnessResult, item, result) + { + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &item->name} + }); + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, key.chars, 0, NULL); + printf("%.0f%%\n", item->value); + } + else + { + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &item->value}, + {FF_FORMAT_ARG_TYPE_FLOAT, &item->name} + }); + } + + ffStrbufClear(&key); + ffStrbufDestroy(&item->name); + } +} + +void ffInitBrightnessOptions(FFBrightnessOptions* options) +{ + options->moduleName = FF_BRIGHTNESS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_BRIGHTNESS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyBrightnessOptions(FFBrightnessOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +{ + if (strcasecmp(type, FF_BRIGHTNESS_MODULE_NAME) != 0) + return false; + + FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; + ffInitBrightnessOptions(&options); + + if (module) + { + struct lh_entry* entry; + lh_foreach(data->ffjson_object_get_object(module), entry) + { + const char* key = (const char *)lh_entry_k(entry); + if (strcasecmp(key, "type") == 0) + continue; + json_object* val = (struct json_object *)lh_entry_v(entry); + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintBrightness(instance, &options); + return true; +} +#endif diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h new file mode 100644 index 000000000..5f32ddb6f --- /dev/null +++ b/src/modules/brightness/brightness.h @@ -0,0 +1,13 @@ +#pragma once + +#include "fastfetch.h" + +void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options); +void ffInitBrightnessOptions(FFBrightnessOptions* options); +bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value); +void ffDestroyBrightnessOptions(FFBrightnessOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/config.h" +bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#endif diff --git a/src/modules/brightness/option.h b/src/modules/brightness/option.h new file mode 100644 index 000000000..803ea4792 --- /dev/null +++ b/src/modules/brightness/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFBrightnessOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFBrightnessOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 30c0f2451..dd2d2d157 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -18,6 +18,7 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, ffParseBluetoothJsonObject(instance, type, data, module) || ffParseBoardJsonObject(instance, type, data, module) || ffParseBreakJsonObject(instance, type, data, module) || + ffParseBrightnessJsonObject(instance, type, data, module) || ffParseCommandJsonObject(instance, type, data, module) || ffParseDateTimeJsonObject(instance, type, data, module) || ffParseDisplayJsonObject(instance, type, data, module) || diff --git a/src/modules/modules.h b/src/modules/modules.h index bd5a75acf..46ab35e4a 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -6,6 +6,7 @@ #include "modules/battery/battery.h" #include "modules/bios/bios.h" #include "modules/bluetooth/bluetooth.h" +#include "modules/brightness/brightness.h" #include "modules/board/board.h" #include "modules/break/break.h" #include "modules/command/command.h" diff --git a/src/modules/options.h b/src/modules/options.h index 3872909fb..0777c7487 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -6,6 +6,7 @@ #include "modules/bios/option.h" #include "modules/bluetooth/option.h" #include "modules/board/option.h" +#include "modules/brightness/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From 5f52c64d4d60aaa98cba09e1318e0b5868c1d0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 11:24:49 +0800 Subject: [PATCH 025/493] JsonConfig: code simplify --- src/common/config.h | 17 ++++++- src/common/library.h | 8 ++-- src/modules/battery/battery.c | 46 ++++++++---------- src/modules/bios/bios.c | 18 +++---- src/modules/bluetooth/bluetooth.c | 30 +++++------- src/modules/board/board.c | 18 +++---- src/modules/brightness/brightness.c | 18 +++---- src/modules/command/command.c | 42 +++++++--------- src/modules/datetime/datetime.c | 18 +++---- src/modules/display/display.c | 74 +++++++++++++---------------- src/modules/host/host.c | 18 +++---- src/modules/jsonconfig/jsonconfig.c | 50 +++++++++++-------- src/modules/kernel/kernel.c | 18 +++---- src/modules/os/os.c | 34 ++++++------- src/modules/separator/separator.c | 24 ++++------ src/modules/title/title.c | 24 ++++------ 16 files changed, 200 insertions(+), 257 deletions(-) diff --git a/src/common/config.h b/src/common/config.h index d52b88440..4254e2126 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -19,11 +19,24 @@ typedef struct JSONCData FF_LIBRARY_SYMBOL(json_object_get_object) FF_LIBRARY_SYMBOL(json_object_object_get) FF_LIBRARY_SYMBOL(json_object_put) - - json_object* root; } JSONCData; bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs); const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result, FFKeyValuePair pairs[]); +// Modified from json_object_object_foreach +#define FF_JSON_OBJECT_OBJECT_FOREACH(data, obj, keyVar, valVar) \ + const char* keyVar = NULL; \ + json_object* valVar = NULL; \ + for (struct lh_entry* entry##keyVar = (obj) ? lh_table_head(data->ffjson_object_get_object(obj)) : NULL; \ + ({ \ + if (entry##keyVar) \ + { \ + keyVar = (const char*) lh_entry_k(entry##keyVar); \ + valVar = (json_object*) lh_entry_v(entry##keyVar); \ + }; \ + entry##keyVar; \ + }); \ + entry##keyVar = lh_entry_next(entry##keyVar)) + #endif diff --git a/src/common/library.h b/src/common/library.h index a0de3d621..3f4a8f237 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -62,16 +62,16 @@ static inline void ffLibraryUnload(void** handle) __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); #define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName.ff ## symbolName, symbolName, returnValue); + FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, returnValue); #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName.ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); + FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(library, varName, symbolName, alternateName) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, varName.ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); + FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, (varName).ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName->ff ## symbolName, symbolName, returnValue); + FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue); void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...); diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index f76f67797..6bc094450 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -156,35 +156,29 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; ffInitBatteryOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + #ifdef __linux__ + if (strcasecmp(key, "dir") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - #ifdef __linux__ - if (strcasecmp(key, "dir") == 0) - { - ffStrbufSetS(&options.dir, data->ffjson_object_get_string(val)); - continue; - } - #endif - - if (strcasecmp(key, "temp") == 0) - { - options.temp = (bool) data->ffjson_object_get_boolean(val); - continue; - } - - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffStrbufSetS(&options.dir, data->ffjson_object_get_string(val)); + continue; } + #endif + + if (strcasecmp(key, "temp") == 0) + { + options.temp = (bool) data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintBattery(instance, &options); diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 718e404a9..87f68bad1 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -76,21 +76,15 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* da FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; ffInitBiosOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintBios(instance, &options); diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 90d5c2f4d..5000db9f6 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -97,27 +97,21 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCDat FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; ffInitBluetoothOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "showConnected") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "showConnected") == 0) - { - options.showDisconnected = data->ffjson_object_get_boolean(val); - continue; - } - - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + options.showDisconnected = data->ffjson_object_get_boolean(val); + continue; } + + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintBluetooth(instance, &options); diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 6f41aa76e..37cb8717e 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -74,21 +74,15 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* d FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; ffInitBoardOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintBoard(instance, &options); diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index fd85ea459..a51aee300 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -88,21 +88,15 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCDa FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; ffInitBrightnessOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintBrightness(instance, &options); diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 43143fb5f..fcc700bcb 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -93,33 +93,27 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; ffInitCommandOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "shell") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "shell") == 0) - { - ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val)); - continue; - } - - if (strcasecmp(key, "text") == 0) - { - ffStrbufSetS(&options.text, data->ffjson_object_get_string(val)); - continue; - } - - ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val)); + continue; } + + if (strcasecmp(key, "text") == 0) + { + ffStrbufSetS(&options.text, data->ffjson_object_get_string(val)); + continue; + } + + ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintCommand(instance, &options); diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 40d09b851..c3db61512 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -79,21 +79,15 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; ffInitDateTimeOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintDateTime(instance, &options); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 72330878c..798698ce3 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -167,49 +167,43 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; ffInitDisplayOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "compactType") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "compactType") == 0) - { - int value; - const char* error = ffJsonConfigParseEnum(data, val, &value, (FFKeyValuePair[]) { - { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, - { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, - { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, - {}, - }); - if (error) - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); - else - options.compactType = (FFDisplayCompactType) value; - continue; - } - - if (strcasecmp(key, "detectName") == 0) - { - options.detectName = data->ffjson_object_get_boolean(val); - continue; - } - - if (strcasecmp(key, "preciseRefreshRate") == 0) - { - options.preciseRefreshRate = data->ffjson_object_get_boolean(val); - continue; - } - - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + int value; + const char* error = ffJsonConfigParseEnum(data, val, &value, (FFKeyValuePair[]) { + { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, + { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, + { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, + {}, + }); + if (error) + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.compactType = (FFDisplayCompactType) value; + continue; } + + if (strcasecmp(key, "detectName") == 0) + { + options.detectName = data->ffjson_object_get_boolean(val); + continue; + } + + if (strcasecmp(key, "preciseRefreshRate") == 0) + { + options.preciseRefreshRate = data->ffjson_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintDisplay(instance, &options); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index d4a498c13..417da2816 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -85,21 +85,15 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* da FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; ffInitHostOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintHost(instance, &options); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index dd2d2d157..fc2e30bfd 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -29,11 +29,17 @@ static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, false; } -static inline void wrapJsoncFree(JSONCData* data) +typedef struct JsonConfigData { - assert(data); - if (data->root) - data->ffjson_object_put(data->root); + JSONCData data; + json_object* root; +} JsonConfigData; + +static inline void wrapJsoncFree(JsonConfigData* jsonConfig) +{ + assert(jsonConfig); + if (jsonConfig->root) + jsonConfig->data.ffjson_object_put(jsonConfig->root); } static const char* parseModules(FFinstance* instance, JSONCData* data, json_object* modules) @@ -52,7 +58,8 @@ static const char* parseModules(FFinstance* instance, JSONCData* data, json_obje } else if (data->ffjson_object_is_type(module, json_type_object)) { - type = data->ffjson_object_get_string(data->ffjson_object_object_get(module, "type")); + json_object* object = data->ffjson_object_object_get(module, "type"); + type = data->ffjson_object_get_string(object); if (!type) return "module object must contain a type key"; } else @@ -74,18 +81,19 @@ static const char* printJsonConfig(FFinstance* instance) "libjson-c" FF_LIBRARY_EXTENSION, 5 #endif ) - JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_boolean) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_int) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_object) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) + JsonConfigData __attribute__((__cleanup__(wrapJsoncFree))) jsonConfig = {}; + JSONCData* data = &jsonConfig.data; + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_tokener_parse) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_is_type) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_array) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_boolean) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_double) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_int) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_string_len) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_string) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_object) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_object_get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_put) FF_STRBUF_AUTO_DESTROY content; ffStrbufInit(&content); @@ -98,11 +106,11 @@ static const char* printJsonConfig(FFinstance* instance) if (success) break; } - data.root = data.ffjson_tokener_parse(content.chars); - if (!data.root) + jsonConfig.root = data->ffjson_tokener_parse(content.chars); + if (!jsonConfig.root) return "Failed to parse JSON config file"; - lh_table* rootObject = data.ffjson_object_get_object(data.root); + lh_table* rootObject = data->ffjson_object_get_object(jsonConfig.root); if (!rootObject) return "Invalid JSON config format. Root value must be an object"; @@ -114,7 +122,7 @@ static const char* printJsonConfig(FFinstance* instance) if (strcmp(key, "modules") == 0) { - const char* error = parseModules(instance, &data, val); + const char* error = parseModules(instance, data, val); if (error) return error; } else diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 31f206581..c1abfa977 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -60,21 +60,15 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; ffInitKernelOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintKernel(instance, &options); diff --git a/src/modules/os/os.c b/src/modules/os/os.c index e87488ded..2650948a9 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -183,29 +183,23 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; ffInitOSOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) - { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) + if (strcasecmp(key, "type") == 0) + continue; + + if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) + continue; + + #if defined(__linux__) || defined(__FreeBSD__) + if (strcasecmp(key, "file") == 0) + { + ffStrbufSetS(&options.file, data->ffjson_object_get_string(val)); continue; - json_object* val = (struct json_object *)lh_entry_v(entry); + } + #endif - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "file") == 0) - { - ffStrbufSetS(&options.file, data->ffjson_object_get_string(val)); - continue; - } - #endif - - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } + ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } ffPrintOS(instance, &options); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 1c6b92bc9..7fd4bc615 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -69,24 +69,18 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCDat FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; ffInitSeparatorOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (strcasecmp(key, "string") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (strcasecmp(key, "string") == 0) - { - ffStrbufSetS(&options.string, data->ffjson_object_get_string(val)); - continue; - } - - ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffStrbufSetS(&options.string, data->ffjson_object_get_string(val)); + continue; } + + ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } ffPrintSeparator(instance, &options); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 3503d01b3..88cae7e77 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -69,24 +69,18 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* d FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; ffInitTitleOptions(&options); - if (module) + FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) { - struct lh_entry* entry; - lh_foreach(data->ffjson_object_get_object(module), entry) + if (strcasecmp(key, "type") == 0) + continue; + + if (strcasecmp(key, "fdqn") == 0) { - const char* key = (const char *)lh_entry_k(entry); - if (strcasecmp(key, "type") == 0) - continue; - json_object* val = (struct json_object *)lh_entry_v(entry); - - if (strcasecmp(key, "fdqn") == 0) - { - options.fdqn = data->ffjson_object_get_boolean(val); - continue; - } - - ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + options.fdqn = data->ffjson_object_get_boolean(val); + continue; } + + ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } ffPrintTitle(instance, &options); From dca9ce4b2d843230d48ee56d21fb358b6d0875fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 15:24:40 +0800 Subject: [PATCH 026/493] JsonConfig: refactor to get rid of `data-ffjson_*` --- CMakeLists.txt | 3 +- src/common/config.h | 42 ------- src/common/json.c | 139 ++++++++++++++++++++++ src/common/json.h | 18 +++ src/common/{config.c => jsonconfig.c} | 20 ++-- src/common/jsonconfig.h | 10 ++ src/detection/terminalfont/terminalfont.c | 79 ++++-------- src/fastfetch.c | 3 +- src/modules/battery/battery.c | 43 +++---- src/modules/battery/battery.h | 4 +- src/modules/bios/bios.c | 17 +-- src/modules/bios/bios.h | 4 +- src/modules/bluetooth/bluetooth.c | 29 +++-- src/modules/bluetooth/bluetooth.h | 4 +- src/modules/board/board.c | 17 +-- src/modules/board/board.h | 4 +- src/modules/break/break.c | 2 +- src/modules/break/break.h | 4 +- src/modules/brightness/brightness.c | 17 +-- src/modules/brightness/brightness.h | 4 +- src/modules/command/command.c | 39 +++--- src/modules/command/command.h | 4 +- src/modules/datetime/datetime.c | 17 +-- src/modules/datetime/datetime.h | 4 +- src/modules/display/display.c | 69 ++++++----- src/modules/display/display.h | 4 +- src/modules/host/host.c | 17 +-- src/modules/host/host.h | 4 +- src/modules/jsonconfig/jsonconfig.c | 94 +++++---------- src/modules/kernel/kernel.c | 17 +-- src/modules/kernel/kernel.h | 4 +- src/modules/os/os.c | 33 ++--- src/modules/os/os.h | 4 +- src/modules/separator/separator.c | 23 ++-- src/modules/separator/separator.h | 4 +- src/modules/title/title.c | 23 ++-- src/modules/title/title.h | 4 +- 37 files changed, 463 insertions(+), 364 deletions(-) delete mode 100644 src/common/config.h create mode 100644 src/common/json.c create mode 100644 src/common/json.h rename src/common/{config.c => jsonconfig.c} (51%) create mode 100644 src/common/jsonconfig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e85996d78..162626cf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,10 +228,11 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h) set(LIBFASTFETCH_SRC src/common/bar.c - src/common/config.c src/common/font.c src/common/format.c src/common/init.c + src/common/json.c + src/common/jsonconfig.c src/common/library.c src/common/option.c src/common/parsing.c diff --git a/src/common/config.h b/src/common/config.h deleted file mode 100644 index 4254e2126..000000000 --- a/src/common/config.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#ifdef FF_HAVE_JSONC - -#include - -#include "common/library.h" - -typedef struct JSONCData -{ - FF_LIBRARY_SYMBOL(json_tokener_parse) - FF_LIBRARY_SYMBOL(json_object_is_type) - FF_LIBRARY_SYMBOL(json_object_get_array) - FF_LIBRARY_SYMBOL(json_object_get_boolean) - FF_LIBRARY_SYMBOL(json_object_get_double) - FF_LIBRARY_SYMBOL(json_object_get_int) - FF_LIBRARY_SYMBOL(json_object_get_string_len) - FF_LIBRARY_SYMBOL(json_object_get_string) - FF_LIBRARY_SYMBOL(json_object_get_object) - FF_LIBRARY_SYMBOL(json_object_object_get) - FF_LIBRARY_SYMBOL(json_object_put) -} JSONCData; - -bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs); -const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result, FFKeyValuePair pairs[]); - -// Modified from json_object_object_foreach -#define FF_JSON_OBJECT_OBJECT_FOREACH(data, obj, keyVar, valVar) \ - const char* keyVar = NULL; \ - json_object* valVar = NULL; \ - for (struct lh_entry* entry##keyVar = (obj) ? lh_table_head(data->ffjson_object_get_object(obj)) : NULL; \ - ({ \ - if (entry##keyVar) \ - { \ - keyVar = (const char*) lh_entry_k(entry##keyVar); \ - valVar = (json_object*) lh_entry_v(entry##keyVar); \ - }; \ - entry##keyVar; \ - }); \ - entry##keyVar = lh_entry_next(entry##keyVar)) - -#endif diff --git a/src/common/json.c b/src/common/json.c new file mode 100644 index 000000000..cfbcd1f64 --- /dev/null +++ b/src/common/json.c @@ -0,0 +1,139 @@ +#include "common/json.h" + +#ifdef FF_HAVE_JSONC + +#include "common/library.h" +#include "common/thread.h" + +#include + +typedef struct FFJsonLibrary +{ + FF_LIBRARY_SYMBOL(json_tokener_parse) + FF_LIBRARY_SYMBOL(json_object_is_type) + FF_LIBRARY_SYMBOL(json_object_get_array) + FF_LIBRARY_SYMBOL(json_object_get_boolean) + FF_LIBRARY_SYMBOL(json_object_get_double) + FF_LIBRARY_SYMBOL(json_object_get_int) + FF_LIBRARY_SYMBOL(json_object_get_string_len) + FF_LIBRARY_SYMBOL(json_object_get_string) + FF_LIBRARY_SYMBOL(json_object_get_object) + FF_LIBRARY_SYMBOL(json_object_object_get) + FF_LIBRARY_SYMBOL(json_object_put) +} FFJsonLibrary; + +static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance) +{ + assert(instance); + + static FFJsonLibrary lib; + FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, NULL, + #ifdef _WIN32 + "libjson-c-5" FF_LIBRARY_EXTENSION, -1 + #else + "libjson-c" FF_LIBRARY_EXTENSION, 5 + #endif + ) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_tokener_parse, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_is_type, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_array, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_boolean, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_double, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_int, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string_len, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_object, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_get, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_put, NULL) + libjsonc = NULL; // don't dlclose automatically + return &lib; +} + +const FFJsonLibrary* ffJsonLib = NULL; +bool ffJsonLoadLibrary(const FFinstance* instance) +{ + static bool loaded = false; + static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; + + if (!loaded) + { + ffThreadMutexLock(&mutex); + + if(!loaded) + { + loaded = true; + ffJsonLib = loadLibSymbols(instance); + } + + ffThreadMutexUnlock(&mutex); + } + return !!ffJsonLib; +} + +struct json_object *json_tokener_parse(const char *str) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_tokener_parse(str); +} + +int json_object_is_type(const json_object *obj, enum json_type type) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_is_type(obj, type); +} + +struct array_list *json_object_get_array(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_array(obj); +} + +json_bool json_object_get_boolean(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_boolean(obj); +} + +double json_object_get_double(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_double(obj); +} + +int32_t json_object_get_int(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_int(obj); +} + +int json_object_get_string_len(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_string_len(obj); +} + +const char *json_object_get_string(json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_string(obj); +} + +struct lh_table *json_object_get_object(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_object(obj); +} + +struct json_object *json_object_object_get(const json_object *obj, const char *key) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_get(obj, key); +} + +int json_object_put(json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_put(obj); +} + +#endif diff --git a/src/common/json.h b/src/common/json.h new file mode 100644 index 000000000..e1bb3ad59 --- /dev/null +++ b/src/common/json.h @@ -0,0 +1,18 @@ +#pragma once + +#ifdef FF_HAVE_JSONC + +#include "fastfetch.h" + +#include + +bool ffJsonLoadLibrary(const FFinstance* instance); + +static inline void wrapJsoncFree(json_object** root) +{ + assert(root); + if (*root) + json_object_put(*root); +} + +#endif diff --git a/src/common/config.c b/src/common/jsonconfig.c similarity index 51% rename from src/common/config.c rename to src/common/jsonconfig.c index c154583c9..151e058e5 100644 --- a/src/common/config.c +++ b/src/common/jsonconfig.c @@ -1,33 +1,33 @@ #include "fastfetch.h" -#include "common/config.h" +#include "common/jsonconfig.h" #ifdef FF_HAVE_JSONC -bool ffJsonConfigParseModuleArgs(JSONCData* data, const char* key, json_object* val, FFModuleArgs* moduleArgs) +bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs) { if(strcasecmp(key, "key") == 0) { - ffStrbufSetNS(&moduleArgs->key, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->key, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); return true; } else if(strcasecmp(key, "format") == 0) { - ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); return true; } else if(strcasecmp(key, "error") == 0) { - ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) data->ffjson_object_get_string_len(val), data->ffjson_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); return true; } return false; } -const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result, FFKeyValuePair pairs[]) +const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[]) { - if (data->ffjson_object_is_type(val, json_type_int)) + if (json_object_is_type(val, json_type_int)) { - int intVal = data->ffjson_object_get_int(val); + int intVal = json_object_get_int(val); for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { @@ -40,9 +40,9 @@ const char* ffJsonConfigParseEnum(JSONCData* data, json_object* val, int* result return "Invalid enum integer"; } - else if (data->ffjson_object_is_type(val, json_type_string)) + else if (json_object_is_type(val, json_type_string)) { - const char* strVal = data->ffjson_object_get_string(val); + const char* strVal = json_object_get_string(val); for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { if (strcasecmp(strVal, pPair->key) == 0) diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h new file mode 100644 index 000000000..76a72c304 --- /dev/null +++ b/src/common/jsonconfig.h @@ -0,0 +1,10 @@ +#pragma once + +#ifdef FF_HAVE_JSONC + +#include "common/json.h" + +bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs); +const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[]); + +#endif diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index d9693f637..2e502861a 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -71,80 +71,45 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) #include "common/library.h" #include "common/processing.h" +#include "common/json.h" #include -#include -typedef struct JSONCData +static const char* detectWTProfile(json_object* profile, FFstrbuf* name, double* size) { - FF_LIBRARY_SYMBOL(json_tokener_parse) - FF_LIBRARY_SYMBOL(json_object_get_array) - FF_LIBRARY_SYMBOL(json_object_is_type) - FF_LIBRARY_SYMBOL(json_object_get_double) - FF_LIBRARY_SYMBOL(json_object_get_string_len) - FF_LIBRARY_SYMBOL(json_object_get_string) - FF_LIBRARY_SYMBOL(json_object_object_get) - FF_LIBRARY_SYMBOL(json_object_put) - - json_object* root; -} JSONCData; - -static const char* detectWTProfile(JSONCData* data, json_object* profile, FFstrbuf* name, double* size) -{ - json_object* font = data->ffjson_object_object_get(profile, "font"); + json_object* font = json_object_object_get(profile, "font"); if (!font) return "json_object_object_get(profile, \"font\"); failed"; - if (!data->ffjson_object_is_type(font, json_type_object)) + if (!json_object_is_type(font, json_type_object)) return "json_object_is_type(font, json_type_object) returns false"; if (name->length == 0) { - json_object* pface = data->ffjson_object_object_get(font, "face"); - if(data->ffjson_object_is_type(pface, json_type_string)) - ffStrbufAppendNS(name, (uint32_t) data->ffjson_object_get_string_len(pface), data->ffjson_object_get_string(pface)); + json_object* pface = json_object_object_get(font, "face"); + if(json_object_is_type(pface, json_type_string)) + ffStrbufAppendNS(name, (uint32_t) json_object_get_string_len(pface), json_object_get_string(pface)); } if (*size < 0) { - json_object* psize = data->ffjson_object_object_get(font, "size"); - if (data->ffjson_object_is_type(psize, json_type_int) || data->ffjson_object_is_type(psize, json_type_double)) - *size = data->ffjson_object_get_double(psize); + json_object* psize = json_object_object_get(font, "size"); + if (json_object_is_type(psize, json_type_int) || json_object_is_type(psize, json_type_double)) + *size = json_object_get_double(psize); } return NULL; } -static inline void wrapJsoncFree(JSONCData* data) -{ - assert(data); - if (data->root) - data->ffjson_object_put(data->root); -} - static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, double* size) { - FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", - #ifdef _WIN32 - "libjson-c-5" FF_LIBRARY_EXTENSION, -1 - #else - "libjson-c" FF_LIBRARY_EXTENSION, 5 - #endif - ) - JSONCData __attribute__((__cleanup__(wrapJsoncFree))) data = {}; - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_tokener_parse) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_is_type) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_array) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_double) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string_len) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_get_string) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_object_get) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, data, json_object_put) + if (ffJsonLoadLibrary(instance)) + return "Failed to load json-c library"; - data.root = data.ffjson_tokener_parse(content->chars); - if (!data.root) + json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content->chars); + if (!root) return "Failed to parse WT JSON config file"; - json_object* profiles = data.ffjson_object_object_get(data.root, "profiles"); + json_object* profiles = json_object_object_get(root, "profiles"); if (!profiles) return "json_object_object_get(root, \"profiles\") failed"; @@ -153,29 +118,29 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten ffStrbufTrim(&wtProfileId, '\''); if (wtProfileId.length > 0) { - array_list* list = data.ffjson_object_get_array(data.ffjson_object_object_get(profiles, "list")); + array_list* list = json_object_get_array(json_object_object_get(profiles, "list")); if (list) { for (size_t idx = 0; idx < list->length; ++idx) { json_object* profile = (json_object*) list->array[idx]; - json_object* guid = data.ffjson_object_object_get(profile, "guid"); + json_object* guid = json_object_object_get(profile, "guid"); - if (!data.ffjson_object_is_type(guid, json_type_string)) + if (!json_object_is_type(guid, json_type_string)) continue; - if(ffStrbufEqualS(&wtProfileId, data.ffjson_object_get_string(guid))) + if(ffStrbufEqualS(&wtProfileId, json_object_get_string(guid))) { - detectWTProfile(&data, profile, name, size); + detectWTProfile(profile, name, size); break; } } } } - json_object* defaults = data.ffjson_object_object_get(profiles, "defaults"); + json_object* defaults = json_object_object_get(profiles, "defaults"); if (defaults) - detectWTProfile(&data, defaults, name, size); + detectWTProfile(defaults, name, size); if(name->length == 0) ffStrbufSetS(name, "Cascadia Mono"); diff --git a/src/fastfetch.c b/src/fastfetch.c index 6f28ca97c..aafdbabd1 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -18,8 +18,7 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" -#include "modules/os/os.h" -#include "common/config.h" +#include "common/jsonconfig.h" #include "modules/modules.h" typedef struct CustomValue diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 6bc094450..38f95a40a 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -148,7 +148,7 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_BATTERY_MODULE_NAME) != 0) return false; @@ -156,29 +156,32 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; ffInitBatteryOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - #ifdef __linux__ - if (strcasecmp(key, "dir") == 0) + json_object_object_foreach(module, key, val) { - ffStrbufSetS(&options.dir, data->ffjson_object_get_string(val)); - continue; - } - #endif + if (strcasecmp(key, "type") == 0) + continue; - if (strcasecmp(key, "temp") == 0) - { - options.temp = (bool) data->ffjson_object_get_boolean(val); - continue; - } + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + #ifdef __linux__ + if (strcasecmp(key, "dir") == 0) + { + ffStrbufSetS(&options.dir, json_object_get_string(val)); + continue; + } + #endif + + if (strcasecmp(key, "temp") == 0) + { + options.temp = (bool) json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintBattery(instance, &options); diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index 20d76a50b..4b69fbd10 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -9,6 +9,6 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co void ffDestroyBatteryOptions(FFBatteryOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 87f68bad1..b936bd6f3 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -68,7 +68,7 @@ void ffDestroyBiosOptions(FFBiosOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_BIOS_MODULE_NAME) != 0) return false; @@ -76,15 +76,18 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* da FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; ffInitBiosOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintBios(instance, &options); diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h index c751285c5..2b9a82149 100644 --- a/src/modules/bios/bios.h +++ b/src/modules/bios/bios.h @@ -8,6 +8,6 @@ bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const ch void ffDestroyBiosOptions(FFBiosOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBiosJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 5000db9f6..503dfe569 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -89,7 +89,7 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_BLUETOOTH_MODULE_NAME) != 0) return false; @@ -97,21 +97,24 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCDat FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; ffInitBluetoothOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "showConnected") == 0) + json_object_object_foreach(module, key, val) { - options.showDisconnected = data->ffjson_object_get_boolean(val); - continue; - } + if (strcasecmp(key, "type") == 0) + continue; - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "showConnected") == 0) + { + options.showDisconnected = json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintBluetooth(instance, &options); diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h index 500d39290..8350590e6 100644 --- a/src/modules/bluetooth/bluetooth.h +++ b/src/modules/bluetooth/bluetooth.h @@ -8,6 +8,6 @@ bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key void ffDestroyBluetoothOptions(FFBluetoothOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 37cb8717e..01efb70c4 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -66,7 +66,7 @@ void ffDestroyBoardOptions(FFBoardOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_BOARD_MODULE_NAME) != 0) return false; @@ -74,15 +74,18 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* d FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; ffInitBoardOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintBoard(instance, &options); diff --git a/src/modules/board/board.h b/src/modules/board/board.h index 2027baf4b..4763aefeb 100644 --- a/src/modules/board/board.h +++ b/src/modules/board/board.h @@ -8,6 +8,6 @@ bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const void ffDestroyBoardOptions(FFBoardOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBoardJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 05587a6fd..4fe59425f 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -11,7 +11,7 @@ void ffPrintBreak(FFinstance* instance) } #ifdef FF_HAVE_JSONC -bool ffParseBreakJsonObject(FFinstance* instance, const char* type, FF_MAYBE_UNUSED JSONCData* data, FF_MAYBE_UNUSED json_object* module) +bool ffParseBreakJsonObject(FFinstance* instance, const char* type, FF_MAYBE_UNUSED json_object* module) { if (strcasecmp(type, FF_BREAK_MODULE_NAME) != 0) return false; diff --git a/src/modules/break/break.h b/src/modules/break/break.h index 81e40f5c8..5be05f55d 100644 --- a/src/modules/break/break.h +++ b/src/modules/break/break.h @@ -5,6 +5,6 @@ void ffPrintBreak(FFinstance* instance); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBreakJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBreakJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index a51aee300..af0e4a3f9 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -80,7 +80,7 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_BRIGHTNESS_MODULE_NAME) != 0) return false; @@ -88,15 +88,18 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCDa FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; ffInitBrightnessOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintBrightness(instance, &options); diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h index 5f32ddb6f..9cde955e5 100644 --- a/src/modules/brightness/brightness.h +++ b/src/modules/brightness/brightness.h @@ -8,6 +8,6 @@ bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* k void ffDestroyBrightnessOptions(FFBrightnessOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/command/command.c b/src/modules/command/command.c index fcc700bcb..d2de35eb4 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -85,7 +85,7 @@ void ffDestroyCommandOptions(FFCommandOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_COMMAND_MODULE_NAME) != 0) return false; @@ -93,27 +93,30 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; ffInitCommandOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "shell") == 0) + json_object_object_foreach(module, key, val) { - ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val)); - continue; - } + if (strcasecmp(key, "type") == 0) + continue; - if (strcasecmp(key, "text") == 0) - { - ffStrbufSetS(&options.text, data->ffjson_object_get_string(val)); - continue; - } + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + if (strcasecmp(key, "shell") == 0) + { + ffStrbufSetS(&options.shell, json_object_get_string(val)); + continue; + } + + if (strcasecmp(key, "text") == 0) + { + ffStrbufSetS(&options.text, json_object_get_string(val)); + continue; + } + + ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintCommand(instance, &options); diff --git a/src/modules/command/command.h b/src/modules/command/command.h index de894975b..bcee46df7 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -8,6 +8,6 @@ bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, co void ffDestroyCommandOptions(FFCommandOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index c3db61512..58eb07958 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -71,7 +71,7 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_DATETIME_MODULE_NAME) != 0) return false; @@ -79,15 +79,18 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; ffInitDateTimeOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintDateTime(instance, &options); diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index 7536e3da7..1a92349e0 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -8,6 +8,6 @@ bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, void ffDestroyDateTimeOptions(FFDateTimeOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 798698ce3..16a7d9b00 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -159,7 +159,7 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_DISPLAY_MODULE_NAME) != 0) return false; @@ -167,43 +167,46 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; ffInitDisplayOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - if (strcasecmp(key, "compactType") == 0) + json_object_object_foreach(module, key, val) { - int value; - const char* error = ffJsonConfigParseEnum(data, val, &value, (FFKeyValuePair[]) { - { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, - { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, - { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, - {}, - }); - if (error) - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); - else - options.compactType = (FFDisplayCompactType) value; - continue; - } + if (strcasecmp(key, "type") == 0) + continue; - if (strcasecmp(key, "detectName") == 0) - { - options.detectName = data->ffjson_object_get_boolean(val); - continue; - } + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - if (strcasecmp(key, "preciseRefreshRate") == 0) - { - options.preciseRefreshRate = data->ffjson_object_get_boolean(val); - continue; - } + if (strcasecmp(key, "compactType") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, + { "original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT }, + { "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT }, + {}, + }); + if (error) + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.compactType = (FFDisplayCompactType) value; + continue; + } - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + if (strcasecmp(key, "detectName") == 0) + { + options.detectName = json_object_get_boolean(val); + continue; + } + + if (strcasecmp(key, "preciseRefreshRate") == 0) + { + options.preciseRefreshRate = json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintDisplay(instance, &options); diff --git a/src/modules/display/display.h b/src/modules/display/display.h index bb09d0e5f..8a4dea42f 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -8,6 +8,6 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co void ffDestroyDisplayOptions(FFDisplayOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 417da2816..2ec61f6db 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -77,7 +77,7 @@ void ffDestroyHostOptions(FFHostOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_HOST_MODULE_NAME) != 0) return false; @@ -85,15 +85,18 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* da FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; ffInitHostOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintHost(instance, &options); diff --git a/src/modules/host/host.h b/src/modules/host/host.h index c2a0ca695..3a848542b 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -8,6 +8,6 @@ bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const ch void ffDestroyHostOptions(FFHostOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseHostJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index fc2e30bfd..4538cc96d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -1,71 +1,59 @@ #include "modules/jsonconfig/jsonconfig.h" -#include "common/config.h" +#include "common/jsonconfig.h" #include "common/printing.h" #ifdef FF_HAVE_JSONC #include "common/io/io.h" +#include "common/json.h" #include "modules/modules.h" #include -static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module) { return - ffParseTitleJsonObject(instance, type, data, module) || - ffParseBatteryJsonObject(instance, type, data, module) || - ffParseBiosJsonObject(instance, type, data, module) || - ffParseBluetoothJsonObject(instance, type, data, module) || - ffParseBoardJsonObject(instance, type, data, module) || - ffParseBreakJsonObject(instance, type, data, module) || - ffParseBrightnessJsonObject(instance, type, data, module) || - ffParseCommandJsonObject(instance, type, data, module) || - ffParseDateTimeJsonObject(instance, type, data, module) || - ffParseDisplayJsonObject(instance, type, data, module) || - ffParseHostJsonObject(instance, type, data, module) || - ffParseKernelJsonObject(instance, type, data, module) || - ffParseOSJsonObject(instance, type, data, module) || - ffParseSeparatorJsonObject(instance, type, data, module) || + ffParseTitleJsonObject(instance, type, module) || + ffParseBatteryJsonObject(instance, type, module) || + ffParseBiosJsonObject(instance, type, module) || + ffParseBluetoothJsonObject(instance, type, module) || + ffParseBoardJsonObject(instance, type, module) || + ffParseBreakJsonObject(instance, type, module) || + ffParseBrightnessJsonObject(instance, type, module) || + ffParseCommandJsonObject(instance, type, module) || + ffParseDateTimeJsonObject(instance, type, module) || + ffParseDisplayJsonObject(instance, type, module) || + ffParseHostJsonObject(instance, type, module) || + ffParseKernelJsonObject(instance, type, module) || + ffParseOSJsonObject(instance, type, module) || + ffParseSeparatorJsonObject(instance, type, module) || false; } -typedef struct JsonConfigData +static const char* parseModules(FFinstance* instance, json_object* modules) { - JSONCData data; - json_object* root; -} JsonConfigData; - -static inline void wrapJsoncFree(JsonConfigData* jsonConfig) -{ - assert(jsonConfig); - if (jsonConfig->root) - jsonConfig->data.ffjson_object_put(jsonConfig->root); -} - -static const char* parseModules(FFinstance* instance, JSONCData* data, json_object* modules) -{ - array_list* list = data->ffjson_object_get_array(modules); + array_list* list = json_object_get_array(modules); if (!list) return "modules must be an array of strings or objects"; for (size_t idx = 0; idx < list->length; ++idx) { json_object* module = (json_object*) list->array[idx]; const char* type = NULL; - if (data->ffjson_object_is_type(module, json_type_string)) + if (json_object_is_type(module, json_type_string)) { - type = data->ffjson_object_get_string(module); + type = json_object_get_string(module); module = NULL; } - else if (data->ffjson_object_is_type(module, json_type_object)) + else if (json_object_is_type(module, json_type_object)) { - json_object* object = data->ffjson_object_object_get(module, "type"); - type = data->ffjson_object_get_string(object); + json_object* object = json_object_object_get(module, "type"); + type = json_object_get_string(object); if (!type) return "module object must contain a type key"; } else return "modules must be an array of strings or objects"; - if(!parseModuleJsonObject(instance, type, data, module)) + if(!parseModuleJsonObject(instance, type, module)) return "Unknown module type"; } @@ -74,26 +62,8 @@ static const char* parseModules(FFinstance* instance, JSONCData* data, json_obje static const char* printJsonConfig(FFinstance* instance) { - FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, "dlopen libjson-c" FF_LIBRARY_EXTENSION" failed", - #ifdef _WIN32 - "libjson-c-5" FF_LIBRARY_EXTENSION, -1 - #else - "libjson-c" FF_LIBRARY_EXTENSION, 5 - #endif - ) - JsonConfigData __attribute__((__cleanup__(wrapJsoncFree))) jsonConfig = {}; - JSONCData* data = &jsonConfig.data; - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_tokener_parse) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_is_type) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_array) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_boolean) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_double) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_int) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_string_len) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_string) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_get_object) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_object_get) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libjsonc, *data, json_object_put) + if (!ffJsonLoadLibrary(instance)) + return "Failed to load json-c library"; FF_STRBUF_AUTO_DESTROY content; ffStrbufInit(&content); @@ -106,11 +76,11 @@ static const char* printJsonConfig(FFinstance* instance) if (success) break; } - jsonConfig.root = data->ffjson_tokener_parse(content.chars); - if (!jsonConfig.root) + json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content.chars); + if (!root) return "Failed to parse JSON config file"; - lh_table* rootObject = data->ffjson_object_get_object(jsonConfig.root); + lh_table* rootObject = json_object_get_object(root); if (!rootObject) return "Invalid JSON config format. Root value must be an object"; @@ -118,11 +88,11 @@ static const char* printJsonConfig(FFinstance* instance) lh_foreach(rootObject, entry) { const char* key = (const char *)lh_entry_k(entry); - json_object* val = (struct json_object *)lh_entry_v(entry); + json_object* val = (json_object *)lh_entry_v(entry); if (strcmp(key, "modules") == 0) { - const char* error = parseModules(instance, data, val); + const char* error = parseModules(instance, val); if (error) return error; } else diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index c1abfa977..6bbd06bf9 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -52,7 +52,7 @@ void ffDestroyKernelOptions(FFKernelOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_KERNEL_MODULE_NAME) != 0) return false; @@ -60,15 +60,18 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; ffInitKernelOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) + continue; - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; - ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintKernel(instance, &options); diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h index 7d3b55b35..1bdb63e84 100644 --- a/src/modules/kernel/kernel.h +++ b/src/modules/kernel/kernel.h @@ -9,6 +9,6 @@ bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, cons void ffDestroyKernelOptions(FFKernelOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseKernelJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 2650948a9..6cb032f5e 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -175,7 +175,7 @@ void ffDestroyOSOptions(FFOSOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_OS_MODULE_NAME) != 0) return false; @@ -183,23 +183,26 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; ffInitOSOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs)) - continue; - - #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "file") == 0) - { - ffStrbufSetS(&options.file, data->ffjson_object_get_string(val)); + json_object_object_foreach(module, key, val) + { + if (strcasecmp(key, "type") == 0) continue; - } - #endif - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + #if defined(__linux__) || defined(__FreeBSD__) + if (strcasecmp(key, "file") == 0) + { + ffStrbufSetS(&options.file, json_object_get_string(val)); + continue; + } + #endif + + ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } } ffPrintOS(instance, &options); diff --git a/src/modules/os/os.h b/src/modules/os/os.h index 9d66a32d4..dc685a687 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -9,6 +9,6 @@ bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* void ffDestroyOSOptions(FFOSOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 7fd4bc615..d40602b08 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -61,7 +61,7 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_SEPARATOR_MODULE_NAME) != 0) return false; @@ -69,18 +69,21 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCDat FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; ffInitSeparatorOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (strcasecmp(key, "string") == 0) + json_object_object_foreach(module, key, val) { - ffStrbufSetS(&options.string, data->ffjson_object_get_string(val)); - continue; - } + if (strcasecmp(key, "type") == 0) + continue; - ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + if (strcasecmp(key, "string") == 0) + { + ffStrbufSetS(&options.string, json_object_get_string(val)); + continue; + } + + ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + } } ffPrintSeparator(instance, &options); diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h index 295afa215..dccebb0c4 100644 --- a/src/modules/separator/separator.h +++ b/src/modules/separator/separator.h @@ -9,6 +9,6 @@ bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key void ffDestroySeparatorOptions(FFSeparatorOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module); #endif diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 88cae7e77..118090af6 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -61,7 +61,7 @@ void ffDestroyTitleOptions(FFTitleOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module) +bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module) { if (strcasecmp(type, FF_TITLE_MODULE_NAME) != 0) return false; @@ -69,18 +69,21 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* d FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; ffInitTitleOptions(&options); - FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val) + if (module) { - if (strcasecmp(key, "type") == 0) - continue; - - if (strcasecmp(key, "fdqn") == 0) + json_object_object_foreach(module, key, val) { - options.fdqn = data->ffjson_object_get_boolean(val); - continue; - } + if (strcasecmp(key, "type") == 0) + continue; - ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + if (strcasecmp(key, "fdqn") == 0) + { + options.fdqn = json_object_get_boolean(val); + continue; + } + + ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + } } ffPrintTitle(instance, &options); diff --git a/src/modules/title/title.h b/src/modules/title/title.h index b361e72c7..7d0a8a609 100644 --- a/src/modules/title/title.h +++ b/src/modules/title/title.h @@ -9,6 +9,6 @@ bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const void ffDestroyTitleOptions(FFTitleOptions* options); #ifdef FF_HAVE_JSONC -#include "common/config.h" -bool ffParseTitleJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module); +#include "common/jsonconfig.h" +bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module); #endif From ff721218f5bfae91b76f95f989f34082d012295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 16:54:50 +0800 Subject: [PATCH 027/493] JsonConfig: simplify code --- src/common/json.c | 16 +++++ src/fastfetch.c | 24 ++++---- src/modules/battery/battery.c | 10 +--- src/modules/battery/battery.h | 4 +- src/modules/bios/bios.c | 10 +--- src/modules/bios/bios.h | 4 +- src/modules/bluetooth/bluetooth.c | 10 +--- src/modules/bluetooth/bluetooth.h | 4 +- src/modules/board/board.c | 10 +--- src/modules/board/board.h | 4 +- src/modules/break/break.c | 10 +--- src/modules/break/break.h | 4 +- src/modules/brightness/brightness.c | 10 +--- src/modules/brightness/brightness.h | 4 +- src/modules/command/command.c | 11 +--- src/modules/command/command.h | 4 +- src/modules/datetime/datetime.c | 10 +--- src/modules/datetime/datetime.h | 4 +- src/modules/display/display.c | 10 +--- src/modules/display/display.h | 4 +- src/modules/host/host.c | 10 +--- src/modules/host/host.h | 4 +- src/modules/jsonconfig/jsonconfig.c | 93 +++++++++++++++++++++++------ src/modules/jsonconfig/jsonconfig.h | 2 + src/modules/kernel/kernel.c | 10 +--- src/modules/kernel/kernel.h | 4 +- src/modules/os/os.c | 10 +--- src/modules/os/os.h | 4 +- src/modules/separator/separator.c | 11 +--- src/modules/separator/separator.h | 4 +- src/modules/title/title.c | 11 +--- src/modules/title/title.h | 4 +- 32 files changed, 162 insertions(+), 172 deletions(-) diff --git a/src/common/json.c b/src/common/json.c index cfbcd1f64..053854675 100644 --- a/src/common/json.c +++ b/src/common/json.c @@ -18,7 +18,9 @@ typedef struct FFJsonLibrary FF_LIBRARY_SYMBOL(json_object_get_string_len) FF_LIBRARY_SYMBOL(json_object_get_string) FF_LIBRARY_SYMBOL(json_object_get_object) + FF_LIBRARY_SYMBOL(json_object_object_del) FF_LIBRARY_SYMBOL(json_object_object_get) + FF_LIBRARY_SYMBOL(json_object_object_length) FF_LIBRARY_SYMBOL(json_object_put) } FFJsonLibrary; @@ -43,7 +45,9 @@ static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance) FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string_len, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_object, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_del, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_get, NULL) + FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_length, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_put, NULL) libjsonc = NULL; // don't dlclose automatically return &lib; @@ -124,12 +128,24 @@ struct lh_table *json_object_get_object(const json_object *obj) return ffJsonLib->ffjson_object_get_object(obj); } +void json_object_object_del(struct json_object *obj, const char *key) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_del(obj, key); +} + struct json_object *json_object_object_get(const json_object *obj, const char *key) { assert(ffJsonLib); return ffJsonLib->ffjson_object_object_get(obj, key); } +int json_object_object_length(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_length(obj); +} + int json_object_put(json_object *obj) { assert(ffJsonLib); diff --git a/src/fastfetch.c b/src/fastfetch.c index aafdbabd1..80df7fc42 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1251,23 +1251,23 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char if(strcasecmp(line, "break") == 0) ffPrintBreak(instance); - else if(strcasecmp(line, "title") == 0) + else if(strcasecmp(line, FF_TITLE_MODULE_NAME) == 0) ffPrintTitle(instance, &instance->config.title); - else if(strcasecmp(line, "separator") == 0) + else if(strcasecmp(line, FF_SEPARATOR_MODULE_NAME) == 0) ffPrintSeparator(instance, &instance->config.separator); - else if(strcasecmp(line, "os") == 0) + else if(strcasecmp(line, FF_OS_MODULE_NAME) == 0) ffPrintOS(instance, &instance->config.os); - else if(strcasecmp(line, "host") == 0) + else if(strcasecmp(line, FF_HOST_MODULE_NAME) == 0) ffPrintHost(instance, &instance->config.host); - else if(strcasecmp(line, "bios") == 0) + else if(strcasecmp(line, FF_BIOS_MODULE_NAME) == 0) ffPrintBios(instance, &instance->config.bios); - else if(strcasecmp(line, "board") == 0) + else if(strcasecmp(line, FF_BOARD_MODULE_NAME) == 0) ffPrintBoard(instance, &instance->config.board); - else if(strcasecmp(line, "brightness") == 0) + else if(strcasecmp(line, FF_BRIGHTNESS_MODULE_NAME) == 0) ffPrintBrightness(instance, &instance->config.brightness); else if(strcasecmp(line, "chassis") == 0) ffPrintChassis(instance); - else if(strcasecmp(line, "kernel") == 0) + else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0) ffPrintKernel(instance, &instance->config.kernel); else if(strcasecmp(line, "uptime") == 0) ffPrintUptime(instance); @@ -1277,7 +1277,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintPackages(instance); else if(strcasecmp(line, "shell") == 0) ffPrintShell(instance); - else if(strcasecmp(line, "display") == 0) + else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0) ffPrintDisplay(instance, &instance->config.display); else if(strcasecmp(line, "desktopenvironment") == 0 || strcasecmp(line, "de") == 0) ffPrintDesktopEnvironment(instance); @@ -1329,7 +1329,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintPlayer(instance); else if(strcasecmp(line, "media") == 0) ffPrintMedia(instance); - else if(strcasecmp(line, "datetime") == 0) + else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) ffPrintDateTime(instance, &instance->config.dateTime); else if(strcasecmp(line, "colors") == 0) ffPrintColors(instance); @@ -1341,7 +1341,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintOpenCL(instance); else if(strcasecmp(line, "users") == 0) ffPrintUsers(instance); - else if(strcasecmp(line, "command") == 0) + else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0) ffPrintCommand(instance, &instance->config.command); else if(strcasecmp(line, "bluetooth") == 0) ffPrintBluetooth(instance, &instance->config.bluetooth); @@ -1349,7 +1349,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintSound(instance); else if(strcasecmp(line, "gamepad") == 0) ffPrintGamepad(instance); - else if(strcasecmp(line, "jsonconfig") == 0) + else if(strcasecmp(line, FF_JSONCONFIG_MODULE_NAME) == 0) ffPrintJsonConfig(instance); else ffPrintErrorString(instance, line, 0, NULL, NULL, ""); diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 38f95a40a..e3ec40eed 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -4,7 +4,6 @@ #include "detection/battery/battery.h" #include "modules/battery/battery.h" -#define FF_BATTERY_MODULE_NAME "Battery" #define FF_BATTERY_NUM_FORMAT_ARGS 5 static void printBattery(FFinstance* instance, FFBatteryOptions* options, BatteryResult* result, uint8_t index) @@ -148,11 +147,8 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseBatteryJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_BATTERY_MODULE_NAME) != 0) - return false; - FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; ffInitBatteryOptions(&options); @@ -160,9 +156,6 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_objec { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -185,6 +178,5 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_objec } ffPrintBattery(instance, &options); - return true; } #endif diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index 4b69fbd10..efe7f9132 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_BATTERY_MODULE_NAME "Battery" + void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); void ffInitBatteryOptions(FFBatteryOptions* options); @@ -10,5 +12,5 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBatteryJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index b936bd6f3..12e79e048 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -3,7 +3,6 @@ #include "detection/bios/bios.h" #include "modules/bios/bios.h" -#define FF_BIOS_MODULE_NAME "Bios" #define FF_BIOS_NUM_FORMAT_ARGS 4 void ffPrintBios(FFinstance* instance, FFBiosOptions* options) @@ -68,11 +67,8 @@ void ffDestroyBiosOptions(FFBiosOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseBiosJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_BIOS_MODULE_NAME) != 0) - return false; - FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; ffInitBiosOptions(&options); @@ -80,9 +76,6 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -91,6 +84,5 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* } ffPrintBios(instance, &options); - return true; } #endif diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h index 2b9a82149..8ff5c7837 100644 --- a/src/modules/bios/bios.h +++ b/src/modules/bios/bios.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_BIOS_MODULE_NAME "Bios" + void ffPrintBios(FFinstance* instance, FFBiosOptions* options); void ffInitBiosOptions(FFBiosOptions* options); bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyBiosOptions(FFBiosOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBiosJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 503dfe569..1b33db8bf 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -2,7 +2,6 @@ #include "detection/bluetooth/bluetooth.h" #include "modules/bluetooth/bluetooth.h" -#define FF_BLUETOOTH_MODULE_NAME "Bluetooth" #define FF_BLUETOOTH_NUM_FORMAT_ARGS 4 static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index) @@ -89,11 +88,8 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_BLUETOOTH_MODULE_NAME) != 0) - return false; - FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; ffInitBluetoothOptions(&options); @@ -101,9 +97,6 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_obj { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -118,6 +111,5 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_obj } ffPrintBluetooth(instance, &options); - return true; } #endif diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h index 8350590e6..5c72b0ec7 100644 --- a/src/modules/bluetooth/bluetooth.h +++ b/src/modules/bluetooth/bluetooth.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_BLUETOOTH_MODULE_NAME "Bluetooth" + void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options); void ffInitBluetoothOptions(FFBluetoothOptions* options); bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 01efb70c4..39c1fab01 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -3,7 +3,6 @@ #include "detection/board/board.h" #include "modules/board/board.h" -#define FF_BOARD_MODULE_NAME "Board" #define FF_BOARD_NUM_FORMAT_ARGS 3 void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) @@ -66,11 +65,8 @@ void ffDestroyBoardOptions(FFBoardOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseBoardJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_BOARD_MODULE_NAME) != 0) - return false; - FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; ffInitBoardOptions(&options); @@ -78,9 +74,6 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -89,6 +82,5 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* } ffPrintBoard(instance, &options); - return true; } #endif diff --git a/src/modules/board/board.h b/src/modules/board/board.h index 4763aefeb..10b9c6f5c 100644 --- a/src/modules/board/board.h +++ b/src/modules/board/board.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_BOARD_MODULE_NAME "Board" + void ffPrintBoard(FFinstance* instance, FFBoardOptions* options); void ffInitBoardOptions(FFBoardOptions* options); bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyBoardOptions(FFBoardOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBoardJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 4fe59425f..59d205210 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -2,8 +2,6 @@ #include "common/printing.h" #include "modules/break/break.h" -#define FF_BREAK_MODULE_NAME "Break" - void ffPrintBreak(FFinstance* instance) { ffLogoPrintLine(instance); @@ -11,12 +9,8 @@ void ffPrintBreak(FFinstance* instance) } #ifdef FF_HAVE_JSONC -bool ffParseBreakJsonObject(FFinstance* instance, const char* type, FF_MAYBE_UNUSED json_object* module) +void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module) { - if (strcasecmp(type, FF_BREAK_MODULE_NAME) != 0) - return false; - - ffPrintBreak(instance); - return true; + return ffPrintBreak(instance); } #endif diff --git a/src/modules/break/break.h b/src/modules/break/break.h index 5be05f55d..a7b34957d 100644 --- a/src/modules/break/break.h +++ b/src/modules/break/break.h @@ -2,9 +2,11 @@ #include "fastfetch.h" +#define FF_BREAK_MODULE_NAME "Break" + void ffPrintBreak(FFinstance* instance); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBreakJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBreakJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index af0e4a3f9..655501a98 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -3,7 +3,6 @@ #include "detection/brightness/brightness.h" #include "modules/brightness/brightness.h" -#define FF_BRIGHTNESS_MODULE_NAME "Brightness" #define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2 void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) @@ -80,11 +79,8 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_BRIGHTNESS_MODULE_NAME) != 0) - return false; - FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; ffInitBrightnessOptions(&options); @@ -92,9 +88,6 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_ob { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -103,6 +96,5 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_ob } ffPrintBrightness(instance, &options); - return true; } #endif diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h index 9cde955e5..58fbbf302 100644 --- a/src/modules/brightness/brightness.h +++ b/src/modules/brightness/brightness.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_BRIGHTNESS_MODULE_NAME "Brightness" + void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options); void ffInitBrightnessOptions(FFBrightnessOptions* options); bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/command/command.c b/src/modules/command/command.c index d2de35eb4..92768cd31 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -4,8 +4,6 @@ #include "common/processing.h" #include "modules/command/command.h" -#define FF_COMMAND_MODULE_NAME "Command" - void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) { FF_STRBUF_AUTO_DESTROY result; @@ -85,11 +83,8 @@ void ffDestroyCommandOptions(FFCommandOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseCommandJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_COMMAND_MODULE_NAME) != 0) - return false; - FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; ffInitCommandOptions(&options); @@ -97,9 +92,6 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_objec { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -120,6 +112,5 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_objec } ffPrintCommand(instance, &options); - return true; } #endif diff --git a/src/modules/command/command.h b/src/modules/command/command.h index bcee46df7..9944b9bd7 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_COMMAND_MODULE_NAME "Command" + void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); void ffInitCommandOptions(FFCommandOptions* options); bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyCommandOptions(FFCommandOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseCommandJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 58eb07958..654060f77 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -3,7 +3,6 @@ #include "detection/datetime/datetime.h" #include "modules/datetime/datetime.h" -#define FF_DATETIME_MODULE_NAME "DateTime" #define FF_DATETIME_DISPLAY_NAME "Date & Time" #define FF_DATETIME_NUM_FORMAT_ARGS 20 @@ -71,11 +70,8 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_DATETIME_MODULE_NAME) != 0) - return false; - FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; ffInitDateTimeOptions(&options); @@ -83,9 +79,6 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_obje { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -94,6 +87,5 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_obje } ffPrintDateTime(instance, &options); - return true; } #endif diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index 1a92349e0..737646611 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_DATETIME_MODULE_NAME "DateTime" + void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); void ffInitDateTimeOptions(FFDateTimeOptions* options); bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 16a7d9b00..737ad228d 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -3,7 +3,6 @@ #include "detection/displayserver/displayserver.h" #include "modules/display/display.h" -#define FF_DISPLAY_MODULE_NAME "Display" #define FF_DISPLAY_NUM_FORMAT_ARGS 7 void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) @@ -159,11 +158,8 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseDisplayJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_DISPLAY_MODULE_NAME) != 0) - return false; - FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; ffInitDisplayOptions(&options); @@ -171,9 +167,6 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_objec { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -210,6 +203,5 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_objec } ffPrintDisplay(instance, &options); - return true; } #endif diff --git a/src/modules/display/display.h b/src/modules/display/display.h index 8a4dea42f..f5f31627c 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_DISPLAY_MODULE_NAME "Display" + void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options); void ffInitDisplayOptions(FFDisplayOptions* options); bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseDisplayJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 2ec61f6db..0dfd42f4c 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -3,7 +3,6 @@ #include "detection/host/host.h" #include "modules/host/host.h" -#define FF_HOST_MODULE_NAME "Host" #define FF_HOST_NUM_FORMAT_ARGS 5 void ffPrintHost(FFinstance* instance, FFHostOptions* options) @@ -77,11 +76,8 @@ void ffDestroyHostOptions(FFHostOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseHostJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_HOST_MODULE_NAME) != 0) - return false; - FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; ffInitHostOptions(&options); @@ -89,9 +85,6 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -100,6 +93,5 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* } ffPrintHost(instance, &options); - return true; } #endif diff --git a/src/modules/host/host.h b/src/modules/host/host.h index 3a848542b..9801d8010 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -2,6 +2,8 @@ #include "fastfetch.h" +#define FF_HOST_MODULE_NAME "Host" + void ffPrintHost(FFinstance* instance, FFHostOptions* options); void ffInitHostOptions(FFHostOptions* options); bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value); @@ -9,5 +11,5 @@ void ffDestroyHostOptions(FFHostOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseHostJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 4538cc96d..e2ee26dfb 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -9,25 +9,80 @@ #include "modules/modules.h" #include +#include -static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module) +static inline bool tryModule(FFinstance* instance, const char* type, json_object* module, const char* moduleName, void (*const f)(FFinstance *instance, json_object *module)) { - return - ffParseTitleJsonObject(instance, type, module) || - ffParseBatteryJsonObject(instance, type, module) || - ffParseBiosJsonObject(instance, type, module) || - ffParseBluetoothJsonObject(instance, type, module) || - ffParseBoardJsonObject(instance, type, module) || - ffParseBreakJsonObject(instance, type, module) || - ffParseBrightnessJsonObject(instance, type, module) || - ffParseCommandJsonObject(instance, type, module) || - ffParseDateTimeJsonObject(instance, type, module) || - ffParseDisplayJsonObject(instance, type, module) || - ffParseHostJsonObject(instance, type, module) || - ffParseKernelJsonObject(instance, type, module) || - ffParseOSJsonObject(instance, type, module) || - ffParseSeparatorJsonObject(instance, type, module) || - false; + if (strcasecmp(type, moduleName) == 0) + { + if (module) json_object_object_del(module, "type"); // this line frees `type` + f(instance, module); + return true; + } + return false; +} + +static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module) +{ + switch (toupper(type[0])) + { + case 'B': { + return + tryModule(instance, type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) || + tryModule(instance, type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) || + tryModule(instance, type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) || + tryModule(instance, type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) || + tryModule(instance, type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) || + tryModule(instance, type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) || + false; + } + + case 'C': { + return + tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || + false; + } + + case 'D': { + return + tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || + tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || + false; + } + + case 'H': { + return + tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || + false; + } + + case 'K': { + return + tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || + false; + } + + case 'O': { + return + tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || + false; + } + + case 'S': { + return + tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || + false; + } + + case 'T': { + return + tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || + false; + } + + default: + return false; + } } static const char* parseModules(FFinstance* instance, json_object* modules) @@ -48,7 +103,9 @@ static const char* parseModules(FFinstance* instance, json_object* modules) { json_object* object = json_object_object_get(module, "type"); type = json_object_get_string(object); - if (!type) return "module object must contain a type key"; + if (!type) return "module object must contain a \"type\" key ( case sensitive )"; + if (json_object_object_length(module) == 1) // contains only Property type + module = NULL; } else return "modules must be an array of strings or objects"; diff --git a/src/modules/jsonconfig/jsonconfig.h b/src/modules/jsonconfig/jsonconfig.h index a29f7bda5..fe0b7e43a 100644 --- a/src/modules/jsonconfig/jsonconfig.h +++ b/src/modules/jsonconfig/jsonconfig.h @@ -2,4 +2,6 @@ #include "fastfetch.h" +#define FF_JSONCONFIG_MODULE_NAME "JsonConfig" + void ffPrintJsonConfig(FFinstance* instance); diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 6bbd06bf9..36b5e8545 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -2,7 +2,6 @@ #include "common/printing.h" #include "modules/kernel/kernel.h" -#define FF_KERNEL_MODULE_NAME "Kernel" #define FF_KERNEL_NUM_FORMAT_ARGS 4 void ffPrintKernel(FFinstance* instance, FFKernelOptions* options) @@ -52,11 +51,8 @@ void ffDestroyKernelOptions(FFKernelOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseKernelJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_KERNEL_MODULE_NAME) != 0) - return false; - FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; ffInitKernelOptions(&options); @@ -64,9 +60,6 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -75,6 +68,5 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object } ffPrintKernel(instance, &options); - return true; } #endif diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h index 1bdb63e84..ee0d78300 100644 --- a/src/modules/kernel/kernel.h +++ b/src/modules/kernel/kernel.h @@ -3,6 +3,8 @@ #include "fastfetch.h" #include "modules/kernel/option.h" +#define FF_KERNEL_MODULE_NAME "Kernel" + void ffPrintKernel(FFinstance* instance, FFKernelOptions* options); void ffInitKernelOptions(FFKernelOptions* options); bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value); @@ -10,5 +12,5 @@ void ffDestroyKernelOptions(FFKernelOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseKernelJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 6cb032f5e..637c1094a 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -6,7 +6,6 @@ #include -#define FF_OS_MODULE_NAME "OS" #define FF_OS_NUM_FORMAT_ARGS 12 static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result) @@ -175,11 +174,8 @@ void ffDestroyOSOptions(FFOSOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseOSJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_OS_MODULE_NAME) != 0) - return false; - FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; ffInitOSOptions(&options); @@ -187,9 +183,6 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* mo { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -206,6 +199,5 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* mo } ffPrintOS(instance, &options); - return true; } #endif diff --git a/src/modules/os/os.h b/src/modules/os/os.h index dc685a687..90e9c5981 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -3,6 +3,8 @@ #include "fastfetch.h" #include "modules/os/option.h" +#define FF_OS_MODULE_NAME "OS" + void ffPrintOS(FFinstance* instance, FFOSOptions* options); void ffInitOSOptions(FFOSOptions* options); bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value); @@ -10,5 +12,5 @@ void ffDestroyOSOptions(FFOSOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseOSJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index d40602b08..d693dc398 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -2,8 +2,6 @@ #include "common/printing.h" #include "modules/separator/separator.h" -#define FF_SEPARATOR_MODULE_NAME "Separator" - void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) { uint32_t titleLength = instance->state.titleLength; @@ -61,11 +59,8 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_SEPARATOR_MODULE_NAME) != 0) - return false; - FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; ffInitSeparatorOptions(&options); @@ -73,9 +68,6 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_obj { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (strcasecmp(key, "string") == 0) { ffStrbufSetS(&options.string, json_object_get_string(val)); @@ -87,6 +79,5 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_obj } ffPrintSeparator(instance, &options); - return true; } #endif diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h index dccebb0c4..de26799bc 100644 --- a/src/modules/separator/separator.h +++ b/src/modules/separator/separator.h @@ -3,6 +3,8 @@ #include "fastfetch.h" #include "modules/separator/option.h" +#define FF_SEPARATOR_MODULE_NAME "Separator" + void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options); void ffInitSeparatorOptions(FFSeparatorOptions* options); bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value); @@ -10,5 +12,5 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module); #endif diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 118090af6..fcdcdd3a1 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -3,8 +3,6 @@ #include "util/textModifier.h" #include "modules/title/title.h" -#define FF_TITLE_MODULE_NAME "Title" - static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) { if(!instance->config.pipe) @@ -61,11 +59,8 @@ void ffDestroyTitleOptions(FFTitleOptions* options) } #ifdef FF_HAVE_JSONC -bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module) +void ffParseTitleJsonObject(FFinstance* instance, json_object* module) { - if (strcasecmp(type, FF_TITLE_MODULE_NAME) != 0) - return false; - FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; ffInitTitleOptions(&options); @@ -73,9 +68,6 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* { json_object_object_foreach(module, key, val) { - if (strcasecmp(key, "type") == 0) - continue; - if (strcasecmp(key, "fdqn") == 0) { options.fdqn = json_object_get_boolean(val); @@ -87,6 +79,5 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* } ffPrintTitle(instance, &options); - return true; } #endif diff --git a/src/modules/title/title.h b/src/modules/title/title.h index 7d0a8a609..ab6e07eae 100644 --- a/src/modules/title/title.h +++ b/src/modules/title/title.h @@ -3,6 +3,8 @@ #include "fastfetch.h" #include "modules/title/option.h" +#define FF_TITLE_MODULE_NAME "Title" + void ffPrintTitle(FFinstance* instance, FFTitleOptions* options); void ffInitTitleOptions(FFTitleOptions* options); bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value); @@ -10,5 +12,5 @@ void ffDestroyTitleOptions(FFTitleOptions* options); #ifdef FF_HAVE_JSONC #include "common/jsonconfig.h" -bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module); +void ffParseTitleJsonObject(FFinstance* instance, json_object* module); #endif From 9209ac5773a1ead7890a74375caff246d429bb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 17:02:54 +0800 Subject: [PATCH 028/493] Colors: support JSON config --- CMakeLists.txt | 2 +- src/fastfetch.c | 2 +- src/modules/{ => colors}/colors.c | 8 ++++++++ src/modules/colors/colors.h | 12 ++++++++++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + 6 files changed, 24 insertions(+), 2 deletions(-) rename src/modules/{ => colors}/colors.c (82%) create mode 100644 src/modules/colors/colors.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 162626cf4..6090b0de2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,7 +269,7 @@ set(LIBFASTFETCH_SRC src/modules/brightness/brightness.c src/modules/break/break.c src/modules/chassis.c - src/modules/colors.c + src/modules/colors/colors.c src/modules/cpu.c src/modules/cpuUsage.c src/modules/cursor.c diff --git a/src/fastfetch.c b/src/fastfetch.c index 80df7fc42..259eb23a7 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1331,7 +1331,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintMedia(instance); else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) ffPrintDateTime(instance, &instance->config.dateTime); - else if(strcasecmp(line, "colors") == 0) + else if(strcasecmp(line, FF_COLORS_MODULE_NAME) == 0) ffPrintColors(instance); else if(strcasecmp(line, "vulkan") == 0) ffPrintVulkan(instance); diff --git a/src/modules/colors.c b/src/modules/colors/colors.c similarity index 82% rename from src/modules/colors.c rename to src/modules/colors/colors.c index 186a225cf..a355844c5 100644 --- a/src/modules/colors.c +++ b/src/modules/colors/colors.c @@ -1,6 +1,7 @@ #include "fastfetch.h" #include "common/printing.h" #include "util/textModifier.h" +#include "modules/colors/colors.h" void ffPrintColors(FFinstance* instance) { @@ -28,3 +29,10 @@ void ffPrintColors(FFinstance* instance) puts(FASTFETCH_TEXT_MODIFIER_RESET); } + +#ifdef FF_HAVE_JSONC +void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module) +{ + return ffPrintColors(instance); +} +#endif diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h new file mode 100644 index 000000000..11887735d --- /dev/null +++ b/src/modules/colors/colors.h @@ -0,0 +1,12 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_COLORS_MODULE_NAME "Colors" + +void ffPrintColors(FFinstance* instance); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseColorsJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index e2ee26dfb..50adc012b 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -40,6 +40,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'C': { return tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || + tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 46ab35e4a..f9c8d51ee 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -10,6 +10,7 @@ #include "modules/board/board.h" #include "modules/break/break.h" #include "modules/command/command.h" +#include "modules/colors/colors.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" #include "modules/host/host.h" From f205982ae54d40c0d62553e16b9d1b8780f8496d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 18:17:24 +0800 Subject: [PATCH 029/493] CPU: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 5 +- src/detection/cpu/cpu_apple.c | 2 +- src/detection/cpu/cpu_bsd.c | 4 +- src/detection/cpu/cpu_linux.c | 2 +- src/detection/cpu/cpu_windows.c | 2 +- src/fastfetch.c | 9 +-- src/fastfetch.h | 4 +- src/flashfetch.c | 2 +- src/modules/cpu.c | 56 -------------- src/modules/cpu/cpu.c | 111 ++++++++++++++++++++++++++++ src/modules/cpu/cpu.h | 15 ++++ src/modules/cpu/option.h | 13 ++++ src/modules/cpuUsage.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 17 files changed, 157 insertions(+), 75 deletions(-) delete mode 100644 src/modules/cpu.c create mode 100644 src/modules/cpu/cpu.c create mode 100644 src/modules/cpu/cpu.h create mode 100644 src/modules/cpu/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6090b0de2..aa3eef464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,7 +270,7 @@ set(LIBFASTFETCH_SRC src/modules/break/break.c src/modules/chassis.c src/modules/colors/colors.c - src/modules/cpu.c + src/modules/cpu/cpu.c src/modules/cpuUsage.c src/modules/cursor.c src/modules/custom.c diff --git a/src/common/init.c b/src/common/init.c index a09e34fa8..56e1c8d2d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -80,7 +80,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.cursor); initModuleArg(&instance->config.terminal); initModuleArg(&instance->config.terminalFont); - initModuleArg(&instance->config.cpu); + ffInitCPUOptions(&instance->config.cpu); initModuleArg(&instance->config.cpuUsage); initModuleArg(&instance->config.gpu); initModuleArg(&instance->config.memory); @@ -132,7 +132,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.cpuTemp = false; instance->config.gpuTemp = false; instance->config.gpuForceVulkan = false; @@ -316,7 +315,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.cursor); destroyModuleArg(&instance->config.terminal); destroyModuleArg(&instance->config.terminalFont); - destroyModuleArg(&instance->config.cpu); + ffDestroyCPUOptions(&instance->config.cpu); destroyModuleArg(&instance->config.cpuUsage); destroyModuleArg(&instance->config.gpu); destroyModuleArg(&instance->config.memory); diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index 3de61f93d..7f3f3598f 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -65,7 +65,7 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) if(cpu->frequencyMax == 0.0) cpu->frequencyMax = getFrequency("hw.cpufrequency"); - if (instance->config.cpuTemp) + if (instance->config.cpu.temp) cpu->temperature = detectCpuTemp(&cpu->name); else cpu->temperature = FF_CPU_TEMP_UNSET; diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 2308c8985..9f1e018d3 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -5,9 +5,9 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) { FF_UNUSED(instance); - if (instance->config.cpuTemp) + if (instance->config.cpu.temp) { - FFstrbuf cpuTemp; + FF_STRBUF_AUTO_DESTROY cpuTemp; ffStrbufInit(&cpuTemp); if(ffSysctlGetString("temperature", &cpuTemp)) cpu->temperature = FF_CPU_TEMP_UNSET; diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 202317033..d46221333 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -106,7 +106,7 @@ static void parseIsa(FFstrbuf* cpuIsa) void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) { - if(instance->config.cpuTemp) + if(instance->config.cpu.temp) cpu->temperature = detectCPUTemp(); else cpu->temperature = FF_CPU_TEMP_UNSET; diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index b38d5bb63..13413bec3 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -51,6 +51,6 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL); ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL); - if(instance->config.cpuTemp) + if(instance->config.cpu.temp) ffDetectSmbiosTemp(&cpu->temperature, NULL); } diff --git a/src/fastfetch.c b/src/fastfetch.c index 259eb23a7..a2d43ad04 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1010,6 +1010,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(ffParseHostCommandOptions(&instance->config.host, key, value)) {} + else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(ffParseBiosCommandOptions(&instance->config.bios, key, value)) {} else if(ffParseBoardCommandOptions(&instance->config.board, key, value)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} @@ -1032,7 +1033,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "cursor", &instance->config.cursor)) {} else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {} else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} - else if(optionParseModuleArgs(key, value, "cpu", &instance->config.cpu)) {} + else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} else if(optionParseModuleArgs(key, value, "cpu-usage", &instance->config.cpuUsage)) {} else if(optionParseModuleArgs(key, value, "gpu", &instance->config.gpu)) {} else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} @@ -1121,8 +1122,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--cpu-temp") == 0) - instance->config.cpuTemp = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-temp") == 0) instance->config.gpuTemp = optionParseBoolean(value); else if(strcasecmp(key, "--gpu-force-vulkan") == 0) @@ -1299,8 +1298,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintTerminal(instance); else if(strcasecmp(line, "terminalfont") == 0) ffPrintTerminalFont(instance); - else if(strcasecmp(line, "cpu") == 0) - ffPrintCPU(instance); + else if(strcasecmp(line, FF_CPU_MODULE_NAME) == 0) + ffPrintCPU(instance, &instance->config.cpu); else if(strcasecmp(line, "cpuusage") == 0) ffPrintCPUUsage(instance); else if(strcasecmp(line, "gpu") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3fe6d3f54..3287874e1 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -116,7 +116,7 @@ typedef struct FFconfig FFModuleArgs cursor; FFModuleArgs terminal; FFModuleArgs terminalFont; - FFModuleArgs cpu; + FFCPUOptions cpu; FFModuleArgs cpuUsage; FFModuleArgs gpu; FFModuleArgs memory; @@ -166,7 +166,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - bool cpuTemp; bool gpuTemp; bool gpuForceVulkan; @@ -265,7 +264,6 @@ void ffPrintFont(FFinstance* instance); void ffPrintCursor(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); -void ffPrintCPU(FFinstance* instance); void ffPrintCPUUsage(FFinstance* instance); void ffPrintGPU(FFinstance* instance); void ffPrintMemory(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index ef097343e..06ee5c0a6 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -43,7 +43,7 @@ int main(int argc, char** argv) ffPrintCursor(&instance); ffPrintTerminal(&instance); ffPrintTerminalFont(&instance); - ffPrintCPU(&instance); + ffPrintCPU(&instance, &instance.config.cpu); ffPrintGPU(&instance); ffPrintMemory(&instance); //ffPrintSwap(&instance); diff --git a/src/modules/cpu.c b/src/modules/cpu.c deleted file mode 100644 index eb38a9805..000000000 --- a/src/modules/cpu.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/cpu/cpu.h" - -#define FF_CPU_MODULE_NAME "CPU" -#define FF_CPU_NUM_FORMAT_ARGS 8 - -void ffPrintCPU(FFinstance* instance) -{ - const FFCPUResult* cpu = ffDetectCPU(instance); - - if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1) - { - ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, "No CPU detected"); - return; - } - - if(instance->config.cpu.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu.key); - - if(cpu->name.length > 0) - ffStrbufWriteTo(&cpu->name, stdout); - else if(cpu->vendor.length > 0) - { - ffStrbufWriteTo(&cpu->vendor, stdout); - fputs(" CPU", stdout); - } - else - fputs("CPU", stdout); - - if(cpu->coresOnline > 1) - printf(" (%u)", cpu->coresOnline); - - if(cpu->frequencyMax > 0.0) - printf(" @ %.9g GHz", cpu->frequencyMax); - - if(cpu->temperature == cpu->temperature) //FF_CPU_TEMP_UNSET - printf(" - %.1f°C", cpu->temperature); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature} - }); - } -} diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c new file mode 100644 index 000000000..07c16c28a --- /dev/null +++ b/src/modules/cpu/cpu.c @@ -0,0 +1,111 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/cpu/cpu.h" +#include "modules/cpu/cpu.h" + +#define FF_CPU_NUM_FORMAT_ARGS 8 + +void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) +{ + const FFCPUResult* cpu = ffDetectCPU(instance); + + if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1) + { + ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key); + + if(cpu->name.length > 0) + ffStrbufWriteTo(&cpu->name, stdout); + else if(cpu->vendor.length > 0) + { + ffStrbufWriteTo(&cpu->vendor, stdout); + fputs(" CPU", stdout); + } + else + fputs("CPU", stdout); + + if(cpu->coresOnline > 1) + printf(" (%u)", cpu->coresOnline); + + if(cpu->frequencyMax > 0.0) + printf(" @ %.9g GHz", cpu->frequencyMax); + + if(cpu->temperature == cpu->temperature) //FF_CPU_TEMP_UNSET + printf(" - %.1f°C", cpu->temperature); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature} + }); + } +} + +void ffInitCPUOptions(FFCPUOptions* options) +{ + options->moduleName = FF_CPU_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + options->temp = false; +} + +bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_CPU_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "temp") == 0) + { + options->temp = ffOptionParseBoolean(value); + return true; + } + + return false; +} + +void ffDestroyCPUOptions(FFCPUOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseCPUJsonObject(FFinstance* instance, json_object* module) +{ + FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options; + ffInitCPUOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "temp") == 0) + { + options.temp = (bool) json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintCPU(instance, &options); +} +#endif diff --git a/src/modules/cpu/cpu.h b/src/modules/cpu/cpu.h new file mode 100644 index 000000000..04c5c6f7a --- /dev/null +++ b/src/modules/cpu/cpu.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_CPU_MODULE_NAME "CPU" + +void ffPrintCPU(FFinstance* instance, FFCPUOptions* options); +void ffInitCPUOptions(FFCPUOptions* options); +bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value); +void ffDestroyCPUOptions(FFCPUOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseCPUJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/cpu/option.h b/src/modules/cpu/option.h new file mode 100644 index 000000000..9e54bfeaf --- /dev/null +++ b/src/modules/cpu/option.h @@ -0,0 +1,13 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFCPUOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + bool temp; +} FFCPUOptions; diff --git a/src/modules/cpuUsage.c b/src/modules/cpuUsage.c index cb952a06a..73cd0b91c 100644 --- a/src/modules/cpuUsage.c +++ b/src/modules/cpuUsage.c @@ -13,7 +13,7 @@ void ffPrintCPUUsage(FFinstance* instance) if(error) { - ffPrintError(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpu, "%s", error); + ffPrintError(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage, "%s", error); return; } diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 50adc012b..53c1e79bc 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -39,6 +39,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'C': { return + tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index f9c8d51ee..c394a62d8 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -9,6 +9,7 @@ #include "modules/brightness/brightness.h" #include "modules/board/board.h" #include "modules/break/break.h" +#include "modules/cpu/cpu.h" #include "modules/command/command.h" #include "modules/colors/colors.h" #include "modules/datetime/datetime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 0777c7487..2752c3bac 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -7,6 +7,7 @@ #include "modules/bluetooth/option.h" #include "modules/board/option.h" #include "modules/brightness/option.h" +#include "modules/cpu/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From 0f3fa38c04413406a9880e5e2408403d49bdbf70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Mar 2023 20:58:37 +0800 Subject: [PATCH 030/493] TerminalFont: fix Windows Terminal detection --- src/detection/terminalfont/terminalfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 2e502861a..dbb10a8b0 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -102,7 +102,7 @@ static const char* detectWTProfile(json_object* profile, FFstrbuf* name, double* static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, double* size) { - if (ffJsonLoadLibrary(instance)) + if (!ffJsonLoadLibrary(instance)) return "Failed to load json-c library"; json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content->chars); From 305533a0d495ba7b17852afbf9006a709c21c6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 17 Mar 2023 17:56:31 +0800 Subject: [PATCH 031/493] CpuUsage: support JSON config --- CMakeLists.txt | 14 +-- src/common/init.c | 4 +- src/detection/cpuUsage/cpuUsage.h | 8 -- .../cpuUsage.c => cpuusage/cpuusage.c} | 3 +- src/detection/cpuusage/cpuusage.h | 8 ++ .../cpuusage_apple.c} | 2 +- .../cpuusage_bsd.c} | 2 +- .../cpuusage_linux.c} | 2 +- .../cpuusage_windows.c} | 2 +- src/fastfetch.c | 8 +- src/fastfetch.h | 4 +- src/flashfetch.c | 2 +- src/modules/cpuUsage.c | 42 --------- src/modules/cpuusage/cpuusage.c | 85 +++++++++++++++++++ src/modules/cpuusage/cpuusage.h | 15 ++++ src/modules/cpuusage/option.h | 11 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 19 files changed, 142 insertions(+), 73 deletions(-) delete mode 100644 src/detection/cpuUsage/cpuUsage.h rename src/detection/{cpuUsage/cpuUsage.c => cpuusage/cpuusage.c} (95%) create mode 100644 src/detection/cpuusage/cpuusage.h rename src/detection/{cpuUsage/cpuUsage_apple.c => cpuusage/cpuusage_apple.c} (94%) rename src/detection/{cpuUsage/cpuUsage_bsd.c => cpuusage/cpuusage_bsd.c} (93%) rename src/detection/{cpuUsage/cpuUsage_linux.c => cpuusage/cpuusage_linux.c} (95%) rename src/detection/{cpuUsage/cpuUsage_windows.c => cpuusage/cpuusage_windows.c} (97%) delete mode 100644 src/modules/cpuUsage.c create mode 100644 src/modules/cpuusage/cpuusage.c create mode 100644 src/modules/cpuusage/cpuusage.h create mode 100644 src/modules/cpuusage/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index aa3eef464..0f9447715 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,7 +241,7 @@ set(LIBFASTFETCH_SRC src/common/settings.c src/detection/bluetooth/bluetooth.c src/detection/cpu/cpu.c - src/detection/cpuUsage/cpuUsage.c + src/detection/cpuusage/cpuusage.c src/detection/datetime/datetime.c src/detection/disk/disk.c src/detection/displayserver/displayserver.c @@ -271,7 +271,7 @@ set(LIBFASTFETCH_SRC src/modules/chassis.c src/modules/colors/colors.c src/modules/cpu/cpu.c - src/modules/cpuUsage.c + src/modules/cpuusage/cpuusage.c src/modules/cursor.c src/modules/custom.c src/modules/command/command.c @@ -333,7 +333,7 @@ if(LINUX) src/detection/brightness/brightness_linux.c src/detection/chassis/chassis_linux.c src/detection/cpu/cpu_linux.c - src/detection/cpuUsage/cpuUsage_linux.c + src/detection/cpuusage/cpuusage_linux.c src/detection/cursor/cursor_linux.c src/detection/bluetooth/bluetooth_linux.c src/detection/disk/disk_linux.c @@ -383,7 +383,7 @@ elseif(ANDROID) src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_linux.c src/detection/cursor/cursor_nosupport.c - src/detection/cpuUsage/cpuUsage_linux.c + src/detection/cpuusage/cpuusage_linux.c src/detection/disk/disk_linux.c src/detection/displayserver/displayserver_nosupport.c src/detection/font/font_nosupport.c @@ -426,7 +426,7 @@ elseif(BSD) src/detection/brightness/brightness_nosupport.c src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_bsd.c - src/detection/cpuUsage/cpuUsage_bsd.c + src/detection/cpuusage/cpuusage_bsd.c src/detection/cursor/cursor_linux.c src/detection/disk/disk_bsd.c src/detection/displayserver/linux/displayserver_linux.c @@ -475,7 +475,7 @@ elseif(APPLE) src/detection/brightness/brightness_apple.c src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_apple.c - src/detection/cpuUsage/cpuUsage_apple.c + src/detection/cpuusage/cpuUsage_apple.c src/detection/cursor/cursor_apple.m src/detection/disk/disk_apple.m src/detection/disk/disk_bsd.c @@ -520,7 +520,7 @@ elseif(WIN32) src/detection/brightness/brightness_windows.cpp src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_windows.c - src/detection/cpuUsage/cpuUsage_windows.c + src/detection/cpuusage/cpuusage_windows.c src/detection/cursor/cursor_windows.c src/detection/disk/disk_windows.c src/detection/displayserver/displayserver_windows.c diff --git a/src/common/init.c b/src/common/init.c index 56e1c8d2d..7d9882192 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -81,7 +81,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.terminal); initModuleArg(&instance->config.terminalFont); ffInitCPUOptions(&instance->config.cpu); - initModuleArg(&instance->config.cpuUsage); + ffInitCPUUsageOptions(&instance->config.cpuUsage); initModuleArg(&instance->config.gpu); initModuleArg(&instance->config.memory); initModuleArg(&instance->config.swap); @@ -316,7 +316,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.terminal); destroyModuleArg(&instance->config.terminalFont); ffDestroyCPUOptions(&instance->config.cpu); - destroyModuleArg(&instance->config.cpuUsage); + ffDestroyCPUUsageOptions(&instance->config.cpuUsage); destroyModuleArg(&instance->config.gpu); destroyModuleArg(&instance->config.memory); destroyModuleArg(&instance->config.swap); diff --git a/src/detection/cpuUsage/cpuUsage.h b/src/detection/cpuUsage/cpuUsage.h deleted file mode 100644 index 250b30570..000000000 --- a/src/detection/cpuUsage/cpuUsage.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#ifndef FF_INCLUDED_detection_cpu_cpuUsage -#define FF_INCLUDED_detection_cpu_cpuUsage - -const char* ffGetCpuUsageResult(double* result); - -#endif diff --git a/src/detection/cpuUsage/cpuUsage.c b/src/detection/cpuusage/cpuusage.c similarity index 95% rename from src/detection/cpuUsage/cpuUsage.c rename to src/detection/cpuusage/cpuusage.c index 88355668d..7342bbc55 100644 --- a/src/detection/cpuUsage/cpuUsage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -1,6 +1,5 @@ #include "fastfetch.h" -#include "cpuUsage.h" - +#include "detection/cpuusage/cpuusage.h" #include "common/time.h" #include diff --git a/src/detection/cpuusage/cpuusage.h b/src/detection/cpuusage/cpuusage.h new file mode 100644 index 000000000..fb3c81e8e --- /dev/null +++ b/src/detection/cpuusage/cpuusage.h @@ -0,0 +1,8 @@ +#pragma once + +#ifndef FF_INCLUDED_detection_cpuusage_cpuusage +#define FF_INCLUDED_detection_cpuusage_cpuusage + +const char* ffGetCpuUsageResult(double* result); + +#endif diff --git a/src/detection/cpuUsage/cpuUsage_apple.c b/src/detection/cpuusage/cpuusage_apple.c similarity index 94% rename from src/detection/cpuUsage/cpuUsage_apple.c rename to src/detection/cpuusage/cpuusage_apple.c index d3b533f48..b94615219 100644 --- a/src/detection/cpuUsage/cpuUsage_apple.c +++ b/src/detection/cpuusage/cpuusage_apple.c @@ -1,5 +1,5 @@ #include "fastfetch.h" -#include "cpuUsage.h" +#include "detection/cpuusage/cpuusage.h" #include #include diff --git a/src/detection/cpuUsage/cpuUsage_bsd.c b/src/detection/cpuusage/cpuusage_bsd.c similarity index 93% rename from src/detection/cpuUsage/cpuUsage_bsd.c rename to src/detection/cpuusage/cpuusage_bsd.c index d96064fd4..fa1945aaa 100644 --- a/src/detection/cpuUsage/cpuUsage_bsd.c +++ b/src/detection/cpuusage/cpuusage_bsd.c @@ -1,4 +1,4 @@ -#include "cpuUsage.h" +#include "detection/cpuusage/cpuusage.h" #include #include diff --git a/src/detection/cpuUsage/cpuUsage_linux.c b/src/detection/cpuusage/cpuusage_linux.c similarity index 95% rename from src/detection/cpuUsage/cpuUsage_linux.c rename to src/detection/cpuusage/cpuusage_linux.c index 1888b2b13..78c64215e 100644 --- a/src/detection/cpuUsage/cpuUsage_linux.c +++ b/src/detection/cpuusage/cpuusage_linux.c @@ -1,5 +1,5 @@ #include "fastfetch.h" -#include "cpuUsage.h" +#include "detection/cpuusage/cpuusage.h" #include #include diff --git a/src/detection/cpuUsage/cpuUsage_windows.c b/src/detection/cpuusage/cpuusage_windows.c similarity index 97% rename from src/detection/cpuUsage/cpuUsage_windows.c rename to src/detection/cpuusage/cpuusage_windows.c index 60ebef4be..a22250d83 100644 --- a/src/detection/cpuUsage/cpuUsage_windows.c +++ b/src/detection/cpuusage/cpuusage_windows.c @@ -1,5 +1,5 @@ #include "fastfetch.h" -#include "cpuUsage.h" +#include "detection/cpuusage/cpuusage.h" #include "util/mallocHelper.h" diff --git a/src/fastfetch.c b/src/fastfetch.c index a2d43ad04..a93a8f486 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1034,7 +1034,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {} else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} - else if(optionParseModuleArgs(key, value, "cpu-usage", &instance->config.cpuUsage)) {} + else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} else if(optionParseModuleArgs(key, value, "gpu", &instance->config.gpu)) {} else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {} @@ -1300,8 +1300,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintTerminalFont(instance); else if(strcasecmp(line, FF_CPU_MODULE_NAME) == 0) ffPrintCPU(instance, &instance->config.cpu); - else if(strcasecmp(line, "cpuusage") == 0) - ffPrintCPUUsage(instance); + else if(strcasecmp(line, FF_CPUUSAGE_MODULE_NAME) == 0) + ffPrintCPUUsage(instance, &instance->config.cpuUsage); else if(strcasecmp(line, "gpu") == 0) ffPrintGPU(instance); else if(strcasecmp(line, "memory") == 0) @@ -1373,7 +1373,7 @@ int main(int argc, const char** argv) if(data.structure.length == 0) ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE); - if(ffStrbufContainIgnCaseS(&data.structure, "CPUUsage")) + if(ffStrbufContainIgnCaseS(&data.structure, FF_CPUUSAGE_MODULE_NAME)) ffPrepareCPUUsage(); if(instance.config.multithreading) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3287874e1..add99a4f5 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -117,7 +117,7 @@ typedef struct FFconfig FFModuleArgs terminal; FFModuleArgs terminalFont; FFCPUOptions cpu; - FFModuleArgs cpuUsage; + FFCPUUsageOptions cpuUsage; FFModuleArgs gpu; FFModuleArgs memory; FFModuleArgs swap; @@ -242,7 +242,6 @@ void ffLogoBuiltinListAutocompletion(); //Common -void ffPrepareCPUUsage(); void ffPreparePublicIp(FFinstance* instance); void ffPrepareWeather(FFinstance* instance); @@ -264,7 +263,6 @@ void ffPrintFont(FFinstance* instance); void ffPrintCursor(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); -void ffPrintCPUUsage(FFinstance* instance); void ffPrintGPU(FFinstance* instance); void ffPrintMemory(FFinstance* instance); void ffPrintSwap(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 06ee5c0a6..fe269f1a7 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -55,7 +55,7 @@ int main(int argc, char** argv) //ffPrintLocalIp(&instance); //ffPrintPublicIp(&instance); //ffPrintWifi(&instance); - //ffPrintCPUUsage(&instance); + //ffPrintCPUUsage(&instance, &instance.config.cpuUsage); ffPrintLocale(&instance); //ffPrintDateTime(&instance); //ffPrintDate(&instance); diff --git a/src/modules/cpuUsage.c b/src/modules/cpuUsage.c deleted file mode 100644 index 73cd0b91c..000000000 --- a/src/modules/cpuUsage.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "common/bar.h" -#include "detection/cpuUsage/cpuUsage.h" - -#define FF_CPU_USAGE_MODULE_NAME "CPU Usage" -#define FF_CPU_USAGE_NUM_FORMAT_ARGS 1 - -void ffPrintCPUUsage(FFinstance* instance) -{ - double percentage = 0.0/0.0; - const char* error = ffGetCpuUsageResult(&percentage); - - if(error) - { - ffPrintError(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage, "%s", error); - return; - } - - if(instance->config.cpuUsage.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage.key); - - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) - ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - { - if(str.length > 0) - ffStrbufAppendC(&str, ' '); - ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); - } - ffStrbufPutTo(&str, stdout); - } - else - { - ffPrintFormat(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage, FF_CPU_USAGE_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_DOUBLE, &percentage} - }); - } -} diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c new file mode 100644 index 000000000..b7ccddc41 --- /dev/null +++ b/src/modules/cpuusage/cpuusage.c @@ -0,0 +1,85 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "common/bar.h" +#include "detection/cpuusage/cpuusage.h" +#include "modules/cpuusage/cpuusage.h" + +#define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage" +#define FF_CPUUSAGE_NUM_FORMAT_ARGS 1 + +void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options) +{ + double percentage = 0.0/0.0; + const char* error = ffGetCpuUsageResult(&percentage); + + if(error) + { + ffPrintError(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key); + + FF_STRBUF_AUTO_DESTROY str; + ffStrbufInit(&str); + if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8); + if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + { + if(str.length > 0) + ffStrbufAppendC(&str, ' '); + ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); + } + ffStrbufPutTo(&str, stdout); + } + else + { + ffPrintFormat(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_DOUBLE, &percentage} + }); + } +} + +void ffInitCPUUsageOptions(FFCPUUsageOptions* options) +{ + options->moduleName = FF_CPUUSAGE_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_CPUUSAGE_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module) +{ + FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options; + ffInitCPUUsageOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintCPUUsage(instance, &options); +} +#endif diff --git a/src/modules/cpuusage/cpuusage.h b/src/modules/cpuusage/cpuusage.h new file mode 100644 index 000000000..941c7ab84 --- /dev/null +++ b/src/modules/cpuusage/cpuusage.h @@ -0,0 +1,15 @@ +#pragma once + +#define FF_CPUUSAGE_MODULE_NAME "CPUUsage" + +void ffPrepareCPUUsage(); + +void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options); +void ffInitCPUUsageOptions(FFCPUUsageOptions* options); +bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value); +void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/cpuusage/option.h b/src/modules/cpuusage/option.h new file mode 100644 index 000000000..c779b6c5a --- /dev/null +++ b/src/modules/cpuusage/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFCPUUsageOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFCPUUsageOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 53c1e79bc..c96147171 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -40,6 +40,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'C': { return tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || + tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index c394a62d8..ade634349 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -10,6 +10,7 @@ #include "modules/board/board.h" #include "modules/break/break.h" #include "modules/cpu/cpu.h" +#include "modules/cpuusage/cpuusage.h" #include "modules/command/command.h" #include "modules/colors/colors.h" #include "modules/datetime/datetime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 2752c3bac..6bd874fc3 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -8,6 +8,7 @@ #include "modules/board/option.h" #include "modules/brightness/option.h" #include "modules/cpu/option.h" +#include "modules/cpuusage/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From 83dda3e8ab69fe82eec9e8bbbcba09414d66ec8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 20 Mar 2023 14:57:46 +0800 Subject: [PATCH 032/493] Cursor: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/cursor.c | 55 ----------------- src/modules/cursor/cursor.c | 93 +++++++++++++++++++++++++++++ src/modules/cursor/cursor.h | 15 +++++ src/modules/cursor/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 130 insertions(+), 64 deletions(-) delete mode 100644 src/modules/cursor.c create mode 100644 src/modules/cursor/cursor.c create mode 100644 src/modules/cursor/cursor.h create mode 100644 src/modules/cursor/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f9447715..bd9d2029b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,7 +272,7 @@ set(LIBFASTFETCH_SRC src/modules/colors/colors.c src/modules/cpu/cpu.c src/modules/cpuusage/cpuusage.c - src/modules/cursor.c + src/modules/cursor/cursor.c src/modules/custom.c src/modules/command/command.c src/modules/datetime/datetime.c diff --git a/src/common/init.c b/src/common/init.c index 7d9882192..05f6ebb92 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -77,7 +77,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.theme); initModuleArg(&instance->config.icons); initModuleArg(&instance->config.font); - initModuleArg(&instance->config.cursor); + ffInitCursorOptions(&instance->config.cursor); initModuleArg(&instance->config.terminal); initModuleArg(&instance->config.terminalFont); ffInitCPUOptions(&instance->config.cpu); @@ -312,7 +312,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.theme); destroyModuleArg(&instance->config.icons); destroyModuleArg(&instance->config.font); - destroyModuleArg(&instance->config.cursor); + ffDestroyCursorOptions(&instance->config.cursor); destroyModuleArg(&instance->config.terminal); destroyModuleArg(&instance->config.terminalFont); ffDestroyCPUOptions(&instance->config.cpu); diff --git a/src/fastfetch.c b/src/fastfetch.c index a93a8f486..ac1632f2f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1030,7 +1030,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {} else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} else if(optionParseModuleArgs(key, value, "font", &instance->config.font)) {} - else if(optionParseModuleArgs(key, value, "cursor", &instance->config.cursor)) {} + else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {} else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} @@ -1292,8 +1292,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintWallpaper(instance); else if(strcasecmp(line, "font") == 0) ffPrintFont(instance); - else if(strcasecmp(line, "cursor") == 0) - ffPrintCursor(instance); + else if(strcasecmp(line, FF_CURSOR_MODULE_NAME) == 0) + ffPrintCursor(instance, &instance->config.cursor); else if(strcasecmp(line, "terminal") == 0) ffPrintTerminal(instance); else if(strcasecmp(line, "terminalfont") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index add99a4f5..bab35e820 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -113,7 +113,7 @@ typedef struct FFconfig FFModuleArgs theme; FFModuleArgs icons; FFModuleArgs font; - FFModuleArgs cursor; + FFCursorOptions cursor; FFModuleArgs terminal; FFModuleArgs terminalFont; FFCPUOptions cpu; @@ -260,7 +260,6 @@ void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); void ffPrintFont(FFinstance* instance); -void ffPrintCursor(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); void ffPrintGPU(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index fe269f1a7..b5020c6c7 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -40,7 +40,7 @@ int main(int argc, char** argv) ffPrintTheme(&instance); ffPrintIcons(&instance); ffPrintFont(&instance); - ffPrintCursor(&instance); + ffPrintCursor(&instance, &instance.config.cursor); ffPrintTerminal(&instance); ffPrintTerminalFont(&instance); ffPrintCPU(&instance, &instance.config.cpu); diff --git a/src/modules/cursor.c b/src/modules/cursor.c deleted file mode 100644 index a5ddc90be..000000000 --- a/src/modules/cursor.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "fastfetch.h" - -#include "common/printing.h" -#include "detection/cursor/cursor.h" - -#define FF_CURSOR_MODULE_NAME "Cursor" -#define FF_CURSOR_NUM_FORMAT_ARGS 2 - -static void printCursor(FFinstance* instance, FFCursorResult* cursor) -{ - ffStrbufRemoveIgnCaseEndS(&cursor->theme, "cursors"); - ffStrbufRemoveIgnCaseEndS(&cursor->theme, "cursor"); - ffStrbufTrimRight(&cursor->theme, '_'); - ffStrbufTrimRight(&cursor->theme, '-'); - if(cursor->theme.length == 0) - ffStrbufAppendS(&cursor->theme, "default"); - - if(instance->config.cursor.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor.key); - ffStrbufWriteTo(&cursor->theme, stdout); - - if(cursor->size.length > 0) - printf(" (%spx)", cursor->size.chars); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &cursor->theme}, - {FF_FORMAT_ARG_TYPE_STRBUF, &cursor->size} - }); - } -} - - -void ffPrintCursor(FFinstance* instance) -{ - FFCursorResult result; - ffStrbufInit(&result.error); - ffStrbufInit(&result.theme); - ffStrbufInit(&result.size); - - ffDetectCursor(instance, &result); - - if(result.error.length) - ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "%s", result.error.chars); - else - printCursor(instance, &result); - - ffStrbufDestroy(&result.error); - ffStrbufDestroy(&result.theme); - ffStrbufDestroy(&result.size); -} diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c new file mode 100644 index 000000000..1845fac3b --- /dev/null +++ b/src/modules/cursor/cursor.c @@ -0,0 +1,93 @@ +#include "fastfetch.h" + +#include "common/printing.h" +#include "detection/cursor/cursor.h" +#include "modules/cursor/cursor.h" + +#define FF_CURSOR_NUM_FORMAT_ARGS 2 + +void ffPrintCursor(FFinstance* instance, FFCursorOptions* options) +{ + FFCursorResult result; + ffStrbufInit(&result.error); + ffStrbufInit(&result.theme); + ffStrbufInit(&result.size); + + ffDetectCursor(instance, &result); + + if(result.error.length) + ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars); + else + { + ffStrbufRemoveIgnCaseEndS(&result.theme, "cursors"); + ffStrbufRemoveIgnCaseEndS(&result.theme, "cursor"); + ffStrbufTrimRight(&result.theme, '_'); + ffStrbufTrimRight(&result.theme, '-'); + if(result.theme.length == 0) + ffStrbufAppendS(&result.theme, "default"); + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufWriteTo(&result.theme, stdout); + + if(result.size.length > 0) + printf(" (%spx)", result.size.chars); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.size} + }); + } + } + + ffStrbufDestroy(&result.error); + ffStrbufDestroy(&result.theme); + ffStrbufDestroy(&result.size); +} + +void ffInitCursorOptions(FFCursorOptions* options) +{ + options->moduleName = FF_CURSOR_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_CURSOR_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyCursorOptions(FFCursorOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseCursorJsonObject(FFinstance* instance, json_object* module) +{ + FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options; + ffInitCursorOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintCursor(instance, &options); +} +#endif diff --git a/src/modules/cursor/cursor.h b/src/modules/cursor/cursor.h new file mode 100644 index 000000000..913e0668e --- /dev/null +++ b/src/modules/cursor/cursor.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_CURSOR_MODULE_NAME "Cursor" + +void ffPrintCursor(FFinstance* instance, FFCursorOptions* options); +void ffInitCursorOptions(FFCursorOptions* options); +bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value); +void ffDestroyCursorOptions(FFCursorOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseCursorJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/cursor/option.h b/src/modules/cursor/option.h new file mode 100644 index 000000000..9a648c844 --- /dev/null +++ b/src/modules/cursor/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFCursorOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFCursorOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index c96147171..c287f5222 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -43,6 +43,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || + tryModule(instance, type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index ade634349..7b5325717 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -13,6 +13,7 @@ #include "modules/cpuusage/cpuusage.h" #include "modules/command/command.h" #include "modules/colors/colors.h" +#include "modules/cursor/cursor.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" #include "modules/host/host.h" diff --git a/src/modules/options.h b/src/modules/options.h index 6bd874fc3..9f72b93b8 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -9,6 +9,7 @@ #include "modules/brightness/option.h" #include "modules/cpu/option.h" #include "modules/cpuusage/option.h" +#include "modules/cursor/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" From e3e8c689edee50d12ae54a7fdf99b0100445a59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 20 Mar 2023 15:46:00 +0800 Subject: [PATCH 033/493] Custom: support JSON module Note: old command options `--set` and `--set-keyless` were removed. To reuse custom module, JSON config must be used. --- CMakeLists.txt | 3 +- src/common/init.c | 2 + src/fastfetch.c | 52 ++++--------------------- src/fastfetch.h | 2 +- src/modules/custom.c | 10 ----- src/modules/custom/custom.c | 59 +++++++++++++++++++++++++++++ src/modules/custom/custom.h | 15 ++++++++ src/modules/custom/option.h | 11 ++++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/util/FFvaluestore.c | 46 ---------------------- src/util/FFvaluestore.h | 16 -------- 13 files changed, 99 insertions(+), 120 deletions(-) delete mode 100644 src/modules/custom.c create mode 100644 src/modules/custom/custom.c create mode 100644 src/modules/custom/custom.h create mode 100644 src/modules/custom/option.h delete mode 100644 src/util/FFvaluestore.c delete mode 100644 src/util/FFvaluestore.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bd9d2029b..cbcb3330f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,7 +273,7 @@ set(LIBFASTFETCH_SRC src/modules/cpu/cpu.c src/modules/cpuusage/cpuusage.c src/modules/cursor/cursor.c - src/modules/custom.c + src/modules/custom/custom.c src/modules/command/command.c src/modules/datetime/datetime.c src/modules/de.c @@ -316,7 +316,6 @@ set(LIBFASTFETCH_SRC src/modules/jsonconfig/jsonconfig.c src/util/FFlist.c src/util/FFstrbuf.c - src/util/FFvaluestore.c src/util/platform/FFPlatform.c src/util/stringUtils.c ) diff --git a/src/common/init.c b/src/common/init.c index 05f6ebb92..8f3013621 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -65,6 +65,7 @@ static void defaultConfig(FFinstance* instance) ffInitBrightnessOptions(&instance->config.brightness); initModuleArg(&instance->config.chassis); ffInitCommandOptions(&instance->config.command); + ffInitCustomOptions(&instance->config.custom); ffInitKernelOptions(&instance->config.kernel); initModuleArg(&instance->config.uptime); initModuleArg(&instance->config.processes); @@ -300,6 +301,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyBrightnessOptions(&instance->config.brightness); destroyModuleArg(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); + ffDestroyCustomOptions(&instance->config.custom); ffDestroyKernelOptions(&instance->config.kernel); destroyModuleArg(&instance->config.uptime); destroyModuleArg(&instance->config.processes); diff --git a/src/fastfetch.c b/src/fastfetch.c index ac1632f2f..eac551c0f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -3,7 +3,6 @@ #include "common/parsing.h" #include "common/io/io.h" #include "common/time.h" -#include "util/FFvaluestore.h" #include "util/stringUtils.h" #include "logo/logo.h" @@ -30,7 +29,6 @@ typedef struct CustomValue // Things only needed by fastfetch typedef struct FFdata { - FFvaluestore customValues; FFstrbuf structure; bool loadUserConfig; } FFdata; @@ -718,32 +716,6 @@ static uint32_t optionParseUInt32(const char* key, const char* value) return num; } -static void optionParseCustomValue(FFdata* data, const char* key, const char* value, bool printKey) -{ - if(value == NULL) - { - fprintf(stderr, "Error: usage: %s \n", key); - exit(411); - } - - char* separator = strchr(value, '='); - - if(separator == NULL) - { - fprintf(stderr, "Error: usage: %s , '=' missing\n", key); - exit(412); - } - - *separator = '\0'; - - bool created; - CustomValue* customValue = ffValuestoreSet(&data->customValues, value, &created); - if(created) - ffStrbufInit(&customValue->value); - ffStrbufSetS(&customValue->value, separator + 1); - customValue->printKey = printKey; -} - static void optionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...) { if(requestedKey == NULL) @@ -990,10 +962,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseColor(key, value, &instance->config.colorKeys); ffStrbufSet(&instance->config.colorTitle, &instance->config.colorKeys); } - else if(strcasecmp(key, "--set") == 0) - optionParseCustomValue(data, key, value, true); - else if(strcasecmp(key, "--set-keyless") == 0) - optionParseCustomValue(data, key, value, false); else if(strcasecmp(key, "--binary-prefix") == 0) { optionParseEnum(key, value, &instance->config.binaryPrefixType, @@ -1015,6 +983,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseBoardCommandOptions(&instance->config.board, key, value)) {} else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} + else if(ffParseCustomCommandOptions(&instance->config.custom, key, value)) {} else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} else if(optionParseModuleArgs(key, value, "uptime", &instance->config.uptime)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} @@ -1239,16 +1208,9 @@ static void parseArguments(FFinstance* instance, FFdata* data, int argc, const c } } -static void parseStructureCommand(FFinstance* instance, FFdata* data, const char* line) +static void parseStructureCommand(FFinstance* instance, const char* line) { - CustomValue* customValue = ffValuestoreGet(&data->customValues, line); - if(customValue != NULL) - { - ffPrintCustom(instance, customValue->printKey ? line : NULL, customValue->value.chars); - return; - } - - if(strcasecmp(line, "break") == 0) + if(strcasecmp(line, FF_BREAK_MODULE_NAME) == 0) ffPrintBreak(instance); else if(strcasecmp(line, FF_TITLE_MODULE_NAME) == 0) ffPrintTitle(instance, &instance->config.title); @@ -1302,6 +1264,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintCPU(instance, &instance->config.cpu); else if(strcasecmp(line, FF_CPUUSAGE_MODULE_NAME) == 0) ffPrintCPUUsage(instance, &instance->config.cpuUsage); + else if(strcasecmp(line, FF_CUSTOM_MODULE_NAME) == 0) + ffPrintCustom(instance, &instance->config.custom); else if(strcasecmp(line, "gpu") == 0) ffPrintGPU(instance); else if(strcasecmp(line, "memory") == 0) @@ -1310,7 +1274,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char ffPrintSwap(instance); else if(strcasecmp(line, "disk") == 0) ffPrintDisk(instance); - else if(strcasecmp(line, "battery") == 0) + else if(strcasecmp(line, FF_BATTERY_MODULE_NAME) == 0) ffPrintBattery(instance, &instance->config.battery); else if(strcasecmp(line, "poweradapter") == 0) ffPrintPowerAdapter(instance); @@ -1361,7 +1325,6 @@ int main(int argc, const char** argv) //Data stores things only needed for the configuration of fastfetch FFdata data; - ffValuestoreInit(&data.customValues, sizeof(CustomValue)); ffStrbufInitA(&data.structure, 256); data.loadUserConfig = true; @@ -1402,7 +1365,7 @@ int main(int argc, const char** argv) if(__builtin_expect(instance.config.stat, false)) ms = ffTimeGetTick(); - parseStructureCommand(&instance, &data, data.structure.chars + startIndex); + parseStructureCommand(&instance, data.structure.chars + startIndex); if(__builtin_expect(instance.config.stat, false)) { @@ -1424,7 +1387,6 @@ int main(int argc, const char** argv) ffFinish(&instance); ffStrbufDestroy(&data.structure); - ffValuestoreDestroy(&data.customValues); ffDestroyInstance(&instance); } diff --git a/src/fastfetch.h b/src/fastfetch.h index bab35e820..ab3cf6745 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -118,6 +118,7 @@ typedef struct FFconfig FFModuleArgs terminalFont; FFCPUOptions cpu; FFCPUUsageOptions cpuUsage; + FFCustomOptions custom; FFModuleArgs gpu; FFModuleArgs memory; FFModuleArgs swap; @@ -247,7 +248,6 @@ void ffPrepareWeather(FFinstance* instance); //Printing -void ffPrintCustom(FFinstance* instance, const char* key, const char* value); void ffPrintChassis(FFinstance* instance); void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); diff --git a/src/modules/custom.c b/src/modules/custom.c deleted file mode 100644 index f91a5b69e..000000000 --- a/src/modules/custom.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "util/textModifier.h" - -void ffPrintCustom(FFinstance* instance, const char* key, const char* value) -{ - ffPrintLogoAndKey(instance, key, 0, NULL); - ffPrintUserString(value); - puts(FASTFETCH_TEXT_MODIFIER_RESET); -} diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c new file mode 100644 index 000000000..b90f96be4 --- /dev/null +++ b/src/modules/custom/custom.c @@ -0,0 +1,59 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "modules/custom/custom.h" +#include "util/textModifier.h" + +void ffPrintCustom(FFinstance* instance, FFCustomOptions* options) +{ + if (options->moduleArgs.outputFormat.length == 0) + { + ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module"); + return; + } + + ffPrintLogoAndKey(instance, options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintUserString(options->moduleArgs.outputFormat.chars); + puts(FASTFETCH_TEXT_MODIFIER_RESET); +} + +void ffInitCustomOptions(FFCustomOptions* options) +{ + options->moduleName = FF_CUSTOM_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_CUSTOM_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyCustomOptions(FFCustomOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseCustomJsonObject(FFinstance* instance, json_object* module) +{ + FFCustomOptions __attribute__((__cleanup__(ffDestroyCustomOptions))) options; + ffInitCustomOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintCustom(instance, &options); +} +#endif diff --git a/src/modules/custom/custom.h b/src/modules/custom/custom.h new file mode 100644 index 000000000..ab3873549 --- /dev/null +++ b/src/modules/custom/custom.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_CUSTOM_MODULE_NAME "Custom" + +void ffPrintCustom(FFinstance* instance, FFCustomOptions* options); +void ffInitCustomOptions(FFCustomOptions* options); +bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value); +void ffDestroyCustomOptions(FFCustomOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseCustomJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/custom/option.h b/src/modules/custom/option.h new file mode 100644 index 000000000..f2b238831 --- /dev/null +++ b/src/modules/custom/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFCustomOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFCustomOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index c287f5222..65d636942 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -44,6 +44,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || tryModule(instance, type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || + tryModule(instance, type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 7b5325717..baa4d424a 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -14,6 +14,7 @@ #include "modules/command/command.h" #include "modules/colors/colors.h" #include "modules/cursor/cursor.h" +#include "modules/custom/custom.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" #include "modules/host/host.h" diff --git a/src/modules/options.h b/src/modules/options.h index 9f72b93b8..fb0bfad87 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -10,6 +10,7 @@ #include "modules/cpu/option.h" #include "modules/cpuusage/option.h" #include "modules/cursor/option.h" +#include "modules/custom/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" #include "modules/display/option.h" diff --git a/src/util/FFvaluestore.c b/src/util/FFvaluestore.c deleted file mode 100644 index 68040045b..000000000 --- a/src/util/FFvaluestore.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "FFvaluestore.h" - -#include - -typedef char KeyType[32]; //31 byte key + \0 - -void ffValuestoreInit(FFvaluestore* vs, uint32_t valueSize) -{ - ffListInit(vs, (uint32_t) (sizeof(KeyType) + valueSize)); -} - -void* ffValuestoreGet(FFvaluestore* vs, const char* key) -{ - for(uint32_t i = 0; i < vs->length; i++) - { - char* element = ffListGet(vs, i); - if(strcmp(element, key) == 0) - return element + sizeof(KeyType); - } - - return NULL; -} - -void* ffValuestoreSet(FFvaluestore* vs, const char* key, bool* created) -{ - char* element = ffValuestoreGet(vs, key); - if(element != NULL) - { - if(created != NULL) - *created = false; - return element; - } - - element = ffListAdd(vs); - strncpy(element, key, sizeof(KeyType) - 1); - element[sizeof(KeyType) - 1] = '\0'; - - if(created != NULL) - *created = true; - return element + sizeof(KeyType); -} - -void ffValuestoreDestroy(FFvaluestore* vs) -{ - ffListDestroy(vs); -} diff --git a/src/util/FFvaluestore.h b/src/util/FFvaluestore.h deleted file mode 100644 index 4d966837c..000000000 --- a/src/util/FFvaluestore.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#ifndef FASTFETCH_INCLUDED_FFVALUESTORE -#define FASTFETCH_INCLUDED_FFVALUESTORE - -#include "FFlist.h" -#include "FFcheckmacros.h" - -typedef FFlist FFvaluestore; - -void ffValuestoreInit(FFvaluestore* vs, uint32_t valueSize); -FF_C_NODISCARD void* ffValuestoreGet(FFvaluestore* vs, const char* key); -FF_C_NODISCARD void* ffValuestoreSet(FFvaluestore* vs, const char* key, bool* created); //created may be NULL -void ffValuestoreDestroy(FFvaluestore* vs); - -#endif From 9addc016fb9f9771f90c3117da664be85f2e3dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 26 Mar 2023 20:41:03 +0800 Subject: [PATCH 034/493] CMake: fix char case issue --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbcb3330f..414b967b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -474,7 +474,7 @@ elseif(APPLE) src/detection/brightness/brightness_apple.c src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_apple.c - src/detection/cpuusage/cpuUsage_apple.c + src/detection/cpuusage/cpuusage_apple.c src/detection/cursor/cursor_apple.m src/detection/disk/disk_apple.m src/detection/disk/disk_bsd.c From 2359b7e2f4aa24d78e6143017eb7f74ab917b397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 26 Mar 2023 20:42:18 +0800 Subject: [PATCH 035/493] GPU: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 10 +- src/detection/gpu/gpu.c | 2 +- src/detection/gpu/gpu.h | 9 +- src/detection/gpu/gpu_apple.c | 2 +- src/detection/gpu/gpu_linux.c | 2 +- src/fastfetch.c | 14 +- src/fastfetch.h | 9 +- src/flashfetch.c | 2 +- src/modules/gpu.c | 104 --------------- src/modules/gpu/gpu.c | 196 ++++++++++++++++++++++++++++ src/modules/gpu/gpu.h | 13 ++ src/modules/gpu/option.h | 22 ++++ src/modules/jsonconfig/jsonconfig.c | 6 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 16 files changed, 251 insertions(+), 144 deletions(-) delete mode 100644 src/modules/gpu.c create mode 100644 src/modules/gpu/gpu.c create mode 100644 src/modules/gpu/gpu.h create mode 100644 src/modules/gpu/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 414b967b0..ff92d6850 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,7 +279,7 @@ set(LIBFASTFETCH_SRC src/modules/de.c src/modules/disk.c src/modules/font.c - src/modules/gpu.c + src/modules/gpu/gpu.c src/modules/host/host.c src/modules/icons.c src/modules/gamepad.c diff --git a/src/common/init.c b/src/common/init.c index 8f3013621..60ad7c514 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -83,7 +83,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.terminalFont); ffInitCPUOptions(&instance->config.cpu); ffInitCPUUsageOptions(&instance->config.cpuUsage); - initModuleArg(&instance->config.gpu); + ffInitGPUOptions(&instance->config.gpu); initModuleArg(&instance->config.memory); initModuleArg(&instance->config.swap); initModuleArg(&instance->config.disk); @@ -133,12 +133,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.gpuTemp = false; - instance->config.gpuForceVulkan = false; - - instance->config.gpuHideIntegrated = false; - instance->config.gpuHideDiscrete = false; - instance->config.shellVersion = true; instance->config.terminalVersion = true; @@ -319,7 +313,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.terminalFont); ffDestroyCPUOptions(&instance->config.cpu); ffDestroyCPUUsageOptions(&instance->config.cpuUsage); - destroyModuleArg(&instance->config.gpu); + ffDestroyGPUOptions(&instance->config.gpu); destroyModuleArg(&instance->config.memory); destroyModuleArg(&instance->config.swap); destroyModuleArg(&instance->config.disk); diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index b50560dfe..59ac5bf68 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -36,7 +36,7 @@ const FFlist* ffDetectGPU(const FFinstance* instance) { FF_DETECTION_INTERNAL_GUARD(FFlist, ffListInit(&result, sizeof(FFGPUResult)); - if(instance->config.gpuForceVulkan || ffDetectGPUImpl(&result, instance) != NULL) + if(instance->config.gpu.forceVulkan || ffDetectGPUImpl(&result, instance) != NULL) { const FFVulkanResult* vulkan = ffDetectVulkan(instance); result = vulkan->gpus; diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 1d34958bf..2f04a440e 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -14,13 +14,6 @@ extern const char* FF_GPU_VENDOR_NAME_AMD; extern const char* FF_GPU_VENDOR_NAME_INTEL; extern const char* FF_GPU_VENDOR_NAME_NVIDIA; -typedef enum FFGpuType -{ - FF_GPU_TYPE_UNKNOWN, - FF_GPU_TYPE_INTEGRATED, - FF_GPU_TYPE_DISCRETE, -} FFGpuType; - typedef struct FFGPUMemory { uint64_t total; @@ -29,7 +22,7 @@ typedef struct FFGPUMemory typedef struct FFGPUResult { - FFGpuType type; + FFGPUType type; FFstrbuf vendor; FFstrbuf name; FFstrbuf driver; diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 3cde517c8..937b835f6 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -99,7 +99,7 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; - if(instance->config.gpuTemp) + if(instance->config.gpu.temp) gpu->temperature = detectGpuTemp(&gpu->name); else gpu->temperature = FF_GPU_TEMP_UNSET; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 63697050f..d5a081fdd 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -216,7 +216,7 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; - if(instance->config.gpuTemp) + if(instance->config.gpu.temp) pciDetectTemperatur(gpu, device); } diff --git a/src/fastfetch.c b/src/fastfetch.c index eac551c0f..659e552bb 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1004,7 +1004,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} - else if(optionParseModuleArgs(key, value, "gpu", &instance->config.gpu)) {} + else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {} else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {} else if(optionParseModuleArgs(key, value, "disk", &instance->config.disk)) {} @@ -1091,14 +1091,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--gpu-temp") == 0) - instance->config.gpuTemp = optionParseBoolean(value); - else if(strcasecmp(key, "--gpu-force-vulkan") == 0) - instance->config.gpuForceVulkan = optionParseBoolean(value); - else if(strcasecmp(key, "--gpu-hide-integrated") == 0) - instance->config.gpuHideIntegrated = optionParseBoolean(value); - else if(strcasecmp(key, "--gpu-hide-discrete") == 0) - instance->config.gpuHideDiscrete = optionParseBoolean(value); else if(strcasecmp(key, "--shell-version") == 0) instance->config.shellVersion = optionParseBoolean(value); else if(strcasecmp(key, "--terminal-version") == 0) @@ -1266,8 +1258,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintCPUUsage(instance, &instance->config.cpuUsage); else if(strcasecmp(line, FF_CUSTOM_MODULE_NAME) == 0) ffPrintCustom(instance, &instance->config.custom); - else if(strcasecmp(line, "gpu") == 0) - ffPrintGPU(instance); + else if(strcasecmp(line, FF_GPU_MODULE_NAME) == 0) + ffPrintGPU(instance, &instance->config.gpu); else if(strcasecmp(line, "memory") == 0) ffPrintMemory(instance); else if(strcasecmp(line, "swap") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index ab3cf6745..887d6d040 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -119,7 +119,7 @@ typedef struct FFconfig FFCPUOptions cpu; FFCPUUsageOptions cpuUsage; FFCustomOptions custom; - FFModuleArgs gpu; + FFGPUOptions gpu; FFModuleArgs memory; FFModuleArgs swap; FFModuleArgs disk; @@ -167,12 +167,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - bool gpuTemp; - bool gpuForceVulkan; - - bool gpuHideIntegrated; - bool gpuHideDiscrete; - bool shellVersion; bool terminalVersion; @@ -262,7 +256,6 @@ void ffPrintWallpaper(FFinstance* instance); void ffPrintFont(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); -void ffPrintGPU(FFinstance* instance); void ffPrintMemory(FFinstance* instance); void ffPrintSwap(FFinstance* instance); void ffPrintDisk(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index b5020c6c7..4bbc4c765 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) ffPrintTerminal(&instance); ffPrintTerminalFont(&instance); ffPrintCPU(&instance, &instance.config.cpu); - ffPrintGPU(&instance); + ffPrintGPU(&instance, &instance.config.gpu); ffPrintMemory(&instance); //ffPrintSwap(&instance); ffPrintDisk(&instance); diff --git a/src/modules/gpu.c b/src/modules/gpu.c deleted file mode 100644 index 0033d33be..000000000 --- a/src/modules/gpu.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "fastfetch.h" -#include "common/bar.h" -#include "common/parsing.h" -#include "common/printing.h" -#include "detection/host/host.h" -#include "detection/gpu/gpu.h" - -#include - -#define FF_GPU_MODULE_NAME "GPU" -#define FF_GPU_NUM_FORMAT_ARGS 6 - -static void printGPUResult(FFinstance* instance, uint8_t index, const FFGPUResult* gpu) -{ - if(instance->config.gpu.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu.key); - - FF_STRBUF_AUTO_DESTROY output; - ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length); - - if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor)) - { - ffStrbufAppend(&output, &gpu->vendor); - ffStrbufAppendC(&output, ' '); - } - - ffStrbufAppend(&output, &gpu->name); - - if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET) - ffStrbufAppendF(&output, " (%d)", gpu->coreCount); - - if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET - ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature); - - if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0) - { - ffStrbufAppendS(&output, " ("); - - if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) - { - ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output); - ffStrbufAppendS(&output, " / "); - } - ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output); - if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) - { - ffStrbufAppendS(&output, ", "); - ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false); - } - ffStrbufAppendC(&output, ')'); - } - - ffStrbufPutTo(&output, stdout); - } - else - { - const char* type; - if(gpu->type == FF_GPU_TYPE_INTEGRATED) - type = "Integrated"; - else if(gpu->type == FF_GPU_TYPE_DISCRETE) - type = "Discrete"; - else - type = "Unknown"; - - ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature}, - {FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount}, - {FF_FORMAT_ARG_TYPE_STRING, type}, - }); - } -} - -void ffPrintGPU(FFinstance* instance) -{ - const FFlist* gpus = ffDetectGPU(instance); - - FFlist selectedGpus; - ffListInitA(&selectedGpus, sizeof(const FFGPUResult*), gpus->length); - - for(uint32_t i = 0; i < gpus->length; i++) - { - const FFGPUResult* gpu = ffListGet(gpus, i); - - if(gpu->type == FF_GPU_TYPE_INTEGRATED && instance->config.gpuHideIntegrated) - continue; - - if(gpu->type == FF_GPU_TYPE_DISCRETE && instance->config.gpuHideDiscrete) - continue; - - * (const FFGPUResult**) ffListAdd(&selectedGpus) = gpu; - } - - for(uint32_t i = 0; i < selectedGpus.length; i++) - printGPUResult(instance, selectedGpus.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGpus, i)); - - if(selectedGpus.length == 0) - ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "No GPUs found"); - - ffListDestroy(&selectedGpus); -} diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c new file mode 100644 index 000000000..9b544c974 --- /dev/null +++ b/src/modules/gpu/gpu.c @@ -0,0 +1,196 @@ +#include "fastfetch.h" +#include "common/bar.h" +#include "common/parsing.h" +#include "common/printing.h" +#include "detection/host/host.h" +#include "detection/gpu/gpu.h" +#include "modules/gpu/gpu.h" + +#include + +#define FF_GPU_NUM_FORMAT_ARGS 6 + +static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu) +{ + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key); + + FF_STRBUF_AUTO_DESTROY output; + ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length); + + if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor)) + { + ffStrbufAppend(&output, &gpu->vendor); + ffStrbufAppendC(&output, ' '); + } + + ffStrbufAppend(&output, &gpu->name); + + if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET) + ffStrbufAppendF(&output, " (%d)", gpu->coreCount); + + if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET + ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature); + + if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0) + { + ffStrbufAppendS(&output, " ("); + + if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) + { + ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output); + ffStrbufAppendS(&output, " / "); + } + ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output); + if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) + { + ffStrbufAppendS(&output, ", "); + ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false); + } + ffStrbufAppendC(&output, ')'); + } + + ffStrbufPutTo(&output, stdout); + } + else + { + const char* type; + if(gpu->type == FF_GPU_TYPE_INTEGRATED) + type = "Integrated"; + else if(gpu->type == FF_GPU_TYPE_DISCRETE) + type = "Discrete"; + else + type = "Unknown"; + + ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature}, + {FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount}, + {FF_FORMAT_ARG_TYPE_STRING, type}, + }); + } +} + +void ffPrintGPU(FFinstance* instance, FFGPUOptions* options) +{ + const FFlist* gpus = ffDetectGPU(instance); + + FF_LIST_AUTO_DESTROY selectedGPUs; + ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus->length); + + FF_LIST_FOR_EACH(FFGPUResult, gpu, *gpus) + { + if(gpu->type == FF_GPU_TYPE_INTEGRATED && options->hideType == FF_GPU_TYPE_INTEGRATED) + continue; + + if(gpu->type == FF_GPU_TYPE_DISCRETE && options->hideType == FF_GPU_TYPE_DISCRETE) + continue; + + * (const FFGPUResult**) ffListAdd(&selectedGPUs) = gpu; + } + + for(uint32_t i = 0; i < selectedGPUs.length; i++) + printGPUResult(instance, options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); + + if(selectedGPUs.length == 0) + ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); +} + +void ffInitGPUOptions(FFGPUOptions* options) +{ + options->moduleName = FF_GPU_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + options->forceVulkan = false; + options->temp = false; + options->hideType = FF_GPU_TYPE_UNKNOWN; +} + +bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_GPU_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "force-vulkan") == 0) + { + options->forceVulkan = ffOptionParseBoolean(value); + return true; + } + + if (strcasecmp(subKey, "temp") == 0) + { + options->temp = ffOptionParseBoolean(value); + return true; + } + + if (strcasecmp(subKey, "hide-type") == 0) + { + options->hideType = (FFGPUType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "none", FF_GPU_TYPE_UNKNOWN }, + { "intergrated", FF_GPU_TYPE_INTEGRATED }, + { "discrete", FF_GPU_TYPE_DISCRETE }, + {}, + }); + } + + return false; +} + +void ffDestroyGPUOptions(FFGPUOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseGPUJsonObject(FFinstance* instance, json_object* module) +{ + FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options; + ffInitGPUOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "temp") == 0) + { + options.temp = (bool) json_object_get_boolean(val); + continue; + } + + if (strcasecmp(key, "forceVulkan") == 0) + { + options.forceVulkan = (bool) json_object_get_boolean(val); + continue; + } + + if (strcasecmp(key, "hideType") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "none", FF_GPU_TYPE_UNKNOWN }, + { "intergrated", FF_GPU_TYPE_INTEGRATED }, + { "discrete", FF_GPU_TYPE_DISCRETE }, + {}, + }); + if (error) + ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.hideType = (FFGPUType) value; + continue; + } + + ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintGPU(instance, &options); +} +#endif diff --git a/src/modules/gpu/gpu.h b/src/modules/gpu/gpu.h new file mode 100644 index 000000000..156e6ba89 --- /dev/null +++ b/src/modules/gpu/gpu.h @@ -0,0 +1,13 @@ +#pragma once + +#define FF_GPU_MODULE_NAME "GPU" + +void ffPrintGPU(FFinstance* instance, FFGPUOptions* options); +void ffInitGPUOptions(FFGPUOptions* options); +bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value); +void ffDestroyGPUOptions(FFGPUOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseGPUJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/gpu/option.h b/src/modules/gpu/option.h new file mode 100644 index 000000000..0aaa6a6f7 --- /dev/null +++ b/src/modules/gpu/option.h @@ -0,0 +1,22 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFGPUType +{ + FF_GPU_TYPE_UNKNOWN, + FF_GPU_TYPE_INTEGRATED, + FF_GPU_TYPE_DISCRETE, +} FFGPUType; + +typedef struct FFGPUOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFGPUType hideType; + bool temp; + bool forceVulkan; +} FFGPUOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 65d636942..140b8dedc 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -55,6 +55,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'G': { + return + tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || + false; + } + case 'H': { return tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index baa4d424a..1a1d3349b 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -17,6 +17,7 @@ #include "modules/custom/custom.h" #include "modules/datetime/datetime.h" #include "modules/display/display.h" +#include "modules/gpu/gpu.h" #include "modules/host/host.h" #include "modules/kernel/kernel.h" #include "modules/separator/separator.h" diff --git a/src/modules/options.h b/src/modules/options.h index fb0bfad87..0463e7b20 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -15,6 +15,7 @@ #include "modules/datetime/option.h" #include "modules/display/option.h" #include "modules/host/option.h" +#include "modules/gpu/option.h" #include "modules/kernel/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" From 623557f52159c92c8fb6565ee25ea9489d7fd97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 2 Apr 2023 00:13:11 +0800 Subject: [PATCH 036/493] Disk: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 8 +- src/fastfetch.c | 18 +- src/fastfetch.h | 16 +- src/flashfetch.c | 2 +- src/modules/disk.c | 157 --------------- src/modules/disk/disk.c | 291 ++++++++++++++++++++++++++++ src/modules/disk/disk.h | 15 ++ src/modules/disk/option.h | 24 +++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 341 insertions(+), 195 deletions(-) delete mode 100644 src/modules/disk.c create mode 100644 src/modules/disk/disk.c create mode 100644 src/modules/disk/disk.h create mode 100644 src/modules/disk/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ff92d6850..0557ce42a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,7 +277,7 @@ set(LIBFASTFETCH_SRC src/modules/command/command.c src/modules/datetime/datetime.c src/modules/de.c - src/modules/disk.c + src/modules/disk/disk.c src/modules/font.c src/modules/gpu/gpu.c src/modules/host/host.c diff --git a/src/common/init.c b/src/common/init.c index 60ad7c514..bb3843cac 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -86,7 +86,7 @@ static void defaultConfig(FFinstance* instance) ffInitGPUOptions(&instance->config.gpu); initModuleArg(&instance->config.memory); initModuleArg(&instance->config.swap); - initModuleArg(&instance->config.disk); + ffInitDiskOptions(&instance->config.disk); ffInitBatteryOptions(&instance->config.battery); initModuleArg(&instance->config.powerAdapter); initModuleArg(&instance->config.locale); @@ -136,9 +136,6 @@ static void defaultConfig(FFinstance* instance) instance->config.shellVersion = true; instance->config.terminalVersion = true; - ffStrbufInitA(&instance->config.diskFolders, 0); - instance->config.diskShowTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; - instance->config.soundType = FF_SOUND_TYPE_MAIN; instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT; @@ -316,7 +313,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyGPUOptions(&instance->config.gpu); destroyModuleArg(&instance->config.memory); destroyModuleArg(&instance->config.swap); - destroyModuleArg(&instance->config.disk); + ffDestroyDiskOptions(&instance->config.disk); ffDestroyBatteryOptions(&instance->config.battery); destroyModuleArg(&instance->config.powerAdapter); destroyModuleArg(&instance->config.locale); @@ -363,7 +360,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libwlanapi); ffStrbufDestroy(&instance->config.libnm); - ffStrbufDestroy(&instance->config.diskFolders); ffStrbufDestroy(&instance->config.localIpNamePrefix); ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); diff --git a/src/fastfetch.c b/src/fastfetch.c index 659e552bb..6a7da5b28 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1007,7 +1007,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {} else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {} - else if(optionParseModuleArgs(key, value, "disk", &instance->config.disk)) {} + else if(ffParseDiskCommandOptions(&instance->config.disk, key, value)) {} else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} else if(optionParseModuleArgs(key, value, "locale", &instance->config.locale)) {} @@ -1095,18 +1095,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.shellVersion = optionParseBoolean(value); else if(strcasecmp(key, "--terminal-version") == 0) instance->config.terminalVersion = optionParseBoolean(value); - else if(strcasecmp(key, "--disk-folders") == 0) - optionParseString(key, value, &instance->config.diskFolders); - else if(strcasecmp(key, "--disk-show-regular") == 0) - optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_REGULAR_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_REGULAR_BIT); - else if(strcasecmp(key, "--disk-show-removable") == 0) - optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_EXTERNAL_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT); - else if(strcasecmp(key, "--disk-show-hidden") == 0) - optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_HIDDEN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_HIDDEN_BIT); - else if(strcasecmp(key, "--disk-show-subvolumes") == 0) - optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_SUBVOLUME_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT); - else if(strcasecmp(key, "--disk-show-unknown") == 0) - optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_UNKNOWN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT); else if(strcasecmp(key, "--sound-type") == 0) { optionParseEnum(key, value, &instance->config.soundType, @@ -1264,8 +1252,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintMemory(instance); else if(strcasecmp(line, "swap") == 0) ffPrintSwap(instance); - else if(strcasecmp(line, "disk") == 0) - ffPrintDisk(instance); + else if(strcasecmp(line, FF_DISK_MODULE_NAME) == 0) + ffPrintDisk(instance, &instance->config.disk); else if(strcasecmp(line, FF_BATTERY_MODULE_NAME) == 0) ffPrintBattery(instance, &instance->config.battery); else if(strcasecmp(line, "poweradapter") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 887d6d040..79a727e6a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -33,16 +33,6 @@ typedef enum FFLocalIpCompactType FF_LOCALIP_COMPACT_TYPE_ONELINE, } FFLocalIpCompactType; -typedef enum FFDiskType -{ - FF_DISK_TYPE_NONE = 0, - FF_DISK_TYPE_REGULAR_BIT = 1 << 0, - FF_DISK_TYPE_HIDDEN_BIT = 1 << 1, - FF_DISK_TYPE_EXTERNAL_BIT = 1 << 2, - FF_DISK_TYPE_SUBVOLUME_BIT = 1 << 3, - FF_DISK_TYPE_UNKNOWN_BIT = 1 << 4, -} FFDiskType; - typedef enum FFBinaryPrefixType { FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard) @@ -122,7 +112,7 @@ typedef struct FFconfig FFGPUOptions gpu; FFModuleArgs memory; FFModuleArgs swap; - FFModuleArgs disk; + FFDiskOptions disk; FFBatteryOptions battery; FFModuleArgs powerAdapter; FFModuleArgs locale; @@ -170,9 +160,6 @@ typedef struct FFconfig bool shellVersion; bool terminalVersion; - FFstrbuf diskFolders; - FFDiskType diskShowTypes; - FFstrbuf localIpNamePrefix; FFLocalIpType localIpShowType; @@ -258,7 +245,6 @@ void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); void ffPrintMemory(FFinstance* instance); void ffPrintSwap(FFinstance* instance); -void ffPrintDisk(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintLocale(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 4bbc4c765..2b85b8c5d 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -47,7 +47,7 @@ int main(int argc, char** argv) ffPrintGPU(&instance, &instance.config.gpu); ffPrintMemory(&instance); //ffPrintSwap(&instance); - ffPrintDisk(&instance); + ffPrintDisk(&instance, &instance.config.disk); ffPrintBattery(&instance, &instance.config.battery); ffPrintPowerAdapter(&instance); //ffPrintPlayer(&instance); diff --git a/src/modules/disk.c b/src/modules/disk.c deleted file mode 100644 index dd2064d73..000000000 --- a/src/modules/disk.c +++ /dev/null @@ -1,157 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "common/parsing.h" -#include "common/bar.h" -#include "detection/disk/disk.h" - -#define FF_DISK_MODULE_NAME "Disk" -#define FF_DISK_NUM_FORMAT_ARGS 10 - -static void printDisk(FFinstance* instance, const FFDisk* disk) -{ - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); - - if(instance->config.disk.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars); - } - else - { - ffParseFormatString(&key, &instance->config.disk.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint} - }); - } - - FF_STRBUF_AUTO_DESTROY usedPretty; - ffStrbufInit(&usedPretty); - ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty); - - FF_STRBUF_AUTO_DESTROY totalPretty; - ffStrbufInit(&totalPretty); - ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty); - - uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0; - - if(instance->config.disk.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); - - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); - - if(disk->bytesTotal > 0) - { - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) - { - ffAppendPercentBar(instance, &str, bytesPercentage, 0, 5, 8); - ffStrbufAppendC(&str, ' '); - } - - if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) - ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - { - ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0); - ffStrbufAppendC(&str, ' '); - } - } - else - ffStrbufAppendS(&str, "Unknown "); - - if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) - ffStrbufAppendS(&str, "[Removable]"); - - ffStrbufTrimRight(&str, ' '); - ffStrbufPutTo(&str, stdout); - } - else - { - uint8_t filesPercentage = disk->filesTotal > 0 ? (uint8_t) (((double) disk->filesUsed / (double) disk->filesTotal) * 100.0) : 0; - - ffPrintFormatString(instance, key.chars, 0, NULL, &instance->config.disk.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, - {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, - {FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage}, - {FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed}, - {FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal}, - {FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_HIDDEN_BIT)}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name} - }); - } -} - -static void printMountpoint(FFinstance* instance, const FFlist* disks, const char* mountpoint) -{ - for(uint32_t i = disks->length; i > 0; i--) - { - FFDisk* disk = ffListGet(disks, i - 1); - if(strncmp(mountpoint, disk->mountpoint.chars, disk->mountpoint.length) == 0) - { - printDisk(instance, disk); - return; - } - } - - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &instance->config.disk, "No disk found for mountpoint: %s", mountpoint); -} - -static void printMountpoints(FFinstance* instance, const FFlist* disks) -{ - #ifdef _WIN32 - const char separator = ';'; - #else - const char separator = ':'; - #endif - - FF_STRBUF_AUTO_DESTROY mountpoints; - ffStrbufInitCopy(&mountpoints, &instance->config.diskFolders); - ffStrbufTrim(&mountpoints, separator); - - uint32_t startIndex = 0; - while(startIndex < mountpoints.length) - { - uint32_t colonIndex = ffStrbufNextIndexC(&mountpoints, startIndex, separator); - mountpoints.chars[colonIndex] = '\0'; - - printMountpoint(instance, disks, mountpoints.chars + startIndex); - - startIndex = colonIndex + 1; - } -} - -static void printAutodetected(FFinstance* instance, const FFlist* disks) -{ - bool found = false; - - FF_LIST_FOR_EACH(FFDisk, disk, *disks) - { - if(!(disk->type & instance->config.diskShowTypes)) - continue; - - printDisk(instance, disk); - found = true; - } - - if (!found) - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &instance->config.disk, "No disk found"); -} - -void ffPrintDisk(FFinstance* instance) -{ - const FFDiskResult* disks = ffDetectDisks(); - if(disks->error.length > 0) - { - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &instance->config.disk, "%s", disks->error.chars); - return; - } - - if(instance->config.diskFolders.length == 0) - printAutodetected(instance, &disks->disks); - else - printMountpoints(instance, &disks->disks); -} diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c new file mode 100644 index 000000000..ee5585f73 --- /dev/null +++ b/src/modules/disk/disk.c @@ -0,0 +1,291 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "common/parsing.h" +#include "common/bar.h" +#include "detection/disk/disk.h" +#include "modules/disk/disk.h" + +#define FF_DISK_NUM_FORMAT_ARGS 10 +#pragma GCC diagnostic ignored "-Wsign-conversion" + +static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk* disk) +{ + FF_STRBUF_AUTO_DESTROY key; + ffStrbufInit(&key); + + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint} + }); + } + + FF_STRBUF_AUTO_DESTROY usedPretty; + ffStrbufInit(&usedPretty); + ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty); + + FF_STRBUF_AUTO_DESTROY totalPretty; + ffStrbufInit(&totalPretty); + ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty); + + uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0; + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, key.chars, 0, NULL); + + FF_STRBUF_AUTO_DESTROY str; + ffStrbufInit(&str); + + if(disk->bytesTotal > 0) + { + if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + { + ffAppendPercentBar(instance, &str, bytesPercentage, 0, 5, 8); + ffStrbufAppendC(&str, ' '); + } + + if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); + + if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + { + ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0); + ffStrbufAppendC(&str, ' '); + } + } + else + ffStrbufAppendS(&str, "Unknown "); + + if((disk->type & FF_DISK_TYPE_EXTERNAL_BIT) && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + ffStrbufAppendS(&str, "[Removable]"); + + ffStrbufTrimRight(&str, ' '); + ffStrbufPutTo(&str, stdout); + } + else + { + uint8_t filesPercentage = disk->filesTotal > 0 ? (uint8_t) (((double) disk->filesUsed / (double) disk->filesTotal) * 100.0) : 0; + + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, + {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, + {FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage}, + {FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed}, + {FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal}, + {FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage}, + {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)}, + {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_HIDDEN_BIT)}, + {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem}, + {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name} + }); + } +} + +static void printMountpoint(FFinstance* instance, FFDiskOptions* options, const FFlist* disks, const char* mountpoint) +{ + for(uint32_t i = disks->length; i > 0; i--) + { + FFDisk* disk = ffListGet(disks, i - 1); + if(strncmp(mountpoint, disk->mountpoint.chars, disk->mountpoint.length) == 0) + { + printDisk(instance, options, disk); + return; + } + } + + ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint); +} + +static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const FFlist* disks) +{ + #ifdef _WIN32 + const char separator = ';'; + #else + const char separator = ':'; + #endif + + FFstrbuf mountpoints; + ffStrbufInitCopy(&mountpoints, &options->folders); + ffStrbufTrim(&mountpoints, separator); + + uint32_t startIndex = 0; + while(startIndex < mountpoints.length) + { + uint32_t colonIndex = ffStrbufNextIndexC(&mountpoints, startIndex, separator); + mountpoints.chars[colonIndex] = '\0'; + + printMountpoint(instance, options, disks, mountpoints.chars + startIndex); + + startIndex = colonIndex + 1; + } +} + +static void printAutodetected(FFinstance* instance, FFDiskOptions* options, const FFlist* disks) +{ + FF_LIST_FOR_EACH(FFDisk, disk, *disks) + { + if(!(disk->type & options->showTypes)) + continue; + + printDisk(instance, options, disk); + } +} + +void ffPrintDisk(FFinstance* instance, FFDiskOptions* options) +{ + const FFDiskResult* disks = ffDetectDisks(); + if(disks->error.length > 0) + { + ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", disks->error.chars); + return; + } + + if(options->folders.length == 0) + printAutodetected(instance, options, &disks->disks); + else + printMountpoints(instance, options, &disks->disks); +} + + +void ffInitDiskOptions(FFDiskOptions* options) +{ + options->moduleName = FF_DISK_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + ffStrbufInit(&options->folders); + options->showTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; +} + +bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_DISK_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "folders") == 0) + { + ffOptionParseString(key, value, &options->folders); + return true; + } + + if (strcasecmp(subKey, "show-regular") == 0) + { + if (ffOptionParseBoolean(value)) + options->showTypes |= FF_DISK_TYPE_REGULAR_BIT; + else + options->showTypes &= ~FF_DISK_TYPE_REGULAR_BIT; + return true; + } + + if (strcasecmp(subKey, "show-removable") == 0) + { + if (ffOptionParseBoolean(value)) + options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; + else + options->showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT; + return true; + } + + if (strcasecmp(subKey, "show-hidden") == 0) + { + if (ffOptionParseBoolean(value)) + options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT; + else + options->showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT; + return true; + } + + if (strcasecmp(subKey, "show-subvolumes") == 0) + { + if (ffOptionParseBoolean(value)) + options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; + else + options->showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT; + return true; + } + + if (strcasecmp(subKey, "show-unknown") == 0) + { + if (ffOptionParseBoolean(value)) + options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; + else + options->showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT; + return true; + } + + return false; +} + +void ffDestroyDiskOptions(FFDiskOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseDiskJsonObject(FFinstance* instance, json_object* module) +{ + FFDiskOptions __attribute__((__cleanup__(ffDestroyDiskOptions))) options; + ffInitDiskOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "folders") == 0) + { + ffStrbufSetS(&options.folders, json_object_get_string(val)); + continue; + } + + if (strcasecmp(key, "showRemovable") == 0) + { + if (json_object_get_boolean(val)) + options.showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; + else + options.showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT; + continue; + } + + if (strcasecmp(key, "showHidden") == 0) + { + if (json_object_get_boolean(val)) + options.showTypes |= FF_DISK_TYPE_HIDDEN_BIT; + else + options.showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT; + continue; + } + + if (strcasecmp(key, "showSubvolumes") == 0) + { + if (json_object_get_boolean(val)) + options.showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; + else + options.showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT; + continue; + } + + if (strcasecmp(key, "show-unknown") == 0) + { + if (json_object_get_boolean(val)) + options.showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; + else + options.showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT; + continue; + } + + ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintDisk(instance, &options); +} +#endif diff --git a/src/modules/disk/disk.h b/src/modules/disk/disk.h new file mode 100644 index 000000000..5d3fc05ba --- /dev/null +++ b/src/modules/disk/disk.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_DISK_MODULE_NAME "Disk" + +void ffPrintDisk(FFinstance* instance, FFDiskOptions* options); +void ffInitDiskOptions(FFDiskOptions* options); +bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value); +void ffDestroyDiskOptions(FFDiskOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseDiskJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/disk/option.h b/src/modules/disk/option.h new file mode 100644 index 000000000..702e5bcbf --- /dev/null +++ b/src/modules/disk/option.h @@ -0,0 +1,24 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFDiskType +{ + FF_DISK_TYPE_NONE = 0, + FF_DISK_TYPE_REGULAR_BIT = 1 << 0, + FF_DISK_TYPE_HIDDEN_BIT = 1 << 1, + FF_DISK_TYPE_EXTERNAL_BIT = 1 << 2, + FF_DISK_TYPE_SUBVOLUME_BIT = 1 << 3, + FF_DISK_TYPE_UNKNOWN_BIT = 1 << 4, +} FFDiskType; + +typedef struct FFDiskOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFstrbuf folders; + FFDiskType showTypes; +} FFDiskOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 140b8dedc..58a2af865 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -52,6 +52,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o return tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || + tryModule(instance, type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 1a1d3349b..53b48ea51 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -16,6 +16,7 @@ #include "modules/cursor/cursor.h" #include "modules/custom/custom.h" #include "modules/datetime/datetime.h" +#include "modules/disk/disk.h" #include "modules/display/display.h" #include "modules/gpu/gpu.h" #include "modules/host/host.h" diff --git a/src/modules/options.h b/src/modules/options.h index 0463e7b20..5c5b57385 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -13,6 +13,7 @@ #include "modules/custom/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" +#include "modules/disk/option.h" #include "modules/display/option.h" #include "modules/host/option.h" #include "modules/gpu/option.h" From 8dc443f827a4645cfefcfb5d26371b168671d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Apr 2023 11:01:42 +0800 Subject: [PATCH 037/493] Gamepad: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/modules/gamepad.c | 48 --------------- src/modules/gamepad/gamepad.c | 90 +++++++++++++++++++++++++++++ src/modules/gamepad/gamepad.h | 15 +++++ src/modules/gamepad/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 11 files changed, 126 insertions(+), 56 deletions(-) delete mode 100644 src/modules/gamepad.c create mode 100644 src/modules/gamepad/gamepad.c create mode 100644 src/modules/gamepad/gamepad.h create mode 100644 src/modules/gamepad/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0557ce42a..6a984849b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,7 +282,7 @@ set(LIBFASTFETCH_SRC src/modules/gpu/gpu.c src/modules/host/host.c src/modules/icons.c - src/modules/gamepad.c + src/modules/gamepad/gamepad.c src/modules/kernel/kernel.c src/modules/locale.c src/modules/localip.c diff --git a/src/common/init.c b/src/common/init.c index bb3843cac..d9f186694 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -105,7 +105,7 @@ static void defaultConfig(FFinstance* instance) ffInitBluetoothOptions(&instance->config.bluetooth); initModuleArg(&instance->config.sound); ffInitSeparatorOptions(&instance->config.separator); - initModuleArg(&instance->config.gamepad); + ffInitGamepadOptions(&instance->config.gamepad); ffStrbufInitA(&instance->config.libPCI, 0); ffStrbufInitA(&instance->config.libVulkan, 0); @@ -332,7 +332,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyBluetoothOptions(&instance->config.bluetooth); ffDestroySeparatorOptions(&instance->config.separator); destroyModuleArg(&instance->config.sound); - destroyModuleArg(&instance->config.gamepad); + ffDestroyGamepadOptions(&instance->config.gamepad); ffStrbufDestroy(&instance->config.libPCI); ffStrbufDestroy(&instance->config.libVulkan); diff --git a/src/fastfetch.c b/src/fastfetch.c index 6a7da5b28..af3bb42fa 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1024,7 +1024,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(optionParseModuleArgs(key, value, "sound", &instance->config.sound)) {} - else if(optionParseModuleArgs(key, value, "gamepad", &instance->config.gamepad)) {} + else if(ffParseGamepadCommandOptions(&instance->config.gamepad, key, value)) {} /////////////////// //Library options// @@ -1290,8 +1290,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintBluetooth(instance, &instance->config.bluetooth); else if(strcasecmp(line, "sound") == 0) ffPrintSound(instance); - else if(strcasecmp(line, "gamepad") == 0) - ffPrintGamepad(instance); + else if(strcasecmp(line, FF_GAMEPAD_MODULE_NAME) == 0) + ffPrintGamepad(instance, &instance->config.gamepad); else if(strcasecmp(line, FF_JSONCONFIG_MODULE_NAME) == 0) ffPrintJsonConfig(instance); else diff --git a/src/fastfetch.h b/src/fastfetch.h index 79a727e6a..dbf48833d 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -129,7 +129,7 @@ typedef struct FFconfig FFBluetoothOptions bluetooth; FFSeparatorOptions separator; FFModuleArgs sound; - FFModuleArgs gamepad; + FFGamepadOptions gamepad; FFstrbuf libPCI; FFstrbuf libVulkan; @@ -262,6 +262,5 @@ void ffPrintOpenGL(FFinstance* instance); void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); void ffPrintSound(FFinstance* instance); -void ffPrintGamepad(FFinstance* instance); #endif diff --git a/src/modules/gamepad.c b/src/modules/gamepad.c deleted file mode 100644 index 6bcb332f8..000000000 --- a/src/modules/gamepad.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "common/printing.h" -#include "detection/gamepad/gamepad.h" - -#define FF_GAMEPAD_MODULE_NAME "Gamepad" -#define FF_GAMEPAD_NUM_FORMAT_ARGS 2 - -static void printDevice(FFinstance* instance, const FFGamepadDevice* device, uint8_t index) -{ - if(instance->config.gamepad.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &instance->config.gamepad.key); - ffStrbufPutTo(&device->name, stdout); - } - else - { - ffPrintFormat(instance, FF_GAMEPAD_MODULE_NAME, index, &instance->config.gamepad, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier}, - }); - } -} - -void ffPrintGamepad(FFinstance* instance) -{ - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFGamepadDevice)); - const char* error = ffDetectGamepad(instance, &result); - - if(error) - { - ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &instance->config.gamepad, "%s", error); - return; - } - - if(!result.length) - { - ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &instance->config.gamepad, "No devices detected"); - return; - } - - uint8_t index = 0; - FF_LIST_FOR_EACH(FFGamepadDevice, device, result) - { - printDevice(instance, device, result.length > 1 ? ++index : 0); - ffStrbufDestroy(&device->identifier); - ffStrbufDestroy(&device->name); - } -} diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c new file mode 100644 index 000000000..a0cd64f27 --- /dev/null +++ b/src/modules/gamepad/gamepad.c @@ -0,0 +1,90 @@ +#include "common/printing.h" +#include "detection/gamepad/gamepad.h" +#include "modules/gamepad/gamepad.h" + +#define FF_GAMEPAD_NUM_FORMAT_ARGS 2 + +static void printDevice(FFinstance* instance, FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index) +{ + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key); + ffStrbufPutTo(&device->name, stdout); + } + else + { + ffPrintFormat(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier}, + }); + } +} + +void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options) +{ + FF_LIST_AUTO_DESTROY result; + ffListInit(&result, sizeof(FFGamepadDevice)); + const char* error = ffDetectGamepad(instance, &result); + + if(error) + { + ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(!result.length) + { + ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected"); + return; + } + + uint8_t index = 0; + FF_LIST_FOR_EACH(FFGamepadDevice, device, result) + { + printDevice(instance, options, device, result.length > 1 ? ++index : 0); + ffStrbufDestroy(&device->identifier); + ffStrbufDestroy(&device->name); + } +} + +void ffInitGamepadOptions(FFGamepadOptions* options) +{ + options->moduleName = FF_GAMEPAD_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_GAMEPAD_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyGamepadOptions(FFGamepadOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseGamepadJsonObject(FFinstance* instance, json_object* module) +{ + FFGamepadOptions __attribute__((__cleanup__(ffDestroyGamepadOptions))) options; + ffInitGamepadOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintGamepad(instance, &options); +} +#endif diff --git a/src/modules/gamepad/gamepad.h b/src/modules/gamepad/gamepad.h new file mode 100644 index 000000000..2ada4ad2f --- /dev/null +++ b/src/modules/gamepad/gamepad.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_GAMEPAD_MODULE_NAME "Gamepad" + +void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options); +void ffInitGamepadOptions(FFGamepadOptions* options); +bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value); +void ffDestroyGamepadOptions(FFGamepadOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseGamepadJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/gamepad/option.h b/src/modules/gamepad/option.h new file mode 100644 index 000000000..6cca7f2fd --- /dev/null +++ b/src/modules/gamepad/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFGamepadOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFGamepadOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 58a2af865..012348521 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -58,6 +58,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'G': { return + tryModule(instance, type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 53b48ea51..c033acb3a 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -18,6 +18,7 @@ #include "modules/datetime/datetime.h" #include "modules/disk/disk.h" #include "modules/display/display.h" +#include "modules/gamepad/gamepad.h" #include "modules/gpu/gpu.h" #include "modules/host/host.h" #include "modules/kernel/kernel.h" diff --git a/src/modules/options.h b/src/modules/options.h index 5c5b57385..919b8793a 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -16,6 +16,7 @@ #include "modules/disk/option.h" #include "modules/display/option.h" #include "modules/host/option.h" +#include "modules/gamepad/option.h" #include "modules/gpu/option.h" #include "modules/kernel/option.h" #include "modules/os/option.h" From 3526092b3887fe6f53bafa0d5a39530107e15b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Apr 2023 12:28:52 +0800 Subject: [PATCH 038/493] Font: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/font.c | 34 ------------- src/modules/font/font.c | 75 +++++++++++++++++++++++++++++ src/modules/font/font.h | 15 ++++++ src/modules/font/option.h | 11 +++++ src/modules/jsonconfig/jsonconfig.c | 6 +++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 117 insertions(+), 43 deletions(-) delete mode 100644 src/modules/font.c create mode 100644 src/modules/font/font.c create mode 100644 src/modules/font/font.h create mode 100644 src/modules/font/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a984849b..244924952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,7 @@ set(LIBFASTFETCH_SRC src/modules/datetime/datetime.c src/modules/de.c src/modules/disk/disk.c - src/modules/font.c + src/modules/font/font.c src/modules/gpu/gpu.c src/modules/host/host.c src/modules/icons.c diff --git a/src/common/init.c b/src/common/init.c index d9f186694..a049663e3 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -77,7 +77,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.wmTheme); initModuleArg(&instance->config.theme); initModuleArg(&instance->config.icons); - initModuleArg(&instance->config.font); + ffInitFontOptions(&instance->config.font); ffInitCursorOptions(&instance->config.cursor); initModuleArg(&instance->config.terminal); initModuleArg(&instance->config.terminalFont); @@ -304,7 +304,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.wmTheme); destroyModuleArg(&instance->config.theme); destroyModuleArg(&instance->config.icons); - destroyModuleArg(&instance->config.font); + ffDestroyFontOptions(&instance->config.font); ffDestroyCursorOptions(&instance->config.cursor); destroyModuleArg(&instance->config.terminal); destroyModuleArg(&instance->config.terminalFont); diff --git a/src/fastfetch.c b/src/fastfetch.c index af3bb42fa..d481622bc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -998,7 +998,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {} else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} - else if(optionParseModuleArgs(key, value, "font", &instance->config.font)) {} + else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {} else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} @@ -1232,8 +1232,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintIcons(instance); else if(strcasecmp(line, "wallpaper") == 0) ffPrintWallpaper(instance); - else if(strcasecmp(line, "font") == 0) - ffPrintFont(instance); + else if(strcasecmp(line, FF_FONT_MODULE_NAME) == 0) + ffPrintFont(instance, &instance->config.font); else if(strcasecmp(line, FF_CURSOR_MODULE_NAME) == 0) ffPrintCursor(instance, &instance->config.cursor); else if(strcasecmp(line, "terminal") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index dbf48833d..04c66f3b8 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -102,7 +102,7 @@ typedef struct FFconfig FFModuleArgs wmTheme; FFModuleArgs theme; FFModuleArgs icons; - FFModuleArgs font; + FFFontOptions font; FFCursorOptions cursor; FFModuleArgs terminal; FFModuleArgs terminalFont; @@ -240,7 +240,6 @@ void ffPrintWMTheme(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); -void ffPrintFont(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); void ffPrintMemory(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 2b85b8c5d..051a67cab 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -39,7 +39,7 @@ int main(int argc, char** argv) ffPrintWMTheme(&instance); ffPrintTheme(&instance); ffPrintIcons(&instance); - ffPrintFont(&instance); + ffPrintFont(&instance, &instance.config.font); ffPrintCursor(&instance, &instance.config.cursor); ffPrintTerminal(&instance); ffPrintTerminalFont(&instance); diff --git a/src/modules/font.c b/src/modules/font.c deleted file mode 100644 index c33d144fe..000000000 --- a/src/modules/font.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/font/font.h" -#include "detection/displayserver/displayserver.h" - -#define FF_FONT_MODULE_NAME "Font" -#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1) - -void ffPrintFont(FFinstance* instance) -{ - const FFFontResult* font = ffDetectFont(instance); - - if(font->error.length > 0) - { - ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, "%s", font->error.chars); - return; - } - - if(instance->config.font.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font.key); - ffStrbufPutTo(&font->display, stdout); - } - else - { - ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[0]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[1]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[2]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[3]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->display}, - }); - } -} diff --git a/src/modules/font/font.c b/src/modules/font/font.c new file mode 100644 index 000000000..be9159c6f --- /dev/null +++ b/src/modules/font/font.c @@ -0,0 +1,75 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/font/font.h" +#include "modules/font/font.h" + +#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1) + +void ffPrintFont(FFinstance* instance, FFFontOptions* options) +{ + const FFFontResult* font = ffDetectFont(instance); + + if(font->error.length > 0) + { + ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", font->error.chars); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&font->display, stdout); + } + else + { + ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[0]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[1]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[2]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[3]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font->display}, + }); + } +} + +void ffInitFontOptions(FFFontOptions* options) +{ + options->moduleName = FF_FONT_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_FONT_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyFontOptions(FFFontOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseFontJsonObject(FFinstance* instance, json_object* module) +{ + FFFontOptions __attribute__((__cleanup__(ffDestroyFontOptions))) options; + ffInitFontOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintFont(instance, &options); +} +#endif diff --git a/src/modules/font/font.h b/src/modules/font/font.h new file mode 100644 index 000000000..36627b72f --- /dev/null +++ b/src/modules/font/font.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_FONT_MODULE_NAME "Font" + +void ffPrintFont(FFinstance* instance, FFFontOptions* options); +void ffInitFontOptions(FFFontOptions* options); +bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value); +void ffDestroyFontOptions(FFFontOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseFontJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/font/option.h b/src/modules/font/option.h new file mode 100644 index 000000000..9318bac4b --- /dev/null +++ b/src/modules/font/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFFontOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFFontOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 012348521..ba4ba7e51 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -56,6 +56,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'F': { + return + tryModule(instance, type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) || + false; + } + case 'G': { return tryModule(instance, type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index c033acb3a..c4e04e954 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -18,6 +18,7 @@ #include "modules/datetime/datetime.h" #include "modules/disk/disk.h" #include "modules/display/display.h" +#include "modules/font/font.h" #include "modules/gamepad/gamepad.h" #include "modules/gpu/gpu.h" #include "modules/host/host.h" diff --git a/src/modules/options.h b/src/modules/options.h index 919b8793a..d74d5976c 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -15,6 +15,7 @@ #include "modules/datetime/option.h" #include "modules/disk/option.h" #include "modules/display/option.h" +#include "modules/font/option.h" #include "modules/host/option.h" #include "modules/gamepad/option.h" #include "modules/gpu/option.h" From 0b96818f6d339ecc2251bba6799a7a852aee065e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Apr 2023 17:47:42 +0800 Subject: [PATCH 039/493] Locale: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 6 +++ src/modules/locale.c | 33 ------------- src/modules/locale/locale.c | 73 +++++++++++++++++++++++++++++ src/modules/locale/locale.h | 15 ++++++ src/modules/locale/option.h | 11 +++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 115 insertions(+), 42 deletions(-) delete mode 100644 src/modules/locale.c create mode 100644 src/modules/locale/locale.c create mode 100644 src/modules/locale/locale.h create mode 100644 src/modules/locale/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 244924952..1ca63dc97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,7 +284,7 @@ set(LIBFASTFETCH_SRC src/modules/icons.c src/modules/gamepad/gamepad.c src/modules/kernel/kernel.c - src/modules/locale.c + src/modules/locale/locale.c src/modules/localip.c src/modules/memory.c src/modules/opencl.c diff --git a/src/common/init.c b/src/common/init.c index a049663e3..791367863 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -89,7 +89,7 @@ static void defaultConfig(FFinstance* instance) ffInitDiskOptions(&instance->config.disk); ffInitBatteryOptions(&instance->config.battery); initModuleArg(&instance->config.powerAdapter); - initModuleArg(&instance->config.locale); + ffInitLocaleOptions(&instance->config.locale); initModuleArg(&instance->config.localIP); initModuleArg(&instance->config.publicIP); initModuleArg(&instance->config.weather); @@ -316,7 +316,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyDiskOptions(&instance->config.disk); ffDestroyBatteryOptions(&instance->config.battery); destroyModuleArg(&instance->config.powerAdapter); - destroyModuleArg(&instance->config.locale); + ffDestroyLocaleOptions(&instance->config.locale); destroyModuleArg(&instance->config.localIP); destroyModuleArg(&instance->config.publicIP); destroyModuleArg(&instance->config.wallpaper); diff --git a/src/fastfetch.c b/src/fastfetch.c index d481622bc..e3b9492fc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1010,7 +1010,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseDiskCommandOptions(&instance->config.disk, key, value)) {} else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} - else if(optionParseModuleArgs(key, value, "locale", &instance->config.locale)) {} + else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} else if(optionParseModuleArgs(key, value, "localip", &instance->config.localIP)) {} else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} @@ -1258,8 +1258,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintBattery(instance, &instance->config.battery); else if(strcasecmp(line, "poweradapter") == 0) ffPrintPowerAdapter(instance); - else if(strcasecmp(line, "locale") == 0) - ffPrintLocale(instance); + else if(strcasecmp(line, FF_LOCALE_MODULE_NAME) == 0) + ffPrintLocale(instance, &instance->config.locale); else if(strcasecmp(line, "localip") == 0) ffPrintLocalIp(instance); else if(strcasecmp(line, "publicip") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 04c66f3b8..d7d513737 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -115,7 +115,7 @@ typedef struct FFconfig FFDiskOptions disk; FFBatteryOptions battery; FFModuleArgs powerAdapter; - FFModuleArgs locale; + FFLocaleOptions locale; FFModuleArgs localIP; FFModuleArgs publicIP; FFModuleArgs weather; @@ -245,7 +245,6 @@ void ffPrintTerminalFont(FFinstance* instance); void ffPrintMemory(FFinstance* instance); void ffPrintSwap(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); -void ffPrintLocale(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); diff --git a/src/flashfetch.c b/src/flashfetch.c index 051a67cab..4c0db155e 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -56,7 +56,7 @@ int main(int argc, char** argv) //ffPrintPublicIp(&instance); //ffPrintWifi(&instance); //ffPrintCPUUsage(&instance, &instance.config.cpuUsage); - ffPrintLocale(&instance); + ffPrintLocale(&instance, &instance.config.locale); //ffPrintDateTime(&instance); //ffPrintDate(&instance); //ffPrintTime(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index ba4ba7e51..13ec41c67 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -81,6 +81,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'L': { + return + tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || + false; + } + case 'O': { return tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || diff --git a/src/modules/locale.c b/src/modules/locale.c deleted file mode 100644 index 8c56b0638..000000000 --- a/src/modules/locale.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/locale/locale.h" - -#define FF_LOCALE_MODULE_NAME "Locale" -#define FF_LOCALE_NUM_FORMAT_ARGS 1 - -void ffPrintLocale(FFinstance* instance) -{ - FFstrbuf locale; - ffStrbufInit(&locale); - - ffDetectLocale(&locale); - if(locale.length == 0) - { - ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, "No locale found"); - return; - } - - if(instance->config.locale.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale.key); - ffStrbufPutTo(&locale, stdout); - } - else - { - ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &locale} - }); - } - - ffStrbufDestroy(&locale); -} diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c new file mode 100644 index 000000000..5d3a510dd --- /dev/null +++ b/src/modules/locale/locale.c @@ -0,0 +1,73 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/locale/locale.h" +#include "modules/locale/locale.h" + +#define FF_LOCALE_NUM_FORMAT_ARGS 1 + +void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options) +{ + FF_STRBUF_AUTO_DESTROY locale; + ffStrbufInit(&locale); + + ffDetectLocale(&locale); + if(locale.length == 0) + { + ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&locale, stdout); + } + else + { + ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &locale} + }); + } +} + +void ffInitLocaleOptions(FFLocaleOptions* options) +{ + options->moduleName = FF_LOCALE_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_LOCALE_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyLocaleOptions(FFLocaleOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseLocaleJsonObject(FFinstance* instance, json_object* module) +{ + FFLocaleOptions __attribute__((__cleanup__(ffDestroyLocaleOptions))) options; + ffInitLocaleOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintLocale(instance, &options); +} +#endif diff --git a/src/modules/locale/locale.h b/src/modules/locale/locale.h new file mode 100644 index 000000000..e02f91154 --- /dev/null +++ b/src/modules/locale/locale.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_LOCALE_MODULE_NAME "Locale" + +void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options); +void ffInitLocaleOptions(FFLocaleOptions* options); +bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value); +void ffDestroyLocaleOptions(FFLocaleOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseLocaleJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/locale/option.h b/src/modules/locale/option.h new file mode 100644 index 000000000..3e3253037 --- /dev/null +++ b/src/modules/locale/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFLocaleOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFLocaleOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index c4e04e954..31310935b 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -23,6 +23,7 @@ #include "modules/gpu/gpu.h" #include "modules/host/host.h" #include "modules/kernel/kernel.h" +#include "modules/locale/locale.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index d74d5976c..7cc1569a4 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -20,6 +20,7 @@ #include "modules/gamepad/option.h" #include "modules/gpu/option.h" #include "modules/kernel/option.h" +#include "modules/locale/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" From 7e85db68430611a2c86c8b1e4b5b186e1f917fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Apr 2023 20:46:50 +0800 Subject: [PATCH 040/493] LocalIP: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 8 +- src/detection/localip/localip.h | 2 +- src/detection/localip/localip_linux.c | 14 +- src/detection/localip/localip_windows.c | 12 +- src/fastfetch.c | 16 +- src/fastfetch.h | 24 +-- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/localip.c | 119 ----------- src/modules/localip/localip.c | 269 ++++++++++++++++++++++++ src/modules/localip/localip.h | 15 ++ src/modules/localip/option.h | 25 +++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 14 files changed, 332 insertions(+), 177 deletions(-) delete mode 100644 src/modules/localip.c create mode 100644 src/modules/localip/localip.c create mode 100644 src/modules/localip/localip.h create mode 100644 src/modules/localip/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca63dc97..cb7ed9dc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,7 +285,7 @@ set(LIBFASTFETCH_SRC src/modules/gamepad/gamepad.c src/modules/kernel/kernel.c src/modules/locale/locale.c - src/modules/localip.c + src/modules/localip/localip.c src/modules/memory.c src/modules/opencl.c src/modules/opengl.c diff --git a/src/common/init.c b/src/common/init.c index 791367863..fb2ce3889 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -90,7 +90,7 @@ static void defaultConfig(FFinstance* instance) ffInitBatteryOptions(&instance->config.battery); initModuleArg(&instance->config.powerAdapter); ffInitLocaleOptions(&instance->config.locale); - initModuleArg(&instance->config.localIP); + ffInitLocalIpOptions(&instance->config.localIP); initModuleArg(&instance->config.publicIP); initModuleArg(&instance->config.weather); initModuleArg(&instance->config.wifi); @@ -138,9 +138,6 @@ static void defaultConfig(FFinstance* instance) instance->config.soundType = FF_SOUND_TYPE_MAIN; - instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT; - ffStrbufInit(&instance->config.localIpNamePrefix); - instance->config.publicIpTimeout = 0; ffStrbufInit(&instance->config.publicIpUrl); @@ -317,7 +314,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyBatteryOptions(&instance->config.battery); destroyModuleArg(&instance->config.powerAdapter); ffDestroyLocaleOptions(&instance->config.locale); - destroyModuleArg(&instance->config.localIP); + ffDestroyLocalIpOptions(&instance->config.localIP); destroyModuleArg(&instance->config.publicIP); destroyModuleArg(&instance->config.wallpaper); destroyModuleArg(&instance->config.weather); @@ -360,7 +357,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libwlanapi); ffStrbufDestroy(&instance->config.libnm); - ffStrbufDestroy(&instance->config.localIpNamePrefix); ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); ffStrbufDestroy(&instance->config.playerName); diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index f90e97c26..4c9a91539 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -13,6 +13,6 @@ typedef struct FFLocalIpResult FFstrbuf mac; } FFLocalIpResult; -const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results); +const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results); #endif diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index b753d1447..29383c2ae 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -46,7 +46,7 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type) } } -const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) +const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { struct ifaddrs* ifAddrStruct = NULL; if(getifaddrs(&ifAddrStruct) < 0) @@ -57,15 +57,15 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) if (!ifa->ifa_addr || !(ifa->ifa_flags & IFF_RUNNING)) continue; - if ((ifa->ifa_flags & IFF_LOOPBACK) && !(instance->config.localIpShowType & FF_LOCALIP_TYPE_LOOP_BIT)) + if ((ifa->ifa_flags & IFF_LOOPBACK) && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) continue; - if (instance->config.localIpNamePrefix.length && strncmp(ifa->ifa_name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0) + if (options->namePrefix.length && strncmp(ifa->ifa_name, options->namePrefix.chars, options->namePrefix.length) != 0) continue; if (ifa->ifa_addr->sa_family == AF_INET) { - if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV4_BIT)) + if (!(options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) continue; struct sockaddr_in* ipv4 = (struct sockaddr_in*) ifa->ifa_addr; @@ -75,7 +75,7 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) } else if (ifa->ifa_addr->sa_family == AF_INET6) { - if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV6_BIT)) + if (!(options->showType & FF_LOCALIP_TYPE_IPV6_BIT)) continue; struct sockaddr_in6* ipv6 = (struct sockaddr_in6 *)ifa->ifa_addr; @@ -86,7 +86,7 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) #if defined(__FreeBSD__) || defined(__APPLE__) else if (ifa->ifa_addr->sa_family == AF_LINK) { - if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT)) + if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT)) continue; char addressBuffer[32]; @@ -98,7 +98,7 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) #else else if (ifa->ifa_addr->sa_family == AF_PACKET) { - if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT)) + if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT)) continue; char addressBuffer[32]; diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index aa3c1dd52..d1295afb0 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -37,7 +37,7 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type } } -const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) +const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL; @@ -51,8 +51,8 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) assert(adapter_addresses); DWORD error = GetAdaptersAddresses( - instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV4_BIT - ? instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET + options->showType & FF_LOCALIP_TYPE_IPV4_BIT + ? options->showType & FF_LOCALIP_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET : AF_INET6, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, @@ -71,17 +71,17 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results) for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next) { bool isLoop = adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK; - if (isLoop && !(instance->config.localIpShowType & FF_LOCALIP_TYPE_LOOP_BIT)) + if (isLoop && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT)) continue; bool newIp = true; char name[128]; WideCharToMultiByte(CP_UTF8, 0, adapter->FriendlyName, -1, name, sizeof(name), NULL, NULL); - if (instance->config.localIpNamePrefix.length && strncmp(name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0) + if (options->namePrefix.length && strncmp(name, options->namePrefix.chars, options->namePrefix.length) != 0) continue; - if (instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) + if (options->showType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6) { char addressBuffer[32]; uint8_t* ptr = adapter->PhysicalAddress; diff --git a/src/fastfetch.c b/src/fastfetch.c index e3b9492fc..e1884e5f6 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1011,7 +1011,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} - else if(optionParseModuleArgs(key, value, "localip", &instance->config.localIP)) {} + else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {} @@ -1104,18 +1104,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con NULL ); } - else if(strcasecmp(key, "--localip-show-ipv4") == 0) - optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_IPV4_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_IPV4_BIT); - else if(strcasecmp(key, "--localip-show-ipv6") == 0) - optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_IPV6_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_IPV6_BIT); - else if(strcasecmp(key, "--localip-show-mac") == 0) - optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_MAC_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_MAC_BIT); - else if(strcasecmp(key, "--localip-show-loop") == 0) - optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_LOOP_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_LOOP_BIT); - else if(strcasecmp(key, "--localip-compact") == 0) - optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_COMPACT_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_COMPACT_BIT); - else if(strcasecmp(key, "--localip-name-prefix") == 0) - optionParseString(key, value, &instance->config.localIpNamePrefix); else if(strcasecmp(key, "--player-name") == 0) optionParseString(key, value, &instance->config.playerName); else if(strcasecmp(key, "--publicip-url") == 0) @@ -1261,7 +1249,7 @@ static void parseStructureCommand(FFinstance* instance, const char* line) else if(strcasecmp(line, FF_LOCALE_MODULE_NAME) == 0) ffPrintLocale(instance, &instance->config.locale); else if(strcasecmp(line, "localip") == 0) - ffPrintLocalIp(instance); + ffPrintLocalIp(instance, &instance->config.localIP); else if(strcasecmp(line, "publicip") == 0) ffPrintPublicIp(instance); else if(strcasecmp(line, "wifi") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index d7d513737..2068ab03b 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -26,13 +26,6 @@ typedef enum FFSoundType FF_SOUND_TYPE_ALL, } FFSoundType; -typedef enum FFLocalIpCompactType -{ - FF_LOCALIP_COMPACT_TYPE_NONE, - FF_LOCALIP_COMPACT_TYPE_MULTILINE, - FF_LOCALIP_COMPACT_TYPE_ONELINE, -} FFLocalIpCompactType; - typedef enum FFBinaryPrefixType { FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard) @@ -48,17 +41,6 @@ typedef enum FFGLType FF_GL_TYPE_OSMESA } FFGLType; -typedef enum FFLocalIpType -{ - FF_LOCALIP_TYPE_NONE, - FF_LOCALIP_TYPE_LOOP_BIT = 1 << 0, - FF_LOCALIP_TYPE_IPV4_BIT = 1 << 1, - FF_LOCALIP_TYPE_IPV6_BIT = 1 << 2, - FF_LOCALIP_TYPE_MAC_BIT = 1 << 3, - - FF_LOCALIP_TYPE_COMPACT_BIT = 1 << 10, -} FFLocalIpType; - typedef struct FFconfig { FFLogoOptions logo; @@ -116,7 +98,7 @@ typedef struct FFconfig FFBatteryOptions battery; FFModuleArgs powerAdapter; FFLocaleOptions locale; - FFModuleArgs localIP; + FFLocalIpOptions localIP; FFModuleArgs publicIP; FFModuleArgs weather; FFModuleArgs player; @@ -160,9 +142,6 @@ typedef struct FFconfig bool shellVersion; bool terminalVersion; - FFstrbuf localIpNamePrefix; - FFLocalIpType localIpShowType; - FFstrbuf publicIpUrl; uint32_t publicIpTimeout; @@ -250,7 +229,6 @@ void ffPrintMedia(FFinstance* instance); void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); void ffPrintDate(FFinstance* instance); void ffPrintTime(FFinstance* instance); -void ffPrintLocalIp(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintWifi(FFinstance* instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 13ec41c67..f1f12cd93 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -84,6 +84,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'L': { return tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || + tryModule(instance, type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || false; } diff --git a/src/modules/localip.c b/src/modules/localip.c deleted file mode 100644 index 5d6de0bad..000000000 --- a/src/modules/localip.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/localip/localip.h" - -#define FF_LOCALIP_MODULE_NAME "Local IP" -#define FF_LOCALIP_NUM_FORMAT_ARGS 2 - -static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right) -{ - return ffStrbufComp(&left->name, &right->name); -} - -static void formatKey(const FFinstance* instance, const FFLocalIpResult* ip, FFstrbuf* key) -{ - if(instance->config.localIP.key.length == 0) - { - if(ip->name.length) - ffStrbufSetF(key, FF_LOCALIP_MODULE_NAME " (%*s)", ip->name.length, ip->name.chars); - else - ffStrbufSetS(key, FF_LOCALIP_MODULE_NAME); - } - else - { - ffStrbufClear(key); - ffParseFormatString(key, &instance->config.localIP.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name} - }); - } -} - -static void printIp(FFLocalIpResult* ip) -{ - bool flag = false; - if (ip->ipv4.length) - { - ffStrbufWriteTo(&ip->ipv4, stdout); - flag = true; - } - if (ip->ipv6.length) - { - if (flag) putchar(' '); - ffStrbufWriteTo(&ip->ipv6, stdout); - flag = true; - } - if (ip->mac.length) - { - if (flag) - printf(" (%s)", ip->mac.chars); - else - ffStrbufWriteTo(&ip->mac, stdout); - } -} - -void ffPrintLocalIp(FFinstance* instance) -{ - FF_LIST_AUTO_DESTROY results; - ffListInit(&results, sizeof(FFLocalIpResult)); - - const char* error = ffDetectLocalIps(instance, &results); - - if(error) - { - ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP, "%s", error); - return; - } - - if(results.length == 0) - { - ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP, "Failed to detect any IPs"); - return; - } - - ffListSort(&results, (void*) sortIps); - - if (instance->config.localIpShowType & FF_LOCALIP_TYPE_COMPACT_BIT) - { - ffPrintLogoAndKey(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP.key); - - FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) - { - if ((void*) ip != (void*) results.data) - fputs(" - ", stdout); - printIp(ip); - } - } - else - { - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); - - FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) - { - formatKey(instance, ip, &key); - if(instance->config.localIP.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); - printIp(ip); - putchar('\n'); - } - else - { - ffPrintFormatString(instance, key.chars, 0, NULL, &instance->config.localIP.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, - }); - } - } - } - - FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) - { - ffStrbufDestroy(&ip->name); - ffStrbufDestroy(&ip->ipv4); - ffStrbufDestroy(&ip->ipv6); - ffStrbufDestroy(&ip->mac); - } -} diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c new file mode 100644 index 000000000..b10507b8b --- /dev/null +++ b/src/modules/localip/localip.c @@ -0,0 +1,269 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/localip/localip.h" +#include "modules/localip/localip.h" + +#define FF_LOCALIP_DISPLAY_NAME "Local IP" +#define FF_LOCALIP_NUM_FORMAT_ARGS 2 +#pragma GCC diagnostic ignored "-Wsign-conversion" + +static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right) +{ + return ffStrbufComp(&left->name, &right->name); +} + +static void formatKey(const FFLocalIpOptions* options, const FFLocalIpResult* ip, FFstrbuf* key) +{ + if(options->moduleArgs.key.length == 0) + { + if(ip->name.length) + ffStrbufSetF(key, FF_LOCALIP_DISPLAY_NAME " (%s)", ip->name.chars); + else + ffStrbufSetS(key, FF_LOCALIP_DISPLAY_NAME); + } + else + { + ffStrbufClear(key); + ffParseFormatString(key, &options->moduleArgs.key, 2, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, + }); + } +} + +static void printIp(FFLocalIpResult* ip) +{ + bool flag = false; + if (ip->ipv4.length) + { + ffStrbufWriteTo(&ip->ipv4, stdout); + flag = true; + } + if (ip->ipv6.length) + { + if (flag) putchar(' '); + ffStrbufWriteTo(&ip->ipv6, stdout); + flag = true; + } + if (ip->mac.length) + { + if (flag) + printf(" (%s)", ip->mac.chars); + else + ffStrbufWriteTo(&ip->mac, stdout); + } +} + +void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) +{ + FF_LIST_AUTO_DESTROY results; + ffListInit(&results, sizeof(FFLocalIpResult)); + + const char* error = ffDetectLocalIps(options, &results); + + if(error) + { + ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(results.length == 0) + { + ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs"); + return; + } + + ffListSort(&results, (const void*) sortIps); + + if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT) + { + ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key); + + FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) + { + if ((void*) ip != (void*) results.data) + fputs(" - ", stdout); + printIp(ip); + } + } + else + { + FF_STRBUF_AUTO_DESTROY key; + ffStrbufInit(&key); + + FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) + { + formatKey(options, ip, &key); + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, key.chars, 0, NULL); + printIp(ip); + putchar('\n'); + } + else + { + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4}, + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, + }); + } + } + } + + FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) + { + ffStrbufDestroy(&ip->name); + ffStrbufDestroy(&ip->ipv4); + ffStrbufDestroy(&ip->ipv6); + ffStrbufDestroy(&ip->mac); + } +} + +void ffInitLocalIpOptions(FFLocalIpOptions* options) +{ + options->moduleName = FF_LOCALIP_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + options->showType = FF_LOCALIP_TYPE_IPV4_BIT; + ffStrbufInit(&options->namePrefix); +} + +bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_LOCALIP_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "show-ipv4") == 0) + { + if (ffOptionParseBoolean(value)) + options->showType |= FF_LOCALIP_TYPE_IPV4_BIT; + else + options->showType &= ~FF_LOCALIP_TYPE_IPV4_BIT; + return true; + } + + if (strcasecmp(subKey, "show-ipv6") == 0) + { + if (ffOptionParseBoolean(value)) + options->showType |= FF_LOCALIP_TYPE_IPV6_BIT; + else + options->showType &= ~FF_LOCALIP_TYPE_IPV6_BIT; + return true; + } + + if (strcasecmp(subKey, "show-mac") == 0) + { + if (ffOptionParseBoolean(value)) + options->showType |= FF_LOCALIP_TYPE_MAC_BIT; + else + options->showType &= ~FF_LOCALIP_TYPE_MAC_BIT; + return true; + } + + if (strcasecmp(subKey, "show-loop") == 0) + { + if (ffOptionParseBoolean(value)) + options->showType |= FF_LOCALIP_TYPE_LOOP_BIT; + else + options->showType &= ~FF_LOCALIP_TYPE_LOOP_BIT; + return true; + } + + if(strcasecmp(subKey, "compact") == 0) + { + if (ffOptionParseBoolean(value)) + options->showType |= FF_LOCALIP_TYPE_COMPACT_BIT; + else + options->showType &= ~FF_LOCALIP_TYPE_COMPACT_BIT; + return true; + } + + if (strcasecmp(subKey, "name-prefix") == 0) + { + ffOptionParseString(key, value, &options->namePrefix); + return true; + } + + return false; +} + +void ffDestroyLocalIpOptions(FFLocalIpOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + ffStrbufDestroy(&options->namePrefix); +} + +#ifdef FF_HAVE_JSONC +void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) +{ + FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options; + ffInitLocalIpOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "showIpv4") == 0) + { + if (json_object_get_boolean(val)) + options.showType |= FF_LOCALIP_TYPE_IPV4_BIT; + else + options.showType &= ~FF_LOCALIP_TYPE_IPV4_BIT; + continue; + } + + if (strcasecmp(key, "showIpv6") == 0) + { + if (json_object_get_boolean(val)) + options.showType |= FF_LOCALIP_TYPE_IPV6_BIT; + else + options.showType &= ~FF_LOCALIP_TYPE_IPV6_BIT; + continue; + } + + if (strcasecmp(key, "showMac") == 0) + { + if (json_object_get_boolean(val)) + options.showType |= FF_LOCALIP_TYPE_MAC_BIT; + else + options.showType &= ~FF_LOCALIP_TYPE_MAC_BIT; + continue; + } + + if (strcasecmp(key, "showLoop") == 0) + { + if (json_object_get_boolean(val)) + options.showType |= FF_LOCALIP_TYPE_LOOP_BIT; + else + options.showType &= ~FF_LOCALIP_TYPE_LOOP_BIT; + continue; + } + + if (strcasecmp(key, "compact") == 0) + { + if (json_object_get_boolean(val)) + options.showType |= FF_LOCALIP_TYPE_COMPACT_BIT; + else + options.showType &= ~FF_LOCALIP_TYPE_COMPACT_BIT; + continue; + } + + if (strcasecmp(key, "namePrefix") == 0) + { + ffStrbufSetS(&options.namePrefix, json_object_get_string(val)); + continue; + } + + ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintLocalIp(instance, &options); +} +#endif diff --git a/src/modules/localip/localip.h b/src/modules/localip/localip.h new file mode 100644 index 000000000..e27babe41 --- /dev/null +++ b/src/modules/localip/localip.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_LOCALIP_MODULE_NAME "LocalIp" + +void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options); +void ffInitLocalIpOptions(FFLocalIpOptions* options); +bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value); +void ffDestroyLocalIpOptions(FFLocalIpOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/localip/option.h b/src/modules/localip/option.h new file mode 100644 index 000000000..65dcfc60d --- /dev/null +++ b/src/modules/localip/option.h @@ -0,0 +1,25 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFLocalIpType +{ + FF_LOCALIP_TYPE_NONE, + FF_LOCALIP_TYPE_LOOP_BIT = 1 << 0, + FF_LOCALIP_TYPE_IPV4_BIT = 1 << 1, + FF_LOCALIP_TYPE_IPV6_BIT = 1 << 2, + FF_LOCALIP_TYPE_MAC_BIT = 1 << 3, + + FF_LOCALIP_TYPE_COMPACT_BIT = 1 << 10, +} FFLocalIpType; + +typedef struct FFLocalIpOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFLocalIpType showType; + FFstrbuf namePrefix; +} FFLocalIpOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index 31310935b..49c3fa56b 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -24,6 +24,7 @@ #include "modules/host/host.h" #include "modules/kernel/kernel.h" #include "modules/locale/locale.h" +#include "modules/localip/localip.h" #include "modules/separator/separator.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index 7cc1569a4..f8045ac9b 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -21,6 +21,7 @@ #include "modules/gpu/option.h" #include "modules/kernel/option.h" #include "modules/locale/option.h" +#include "modules/localip/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/title/option.h" From 2df1305521a538b01f30c32ae1c6533ff4393152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Apr 2023 14:05:09 +0800 Subject: [PATCH 041/493] Sound: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 6 +- src/fastfetch.c | 17 +-- src/fastfetch.h | 12 +-- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/sound.c | 85 --------------- src/modules/sound/option.h | 20 ++++ src/modules/sound/sound.c | 154 ++++++++++++++++++++++++++++ src/modules/sound/sound.h | 16 +++ 12 files changed, 202 insertions(+), 115 deletions(-) delete mode 100644 src/modules/sound.c create mode 100644 src/modules/sound/option.h create mode 100644 src/modules/sound/sound.c create mode 100644 src/modules/sound/sound.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7ed9dc0..488ec3f18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,7 +298,7 @@ set(LIBFASTFETCH_SRC src/modules/display/display.c src/modules/separator/separator.c src/modules/shell.c - src/modules/sound.c + src/modules/sound/sound.c src/modules/swap.c src/modules/media.c src/modules/terminal.c diff --git a/src/common/init.c b/src/common/init.c index fb2ce3889..d805d0724 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -103,7 +103,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.openCL); initModuleArg(&instance->config.users); ffInitBluetoothOptions(&instance->config.bluetooth); - initModuleArg(&instance->config.sound); + ffInitSoundOptions(&instance->config.sound); ffInitSeparatorOptions(&instance->config.separator); ffInitGamepadOptions(&instance->config.gamepad); @@ -136,8 +136,6 @@ static void defaultConfig(FFinstance* instance) instance->config.shellVersion = true; instance->config.terminalVersion = true; - instance->config.soundType = FF_SOUND_TYPE_MAIN; - instance->config.publicIpTimeout = 0; ffStrbufInit(&instance->config.publicIpUrl); @@ -328,7 +326,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.users); ffDestroyBluetoothOptions(&instance->config.bluetooth); ffDestroySeparatorOptions(&instance->config.separator); - destroyModuleArg(&instance->config.sound); + ffDestroySoundOptions(&instance->config.sound); ffDestroyGamepadOptions(&instance->config.gamepad); ffStrbufDestroy(&instance->config.libPCI); diff --git a/src/fastfetch.c b/src/fastfetch.c index e1884e5f6..50546fea8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1023,7 +1023,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} - else if(optionParseModuleArgs(key, value, "sound", &instance->config.sound)) {} + else if(ffParseSoundCommandOptions(&instance->config.sound, key, value)) {} else if(ffParseGamepadCommandOptions(&instance->config.gamepad, key, value)) {} /////////////////// @@ -1095,15 +1095,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.shellVersion = optionParseBoolean(value); else if(strcasecmp(key, "--terminal-version") == 0) instance->config.terminalVersion = optionParseBoolean(value); - else if(strcasecmp(key, "--sound-type") == 0) - { - optionParseEnum(key, value, &instance->config.soundType, - "main", FF_SOUND_TYPE_MAIN, - "active", FF_SOUND_TYPE_ACTIVE, - "all", FF_SOUND_TYPE_ALL, - NULL - ); - } else if(strcasecmp(key, "--player-name") == 0) optionParseString(key, value, &instance->config.playerName); else if(strcasecmp(key, "--publicip-url") == 0) @@ -1274,10 +1265,10 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintUsers(instance); else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0) ffPrintCommand(instance, &instance->config.command); - else if(strcasecmp(line, "bluetooth") == 0) + else if(strcasecmp(line, FF_BLUETOOTH_MODULE_NAME) == 0) ffPrintBluetooth(instance, &instance->config.bluetooth); - else if(strcasecmp(line, "sound") == 0) - ffPrintSound(instance); + else if(strcasecmp(line, FF_SOUND_MODULE_NAME) == 0) + ffPrintSound(instance, &instance->config.sound); else if(strcasecmp(line, FF_GAMEPAD_MODULE_NAME) == 0) ffPrintGamepad(instance, &instance->config.gamepad); else if(strcasecmp(line, FF_JSONCONFIG_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 2068ab03b..1e6b9ee1e 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -19,13 +19,6 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #include "modules/options.h" #include "logo/option.h" -typedef enum FFSoundType -{ - FF_SOUND_TYPE_MAIN, - FF_SOUND_TYPE_ACTIVE, - FF_SOUND_TYPE_ALL, -} FFSoundType; - typedef enum FFBinaryPrefixType { FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard) @@ -110,7 +103,7 @@ typedef struct FFconfig FFModuleArgs users; FFBluetoothOptions bluetooth; FFSeparatorOptions separator; - FFModuleArgs sound; + FFSoundOptions sound; FFGamepadOptions gamepad; FFstrbuf libPCI; @@ -148,8 +141,6 @@ typedef struct FFconfig FFstrbuf weatherOutputFormat; uint32_t weatherTimeout; - FFSoundType soundType; - FFstrbuf playerName; uint32_t percentType; @@ -237,6 +228,5 @@ void ffPrintVulkan(FFinstance* instance); void ffPrintOpenGL(FFinstance* instance); void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); -void ffPrintSound(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index 4c0db155e..451d72ace 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -66,7 +66,7 @@ int main(int argc, char** argv) //ffPrintUsers(&instance); //ffPrintWeather(&instance); //ffPrintBluetooth(&instance); - //ffPrintSound(&instance); + //ffPrintSound(&instance, &instance.config.sound); //ffPrintGamepad(&instance); ffPrintBreak(&instance); ffPrintColors(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index f1f12cd93..0311a4711 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -97,6 +97,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'S': { return tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || + tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 49c3fa56b..e2fff95f3 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -26,5 +26,6 @@ #include "modules/locale/locale.h" #include "modules/localip/localip.h" #include "modules/separator/separator.h" +#include "modules/sound/sound.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" diff --git a/src/modules/options.h b/src/modules/options.h index f8045ac9b..fc2b460a5 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -24,4 +24,5 @@ #include "modules/localip/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" +#include "modules/sound/option.h" #include "modules/title/option.h" diff --git a/src/modules/sound.c b/src/modules/sound.c deleted file mode 100644 index ffc4aee76..000000000 --- a/src/modules/sound.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "common/printing.h" -#include "detection/sound/sound.h" - -#define FF_SOUND_MODULE_NAME "Sound" -#define FF_SOUND_NUM_FORMAT_ARGS 4 - -static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8_t index) -{ - if(instance->config.sound.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &instance->config.sound.key); - ffStrbufWriteTo(&device->name, stdout); - - if(device->volume != FF_SOUND_VOLUME_UNKNOWN) - { - if(device->volume > 0) - printf(" (%d%%)", device->volume); - else - fputs(" (muted)", stdout); - } - - if(device->main && index > 0) - fputs(" (*)", stdout); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_SOUND_MODULE_NAME, index, &instance->config.sound, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_BOOL, &device->main}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, - {FF_FORMAT_ARG_TYPE_UINT8, &device->volume}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} - }); - } -} - -static void printSound(FFinstance* instance, FFlist* devices) -{ - FF_LIST_AUTO_DESTROY filtered; - ffListInit(&filtered, sizeof(FFSoundDevice*)); - - FF_LIST_FOR_EACH(FFSoundDevice, device, *devices) - { - switch (instance->config.soundType) - { - case FF_SOUND_TYPE_MAIN: if (!device->main) continue; break; - case FF_SOUND_TYPE_ACTIVE: if (!device->active) continue; break; - case FF_SOUND_TYPE_ALL: break; - } - - *(FFSoundDevice**)ffListAdd(&filtered) = device; - } - - if(filtered.length == 0) - { - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &instance->config.sound, "No active sound devices found"); - return; - } - - uint8_t index = 1; - FF_LIST_FOR_EACH(FFSoundDevice*, device, filtered) - printDevice(instance, *device, filtered.length == 1 ? 0 : index++); -} - -void ffPrintSound(FFinstance* instance) -{ - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFSoundDevice)); - const char* error = ffDetectSound(instance, &result); - - if(error) - { - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &instance->config.sound, "%s", error); - return; - } - - printSound(instance, &result); - - FF_LIST_FOR_EACH(FFSoundDevice, device, result) - { - ffStrbufDestroy(&device->identifier); - ffStrbufDestroy(&device->name); - } -} diff --git a/src/modules/sound/option.h b/src/modules/sound/option.h new file mode 100644 index 000000000..b0586036b --- /dev/null +++ b/src/modules/sound/option.h @@ -0,0 +1,20 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFSoundType +{ + FF_SOUND_TYPE_MAIN, + FF_SOUND_TYPE_ACTIVE, + FF_SOUND_TYPE_ALL, +} FFSoundType; + +typedef struct FFSoundOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFSoundType soundType; +} FFSoundOptions; diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c new file mode 100644 index 000000000..678c47b5d --- /dev/null +++ b/src/modules/sound/sound.c @@ -0,0 +1,154 @@ +#include "common/printing.h" +#include "detection/sound/sound.h" +#include "modules/sound/sound.h" + +#define FF_SOUND_NUM_FORMAT_ARGS 4 + +static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFSoundDevice* device, uint8_t index) +{ + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key); + ffStrbufWriteTo(&device->name, stdout); + + if(device->volume != FF_SOUND_VOLUME_UNKNOWN) + { + if(device->volume > 0) + printf(" (%d%%)", device->volume); + else + fputs(" (muted)", stdout); + } + + if(device->main && index > 0) + fputs(" (*)", stdout); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_BOOL, &device->main}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, + {FF_FORMAT_ARG_TYPE_UINT8, &device->volume}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} + }); + } +} + +void ffPrintSound(FFinstance* instance, FFSoundOptions* options) +{ + FF_LIST_AUTO_DESTROY result; + ffListInit(&result, sizeof(FFSoundDevice)); + const char* error = ffDetectSound(instance, &result); + + if(error) + { + ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + FF_LIST_AUTO_DESTROY filtered; + ffListInit(&filtered, sizeof(FFSoundDevice*)); + + FF_LIST_FOR_EACH(FFSoundDevice, device, result) + { + switch (options->soundType) + { + case FF_SOUND_TYPE_MAIN: if (!device->main) continue; break; + case FF_SOUND_TYPE_ACTIVE: if (!device->active) continue; break; + case FF_SOUND_TYPE_ALL: break; + } + + *(FFSoundDevice**)ffListAdd(&filtered) = device; + } + + if(filtered.length == 0) + { + ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found"); + return; + } + + uint8_t index = 1; + FF_LIST_FOR_EACH(FFSoundDevice*, device, filtered) + { + printDevice(instance, options, *device, filtered.length == 1 ? 0 : index++); + } + + FF_LIST_FOR_EACH(FFSoundDevice, device, result) + { + ffStrbufDestroy(&device->identifier); + ffStrbufDestroy(&device->name); + } +} + + +void ffInitSoundOptions(FFSoundOptions* options) +{ + options->moduleName = FF_SOUND_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + options->soundType = FF_SOUND_TYPE_MAIN; +} + +bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_SOUND_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "sound-type") == 0) + { + options->soundType = (FFSoundType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "main", FF_SOUND_TYPE_MAIN }, + { "active", FF_SOUND_TYPE_ACTIVE }, + { "all", FF_SOUND_TYPE_ALL }, + {}, + }); + return true; + } + + return false; +} + +void ffDestroySoundOptions(FFSoundOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseSoundJsonObject(FFinstance* instance, json_object* module) +{ + FFSoundOptions __attribute__((__cleanup__(ffDestroySoundOptions))) options; + ffInitSoundOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "soundType") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "main", FF_SOUND_TYPE_MAIN }, + { "active", FF_SOUND_TYPE_ACTIVE }, + { "all", FF_SOUND_TYPE_ALL }, + {}, + }); + if (error) + ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.soundType = (FFSoundType) value; + continue; + } + + ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintSound(instance, &options); +} +#endif diff --git a/src/modules/sound/sound.h b/src/modules/sound/sound.h new file mode 100644 index 000000000..fa9d8dc87 --- /dev/null +++ b/src/modules/sound/sound.h @@ -0,0 +1,16 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/title/option.h" + +#define FF_SOUND_MODULE_NAME "Sound" + +void ffPrintSound(FFinstance* instance, FFSoundOptions* options); +void ffInitSoundOptions(FFSoundOptions* options); +bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value); +void ffDestroySoundOptions(FFSoundOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseSoundJsonObject(FFinstance* instance, json_object* module); +#endif From c7119498a3c1c6137135a3f8f91fff4e4cb56516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Apr 2023 15:29:54 +0800 Subject: [PATCH 042/493] Global: major FFstrbuf related code refactor --- src/common/font.c | 2 +- src/common/format.c | 19 +--- src/common/init.c | 46 +++++----- src/common/io/io_unix.c | 9 +- src/common/io/io_windows.c | 8 +- src/common/library.c | 5 +- src/common/networking_windows.c | 3 +- src/common/printing.c | 17 +--- src/common/processing_windows.c | 3 +- src/common/properties.c | 18 +--- src/detection/battery/battery_android.c | 3 +- src/detection/battery/battery_linux.c | 23 ++--- src/detection/brightness/brightness_linux.c | 6 +- src/detection/cpu/cpu_bsd.c | 3 +- src/detection/cpu/cpu_linux.c | 24 ++--- src/detection/disk/disk_linux.c | 3 +- .../displayserver/displayserver_apple.c | 3 +- .../displayserver/displayserver_nosupport.c | 12 +-- .../displayserver/displayserver_windows.c | 3 +- .../displayserver/linux/displayserver_linux.c | 4 +- src/detection/displayserver/linux/wayland.c | 4 +- src/detection/displayserver/linux/wmde.c | 40 ++------- src/detection/gamepad/gamepad_linux.c | 3 +- src/detection/gpu/gpu_linux.c | 14 +-- src/detection/gtk_qt/gtk.c | 5 +- src/detection/gtk_qt/qt.c | 7 +- src/detection/host/host_android.c | 4 +- src/detection/host/host_linux.c | 4 +- src/detection/icons/icons_linux.c | 3 +- src/detection/media/media.c | 2 +- src/detection/media/media_linux.c | 5 +- src/detection/os/os_apple.m | 8 +- src/detection/packages/packages_apple.c | 6 +- src/detection/packages/packages_linux.c | 16 +--- src/detection/packages/packages_windows.c | 3 +- src/detection/temps/temps_linux.c | 8 +- src/detection/terminalfont/terminalfont.c | 55 +++--------- .../terminalfont/terminalfont_apple.m | 3 +- .../terminalfont/terminalfont_linux.c | 53 +++-------- .../terminalfont/terminalfont_windows.c | 22 ++--- .../terminalshell/terminalshell_linux.c | 5 +- src/detection/theme/theme_linux.c | 6 +- src/detection/wallpaper/wallpaper_apple.c | 3 +- src/detection/wifi/wifi_android.c | 3 +- src/detection/wifi/wifi_linux.c | 7 +- src/detection/wmtheme/wmtheme_linux.c | 8 +- src/detection/wmtheme/wmtheme_windows.c | 3 +- src/fastfetch.c | 5 +- src/logo/image/image.c | 28 ++---- src/logo/logo.c | 10 +-- src/modules/battery/battery.c | 4 +- src/modules/brightness/brightness.c | 3 +- src/modules/chassis.c | 5 +- src/modules/command/command.c | 3 +- src/modules/cpuusage/cpuusage.c | 3 +- src/modules/disk/disk.c | 15 ++-- src/modules/display/display.c | 3 +- src/modules/gpu/gpu.c | 3 +- src/modules/host/host.c | 5 +- src/modules/icons.c | 3 +- src/modules/jsonconfig/jsonconfig.c | 3 +- src/modules/locale/locale.c | 3 +- src/modules/localip/localip.c | 3 +- src/modules/media.c | 10 +-- src/modules/memory.c | 9 +- src/modules/os/os.c | 3 +- src/modules/player.c | 5 +- src/modules/publicip.c | 15 +--- src/modules/swap.c | 9 +- src/modules/users.c | 14 +-- src/modules/wallpaper.c | 3 +- src/modules/weather.c | 10 +-- src/modules/wmtheme.c | 4 +- src/util/FFstrbuf.c | 20 ----- src/util/FFstrbuf.h | 87 ++++++++++++++++++- tests/strbuf.c | 9 +- 76 files changed, 274 insertions(+), 537 deletions(-) diff --git a/src/common/font.c b/src/common/font.c index d789d466f..8d79907b8 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -7,7 +7,7 @@ static void fontInit(FFfont* font) { ffStrbufInit(&font->pretty); ffStrbufInit(&font->name); - ffStrbufInitA(&font->size, 4); + ffStrbufInitA(&font->size, 8); ffListInitA(&font->styles, sizeof(FFstrbuf), 4); } diff --git a/src/common/format.c b/src/common/format.c index 7394822f8..07f54f247 100644 --- a/src/common/format.c +++ b/src/common/format.c @@ -134,18 +134,14 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n continue; } - FFstrbuf placeholderValue; - ffStrbufInit(&placeholderValue); + FF_STRBUF_AUTO_DESTROY placeholderValue = ffStrbufCreate(); while(i < formatstr->length && formatstr->chars[i] != '}') ffStrbufAppendC(&placeholderValue, formatstr->chars[i++]); // test if for stop, if so break the loop if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-') - { - ffStrbufDestroy(&placeholderValue); break; - } // test for end of an if, if so do nothing if(placeholderValue.length == 1 && placeholderValue.chars[0] == '?') @@ -155,7 +151,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n else --numOpenIfs; - ffStrbufDestroy(&placeholderValue); continue; } @@ -167,7 +162,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n else --numOpenNotIfs; - ffStrbufDestroy(&placeholderValue); continue; } @@ -182,7 +176,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n --numOpenColors; } - ffStrbufDestroy(&placeholderValue); continue; } @@ -197,7 +190,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if(index > numArgs) { appendInvalidPlaceholder(buffer, "{?", &placeholderValue, i, formatstr->length); - ffStrbufDestroy(&placeholderValue); continue; } @@ -205,13 +197,11 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if(formatArgSet(&arguments[index - 1])) { ++numOpenIfs; - ffStrbufDestroy(&placeholderValue); continue; } // fastforward to the end of the if without printing the in between i = ffStrbufNextIndexS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" - 1 because the loop will increament it again directly after continue - ffStrbufDestroy(&placeholderValue); continue; } @@ -226,7 +216,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if(index > numArgs) { appendInvalidPlaceholder(buffer, "{/", &placeholderValue, i, formatstr->length); - ffStrbufDestroy(&placeholderValue); continue; } @@ -234,13 +223,11 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if(!formatArgSet(&arguments[index - 1])) { ++numOpenNotIfs; - ffStrbufDestroy(&placeholderValue); continue; } // fastforward to the end of the if without printing the in between i = ffStrbufNextIndexS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" - 1 because the loop will increament it again directly after continue - ffStrbufDestroy(&placeholderValue); continue; } @@ -252,7 +239,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n ffStrbufAppendS(buffer, "\033["); ffStrbufAppend(buffer, &placeholderValue); ffStrbufAppendC(buffer, 'm'); - ffStrbufDestroy(&placeholderValue); continue; } @@ -262,13 +248,10 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if(index > numArgs) { appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length); - ffStrbufDestroy(&placeholderValue); continue; } ffFormatAppendFormatArg(buffer, &arguments[index - 1]); - - ffStrbufDestroy(&placeholderValue); } ffStrbufTrimRight(buffer, ' '); diff --git a/src/common/init.c b/src/common/init.c index d805d0724..b6b8e6c61 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -107,28 +107,28 @@ static void defaultConfig(FFinstance* instance) ffInitSeparatorOptions(&instance->config.separator); ffInitGamepadOptions(&instance->config.gamepad); - ffStrbufInitA(&instance->config.libPCI, 0); - ffStrbufInitA(&instance->config.libVulkan, 0); - ffStrbufInitA(&instance->config.libWayland, 0); - ffStrbufInitA(&instance->config.libXcbRandr, 0); - ffStrbufInitA(&instance->config.libXcb, 0); - ffStrbufInitA(&instance->config.libXrandr, 0); - ffStrbufInitA(&instance->config.libX11, 0); - ffStrbufInitA(&instance->config.libGIO, 0); - ffStrbufInitA(&instance->config.libDConf, 0); - ffStrbufInitA(&instance->config.libDBus, 0); - ffStrbufInitA(&instance->config.libXFConf, 0); - ffStrbufInitA(&instance->config.libSQLite3, 0); - ffStrbufInitA(&instance->config.librpm, 0); - ffStrbufInitA(&instance->config.libImageMagick, 0); - ffStrbufInitA(&instance->config.libZ, 0); - ffStrbufInitA(&instance->config.libChafa, 0); - ffStrbufInitA(&instance->config.libEGL, 0); - ffStrbufInitA(&instance->config.libGLX, 0); - ffStrbufInitA(&instance->config.libOSMesa, 0); - ffStrbufInitA(&instance->config.libOpenCL, 0); - ffStrbufInitA(&instance->config.libJSONC, 0); - ffStrbufInitA(&instance->config.libfreetype, 0); + ffStrbufInit(&instance->config.libPCI); + ffStrbufInit(&instance->config.libVulkan); + ffStrbufInit(&instance->config.libWayland); + ffStrbufInit(&instance->config.libXcbRandr); + ffStrbufInit(&instance->config.libXcb); + ffStrbufInit(&instance->config.libXrandr); + ffStrbufInit(&instance->config.libX11); + ffStrbufInit(&instance->config.libGIO); + ffStrbufInit(&instance->config.libDConf); + ffStrbufInit(&instance->config.libDBus); + ffStrbufInit(&instance->config.libXFConf); + ffStrbufInit(&instance->config.libSQLite3); + ffStrbufInit(&instance->config.librpm); + ffStrbufInit(&instance->config.libImageMagick); + ffStrbufInit(&instance->config.libZ); + ffStrbufInit(&instance->config.libChafa); + ffStrbufInit(&instance->config.libEGL); + ffStrbufInit(&instance->config.libGLX); + ffStrbufInit(&instance->config.libOSMesa); + ffStrbufInit(&instance->config.libOpenCL); + ffStrbufInit(&instance->config.libJSONC); + ffStrbufInit(&instance->config.libfreetype); ffStrbufInit(&instance->config.libPulse); ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); @@ -142,7 +142,7 @@ static void defaultConfig(FFinstance* instance) instance->config.weatherTimeout = 0; ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)"); - ffStrbufInitA(&instance->config.playerName, 0); + ffStrbufInit(&instance->config.playerName); instance->config.percentType = 1; } diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 420e4374e..8d506b05e 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -8,8 +8,7 @@ static void createSubfolders(const char* fileName) { - FFstrbuf path; - ffStrbufInit(&path); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); while(*fileName != '\0') { @@ -18,8 +17,6 @@ static void createSubfolders(const char* fileName) mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH); ++fileName; } - - ffStrbufDestroy(&path); } bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) @@ -218,9 +215,7 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol void ffListFilesRecursively(const char* path) { - FFstrbuf folder; - ffStrbufInitS(&folder, path); + FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path); ffStrbufEnsureEndsWithC(&folder, '/'); listFilesRecursively(&folder, 0, NULL); - ffStrbufDestroy(&folder); } diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index 78cdad740..9a25a159a 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -2,9 +2,7 @@ static void createSubfolders(const char* fileName) { - FF_STRBUF_AUTO_DESTROY path; - ffStrbufInit(&path); - + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); while(*fileName != '\0') { ffStrbufAppendC(&path, *fileName); @@ -141,9 +139,7 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol void ffListFilesRecursively(const char* path) { - FFstrbuf folder; - ffStrbufInitS(&folder, path); + FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path); ffStrbufEnsureEndsWithC(&folder, '/'); listFilesRecursively(&folder, 0, NULL); - ffStrbufDestroy(&folder); } diff --git a/src/common/library.c b/src/common/library.c index e771b8d4d..7f858e966 100644 --- a/src/common/library.c +++ b/src/common/library.c @@ -32,8 +32,7 @@ static void* libraryLoad(const char* path, int maxVersion) if(result != NULL || maxVersion < 0) return result; - FFstrbuf pathbuf; - ffStrbufInitA(&pathbuf, 64); + FF_STRBUF_AUTO_DESTROY pathbuf = ffStrbufCreateA(64); ffStrbufAppendS(&pathbuf, path); ffStrbufAppendC(&pathbuf, '.'); @@ -49,8 +48,6 @@ static void* libraryLoad(const char* path, int maxVersion) ffStrbufSubstrBefore(&pathbuf, originalLength); } - ffStrbufDestroy(&pathbuf); - #endif return result; diff --git a/src/common/networking_windows.c b/src/common/networking_windows.c index 5814acc16..4cb0e1d1a 100644 --- a/src/common/networking_windows.c +++ b/src/common/networking_windows.c @@ -75,8 +75,7 @@ bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, con } } - FF_STRBUF_AUTO_DESTROY command; - ffStrbufInitA(&command, 64); + FF_STRBUF_AUTO_DESTROY command = ffStrbufCreateA(64); ffStrbufAppendS(&command, "GET "); ffStrbufAppendS(&command, path); ffStrbufAppendS(&command, " HTTP/1.1\nHost: "); diff --git a/src/common/printing.c b/src/common/printing.c index 95350e09e..7ea0ecb03 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -26,13 +26,11 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod } else { - FFstrbuf key; - ffStrbufInit(&key); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex} }); ffPrintUserString(key.chars); - ffStrbufDestroy(&key); } if(!instance->config.pipe) @@ -46,9 +44,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) { - FFstrbuf buffer; - ffStrbufInitA(&buffer, 256); - + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(256); ffParseFormatString(&buffer, format, numArgs, arguments); if(buffer.length > 0) @@ -57,8 +53,6 @@ void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t m ffPrintUserString(buffer.chars); putchar('\n'); } - - ffStrbufDestroy(&buffer); } void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) @@ -74,15 +68,10 @@ static void printError(FFinstance* instance, const char* moduleName, uint8_t mod if(hasCustomErrorFormat) { - FFstrbuf error; - ffStrbufInit(&error); - ffStrbufAppendVF(&error, message, arguments); - + FF_STRBUF_AUTO_DESTROY error = ffStrbufCreateVF(message, arguments); ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, 1, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &error} }); - - ffStrbufDestroy(&error); } else { diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index a2db719c1..580a29146 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -28,8 +28,7 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) BOOL success; { - FF_STRBUF_AUTO_DESTROY cmdline; - ffStrbufInitF(&cmdline, "\"%s\"", argv[0]); + FF_STRBUF_AUTO_DESTROY cmdline = ffStrbufCreateF("\"%s\"", argv[0]); for(char* const* parg = &argv[1]; *parg; ++parg) { ffStrbufAppendC(&cmdline, ' '); diff --git a/src/common/properties.c b/src/common/properties.c index 48b797599..6543d14a4 100644 --- a/src/common/properties.c +++ b/src/common/properties.c @@ -146,25 +146,15 @@ done: bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries) { - FFstrbuf absolutePath; - ffStrbufInitA(&absolutePath, 64); - ffStrbufAppend(&absolutePath, &instance->state.platform.homeDir); - ffStrbufAppendC(&absolutePath, '/'); - ffStrbufAppendS(&absolutePath, relativeFile); - - bool result = ffParsePropFileValues(absolutePath.chars, numQueries, queries); - - ffStrbufDestroy(&absolutePath); - - return result; + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateF("%s/%s", instance->state.platform.homeDir.chars, relativeFile); + return ffParsePropFileValues(absolutePath.chars, numQueries, queries); } bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uint32_t numQueries, FFpropquery* queries) { bool foundAFile = false; - FFstrbuf baseDir; - ffStrbufInitA(&baseDir, 64); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); FF_LIST_FOR_EACH(FFstrbuf, dirPrefix, *list) { @@ -189,7 +179,5 @@ bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uin break; } - ffStrbufDestroy(&baseDir); - return foundAFile; } diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index 1bcb48db7..0b90494fc 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -9,8 +9,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { - FF_STRBUF_AUTO_DESTROY buffer; - ffStrbufInit(&buffer); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if(ffProcessAppendStdOut(&buffer, (char* const[]){ FF_TERMUX_API_PATH, diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 7ae4a3639..11da6f4e9 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -8,8 +8,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) { uint32_t dirLength = dir->length; - FFstrbuf testBatteryBuffer; - ffStrbufInit(&testBatteryBuffer); + FF_STRBUF_AUTO_DESTROY testBatteryBuffer = ffStrbufCreate(); //type must exist and be "Battery" ffStrbufAppendS(dir, "/type"); @@ -17,10 +16,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) ffStrbufSubstrBefore(dir, dirLength); if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Battery") != 0) - { - ffStrbufDestroy(&testBatteryBuffer); return; - } //scope may not exist or must not be "Device" ffStrbufAppendS(dir, "/scope"); @@ -28,10 +24,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) ffStrbufSubstrBefore(dir, dirLength); if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0) - { - ffStrbufDestroy(&testBatteryBuffer); return; - } BatteryResult* result = ffListAdd(results); @@ -41,7 +34,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) ffStrbufSubstrBefore(dir, dirLength); if(available) result->capacity = ffStrbufToDouble(&testBatteryBuffer); - ffStrbufDestroy(&testBatteryBuffer); + if(!available) { result->capacity = 0.0/0.0; @@ -76,8 +69,8 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { - FFstrbuf baseDir; - ffStrbufInitA(&baseDir, 64); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); + if(instance->config.battery.dir.length > 0) { ffStrbufAppend(&baseDir, &instance->config.battery.dir); @@ -92,10 +85,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) DIR* dirp = opendir(baseDir.chars); if(dirp == NULL) - { - ffStrbufDestroy(&baseDir); return "opendir(batteryDir) == NULL"; - } struct dirent* entry; while((entry = readdir(dirp)) != NULL) @@ -110,11 +100,8 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) closedir(dirp); - if(results->length == 0) { - ffStrbufDestroy(&baseDir); + if(results->length == 0) return "batteryDir doesn't contain any battery folder"; - } - ffStrbufDestroy(&baseDir); return NULL; } diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 3222faeae..9c00f70e9 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -13,14 +13,12 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) if(dirp == NULL) return "Failed to open `/sys/class/backlight/`"; - FF_STRBUF_AUTO_DESTROY backlightDir; - ffStrbufInitA(&backlightDir, 64); + FF_STRBUF_AUTO_DESTROY backlightDir = ffStrbufCreateA(64); ffStrbufAppendS(&backlightDir, backlightDirPath); uint32_t backlightDirLength = backlightDir.length; - FF_STRBUF_AUTO_DESTROY buffer; - ffStrbufInit(&buffer); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); struct dirent* entry; while((entry = readdir(dirp)) != NULL) diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 9f1e018d3..c3c88e440 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -7,8 +7,7 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) if (instance->config.cpu.temp) { - FF_STRBUF_AUTO_DESTROY cpuTemp; - ffStrbufInit(&cpuTemp); + FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate(); if(ffSysctlGetString("temperature", &cpuTemp)) cpu->temperature = FF_CPU_TEMP_UNSET; else diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index d46221333..bc14e2f18 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -41,12 +41,10 @@ static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrb static double getGHz(const char* file) { - FFstrbuf content; - ffStrbufInit(&content); + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); if(ffAppendFileBuffer(file, &content)) { double herz = ffStrbufToDouble(&content); - ffStrbufDestroy(&content); //ffStrbufToDouble failed if(herz != herz) @@ -111,17 +109,10 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) else cpu->temperature = FF_CPU_TEMP_UNSET; - FFstrbuf physicalCoresBuffer; - ffStrbufInit(&physicalCoresBuffer); - - FFstrbuf cpuMHz; - ffStrbufInit(&cpuMHz); - - FFstrbuf cpuIsa; - ffStrbufInit(&cpuIsa); - - FFstrbuf cpuUarch; - ffStrbufInit(&cpuUarch); + FF_STRBUF_AUTO_DESTROY physicalCoresBuffer = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY cpuIsa = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY cpuUarch = ffStrbufCreate(); parseCpuInfo(cpu, &physicalCoresBuffer, &cpuMHz, &cpuIsa, &cpuUarch); @@ -155,9 +146,4 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) ffStrbufAppendC(&cpu->name, ' '); ffStrbufAppend(&cpu->name, &cpuIsa); } - - ffStrbufDestroy(&physicalCoresBuffer); - ffStrbufDestroy(&cpuMHz); - ffStrbufDestroy(&cpuIsa); - ffStrbufDestroy(&cpuUarch); } diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 6f4eab2bc..2be87af66 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -112,8 +112,7 @@ static void detectName(FFDisk* disk, const FFstrbuf* device) if(stat(device->chars, &deviceStat) != 0) return; - FF_STRBUF_AUTO_DESTROY basePath; - ffStrbufInit(&basePath); + FF_STRBUF_AUTO_DESTROY basePath = ffStrbufCreate(); //Try partlabel first ffStrbufSetS(&basePath, "/dev/disk/by-partlabel/"); diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 05c017a49..e2ae57c5d 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -40,8 +40,7 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) } } - FF_STRBUF_AUTO_DESTROY name; - ffStrbufInit(&name); + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); if(detectName && CoreDisplay_DisplayCreateInfoDictionary) { CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); diff --git a/src/detection/displayserver/displayserver_nosupport.c b/src/detection/displayserver/displayserver_nosupport.c index 359ebc634..bef1e4554 100644 --- a/src/detection/displayserver/displayserver_nosupport.c +++ b/src/detection/displayserver/displayserver_nosupport.c @@ -4,11 +4,11 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins { 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); + ffStrbufInit(&ds->wmProcessName); + ffStrbufInit(&ds->wmPrettyName); + ffStrbufInit(&ds->wmProtocolName); + ffStrbufInit(&ds->deProcessName); + ffStrbufInit(&ds->dePrettyName); + ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 1ee86ef5d..9b7bec99b 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -42,8 +42,7 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) DeleteDC(hdc); } - FF_STRBUF_AUTO_DESTROY name; - ffStrbufInit(&name); + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); if (detectName) { diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 257c60cc1..4d50184f4 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -10,8 +10,7 @@ static void parseDRM(FFDisplayServerResult* result) if(dirp == NULL) return; - FFstrbuf drmDir; - ffStrbufInitA(&drmDir, 64); + FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64); ffStrbufAppendS(&drmDir, drmDirPath); uint32_t drmDirLength = drmDir.length; @@ -48,7 +47,6 @@ static void parseDRM(FFDisplayServerResult* result) } closedir(dirp); - ffStrbufDestroy(&drmDir); } void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index d65fa70a5..b4e31f77e 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -42,13 +42,11 @@ static void waylandDetectWM(int fd, FFDisplayServerResult* result) if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) return; - FFstrbuf procPath; - ffStrbufInit(&procPath); + FF_STRBUF_AUTO_DESTROY procPath = ffStrbufCreate(); ffStrbufAppendF(&procPath, "/proc/%d/cmdline", ucred.pid); //We check the cmdline for the process name, because it is not trimmed. ffReadFileBuffer(procPath.chars, &result->wmProcessName); ffStrbufSubstrBeforeFirstC(&result->wmProcessName, '\0'); //Trim the arguments ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path - ffStrbufDestroy(&procPath); } #else static void waylandDetectWM(int fd, FFDisplayServerResult* result) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index db309b92a..a9e580cbe 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -165,14 +165,9 @@ static void getMate(const FFinstance* instance, FFDisplayServerResult* result) ffStrbufSetS(&result->deProcessName, "mate-session"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_MATE); - FFstrbuf major; - ffStrbufInit(&major); - - FFstrbuf minor; - ffStrbufInit(&minor); - - FFstrbuf micro; - ffStrbufInit(µ); + FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate(); ffParsePropFileDataValues(instance, "mate-about/mate-version.xml", 3, (FFpropquery[]) { {"", &major}, @@ -182,10 +177,6 @@ static void getMate(const FFinstance* instance, FFDisplayServerResult* result) ffParseSemver(&result->deVersion, &major, &minor, µ); - ffStrbufDestroy(&major); - ffStrbufDestroy(&minor); - ffStrbufDestroy(µ); - if(result->deVersion.length == 0 && instance->config.allowSlowOperations) { ffProcessAppendStdOut(&result->deVersion, (char* const[]){ @@ -244,13 +235,10 @@ static void getLXQt(const FFinstance* instance, FFDisplayServerResult* result) ffParsePropLines(result->deVersion.chars , "liblxqt", &result->deVersion); } - FFstrbuf wmProcessNameBuffer; - ffStrbufInit(&wmProcessNameBuffer); + FF_STRBUF_AUTO_DESTROY wmProcessNameBuffer = ffStrbufCreate(); ffParsePropFileConfig(instance, "lxqt/session.conf", "window_manager =", &wmProcessNameBuffer); applyBetterWM(result, wmProcessNameBuffer.chars); - - ffStrbufDestroy(&wmProcessNameBuffer); } static void getBudgie(const FFinstance* instance, FFDisplayServerResult* result) @@ -351,21 +339,14 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re if(proc == NULL) return; - FFstrbuf procPath; - ffStrbufInitA(&procPath, 64); + FF_STRBUF_AUTO_DESTROY procPath = ffStrbufCreateA(64); ffStrbufAppendS(&procPath, "/proc/"); uint32_t procPathLength = procPath.length; - FFstrbuf userID; - ffStrbufInit(&userID); - ffStrbufAppendF(&userID, "%i", getuid()); - - FFstrbuf loginuid; - ffStrbufInit(&loginuid); - - FFstrbuf processName; - ffStrbufInitA(&processName, 256); //Some processes have large command lines (looking at you chrome) + FF_STRBUF_AUTO_DESTROY userID = ffStrbufCreateF("%i", getuid()); + FF_STRBUF_AUTO_DESTROY loginuid = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY processName = ffStrbufCreateA(256); //Some processes have large command lines (looking at you chrome) struct dirent* dirent; while((dirent = readdir(proc)) != NULL) @@ -407,11 +388,6 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re } closedir(proc); - - ffStrbufDestroy(&processName); - ffStrbufDestroy(&loginuid); - ffStrbufDestroy(&userID); - ffStrbufDestroy(&procPath); } void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result) diff --git a/src/detection/gamepad/gamepad_linux.c b/src/detection/gamepad/gamepad_linux.c index ce61a5711..3da034044 100644 --- a/src/detection/gamepad/gamepad_linux.c +++ b/src/detection/gamepad/gamepad_linux.c @@ -10,8 +10,7 @@ const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* if(dirp == NULL) return "opendir(\"/sys/class/input/\") == NULL"; - FF_STRBUF_AUTO_DESTROY path; - ffStrbufInitS(&path, "/sys/class/input/"); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/class/input/"); uint32_t baseLen = path.length; struct dirent* entry; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index d5a081fdd..411bfd45b 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -64,14 +64,9 @@ static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PC #endif } - FFstrbuf query; - ffStrbufInit(&query); - ffStrbufAppendF(&query, "%X, %X,", device->device_id, revId); - + FF_STRBUF_AUTO_DESTROY query = ffStrbufCreateF("%X, %X,", device->device_id, revId); ffParsePropFileData(instance, "libdrm/amdgpu.ids", query.chars, &gpu->name); - ffStrbufDestroy(&query); - const char* removeStrings[] = { "AMD ", "ATI ", " (TM)", "(TM)", @@ -116,10 +111,7 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* if(!ffStrSet(base)) return; - FFstrbuf path; - ffStrbufInitA(&path, 64); - ffStrbufAppendF(&path, "%s/devices/%04x:%02x:%02x.%d/driver", base, device->domain, device->bus, device->dev, device->func); - + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateF("%s/devices/%04x:%02x:%02x.%d/driver", base, device->domain, device->bus, device->dev, device->func); ffStrbufEnsureFree(&gpu->driver, 1023); ssize_t resultLength = readlink(path.chars, gpu->driver.chars, gpu->driver.allocated - 1); //-1 for null terminator if(resultLength > 0) @@ -128,8 +120,6 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* gpu->driver.chars[resultLength] = '\0'; ffStrbufSubstrAfterLastC(&gpu->driver, '/'); } - - ffStrbufDestroy(&path); } static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device) diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index e61c951aa..abd5a857e 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -162,8 +162,7 @@ static void detectGTK(const FFinstance* instance, const char* version, FFGTKResu return; //We need to do this because we use multiple threads on configDirs - FFstrbuf baseDir; - ffStrbufInitA(&baseDir, 64); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); FF_LIST_FOR_EACH(FFstrbuf, configDir, instance->state.platform.configDirs) { @@ -172,8 +171,6 @@ static void detectGTK(const FFinstance* instance, const char* version, FFGTKResu if(allPropertiesSet(result)) break; } - - ffStrbufDestroy(&baseDir); } #define FF_DETECT_GTK_IMPL(version) \ diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 74b54a1df..ebf36fbb9 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -85,8 +85,7 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) bool foundAFile = false; //We need to do this because we use multiple threads on configDirs - FFstrbuf baseDir; - ffStrbufInitA(&baseDir, 64); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); FF_LIST_FOR_EACH(FFstrbuf, configDir, instance->state.platform.configDirs) { @@ -97,13 +96,9 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) foundAFile = true; if(allValuesSet(result)) - { - ffStrbufDestroy(&baseDir); return; - } } - ffStrbufDestroy(&baseDir); if(!foundAFile) return; diff --git a/src/detection/host/host_android.c b/src/detection/host/host_android.c index edeb9cb47..240a65b9d 100644 --- a/src/detection/host/host_android.c +++ b/src/detection/host/host_android.c @@ -32,6 +32,6 @@ void ffDetectHostImpl(FFHostResult* host) //Not implemented - ffStrbufInitA(&host->productVersion, 0); - ffStrbufInitA(&host->productSku, 0); + ffStrbufInit(&host->productVersion); + ffStrbufInit(&host->productSku); } diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 04ae3aa27..766b4f47a 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -89,8 +89,7 @@ void ffDetectHostImpl(FFHostResult* host) { ffStrbufAppendS(&host->productName, "Windows Subsystem for Linux"); - FFstrbuf wslVer; //Wide charactors - ffStrbufInit(&wslVer); + FF_STRBUF_AUTO_DESTROY wslVer = ffStrbufCreate(); //Wide charactors if(!ffProcessAppendStdOut(&wslVer, (char* const[]){ "wsl.exe", "--version", @@ -106,7 +105,6 @@ void ffDetectHostImpl(FFHostResult* host) } ffStrbufAppendC(&host->productName, ')'); } - ffStrbufDestroy(&wslVer); } } } diff --git a/src/detection/icons/icons_linux.c b/src/detection/icons/icons_linux.c index 4ab35b542..5246950db 100644 --- a/src/detection/icons/icons_linux.c +++ b/src/detection/icons/icons_linux.c @@ -18,8 +18,7 @@ const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result) if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) return "No icons could be found"; - FF_STRBUF_AUTO_DESTROY gtkPretty; - ffStrbufInit(>kPretty); + FF_STRBUF_AUTO_DESTROY gtkPretty = ffStrbufCreate(); ffParseGTK(>kPretty, gtk2, gtk3, gtk4); if(plasma->length > 0) diff --git a/src/detection/media/media.c b/src/detection/media/media.c index 5c9d2145f..7bb38d0e5 100644 --- a/src/detection/media/media.c +++ b/src/detection/media/media.c @@ -6,7 +6,7 @@ void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media); const FFMediaResult* ffDetectMedia(const FFinstance* instance) { FF_DETECTION_INTERNAL_GUARD(FFMediaResult, - ffStrbufInitA(&result.error, 0); + ffStrbufInit(&result.error); ffStrbufInit(&result.playerId); ffStrbufInit(&result.player); ffStrbufInit(&result.song); diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index d470641f7..f4e8c9ea2 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -107,12 +107,9 @@ static void getCustomBus(FFDBusData* data, const FFinstance* instance, FFMediaRe return; } - FFstrbuf busName; - ffStrbufInit(&busName); - ffStrbufAppendS(&busName, FF_DBUS_MPRIS_PREFIX); + FF_STRBUF_AUTO_DESTROY busName = ffStrbufCreateS(FF_DBUS_MPRIS_PREFIX); ffStrbufAppend(&busName, &instance->config.playerName); getBusProperties(data, busName.chars, result); - ffStrbufDestroy(&busName); } static void getBestBus(FFDBusData* data, FFMediaResult* result) diff --git a/src/detection/os/os_apple.m b/src/detection/os/os_apple.m index 49a387d42..0b537d718 100644 --- a/src/detection/os/os_apple.m +++ b/src/detection/os/os_apple.m @@ -107,10 +107,10 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) ffStrbufInit(&os->prettyName); ffStrbufInit(&os->versionID); - ffStrbufInitA(&os->codename, 0); - ffStrbufInitA(&os->idLike, 0); - ffStrbufInitA(&os->variant, 0); - ffStrbufInitA(&os->variantID, 0); + ffStrbufInit(&os->codename); + ffStrbufInit(&os->idLike); + ffStrbufInit(&os->variant); + ffStrbufInit(&os->variantID); parseSystemVersion(os); diff --git a/src/detection/packages/packages_apple.c b/src/detection/packages/packages_apple.c index eaaf5f2fa..0f7ab36e0 100644 --- a/src/detection/packages/packages_apple.c +++ b/src/detection/packages/packages_apple.c @@ -28,8 +28,7 @@ static uint32_t getNumElements(const char* dirname, unsigned char type) static void countBrewPackages(const char* dirname, FFPackagesResult* result) { - FF_STRBUF_AUTO_DESTROY baseDir; - ffStrbufInitS(&baseDir, dirname); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateS(dirname); uint32_t baseDirLength = baseDir.length; @@ -54,8 +53,7 @@ static void getBrewPackages(FFPackagesResult* result) static uint32_t countMacPortsPackages(const char* dirname) { - FF_STRBUF_AUTO_DESTROY baseDir; - ffStrbufInitS(&baseDir, dirname); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateS(dirname); ffStrbufAppendS(&baseDir, "/var/macports/software"); return getNumElements(baseDir.chars, DT_DIR); diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index b0b47f37c..4a9c483a0 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -132,12 +132,10 @@ static uint32_t getNixPackagesImpl(char* path) if(!ffPathExists(path, FF_PATHTYPE_DIRECTORY)) return 0; - FFstrbuf output; - ffStrbufInitA(&output, 128); + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(128); //https://github.com/LinusDierheimer/fastfetch/issues/195#issuecomment-1191748222 - FFstrbuf command; - ffStrbufInitA(&command, 255); + FF_STRBUF_AUTO_DESTROY command = ffStrbufCreateA(255); ffStrbufAppendS(&command, "for x in $(nix-store --query --requisites "); ffStrbufAppendS(&command, path); ffStrbufAppendS(&command, "); do if [ -d $x ]; then echo $x ; fi ; done | cut -d- -f2- | egrep '([0-9]{1,}\\.)+[0-9]{1,}' | egrep -v '\\-doc$|\\-man$|\\-info$|\\-dev$|\\-bin$|^nixos-system-nixos-' | uniq | wc -l"); @@ -149,12 +147,7 @@ static uint32_t getNixPackagesImpl(char* path) NULL }); - int result = (int) strtol(output.chars, NULL, 10); - - ffStrbufDestroy(&command); - ffStrbufDestroy(&output); - - return (uint32_t) result; + return (uint32_t) strtol(output.chars, NULL, 10); } static uint32_t getNixPackages(FFstrbuf* baseDir, const char* dirname) @@ -329,8 +322,7 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result) { - FF_STRBUF_AUTO_DESTROY baseDir; - ffStrbufInitA(&baseDir, 512); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(512); ffStrbufAppendS(&baseDir, FASTFETCH_TARGET_DIR_ROOT); if(ffStrbufIgnCaseEqualS(&ffDetectOS(instance)->id, "bedrock")) diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index 086a10ea1..30870ce5d 100644 --- a/src/detection/packages/packages_windows.c +++ b/src/detection/packages/packages_windows.c @@ -34,8 +34,7 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix * static void detectScoop(const FFinstance* instance, FFPackagesResult* result) { - FF_STRBUF_AUTO_DESTROY scoopPath; - ffStrbufInitA(&scoopPath, MAX_PATH + 3); + FF_STRBUF_AUTO_DESTROY scoopPath = ffStrbufCreateA(MAX_PATH + 3); const char* scoopEnv = getenv("SCOOP"); if(ffStrSet(scoopEnv)) diff --git a/src/detection/temps/temps_linux.c b/src/detection/temps/temps_linux.c index 0ade8180f..55506c384 100644 --- a/src/detection/temps/temps_linux.c +++ b/src/detection/temps/temps_linux.c @@ -11,8 +11,7 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value) //https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface uint32_t dirLength = dir->length; - FF_STRBUF_AUTO_DESTROY valueBuffer; - ffStrbufInit(&valueBuffer); + FF_STRBUF_AUTO_DESTROY valueBuffer = ffStrbufCreate(); ffStrbufAppendS(dir, "temp1_input"); if(!ffReadFileBuffer(dir->chars, &valueBuffer)) @@ -58,8 +57,7 @@ const FFTempsResult* ffDetectTemps() ffListInitA(&result.values, sizeof(FFTempValue), 16); - FFstrbuf baseDir; - ffStrbufInitA(&baseDir, 64); + FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); ffStrbufAppendS(&baseDir, "/sys/class/hwmon/"); uint32_t baseDirLength = baseDir.length; @@ -67,7 +65,6 @@ const FFTempsResult* ffDetectTemps() DIR* dirp = opendir(baseDir.chars); if(dirp == NULL) { - ffStrbufDestroy(&baseDir); ffThreadMutexUnlock(&mutex); return &result; } @@ -94,7 +91,6 @@ const FFTempsResult* ffDetectTemps() } closedir(dirp); - ffStrbufDestroy(&baseDir); ffThreadMutexUnlock(&mutex); return &result; diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index dbb10a8b0..cd0764247 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -6,11 +6,8 @@ static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FFstrbuf fontName; - ffStrbufInit(&fontName); - - FFstrbuf fontSize; - ffStrbufInit(&fontSize); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); FFpropquery fontQuery[] = { {"family:", &fontName}, @@ -33,15 +30,11 @@ static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* te ffStrbufAppendS(&fontSize, "11"); ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); - - ffStrbufDestroy(&fontName); - ffStrbufDestroy(&fontSize); } FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { - FFstrbuf fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFile(FASTFETCH_TARGET_DIR_ETC"/vconsole.conf", "Font =", &fontName); @@ -61,8 +54,6 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) ffFontInitCopy(&terminalFont->font, fontName.chars); else ffStrbufAppendS(&terminalFont->error, "Couldn't find Font in "FASTFETCH_TARGET_DIR_ETC"/vconsole.conf"); - - ffStrbufDestroy(&fontName); } #if defined(_WIN32) || defined(__linux__) @@ -113,8 +104,7 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten if (!profiles) return "json_object_object_get(root, \"profiles\") failed"; - FF_STRBUF_AUTO_DESTROY wtProfileId; - ffStrbufInitS(&wtProfileId, getenv("WT_PROFILE_ID")); + FF_STRBUF_AUTO_DESTROY wtProfileId = ffStrbufCreateS(getenv("WT_PROFILE_ID")); ffStrbufTrim(&wtProfileId, '\''); if (wtProfileId.length > 0) { @@ -158,8 +148,7 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) { //https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file - FFstrbuf json; - ffStrbufInit(&json); + FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate(); const char* error = NULL; #ifdef _WIN32 @@ -219,22 +208,18 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu if(error) { ffStrbufAppendS(&terminalFont->error, error); - ffStrbufDestroy(&json); return; } ffStrbufTrimRight(&json, '\n'); if(json.length == 0) { ffStrbufAppendS(&terminalFont->error, "Cannot find file \"settings.json\""); - ffStrbufDestroy(&json); return; } - FFstrbuf name; - ffStrbufInit(&name); + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); double size = -1; error = detectFromWTImpl(instance, &json, &name, &size); - ffStrbufDestroy(&json); if(error) ffStrbufAppendS(&terminalFont->error, error); @@ -244,8 +229,6 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu snprintf(sizeStr, sizeof(sizeStr), "%g", size); ffFontInitValues(&terminalFont->font, name.chars, sizeStr); } - - ffStrbufDestroy(&name); } #else //FF_HAVE_JSONC @@ -262,11 +245,8 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result) { - FF_STRBUF_AUTO_DESTROY fontName; - ffStrbufInit(&fontName); - - FF_STRBUF_AUTO_DESTROY fontSize; - ffStrbufInit(&fontSize); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); FFpropquery fontQuery[] = { {"font_family ", &fontName}, @@ -288,11 +268,8 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFo static void detectTerminator(const FFinstance* instance, FFTerminalFontResult* result) { - FF_STRBUF_AUTO_DESTROY useSystemFont; - ffStrbufInit(&useSystemFont); - - FF_STRBUF_AUTO_DESTROY fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FFpropquery fontQuery[] = { {"use_system_font =", &useSystemFont}, @@ -319,8 +296,7 @@ static void detectTerminator(const FFinstance* instance, FFTerminalFontResult* r static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result) { - FF_STRBUF_AUTO_DESTROY fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ "wezterm", @@ -347,11 +323,8 @@ static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminal static bool detectTabby(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result) { - FF_STRBUF_AUTO_DESTROY fontName; - ffStrbufInit(&fontName); - - FF_STRBUF_AUTO_DESTROY fontSize; - ffStrbufInit(&fontSize); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); FFpropquery fontQuery[] = { {"font: ", &fontName}, @@ -409,7 +382,7 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina const FFTerminalFontResult* ffDetectTerminalFont(const FFinstance* instance) { FF_DETECTION_INTERNAL_GUARD(FFTerminalFontResult, - ffStrbufInitA(&result.error, 0); + ffStrbufInit(&result.error); const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance); diff --git a/src/detection/terminalfont/terminalfont_apple.m b/src/detection/terminalfont/terminalfont_apple.m index 2dd3d03b7..f95503585 100644 --- a/src/detection/terminalfont/terminalfont_apple.m +++ b/src/detection/terminalfont/terminalfont_apple.m @@ -46,8 +46,7 @@ static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* termi static void detectAppleTerminal(FFTerminalFontResult* terminalFont) { - FF_STRBUF_AUTO_DESTROY font; - ffStrbufInit(&font); + FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate(); ffOsascript("tell application \"Terminal\" to font name of window frontmost & \" \" & font size of window frontmost", &font); if(font.length == 0) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 9742a6daa..68f096523 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -35,8 +35,7 @@ static void detectFromGSettings(const FFinstance* instance, char* profilePath, c return; } - FFstrbuf path; - ffStrbufInitA(&path, 128); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateA(128); ffStrbufAppendS(&path, profilePath); ffStrbufAppendS(&path, defaultProfile); ffStrbufAppendC(&path, '/'); @@ -57,64 +56,47 @@ static void detectFromGSettings(const FFinstance* instance, char* profilePath, c else ffStrbufAppendS(&terminalFont->error, "Could't get system monospace font name from GSettings / DConf"); } - - ffStrbufDestroy(&path); } static void detectFromConfigFile(const FFinstance* instance, const char* configFile, const char* start, FFTerminalFontResult* terminalFont) { - FFstrbuf fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFileConfig(instance, configFile, start, &fontName); if(fontName.length == 0) ffStrbufAppendF(&terminalFont->error, "Couldn't find %s in .config/%s", start, configFile); else ffFontInitPango(&terminalFont->font, fontName.chars); - - ffStrbufDestroy(&fontName); } static void detectKonsole(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FFstrbuf profile; - ffStrbufInit(&profile); + FF_STRBUF_AUTO_DESTROY profile = ffStrbufCreate(); ffParsePropFileConfig(instance, "konsolerc", "DefaultProfile =", &profile); if(profile.length == 0) { ffStrbufAppendS(&terminalFont->error, "Couldn't find \"DefaultProfile=%[^\\n]\" in \".config/konsolerc\""); - ffStrbufDestroy(&profile); return; } - FFstrbuf profilePath; - ffStrbufInitA(&profilePath, 32); + FF_STRBUF_AUTO_DESTROY profilePath = ffStrbufCreateA(32); ffStrbufAppendS(&profilePath, "konsole/"); ffStrbufAppend(&profilePath, &profile); - ffStrbufDestroy(&profile); - - FFstrbuf fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFileData(instance, profilePath.chars, "Font =", &fontName); if(fontName.length == 0) ffStrbufAppendF(&terminalFont->error, "Couldn't find \"Font=%%[^\\n]\" in \"%s\"", profilePath.chars); else ffFontInitQt(&terminalFont->font, fontName.chars); - - ffStrbufDestroy(&fontName); - ffStrbufDestroy(&profilePath); } static void detectXFCETerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FFstrbuf useSysFont; - ffStrbufInit(&useSysFont); - - FFstrbuf fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY useSysFont = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFileConfigValues(instance, "xfce4/terminal/terminalrc", 2, (FFpropquery[]) { {"FontUseSystem = ", &useSysFont}, @@ -136,21 +118,14 @@ static void detectXFCETerminal(const FFinstance* instance, FFTerminalFontResult* else ffStrbufAppendS(&terminalFont->error, "Couldn't find xsettings::/Gtk/MonospaceFontName in XFConf"); } - - ffStrbufDestroy(&fontName); - ffStrbufDestroy(&useSysFont); } static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FFstrbuf fontName; - ffStrbufInit(&fontName); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY profile = ffStrbufCreate(); - FFstrbuf fontSize; - ffStrbufInit(&fontSize); - - FFstrbuf profile; - ffStrbufInit(&profile); ffStrbufAppend(&profile, &instance->state.platform.homeDir); ffStrbufAppendS(&profile, ".config/deepin/deepin-terminal/config.conf"); //TODO: Use config dirs FILE* file = fopen(profile.chars, "r"); @@ -180,23 +155,17 @@ static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResul fclose(file); } - ffStrbufDestroy(&profile); - if(fontName.length == 0) ffStrbufAppendS(&fontName, "Noto Sans Mono"); if(fontSize.length == 0) ffStrbufAppendS(&fontSize, "11"); ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); - - ffStrbufDestroy(&fontName); - ffStrbufDestroy(&fontSize); } static void detectFootTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FF_STRBUF_AUTO_DESTROY font; - ffStrbufInit(&font); + FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate(); if (!ffParsePropFileConfig(instance, "foot/foot.ini", "font=", &font) || !ffStrSet(font.chars)) { diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index da2f0568b..3a10e1bd6 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -8,11 +8,8 @@ static void detectMintty(const FFinstance* instance, FFTerminalFontResult* terminalFont) { - FF_STRBUF_AUTO_DESTROY fontName; - ffStrbufInit(&fontName); - - FF_STRBUF_AUTO_DESTROY fontSize; - ffStrbufInit(&fontSize); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); if(!ffParsePropFileConfigValues(instance, "mintty/config", 2, (FFpropquery[]) { {"Font=", &fontName}, @@ -54,14 +51,9 @@ static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* termi FF_UNUSED(instance) //https://conemu.github.io/en/ConEmuXml.html#search-sequence - FFstrbuf path; - ffStrbufInit(&path); - - FFstrbuf fontName; - ffStrbufInit(&fontName); - - FFstrbuf fontSize; - ffStrbufInit(&fontSize); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); const char* paths[] = { "ConEmuDir", "ConEmuBaseDir", "APPDATA" }; for (uint32_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) @@ -77,7 +69,6 @@ static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* termi break; } } - ffStrbufDestroy(&path); if(fontName.length == 0 && fontSize.length == 0) { @@ -96,9 +87,6 @@ static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* termi ffStrbufAppendS(&fontSize, "14"); ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); - - ffStrbufDestroy(&fontName); - ffStrbufDestroy(&fontSize); } void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 6fb5cc008..45bf0091e 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -281,8 +281,7 @@ static void getUserShellFromEnv(const FFinstance* instance, FFTerminalShellResul static void getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* version) { - FFstrbuf command; - ffStrbufInit(&command); + FF_STRBUF_AUTO_DESTROY command = ffStrbufCreate(); ffStrbufAppendS(&command, "printf \"%s\" \"$"); ffStrbufAppendTransformS(&command, exeName, toupper); ffStrbufAppendS(&command, "_VERSION\""); @@ -297,8 +296,6 @@ static void getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* }); ffStrbufSubstrBeforeFirstC(version, '('); ffStrbufRemoveStrings(version, 2, "-release", "release"); - - ffStrbufDestroy(&command); } bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); diff --git a/src/detection/theme/theme_linux.c b/src/detection/theme/theme_linux.c index bcacf89ea..d59c6d2de 100644 --- a/src/detection/theme/theme_linux.c +++ b/src/detection/theme/theme_linux.c @@ -18,8 +18,7 @@ const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result) if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) return "No themes found"; - FF_STRBUF_AUTO_DESTROY plasmaColorPretty; - ffStrbufInit(&plasmaColorPretty); + FF_STRBUF_AUTO_DESTROY plasmaColorPretty = ffStrbufCreate(); if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle)) ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]); else @@ -27,8 +26,7 @@ const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result) ffStrbufTrim(&plasmaColorPretty, ' '); - FF_STRBUF_AUTO_DESTROY gtkPretty; - ffStrbufInit(>kPretty); + FF_STRBUF_AUTO_DESTROY gtkPretty = ffStrbufCreate(); ffParseGTK(>kPretty, gtk2, gtk3, gtk4); if(plasma->widgetStyle.length > 0) diff --git a/src/detection/wallpaper/wallpaper_apple.c b/src/detection/wallpaper/wallpaper_apple.c index f1235ba1e..7d2fb84dc 100644 --- a/src/detection/wallpaper/wallpaper_apple.c +++ b/src/detection/wallpaper/wallpaper_apple.c @@ -8,8 +8,7 @@ const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrb #ifdef FF_HAVE_SQLITE3 - FF_STRBUF_AUTO_DESTROY path; - ffStrbufInitCopy(&path, &instance->state.platform.homeDir); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&instance->state.platform.homeDir); ffStrbufAppendS(&path, "Library/Application Support/Dock/desktoppicture.db"); if (ffSettingsGetSQLite3String(instance, path.chars, "SELECT value\n" diff --git a/src/detection/wifi/wifi_android.c b/src/detection/wifi/wifi_android.c index 8e6e2b072..39ae35541 100644 --- a/src/detection/wifi/wifi_android.c +++ b/src/detection/wifi/wifi_android.c @@ -8,8 +8,7 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) { - FF_STRBUF_AUTO_DESTROY buffer; - ffStrbufInit(&buffer); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if(ffProcessAppendStdOut(&buffer, (char* const[]){ FF_TERMUX_API_PATH, diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index d0a679fdb..a92fa8c2e 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -144,8 +144,7 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul if(instance->config.allowSlowOperations) { - FF_STRBUF_AUTO_DESTROY output; - ffStrbufInit(&output); + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); if(!ffProcessAppendStdOut(&output, (char* const[]){ "iw", "dev", @@ -216,8 +215,7 @@ static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instan if(!infs) return "if_nameindex() failed"; - FFstrbuf path; - ffStrbufInit(&path); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { @@ -307,7 +305,6 @@ static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instan close(sock); } if_freenameindex(infs); - ffStrbufDestroy(&path); return NULL; } diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index e325e0bce..2099a3a2c 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -10,7 +10,7 @@ static bool detectWMThemeFromConfigFile(FFinstance* instance, const char* config { if(!ffParsePropFileConfig(instance, configFile, themeRegex, themeOrError)) { - ffStrbufInitF(themeOrError, "Config file %s doesn't exist", configFile); + ffStrbufAppendF(themeOrError, "Config file %s doesn't exist", configFile); return false; } @@ -131,8 +131,7 @@ static bool detectXFWM4(FFinstance* instance, FFstrbuf* themeOrError) static bool detectOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) { - FFstrbuf absolutePath; - ffStrbufInitA(&absolutePath, 64); + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(64); ffStrbufAppend(&absolutePath, &instance->state.platform.homeDir); //TODO: use config dirs @@ -150,7 +149,6 @@ static bool detectOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName, FF if(file == NULL) { ffStrbufAppendF(themeOrError, "Couldn't open \"%s\"", absolutePath.chars); - ffStrbufDestroy(&absolutePath); return false; } @@ -184,11 +182,9 @@ static bool detectOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName, FF if(themeOrError->length == 0) { ffStrbufAppendF(themeOrError, "Couldn't find theme name in \"%s\"", absolutePath.chars); - ffStrbufDestroy(&absolutePath); return false; } - ffStrbufDestroy(&absolutePath); return true; } diff --git a/src/detection/wmtheme/wmtheme_windows.c b/src/detection/wmtheme/wmtheme_windows.c index 0522b933b..67ea08f83 100644 --- a/src/detection/wmtheme/wmtheme_windows.c +++ b/src/detection/wmtheme/wmtheme_windows.c @@ -66,8 +66,7 @@ bool ffDetectWmTheme(FF_MAYBE_UNUSED FFinstance* instance, FFstrbuf* themeOrErro FF_HKEY_AUTO_DESTROY hKey = NULL; if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, NULL)) { - FF_STRBUF_AUTO_DESTROY theme; - ffStrbufInit(&theme); + FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate(); if(ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, NULL)) { ffStrbufSubstrBeforeLastC(&theme, '.'); diff --git a/src/fastfetch.c b/src/fastfetch.c index 50546fea8..a3a36f7af 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -612,8 +612,7 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char //Try to load as a relative path - FFstrbuf absolutePath; - ffStrbufInitA(&absolutePath, 128); + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs) { @@ -628,8 +627,6 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char return; } - ffStrbufDestroy(&absolutePath); - //File not found fprintf(stderr, "Error: couldn't find config: %s\n", value); diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 9da6584fc..4a033c2b4 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -12,8 +12,7 @@ static FFstrbuf base64Encode(FFstrbuf* in) { const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - FFstrbuf out; - ffStrbufInitA(&out, 8 * (1 + in->length / 6)); + FFstrbuf out = ffStrbufCreateA(8 * (1 + in->length / 6)); unsigned val = 0; int valb = -6; @@ -41,8 +40,7 @@ static bool printImageIterm(FFinstance* instance) return false; } - FFstrbuf buf; - ffStrbufInit(&buf); + FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); if(!ffAppendFileBuffer(instance->config.logo.source.chars, &buf)) { fputs("Logo: Failed to load image file\n", stderr); @@ -51,7 +49,8 @@ static bool printImageIterm(FFinstance* instance) ffPrintCharTimes(' ', instance->config.logo.paddingLeft); ffPrintCharTimes('\n', instance->config.logo.paddingTop); - FFstrbuf base64 = base64Encode(&buf); + + FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&buf); instance->state.logoWidth = instance->config.logo.width + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; instance->state.logoHeight = instance->config.logo.paddingTop + instance->config.logo.height; printf("\033]1337;File=inline=1;width=%u;height=%u;preserveAspectRatio=%u:%s\a\033[9999999D\n\033[%uA", @@ -62,9 +61,6 @@ static bool printImageIterm(FFinstance* instance) (unsigned) instance->state.logoHeight ); - ffStrbufDestroy(&buf); - ffStrbufDestroy(&base64); - return true; } @@ -289,8 +285,7 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData if(!checkAllocationResult(chars, length)) return false; - FFstrbuf result; - ffStrbufInitA(&result, (uint32_t) (length + 1024)); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA((uint32_t) (length + 1024)); const char* currentPos = chars; size_t remainingLength = length; @@ -304,7 +299,6 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData printImagePixels(instance, requestData, &result, isCompressed ? FF_CACHE_FILE_KITTY_COMPRESSED : FF_CACHE_FILE_KITTY_UNCOMPRESSED); - ffStrbufDestroy(&result); free(chars); return true; } @@ -532,8 +526,7 @@ static void readCachedStrbuf(FFLogoRequestData* requestData, FFstrbuf* result, c static uint32_t readCachedUint32(FFLogoRequestData* requestData, const char* cacheFileName) { - FFstrbuf content; - ffStrbufInit(&content); + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); readCachedStrbuf(requestData, &content, cacheFileName); uint32_t result = 0; @@ -546,27 +539,20 @@ static uint32_t readCachedUint32(FFLogoRequestData* requestData, const char* cac memcpy(&result, content.chars, sizeof(result)); - ffStrbufDestroy(&content); - return result; } static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestData) { - FFstrbuf content; - ffStrbufInitA(&content, 32768); + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreateA(32768); if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) readCachedStrbuf(requestData, &content, FF_CACHE_FILE_CHAFA); if(content.length == 0) - { - ffStrbufDestroy(&content); return false; - } ffLogoPrintChars(instance, content.chars, false); - ffStrbufDestroy(&content); return true; } diff --git a/src/logo/logo.c b/src/logo/logo.c index 4b7fa2124..2e2e54f8f 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -302,8 +302,7 @@ static void updateLogoPath(FFinstance* instance) if(ffPathExists(options->source.chars, FF_PATHTYPE_FILE)) return; - FFstrbuf fullPath; - ffStrbufInit(&fullPath); + FF_STRBUF_AUTO_DESTROY fullPath = ffStrbufCreate(); FF_LIST_FOR_EACH(FFstrbuf, dataDir, instance->state.platform.dataDirs) { @@ -318,20 +317,16 @@ static void updateLogoPath(FFinstance* instance) break; } } - - ffStrbufDestroy(&fullPath); } static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, bool raw) { FFLogoOptions* options = &instance->config.logo; - FF_STRBUF_AUTO_DESTROY content; - ffStrbufInit(&content); + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); if(!ffAppendFileBuffer(options->source.chars, &content)) { - ffStrbufDestroy(&content); fputs("Logo: Failed to load file content from logo source\n", stderr); return false; } @@ -341,6 +336,7 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, ffLogoPrintCharsRaw(instance, content.chars, content.length); else ffLogoPrintChars(instance, content.chars, doColorReplacement); + return true; } diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index e3ec40eed..92f5dea6f 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -17,8 +17,7 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter result->status.length > 0 && ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0; - FFstrbuf str; - ffStrbufInit(&str); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(result->capacity >= 0) { @@ -58,7 +57,6 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter } ffStrbufPutTo(&str, stdout); - ffStrbufDestroy(&str); } else { diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 655501a98..71176b922 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -23,8 +23,7 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) return; } - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); FF_LIST_FOR_EACH(FFBrightnessResult, item, result) { diff --git a/src/modules/chassis.c b/src/modules/chassis.c index 997242d65..4932ecc69 100644 --- a/src/modules/chassis.c +++ b/src/modules/chassis.c @@ -26,15 +26,12 @@ void ffPrintChassis(FFinstance* instance) { ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis.key); - FFstrbuf output; - ffStrbufInitCopy(&output, &result.chassisType); + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateCopy(&result.chassisType); if(result.chassisVersion.length > 0) ffStrbufAppendF(&output, " (%s)", result.chassisVersion.chars); ffStrbufPutTo(&output, stdout); - - ffStrbufDestroy(&output); } else { diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 92768cd31..49177119d 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -6,8 +6,7 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) { - FF_STRBUF_AUTO_DESTROY result; - ffStrbufInit(&result); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); const char* error = ffProcessAppendStdOut(&result, (char* const[]){ options->shell.chars, #ifdef _WIN32 diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index b7ccddc41..74a078d34 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -22,8 +22,7 @@ void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options) { ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key); - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8); if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index ee5585f73..eb4c90da1 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -10,8 +10,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk* disk) { - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); if(options->moduleArgs.key.length == 0) { @@ -24,12 +23,10 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk }); } - FF_STRBUF_AUTO_DESTROY usedPretty; - ffStrbufInit(&usedPretty); + FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty); - FF_STRBUF_AUTO_DESTROY totalPretty; - ffStrbufInit(&totalPretty); + FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty); uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0; @@ -38,8 +35,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk { ffPrintLogoAndKey(instance, key.chars, 0, NULL); - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(disk->bytesTotal > 0) { @@ -109,8 +105,7 @@ static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const const char separator = ':'; #endif - FFstrbuf mountpoints; - ffStrbufInitCopy(&mountpoints, &options->folders); + FF_STRBUF_AUTO_DESTROY mountpoints = ffStrbufCreateCopy(&options->folders); ffStrbufTrim(&mountpoints, separator); uint32_t startIndex = 0; diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 737ad228d..40045c6e5 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -43,8 +43,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) return; } - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); for(uint32_t i = 0; i < dsResult->displays.length; i++) { diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 9b544c974..1e3fd17ee 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -16,8 +16,7 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t { ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key); - FF_STRBUF_AUTO_DESTROY output; - ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length); + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(gpu->vendor.length + 1 + gpu->name.length); if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor)) { diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 0dfd42f4c..e6d18874e 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -25,8 +25,7 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) { ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key); - FFstrbuf output; - ffStrbufInit(&output); + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); if(host->productName.length > 0) ffStrbufAppend(&output, &host->productName); @@ -39,8 +38,6 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) } ffStrbufPutTo(&output, stdout); - - ffStrbufDestroy(&output); } else { diff --git a/src/modules/icons.c b/src/modules/icons.c index d6851b973..02bc10368 100644 --- a/src/modules/icons.c +++ b/src/modules/icons.c @@ -7,8 +7,7 @@ void ffPrintIcons(FFinstance* instance) { - FF_STRBUF_AUTO_DESTROY icons; - ffStrbufInit(&icons); + FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate(); const char* error = ffDetectIcons(instance, &icons); if(error) diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 0311a4711..5ae6eef1b 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -149,8 +149,7 @@ static const char* printJsonConfig(FFinstance* instance) if (!ffJsonLoadLibrary(instance)) return "Failed to load json-c library"; - FF_STRBUF_AUTO_DESTROY content; - ffStrbufInit(&content); + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) { uint32_t oldLength = filename->length; diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 5d3a510dd..9a2f99f6d 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -7,8 +7,7 @@ void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options) { - FF_STRBUF_AUTO_DESTROY locale; - ffStrbufInit(&locale); + FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate(); ffDetectLocale(&locale); if(locale.length == 0) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index b10507b8b..92ec3fe21 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -87,8 +87,7 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) } else { - FF_STRBUF_AUTO_DESTROY key; - ffStrbufInit(&key); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { diff --git a/src/modules/media.c b/src/modules/media.c index eb0eaeeb2..74be335e0 100644 --- a/src/modules/media.c +++ b/src/modules/media.c @@ -52,8 +52,7 @@ void ffPrintMedia(FFinstance* instance) return; } - FFstrbuf songPretty; - ffStrbufInitCopy(&songPretty, &media->song); + FF_STRBUF_AUTO_DESTROY songPretty = ffStrbufCreateCopy(&media->song); const char* removeStrings[] = { "(Official Music Video)", "(Official Video)", "(Music Video)", "(Official HD Video)", "[Official Music Video]", "[Official Video]", "[Music Video]", "[Official HD Video]", @@ -72,8 +71,7 @@ void ffPrintMedia(FFinstance* instance) if(instance->config.media.outputFormat.length == 0) { //We don't expose artistPretty to the format, as it might be empty (when the think that the artist is already in the song title) - FFstrbuf artistPretty; - ffStrbufInitCopy(&artistPretty, &media->artist); + FF_STRBUF_AUTO_DESTROY artistPretty = ffStrbufCreateCopy(&media->artist); ffStrbufRemoveIgnCaseEndS(&artistPretty, " - Topic"); ffStrbufRemoveIgnCaseEndS(&artistPretty, "VEVO"); ffStrbufTrimRight(&artistPretty, ' '); @@ -93,8 +91,6 @@ void ffPrintMedia(FFinstance* instance) ffStrbufAppendF(&songPretty, " (%s)", media->status.chars); ffStrbufPutTo(&songPretty, stdout); - - ffStrbufDestroy(&artistPretty); } else { @@ -106,6 +102,4 @@ void ffPrintMedia(FFinstance* instance) {FF_FORMAT_ARG_TYPE_STRBUF, &media->status} }); } - - ffStrbufDestroy(&songPretty); } diff --git a/src/modules/memory.c b/src/modules/memory.c index 3c82b1a7b..729ffc777 100644 --- a/src/modules/memory.c +++ b/src/modules/memory.c @@ -18,12 +18,10 @@ void ffPrintMemory(FFinstance* instance) return; } - FF_STRBUF_AUTO_DESTROY usedPretty; - ffStrbufInit(&usedPretty); + FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty); - FF_STRBUF_AUTO_DESTROY totalPretty; - ffStrbufInit(&totalPretty); + FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 @@ -37,8 +35,7 @@ void ffPrintMemory(FFinstance* instance) puts("Disabled"); else { - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 637c1094a..55a0552e8 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -107,8 +107,7 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - FF_STRBUF_AUTO_DESTROY result; - ffStrbufInit(&result); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0) buildOutputNixOS(instance, os, &result); diff --git a/src/modules/player.c b/src/modules/player.c index 32eecde0f..6f4ab0df2 100644 --- a/src/modules/player.c +++ b/src/modules/player.c @@ -17,8 +17,7 @@ void ffPrintPlayer(FFinstance* instance) return; } - FFstrbuf playerPretty; - ffStrbufInit(&playerPretty); + FF_STRBUF_AUTO_DESTROY playerPretty = ffStrbufCreate(); //If we are on a website, prepend the website name if( @@ -70,6 +69,4 @@ void ffPrintPlayer(FFinstance* instance) {FF_FORMAT_ARG_TYPE_STRBUF, &media->url} }); } - - ffStrbufDestroy(&playerPretty); } diff --git a/src/modules/publicip.c b/src/modules/publicip.c index 61c85698e..2483be9d9 100644 --- a/src/modules/publicip.c +++ b/src/modules/publicip.c @@ -14,13 +14,11 @@ void ffPreparePublicIp(FFinstance* instance) status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/ip", NULL); else { - FFstrbuf host; - ffStrbufInitCopy(&host, &instance->config.publicIpUrl); + FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&instance->config.publicIpUrl); ffStrbufSubstrAfterFirstS(&host, "://"); uint32_t pathStartIndex = ffStrbufFirstIndexC(&host, '/'); - FFstrbuf path; - ffStrbufInit(&path); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); if(pathStartIndex != host.length) { ffStrbufAppendNS(&path, pathStartIndex, host.chars + (host.length - pathStartIndex)); @@ -29,9 +27,6 @@ void ffPreparePublicIp(FFinstance* instance) } status = ffNetworkingSendHttpRequest(&state, host.chars, path.length == 0 ? "/" : path.chars, NULL); - - ffStrbufDestroy(&path); - ffStrbufDestroy(&host); } } @@ -46,15 +41,13 @@ void ffPrintPublicIp(FFinstance* instance) return; } - FFstrbuf result; - ffStrbufInitA(&result, 4096); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); bool success = ffNetworkingRecvHttpResponse(&state, &result, instance->config.publicIpTimeout); if(success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); if(!success || result.length == 0) { ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, "Failed to receive the server response"); - ffStrbufDestroy(&result); return; } @@ -69,6 +62,4 @@ void ffPrintPublicIp(FFinstance* instance) {FF_FORMAT_ARG_TYPE_STRBUF, &result} }); } - - ffStrbufDestroy(&result); } diff --git a/src/modules/swap.c b/src/modules/swap.c index 1f6175b15..37ba2a12b 100644 --- a/src/modules/swap.c +++ b/src/modules/swap.c @@ -18,12 +18,10 @@ void ffPrintSwap(FFinstance* instance) return; } - FF_STRBUF_AUTO_DESTROY usedPretty; - ffStrbufInit(&usedPretty); + FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty); - FF_STRBUF_AUTO_DESTROY totalPretty; - ffStrbufInit(&totalPretty); + FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 @@ -37,8 +35,7 @@ void ffPrintSwap(FFinstance* instance) puts("Disabled"); else { - FF_STRBUF_AUTO_DESTROY str; - ffStrbufInit(&str); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { diff --git a/src/modules/users.c b/src/modules/users.c index 1c78571b2..7fd27c36e 100644 --- a/src/modules/users.c +++ b/src/modules/users.c @@ -7,24 +7,20 @@ void ffPrintUsers(FFinstance* instance) { - FFlist users; + FF_LIST_AUTO_DESTROY users; ffListInit(&users, sizeof(FFstrbuf)); - FFstrbuf error; - ffStrbufInit(&error); + FF_STRBUF_AUTO_DESTROY error = ffStrbufCreate(); ffDetectUsers(&users, &error); if(error.length > 0) { ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &instance->config.users, "%*s", error.length, error.chars); - ffListDestroy(&users); - ffStrbufDestroy(&error); return; } - FFstrbuf result; - ffStrbufInit(&result); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); for(uint32_t i = 0; i < users.length; ++i) { if(i > 0) @@ -34,8 +30,6 @@ void ffPrintUsers(FFinstance* instance) ffStrbufDestroy(user); } - ffListDestroy(&users); - if(instance->config.users.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &instance->config.users.key); @@ -47,6 +41,4 @@ void ffPrintUsers(FFinstance* instance) {FF_FORMAT_ARG_TYPE_STRBUF, &result}, }); } - - ffStrbufDestroy(&result); } diff --git a/src/modules/wallpaper.c b/src/modules/wallpaper.c index 75caa5471..d17aef323 100644 --- a/src/modules/wallpaper.c +++ b/src/modules/wallpaper.c @@ -7,8 +7,7 @@ void ffPrintWallpaper(FFinstance* instance) { - FF_STRBUF_AUTO_DESTROY wallpaper; - ffStrbufInit(&wallpaper); + FF_STRBUF_AUTO_DESTROY wallpaper = ffStrbufCreate(); const char* error = ffDetectWallpaper(instance, &wallpaper); if(error) diff --git a/src/modules/weather.c b/src/modules/weather.c index a6bc63ce9..f26cd4de9 100644 --- a/src/modules/weather.c +++ b/src/modules/weather.c @@ -10,11 +10,9 @@ static int status = -1; void ffPrepareWeather(FFinstance* instance) { - FFstrbuf path; - ffStrbufInitS(&path, "/?format="); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/?format="); ffStrbufAppend(&path, &instance->config.weatherOutputFormat); status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); - ffStrbufDestroy(&path); } void ffPrintWeather(FFinstance* instance) @@ -28,15 +26,13 @@ void ffPrintWeather(FFinstance* instance) return; } - FFstrbuf result; - ffStrbufInitA(&result, 4096); + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); bool success = ffNetworkingRecvHttpResponse(&state, &result, instance->config.weatherTimeout); if (success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); if(!success || result.length == 0) { ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &instance->config.weather, "Failed to receive the server response"); - ffStrbufDestroy(&result); return; } @@ -51,6 +47,4 @@ void ffPrintWeather(FFinstance* instance) {FF_FORMAT_ARG_TYPE_STRBUF, &result} }); } - - ffStrbufDestroy(&result); } diff --git a/src/modules/wmtheme.c b/src/modules/wmtheme.c index 4112d8321..91e46911c 100644 --- a/src/modules/wmtheme.c +++ b/src/modules/wmtheme.c @@ -7,8 +7,7 @@ void ffPrintWMTheme(FFinstance* instance) { - FFstrbuf themeOrError; - ffStrbufInit(&themeOrError); + FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate(); if(ffDetectWmTheme(instance, &themeOrError)) { if(instance->config.wmTheme.outputFormat.length == 0) @@ -27,5 +26,4 @@ void ffPrintWMTheme(FFinstance* instance) { ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmTheme, "%*s", themeOrError.length, themeOrError.chars); } - ffStrbufDestroy(&themeOrError); } diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index bcf946071..eccea2341 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -35,16 +35,6 @@ void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) ffStrbufInit(strbuf); } -void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) -{ - assert(format != NULL); - - va_list arguments; - va_start(arguments, format); - ffStrbufInitVF(strbuf, format, arguments); - va_end(arguments); -} - void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) { assert(format != NULL); @@ -458,13 +448,3 @@ uint16_t ffStrbufToUInt16(const FFstrbuf* strbuf, uint16_t defaultValue) unsigned long result = strtoul(strbuf->chars, &str_end, 10); return str_end == strbuf->chars || result > UINT16_MAX ? defaultValue : (uint16_t)result; } - -void ffStrbufDestroy(FFstrbuf* strbuf) -{ - if(strbuf->allocated == 0) return; - - //Avoid free-after-use. These 3 assignments are cheap so don't remove them - strbuf->allocated = strbuf->length = 0; - free(strbuf->chars); - strbuf->chars = CHAR_NULL_PTR; -} diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index d80a99483..c345d8e21 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -29,9 +29,8 @@ typedef struct FFstrbuf } FFstrbuf; void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate); -void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src); +void ffStrbufInitCopy(FFstrbuf* restrict strbuf, const FFstrbuf* restrict src); void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src); -void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments); void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free); @@ -91,7 +90,55 @@ void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file); FF_C_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf); FF_C_NODISCARD uint16_t ffStrbufToUInt16(const FFstrbuf* strbuf, uint16_t defaultValue); -void ffStrbufDestroy(FFstrbuf* strbuf); +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) +{ + FFstrbuf strbuf; + ffStrbufInitA(&strbuf, allocate); + return strbuf; +} + +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) +{ + FFstrbuf strbuf; + ffStrbufInitCopy(&strbuf, src); + return strbuf; +} + +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) +{ + FFstrbuf strbuf; + ffStrbufInitMove(&strbuf, src); + return strbuf; +} + +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) +{ + FFstrbuf strbuf; + ffStrbufInitVF(&strbuf, format, arguments); + return strbuf; +} + +FF_C_PRINTF(2, 3) +static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) +{ + va_list arguments; + va_start(arguments, format); + ffStrbufInitVF(strbuf, format, arguments); + va_end(arguments); +} + +FF_C_PRINTF(1, 2) +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) +{ + FFstrbuf strbuf; + + va_list arguments; + va_start(arguments, format); + ffStrbufInitVF(&strbuf, format, arguments); + va_end(arguments); + + return strbuf; +} static inline void ffStrbufRecalculateLength(FFstrbuf* strbuf) { @@ -121,19 +168,40 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) strbuf->chars = CHAR_NULL_PTR; } +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate() +{ + FFstrbuf strbuf; + ffStrbufInit(&strbuf); + return strbuf; +} + static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* str) { ffStrbufInit(strbuf); ffStrbufAppendNS(strbuf, length, str); } +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) +{ + FFstrbuf strbuf; + ffStrbufInitNS(&strbuf, length, str); + return strbuf; +} + static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) { ffStrbufInit(strbuf); ffStrbufAppendS(strbuf, str); } -static inline void ffStrbufAppend(FFstrbuf* strbuf, const FFstrbuf* value) +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) +{ + FFstrbuf strbuf; + ffStrbufInitS(&strbuf, str); + return strbuf; +} + +static inline void ffStrbufAppend(FFstrbuf* restrict strbuf, const FFstrbuf* restrict value) { assert(value != strbuf); if(value == NULL) @@ -323,6 +391,17 @@ static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars); } +static inline void ffStrbufDestroy(FFstrbuf* strbuf) +{ + if(strbuf->allocated == 0) return; + + extern char* CHAR_NULL_PTR; + //Avoid free-after-use. These 3 assignments are cheap so don't remove them + strbuf->allocated = strbuf->length = 0; + free(strbuf->chars); + strbuf->chars = CHAR_NULL_PTR; +} + #define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy))) #endif diff --git a/tests/strbuf.c b/tests/strbuf.c index 3d8d3d057..3df30af23 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -28,12 +28,12 @@ int main(void) FFstrbuf strbuf; //destroy 0 - ffStrbufInitA(&strbuf, 0); + ffStrbufInit(&strbuf); ffStrbufDestroy(&strbuf); //initA - ffStrbufInitA(&strbuf, 0); + ffStrbufInit(&strbuf); VERIFY(strbuf.chars[0] == 0); VERIFY(strbuf.allocated == 0); @@ -216,6 +216,11 @@ int main(void) ffStrbufDestroy(&strbuf); + { + FF_STRBUF_AUTO_DESTROY testCreate = ffStrbufCreateS("TEST"); + VERIFY(ffStrbufEqualS(&testCreate, "TEST")); + } + //Success puts("\033[32mAll tests passed!"FASTFETCH_TEXT_MODIFIER_RESET); } From 6d002c175f984e0abc75f5c855cee83d4e44f385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Apr 2023 21:54:40 +0800 Subject: [PATCH 043/493] FFstrbuf: fix building on Windows --- src/util/FFstrbuf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index c345d8e21..32eb3da8c 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -29,7 +29,7 @@ typedef struct FFstrbuf } FFstrbuf; void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate); -void ffStrbufInitCopy(FFstrbuf* restrict strbuf, const FFstrbuf* restrict src); +void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src); void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src); void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments); @@ -201,7 +201,7 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) return strbuf; } -static inline void ffStrbufAppend(FFstrbuf* restrict strbuf, const FFstrbuf* restrict value) +static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value) { assert(value != strbuf); if(value == NULL) From 39582471e8572185bdcff6437f18210858fa374c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Apr 2023 22:41:32 +0800 Subject: [PATCH 044/493] Global: major FFlist related code refactor --- src/detection/battery/battery_apple.c | 3 +-- src/detection/cpu/cpu_apple.c | 3 +-- src/detection/disk/disk_linux.c | 3 +-- src/detection/gpu/gpu_apple.c | 3 +-- src/modules/bluetooth/bluetooth.c | 5 +---- src/modules/brightness/brightness.c | 4 ++-- src/modules/gamepad/gamepad.c | 4 ++-- src/modules/localip/localip.c | 3 +-- src/modules/sound/sound.c | 7 +++---- src/modules/users.c | 3 +-- src/modules/wifi.c | 3 +-- src/util/FFlist.c | 8 -------- src/util/FFlist.h | 24 +++++++++++++++++++++--- tests/list.c | 7 +++++++ 14 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index 8a4214180..af49b9a69 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -7,8 +7,7 @@ static double detectBatteryTemp() { - FF_LIST_AUTO_DESTROY temps; - ffListInit(&temps, sizeof(FFTempValue)); + FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); ffDetectCoreTemps(FF_TEMP_BATTERY, &temps); diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index 7f3f3598f..fb53b60d2 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -15,8 +15,7 @@ static double getFrequency(const char* propName) static double detectCpuTemp(const FFstrbuf* cpuName) { - FF_LIST_AUTO_DESTROY temps; - ffListInit(&temps, sizeof(FFTempValue)); + FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); if(ffStrbufStartsWithS(cpuName, "Apple M1")) ffDetectCoreTemps(FF_TEMP_CPU_M1X, &temps); diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 2be87af66..210417ef4 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -201,8 +201,7 @@ void ffDetectDisksImpl(FFDiskResult* disks) return; } - FF_LIST_AUTO_DESTROY devices; - ffListInit(&devices, sizeof(FFstrbuf)); + FF_LIST_AUTO_DESTROY devices = ffListCreate(sizeof(FFstrbuf)); char* line = NULL; size_t len = 0; diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 937b835f6..2245692b5 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -9,8 +9,7 @@ static double detectGpuTemp(const FFstrbuf* gpuName) { - FF_LIST_AUTO_DESTROY temps; - ffListInit(&temps, sizeof(FFTempValue)); + FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); if(ffStrbufStartsWithS(gpuName, "Apple M1")) ffDetectCoreTemps(FF_TEMP_GPU_M1X, &temps); diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 1b33db8bf..2318336b5 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -37,8 +37,7 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) return; } - FFlist filtered; - ffListInit(&filtered, sizeof(FFBluetoothDevice*)); + FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFBluetoothDevice*)); FF_LIST_FOR_EACH(FFBluetoothDevice, device, bluetooth->devices) { @@ -59,8 +58,6 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); } - - ffListDestroy(&filtered); } void ffInitBluetoothOptions(FFBluetoothOptions* options) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 71176b922..34ae9f8f1 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -7,8 +7,8 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) { - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFBrightnessResult)); + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); + const char* error = ffDetectBrightness(&result); if(error) diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index a0cd64f27..6d4b37c53 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -22,8 +22,8 @@ static void printDevice(FFinstance* instance, FFGamepadOptions* options, const F void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options) { - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFGamepadDevice)); + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFGamepadDevice)); + const char* error = ffDetectGamepad(instance, &result); if(error) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 92ec3fe21..9b27da159 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -55,8 +55,7 @@ static void printIp(FFLocalIpResult* ip) void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) { - FF_LIST_AUTO_DESTROY results; - ffListInit(&results, sizeof(FFLocalIpResult)); + FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult)); const char* error = ffDetectLocalIps(options, &results); diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 678c47b5d..9f5e1c5a4 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -37,8 +37,8 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS void ffPrintSound(FFinstance* instance, FFSoundOptions* options) { - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFSoundDevice)); + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSoundDevice)); + const char* error = ffDetectSound(instance, &result); if(error) @@ -47,8 +47,7 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options) return; } - FF_LIST_AUTO_DESTROY filtered; - ffListInit(&filtered, sizeof(FFSoundDevice*)); + FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFSoundDevice*)); FF_LIST_FOR_EACH(FFSoundDevice, device, result) { diff --git a/src/modules/users.c b/src/modules/users.c index 7fd27c36e..87503d56b 100644 --- a/src/modules/users.c +++ b/src/modules/users.c @@ -7,8 +7,7 @@ void ffPrintUsers(FFinstance* instance) { - FF_LIST_AUTO_DESTROY users; - ffListInit(&users, sizeof(FFstrbuf)); + FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf)); FF_STRBUF_AUTO_DESTROY error = ffStrbufCreate(); diff --git a/src/modules/wifi.c b/src/modules/wifi.c index 06c3768fc..d78d750b4 100644 --- a/src/modules/wifi.c +++ b/src/modules/wifi.c @@ -7,8 +7,7 @@ void ffPrintWifi(FFinstance* instance) { - FF_LIST_AUTO_DESTROY result; - ffListInit(&result, sizeof(FFWifiResult)); + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult)); const char* error = ffDetectWifi(instance, &result); if(error) diff --git a/src/util/FFlist.c b/src/util/FFlist.c index bd643014a..59f5a8b56 100644 --- a/src/util/FFlist.c +++ b/src/util/FFlist.c @@ -55,11 +55,3 @@ bool ffListPop(FFlist* list, void* result) --list->length; return result; } - -void ffListDestroy(FFlist* list) -{ - //Avoid free-after-use. These 3 assignments are cheap so don't remove them - list->capacity = list->length = 0; - free(list->data); - list->data = NULL; -} diff --git a/src/util/FFlist.h b/src/util/FFlist.h index 58612e347..eccd30b55 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -31,12 +31,20 @@ bool ffListShift(FFlist* list, void* result); // Removes the last element, and copy its value to `*result` bool ffListPop(FFlist* list, void* result); -void ffListDestroy(FFlist* list); - static inline void ffListInit(FFlist* list, uint32_t elementSize) { assert(elementSize > 0); - ffListInitA(list, elementSize, 0); + list->elementSize = elementSize; + list->capacity = 0; + list->length = 0; + list->data = NULL; +} + +static inline FFlist ffListCreate(uint32_t elementSize) +{ + FFlist result; + ffListInit(&result, elementSize); + return result; } static inline void* ffListGet(const FFlist* list, uint32_t index) @@ -50,6 +58,16 @@ static inline void ffListSort(FFlist* list, int(*compar)(const void*, const void qsort(list->data, list->length, list->elementSize, compar); } +static inline void ffListDestroy(FFlist* list) +{ + if (!list->data) return; + + //Avoid free-after-use. These 3 assignments are cheap so don't remove them + list->capacity = list->length = 0; + free(list->data); + list->data = NULL; +} + #define FF_LIST_FOR_EACH(itemType, itemVarName, listVar) \ assert(sizeof(itemType) == (listVar).elementSize); \ for(itemType* itemVarName = (itemType*)(listVar).data; \ diff --git a/tests/list.c b/tests/list.c index db4db544a..4ba879097 100644 --- a/tests/list.c +++ b/tests/list.c @@ -108,6 +108,13 @@ int main(void) VERIFY(list.capacity == 0); VERIFY(list.length == 0); + { + FF_LIST_AUTO_DESTROY test = ffListCreate(1); + VERIFY(test.elementSize = 1); + VERIFY(test.capacity == 0); + VERIFY(test.length == 0); + } + //Success puts("\033[32mAll tests passed!"FASTFETCH_TEXT_MODIFIER_RESET); } From 51bc06f60ba78772524bf152d097a5e1efb97e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Apr 2023 19:39:35 +0800 Subject: [PATCH 045/493] Uptime: code refactor --- src/detection/uptime/uptime.h | 2 +- src/detection/uptime/uptime_bsd.c | 10 ++++++---- src/detection/uptime/uptime_linux.c | 7 ++++--- src/detection/uptime/uptime_windows.c | 5 +++-- src/modules/uptime.c | 8 +++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/detection/uptime/uptime.h b/src/detection/uptime/uptime.h index 6a032b47c..447b13d5b 100644 --- a/src/detection/uptime/uptime.h +++ b/src/detection/uptime/uptime.h @@ -5,6 +5,6 @@ #include "fastfetch.h" -uint64_t ffDetectUptime(); +const char* ffDetectUptime(uint64_t* result); #endif diff --git a/src/detection/uptime/uptime_bsd.c b/src/detection/uptime/uptime_bsd.c index 375065c35..4e3a707c6 100644 --- a/src/detection/uptime/uptime_bsd.c +++ b/src/detection/uptime/uptime_bsd.c @@ -4,7 +4,7 @@ #include #include -uint64_t ffDetectUptime() +const char* ffDetectUptime(uint64_t* result) { struct timeval bootTime; size_t bootTimeSize = sizeof(bootTime); @@ -12,8 +12,10 @@ uint64_t ffDetectUptime() (int[]) {CTL_KERN, KERN_BOOTTIME}, 2, &bootTime, &bootTimeSize, NULL, 0 - ) == 0) - return (uint64_t) difftime(time(NULL), bootTime.tv_sec); + ) != 0) + return "sysctl({CTL_KERN, KERN_BOOTTIME}) failed"; - return 0; + *result = (uint64_t) difftime(time(NULL), bootTime.tv_sec); + + return NULL; } diff --git a/src/detection/uptime/uptime_linux.c b/src/detection/uptime/uptime_linux.c index cf4860771..6ba4a51a1 100644 --- a/src/detection/uptime/uptime_linux.c +++ b/src/detection/uptime/uptime_linux.c @@ -2,10 +2,11 @@ #include -uint64_t ffDetectUptime() +const char* ffDetectUptime(uint64_t* result) { struct sysinfo info; if(sysinfo(&info) != 0) - return 0; - return (uint32_t) info.uptime; + return "sysinfo() failed"; + *result = info.uptime; + return NULL; } diff --git a/src/detection/uptime/uptime_windows.c b/src/detection/uptime/uptime_windows.c index 657af033b..55053ab24 100644 --- a/src/detection/uptime/uptime_windows.c +++ b/src/detection/uptime/uptime_windows.c @@ -2,7 +2,8 @@ #include -uint64_t ffDetectUptime() +const char* ffDetectUptime(uint64_t* result) { - return GetTickCount64() / 1000; + *result = GetTickCount64() / 1000; + return NULL; } diff --git a/src/modules/uptime.c b/src/modules/uptime.c index 48d2b4f4a..6e1c81209 100644 --- a/src/modules/uptime.c +++ b/src/modules/uptime.c @@ -7,11 +7,13 @@ void ffPrintUptime(FFinstance* instance) { - uint64_t uptime = ffDetectUptime(); + uint64_t uptime; - if(uptime == 0) + const char* error = ffDetectUptime(&uptime); + + if(error) { - ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &instance->config.uptime, "Uptime could't be detected"); + ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &instance->config.uptime, "%s", error); return; } From a4c8b93a07645bb9648e414e86bede6de0c704e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Apr 2023 19:57:27 +0800 Subject: [PATCH 046/493] Uptime: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/detection/uptime/uptime_linux.c | 2 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 6 ++ src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/uptime.c | 79 ------------------ src/modules/uptime/option.h | 11 +++ src/modules/uptime/uptime.c | 121 ++++++++++++++++++++++++++++ src/modules/uptime/uptime.h | 16 ++++ 13 files changed, 165 insertions(+), 89 deletions(-) delete mode 100644 src/modules/uptime.c create mode 100644 src/modules/uptime/option.h create mode 100644 src/modules/uptime/uptime.c create mode 100644 src/modules/uptime/uptime.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 488ec3f18..f25f85132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,7 +305,7 @@ set(LIBFASTFETCH_SRC src/modules/terminalfont.c src/modules/theme.c src/modules/title/title.c - src/modules/uptime.c + src/modules/uptime/uptime.c src/modules/users.c src/modules/vulkan.c src/modules/wallpaper.c diff --git a/src/common/init.c b/src/common/init.c index b6b8e6c61..5a1f57ce2 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -67,7 +67,7 @@ static void defaultConfig(FFinstance* instance) ffInitCommandOptions(&instance->config.command); ffInitCustomOptions(&instance->config.custom); ffInitKernelOptions(&instance->config.kernel); - initModuleArg(&instance->config.uptime); + ffInitUptimeOptions(&instance->config.uptime); initModuleArg(&instance->config.processes); initModuleArg(&instance->config.packages); initModuleArg(&instance->config.shell); @@ -289,7 +289,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyCommandOptions(&instance->config.command); ffDestroyCustomOptions(&instance->config.custom); ffDestroyKernelOptions(&instance->config.kernel); - destroyModuleArg(&instance->config.uptime); + ffDestroyUptimeOptions(&instance->config.uptime); destroyModuleArg(&instance->config.processes); destroyModuleArg(&instance->config.packages); destroyModuleArg(&instance->config.shell); diff --git a/src/detection/uptime/uptime_linux.c b/src/detection/uptime/uptime_linux.c index 6ba4a51a1..0339bc7e6 100644 --- a/src/detection/uptime/uptime_linux.c +++ b/src/detection/uptime/uptime_linux.c @@ -7,6 +7,6 @@ const char* ffDetectUptime(uint64_t* result) struct sysinfo info; if(sysinfo(&info) != 0) return "sysinfo() failed"; - *result = info.uptime; + *result = (uint64_t) info.uptime; return NULL; } diff --git a/src/fastfetch.c b/src/fastfetch.c index a3a36f7af..fc7066f1f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -982,7 +982,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} else if(ffParseCustomCommandOptions(&instance->config.custom, key, value)) {} else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} - else if(optionParseModuleArgs(key, value, "uptime", &instance->config.uptime)) {} + else if(ffParseUptimeCommandOptions(&instance->config.uptime, key, value)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} else if(optionParseModuleArgs(key, value, "packages", &instance->config.packages)) {} else if(optionParseModuleArgs(key, value, "shell", &instance->config.shell)) {} @@ -1186,10 +1186,10 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintChassis(instance); else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0) ffPrintKernel(instance, &instance->config.kernel); - else if(strcasecmp(line, "uptime") == 0) - ffPrintUptime(instance); else if(strcasecmp(line, "processes") == 0) ffPrintProcesses(instance); + else if(strcasecmp(line, FF_UPTIME_MODULE_NAME) == 0) + ffPrintUptime(instance, &instance->config.uptime); else if(strcasecmp(line, "packages") == 0) ffPrintPackages(instance); else if(strcasecmp(line, "shell") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 1e6b9ee1e..8b6b374c2 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -65,7 +65,7 @@ typedef struct FFconfig FFModuleArgs chassis; FFCommandOptions command; FFKernelOptions kernel; - FFModuleArgs uptime; + FFUptimeOptions uptime; FFModuleArgs processes; FFModuleArgs packages; FFModuleArgs shell; @@ -200,7 +200,6 @@ void ffPrepareWeather(FFinstance* instance); //Printing void ffPrintChassis(FFinstance* instance); -void ffPrintUptime(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintPackages(FFinstance* instance); void ffPrintShell(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 451d72ace..a30b9c528 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -28,8 +28,8 @@ int main(int argc, char** argv) //ffPrintBoard(&instance, &instance.config.board); //ffPrintChassis(&instance); ffPrintKernel(&instance, &instance.config.kernel); - ffPrintUptime(&instance); //ffPrintProcesses(&instance); + ffPrintUptime(&instance, &instance.config.uptime); ffPrintPackages(&instance); ffPrintShell(&instance); ffPrintDisplay(&instance, &instance.config.display); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 5ae6eef1b..4029c0a7d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -107,6 +107,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'U': { + return + tryModule(instance, type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || + false; + } + default: return false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index e2fff95f3..0736365c4 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -29,3 +29,4 @@ #include "modules/sound/sound.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" +#include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index fc2b460a5..1947123e5 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -26,3 +26,4 @@ #include "modules/separator/option.h" #include "modules/sound/option.h" #include "modules/title/option.h" +#include "modules/uptime/option.h" diff --git a/src/modules/uptime.c b/src/modules/uptime.c deleted file mode 100644 index 6e1c81209..000000000 --- a/src/modules/uptime.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/uptime/uptime.h" - -#define FF_UPTIME_MODULE_NAME "Uptime" -#define FF_UPTIME_NUM_FORMAT_ARGS 4 - -void ffPrintUptime(FFinstance* instance) -{ - uint64_t uptime; - - const char* error = ffDetectUptime(&uptime); - - if(error) - { - ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &instance->config.uptime, "%s", error); - return; - } - - uint32_t days = (uint32_t) uptime / 86400; - uint32_t hours = (uint32_t) (uptime - (days * 86400)) / 3600; - uint32_t minutes = (uint32_t) (uptime - (days * 86400) - (hours * 3600)) / 60; - uint32_t seconds = (uint32_t) uptime - (days * 86400) - (hours * 3600) - (minutes * 60); - - if(instance->config.uptime.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &instance->config.uptime.key); - - if(days == 0 && hours == 0 && minutes == 0) - { - printf("%u seconds\n", seconds); - return; - } - - if(days > 0) - { - printf("%u day", days); - - if(days > 1) - putchar('s'); - - if(days >= 100) - fputs("(!)", stdout); - - if(hours > 0 || minutes > 0) - fputs(", ", stdout); - } - - if(hours > 0) - { - printf("%u hour", hours); - - if(hours > 1) - putchar('s'); - - if(minutes > 0) - fputs(", ", stdout); - } - - if(minutes > 0) - { - printf("%u min", minutes); - - if(minutes > 1) - putchar('s'); - } - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_UPTIME_MODULE_NAME, 0, &instance->config.uptime, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &days}, - {FF_FORMAT_ARG_TYPE_UINT, &hours}, - {FF_FORMAT_ARG_TYPE_UINT, &minutes}, - {FF_FORMAT_ARG_TYPE_UINT, &seconds} - }); - } -} diff --git a/src/modules/uptime/option.h b/src/modules/uptime/option.h new file mode 100644 index 000000000..722d236d3 --- /dev/null +++ b/src/modules/uptime/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFUptimeOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFUptimeOptions; diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c new file mode 100644 index 000000000..f7fd7959c --- /dev/null +++ b/src/modules/uptime/uptime.c @@ -0,0 +1,121 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/uptime/uptime.h" +#include "modules/uptime/uptime.h" + +#define FF_UPTIME_NUM_FORMAT_ARGS 4 + +void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) +{ + uint64_t uptime; + + const char* error = ffDetectUptime(&uptime); + + if(error) + { + ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + uint32_t days = (uint32_t) uptime / 86400; + uint32_t hours = (uint32_t) (uptime - (days * 86400)) / 3600; + uint32_t minutes = (uint32_t) (uptime - (days * 86400) - (hours * 3600)) / 60; + uint32_t seconds = (uint32_t) uptime - (days * 86400) - (hours * 3600) - (minutes * 60); + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key); + + if(days == 0 && hours == 0 && minutes == 0) + { + printf("%u seconds\n", seconds); + return; + } + + if(days > 0) + { + printf("%u day", days); + + if(days > 1) + putchar('s'); + + if(days >= 100) + fputs("(!)", stdout); + + if(hours > 0 || minutes > 0) + fputs(", ", stdout); + } + + if(hours > 0) + { + printf("%u hour", hours); + + if(hours > 1) + putchar('s'); + + if(minutes > 0) + fputs(", ", stdout); + } + + if(minutes > 0) + { + printf("%u min", minutes); + + if(minutes > 1) + putchar('s'); + } + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &days}, + {FF_FORMAT_ARG_TYPE_UINT, &hours}, + {FF_FORMAT_ARG_TYPE_UINT, &minutes}, + {FF_FORMAT_ARG_TYPE_UINT, &seconds} + }); + } +} + +void ffInitUptimeOptions(FFUptimeOptions* options) +{ + options->moduleName = FF_UPTIME_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseUptimeCommandOptions(FFUptimeOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_UPTIME_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyUptimeOptions(FFUptimeOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseUptimeJsonObject(FFinstance* instance, json_object* module) +{ + FFUptimeOptions __attribute__((__cleanup__(ffDestroyUptimeOptions))) options; + ffInitUptimeOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintUptime(instance, &options); +} +#endif diff --git a/src/modules/uptime/uptime.h b/src/modules/uptime/uptime.h new file mode 100644 index 000000000..35cc0365a --- /dev/null +++ b/src/modules/uptime/uptime.h @@ -0,0 +1,16 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/title/option.h" + +#define FF_UPTIME_MODULE_NAME "Uptime" + +void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options); +void ffInitUptimeOptions(FFUptimeOptions* options); +bool ffParseUptimeCommandOptions(FFUptimeOptions* options, const char* key, const char* value); +void ffDestroyUptimeOptions(FFUptimeOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseUptimeJsonObject(FFinstance* instance, json_object* module); +#endif From dab5dbf75901e86054b29b99bf621b47a74335eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Apr 2023 19:57:40 +0800 Subject: [PATCH 047/493] DateTime: remove redundant function definitions --- src/fastfetch.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/fastfetch.h b/src/fastfetch.h index 8b6b374c2..482526e29 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -216,9 +216,6 @@ void ffPrintSwap(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); -void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); -void ffPrintDate(FFinstance* instance); -void ffPrintTime(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintWifi(FFinstance* instance); From 31241b64d89bbb987044c57f1ee9f37cff792223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 28 Apr 2023 19:11:55 +0800 Subject: [PATCH 048/493] WMTheme: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 6 +++ src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/wmtheme.c | 29 ------------ src/modules/wmtheme/option.h | 11 +++++ src/modules/wmtheme/wmtheme.c | 72 +++++++++++++++++++++++++++++ src/modules/wmtheme/wmtheme.h | 16 +++++++ 12 files changed, 115 insertions(+), 38 deletions(-) delete mode 100644 src/modules/wmtheme.c create mode 100644 src/modules/wmtheme/option.h create mode 100644 src/modules/wmtheme/wmtheme.c create mode 100644 src/modules/wmtheme/wmtheme.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f25f85132..c6367dd45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,7 +312,7 @@ set(LIBFASTFETCH_SRC src/modules/weather.c src/modules/wifi.c src/modules/wm.c - src/modules/wmtheme.c + src/modules/wmtheme/wmtheme.c src/modules/jsonconfig/jsonconfig.c src/util/FFlist.c src/util/FFstrbuf.c diff --git a/src/common/init.c b/src/common/init.c index 5a1f57ce2..b09f7bc05 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -74,7 +74,7 @@ static void defaultConfig(FFinstance* instance) ffInitDisplayOptions(&instance->config.display); initModuleArg(&instance->config.de); initModuleArg(&instance->config.wm); - initModuleArg(&instance->config.wmTheme); + ffInitWMThemeOptions(&instance->config.wmTheme); initModuleArg(&instance->config.theme); initModuleArg(&instance->config.icons); ffInitFontOptions(&instance->config.font); @@ -296,7 +296,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyDisplayOptions(&instance->config.display); destroyModuleArg(&instance->config.de); destroyModuleArg(&instance->config.wm); - destroyModuleArg(&instance->config.wmTheme); + ffDestroyWMThemeOptions(&instance->config.wmTheme); destroyModuleArg(&instance->config.theme); destroyModuleArg(&instance->config.icons); ffDestroyFontOptions(&instance->config.font); diff --git a/src/fastfetch.c b/src/fastfetch.c index fc7066f1f..3500d9553 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -991,7 +991,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} else if(optionParseModuleArgs(key, value, "wifi", &instance->config.wifi)) {} else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} - else if(optionParseModuleArgs(key, value, "wm-theme", &instance->config.wmTheme)) {} + else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {} else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} @@ -1202,8 +1202,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintWM(instance); else if(strcasecmp(line, "theme") == 0) ffPrintTheme(instance); - else if(strcasecmp(line, "wmtheme") == 0) - ffPrintWMTheme(instance); + else if(strcasecmp(line, FF_WMTHEME_MODULE_NAME) == 0) + ffPrintWMTheme(instance, &instance->config.wmTheme); else if(strcasecmp(line, "icons") == 0) ffPrintIcons(instance); else if(strcasecmp(line, "wallpaper") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 482526e29..2ba69c847 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -74,7 +74,7 @@ typedef struct FFconfig FFModuleArgs wallpaper; FFModuleArgs wifi; FFModuleArgs wm; - FFModuleArgs wmTheme; + FFWMThemeOptions wmTheme; FFModuleArgs theme; FFModuleArgs icons; FFFontOptions font; @@ -205,7 +205,6 @@ void ffPrintPackages(FFinstance* instance); void ffPrintShell(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); -void ffPrintWMTheme(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index a30b9c528..5a72a214a 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) // ffPrintBrightness(&instance); ffPrintDesktopEnvironment(&instance); ffPrintWM(&instance); - ffPrintWMTheme(&instance); + ffPrintWMTheme(&instance, &instance.config.wmTheme); ffPrintTheme(&instance); ffPrintIcons(&instance); ffPrintFont(&instance, &instance.config.font); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 4029c0a7d..b03fe7dca 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -113,6 +113,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'W': { + return + tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || + false; + } + default: return false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 0736365c4..07180f83b 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -30,3 +30,4 @@ #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" +#include "modules/wmtheme/wmtheme.h" diff --git a/src/modules/options.h b/src/modules/options.h index 1947123e5..4bd339b16 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -27,3 +27,4 @@ #include "modules/sound/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" +#include "modules/wmtheme/option.h" diff --git a/src/modules/wmtheme.c b/src/modules/wmtheme.c deleted file mode 100644 index 91e46911c..000000000 --- a/src/modules/wmtheme.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/wmtheme/wmtheme.h" - -#define FF_WMTHEME_MODULE_NAME "WM Theme" -#define FF_WMTHEME_NUM_FORMAT_ARGS 1 - -void ffPrintWMTheme(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate(); - if(ffDetectWmTheme(instance, &themeOrError)) - { - if(instance->config.wmTheme.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmTheme.key); - puts(themeOrError.chars); - } - else - { - ffPrintFormat(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmTheme, FF_WMTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &themeOrError} - }); - } - } - else - { - ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmTheme, "%*s", themeOrError.length, themeOrError.chars); - } -} diff --git a/src/modules/wmtheme/option.h b/src/modules/wmtheme/option.h new file mode 100644 index 000000000..11b14458b --- /dev/null +++ b/src/modules/wmtheme/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFWMThemeOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFWMThemeOptions; diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c new file mode 100644 index 000000000..4a2ffbcd2 --- /dev/null +++ b/src/modules/wmtheme/wmtheme.c @@ -0,0 +1,72 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/wmtheme/wmtheme.h" +#include "modules/wmtheme/wmtheme.h" + +#define FF_WMTHEME_DISPLAY_NAME "WM Theme" +#define FF_WMTHEME_NUM_FORMAT_ARGS 1 + +void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options) +{ + FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate(); + if(ffDetectWmTheme(instance, &themeOrError)) + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key); + puts(themeOrError.chars); + } + else + { + ffPrintFormat(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_WMTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &themeOrError} + }); + } + } + else + { + ffPrintError(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "%*s", themeOrError.length, themeOrError.chars); + } +} + +void ffInitWMThemeOptions(FFWMThemeOptions* options) +{ + options->moduleName = FF_WMTHEME_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseWMThemeCommandOptions(FFWMThemeOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WMTHEME_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyWMThemeOptions(FFWMThemeOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseWMThemeJsonObject(FFinstance* instance, json_object* module) +{ + FFWMThemeOptions __attribute__((__cleanup__(ffDestroyWMThemeOptions))) options; + ffInitWMThemeOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWMTheme(instance, &options); +} +#endif diff --git a/src/modules/wmtheme/wmtheme.h b/src/modules/wmtheme/wmtheme.h new file mode 100644 index 000000000..c1f95312d --- /dev/null +++ b/src/modules/wmtheme/wmtheme.h @@ -0,0 +1,16 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/wmtheme/option.h" + +#define FF_WMTHEME_MODULE_NAME "WMTheme" + +void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options); +void ffInitWMThemeOptions(FFWMThemeOptions* options); +bool ffParseWMThemeCommandOptions(FFWMThemeOptions* options, const char* key, const char* value); +void ffDestroyWMThemeOptions(FFWMThemeOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseWMThemeJsonObject(FFinstance* instance, json_object* module); +#endif From f3190b8979527d05ff5d8f49c02465f124b4effe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 11 May 2023 21:07:04 +0800 Subject: [PATCH 049/493] Memory / Swap: add JSON config support --- CMakeLists.txt | 4 +-- src/common/init.c | 8 ++--- src/fastfetch.c | 12 +++---- src/fastfetch.h | 6 ++-- src/flashfetch.c | 4 +-- src/modules/jsonconfig/jsonconfig.c | 7 ++++ src/modules/{ => memory}/memory.c | 54 +++++++++++++++++++++++++---- src/modules/memory/memory.h | 15 ++++++++ src/modules/memory/option.h | 11 ++++++ src/modules/modules.h | 2 ++ src/modules/options.h | 2 ++ src/modules/swap/option.h | 11 ++++++ src/modules/{ => swap}/swap.c | 54 +++++++++++++++++++++++++---- src/modules/swap/swap.h | 15 ++++++++ 14 files changed, 175 insertions(+), 30 deletions(-) rename src/modules/{ => memory}/memory.c (52%) create mode 100644 src/modules/memory/memory.h create mode 100644 src/modules/memory/option.h create mode 100644 src/modules/swap/option.h rename src/modules/{ => swap}/swap.c (52%) create mode 100644 src/modules/swap/swap.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c6367dd45..2dba0e869 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -286,7 +286,7 @@ set(LIBFASTFETCH_SRC src/modules/kernel/kernel.c src/modules/locale/locale.c src/modules/localip/localip.c - src/modules/memory.c + src/modules/memory/memory.c src/modules/opencl.c src/modules/opengl.c src/modules/os/os.c @@ -299,7 +299,7 @@ set(LIBFASTFETCH_SRC src/modules/separator/separator.c src/modules/shell.c src/modules/sound/sound.c - src/modules/swap.c + src/modules/swap/swap.c src/modules/media.c src/modules/terminal.c src/modules/terminalfont.c diff --git a/src/common/init.c b/src/common/init.c index b09f7bc05..587664fe8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -84,8 +84,8 @@ static void defaultConfig(FFinstance* instance) ffInitCPUOptions(&instance->config.cpu); ffInitCPUUsageOptions(&instance->config.cpuUsage); ffInitGPUOptions(&instance->config.gpu); - initModuleArg(&instance->config.memory); - initModuleArg(&instance->config.swap); + ffInitMemoryOptions(&instance->config.memory); + ffInitSwapOptions(&instance->config.swap); ffInitDiskOptions(&instance->config.disk); ffInitBatteryOptions(&instance->config.battery); initModuleArg(&instance->config.powerAdapter); @@ -306,8 +306,8 @@ static void destroyConfig(FFinstance* instance) ffDestroyCPUOptions(&instance->config.cpu); ffDestroyCPUUsageOptions(&instance->config.cpuUsage); ffDestroyGPUOptions(&instance->config.gpu); - destroyModuleArg(&instance->config.memory); - destroyModuleArg(&instance->config.swap); + ffDestroyMemoryOptions(&instance->config.memory); + ffDestroySwapOptions(&instance->config.swap); ffDestroyDiskOptions(&instance->config.disk); ffDestroyBatteryOptions(&instance->config.battery); destroyModuleArg(&instance->config.powerAdapter); diff --git a/src/fastfetch.c b/src/fastfetch.c index 3500d9553..58eca8995 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1002,8 +1002,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {} - else if(optionParseModuleArgs(key, value, "memory", &instance->config.memory)) {} - else if(optionParseModuleArgs(key, value, "swap", &instance->config.swap)) {} + else if(ffParseMemoryCommandOptions(&instance->config.memory, key, value)) {} + else if(ffParseSwapCommandOptions(&instance->config.swap, key, value)) {} else if(ffParseDiskCommandOptions(&instance->config.disk, key, value)) {} else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} @@ -1224,10 +1224,10 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintCustom(instance, &instance->config.custom); else if(strcasecmp(line, FF_GPU_MODULE_NAME) == 0) ffPrintGPU(instance, &instance->config.gpu); - else if(strcasecmp(line, "memory") == 0) - ffPrintMemory(instance); - else if(strcasecmp(line, "swap") == 0) - ffPrintSwap(instance); + else if(strcasecmp(line, FF_MEMORY_MODULE_NAME) == 0) + ffPrintMemory(instance, &instance->config.memory); + else if(strcasecmp(line, FF_SWAP_MODULE_NAME) == 0) + ffPrintSwap(instance, &instance->config.swap); else if(strcasecmp(line, FF_DISK_MODULE_NAME) == 0) ffPrintDisk(instance, &instance->config.disk); else if(strcasecmp(line, FF_BATTERY_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 2ba69c847..cf8562d86 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -85,8 +85,8 @@ typedef struct FFconfig FFCPUUsageOptions cpuUsage; FFCustomOptions custom; FFGPUOptions gpu; - FFModuleArgs memory; - FFModuleArgs swap; + FFMemoryOptions memory; + FFSwapOptions swap; FFDiskOptions disk; FFBatteryOptions battery; FFModuleArgs powerAdapter; @@ -210,8 +210,6 @@ void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); -void ffPrintMemory(FFinstance* instance); -void ffPrintSwap(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 5a72a214a..7d91d9eec 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -45,8 +45,8 @@ int main(int argc, char** argv) ffPrintTerminalFont(&instance); ffPrintCPU(&instance, &instance.config.cpu); ffPrintGPU(&instance, &instance.config.gpu); - ffPrintMemory(&instance); - //ffPrintSwap(&instance); + ffPrintMemory(&instance, &instance.config.memory); + ffPrintSwap(&instance, &instance.config.swap); ffPrintDisk(&instance, &instance.config.disk); ffPrintBattery(&instance, &instance.config.battery); ffPrintPowerAdapter(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index b03fe7dca..7e27ddc43 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -88,6 +88,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'M': { + return + tryModule(instance, type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || + false; + } + case 'O': { return tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || @@ -98,6 +104,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o return tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || + tryModule(instance, type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || false; } diff --git a/src/modules/memory.c b/src/modules/memory/memory.c similarity index 52% rename from src/modules/memory.c rename to src/modules/memory/memory.c index 729ffc777..552a0dc44 100644 --- a/src/modules/memory.c +++ b/src/modules/memory/memory.c @@ -3,18 +3,18 @@ #include "common/parsing.h" #include "common/bar.h" #include "detection/memory/memory.h" +#include "modules/memory/memory.h" -#define FF_MEMORY_MODULE_NAME "Memory" #define FF_MEMORY_NUM_FORMAT_ARGS 3 -void ffPrintMemory(FFinstance* instance) +void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options) { FFMemoryResult storage; const char* error = ffDetectMemory(&storage); if(error) { - ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory, "%s", error); + ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -28,9 +28,9 @@ void ffPrintMemory(FFinstance* instance) ? 0 : (uint8_t) (((long double) storage.bytesUsed / (long double) storage.bytesTotal) * 100.0); - if(instance->config.memory.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory.key); + ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key); if (storage.bytesTotal == 0) puts("Disabled"); else @@ -55,10 +55,52 @@ void ffPrintMemory(FFinstance* instance) } else { - ffPrintFormat(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &percentage}, }); } } + +void ffInitMemoryOptions(FFMemoryOptions* options) +{ + options->moduleName = FF_MEMORY_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_MEMORY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyMemoryOptions(FFMemoryOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseMemoryJsonObject(FFinstance* instance, json_object* module) +{ + FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options; + ffInitMemoryOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintMemory(instance, &options); +} +#endif diff --git a/src/modules/memory/memory.h b/src/modules/memory/memory.h new file mode 100644 index 000000000..e500d8532 --- /dev/null +++ b/src/modules/memory/memory.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_MEMORY_MODULE_NAME "Memory" + +void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options); +void ffInitMemoryOptions(FFMemoryOptions* options); +bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value); +void ffDestroyMemoryOptions(FFMemoryOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseMemoryJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/memory/option.h b/src/modules/memory/option.h new file mode 100644 index 000000000..1f8b30bf1 --- /dev/null +++ b/src/modules/memory/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFMemoryOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFMemoryOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index 07180f83b..abf78d850 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -25,8 +25,10 @@ #include "modules/kernel/kernel.h" #include "modules/locale/locale.h" #include "modules/localip/localip.h" +#include "modules/memory/memory.h" #include "modules/separator/separator.h" #include "modules/sound/sound.h" +#include "modules/swap/swap.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 4bd339b16..e6fec4bd4 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -22,9 +22,11 @@ #include "modules/kernel/option.h" #include "modules/locale/option.h" #include "modules/localip/option.h" +#include "modules/memory/option.h" #include "modules/os/option.h" #include "modules/separator/option.h" #include "modules/sound/option.h" +#include "modules/swap/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" #include "modules/wmtheme/option.h" diff --git a/src/modules/swap/option.h b/src/modules/swap/option.h new file mode 100644 index 000000000..4053cfbe1 --- /dev/null +++ b/src/modules/swap/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFSwapOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFSwapOptions; diff --git a/src/modules/swap.c b/src/modules/swap/swap.c similarity index 52% rename from src/modules/swap.c rename to src/modules/swap/swap.c index 37ba2a12b..d3029878e 100644 --- a/src/modules/swap.c +++ b/src/modules/swap/swap.c @@ -3,18 +3,18 @@ #include "common/parsing.h" #include "common/bar.h" #include "detection/swap/swap.h" +#include "modules/swap/swap.h" -#define FF_SWAP_MODULE_NAME "Swap" #define FF_SWAP_NUM_FORMAT_ARGS 3 -void ffPrintSwap(FFinstance* instance) +void ffPrintSwap(FFinstance* instance, FFSwapOptions* options) { FFSwapResult storage; const char* error = ffDetectSwap(&storage); if(error) { - ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &instance->config.swap, "%s", error); + ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -28,9 +28,9 @@ void ffPrintSwap(FFinstance* instance) ? 0 : (uint8_t) (((long double) storage.bytesUsed / (long double) storage.bytesTotal) * 100.0); - if(instance->config.swap.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &instance->config.swap.key); + ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key); if (storage.bytesTotal == 0) puts("Disabled"); else @@ -55,10 +55,52 @@ void ffPrintSwap(FFinstance* instance) } else { - ffPrintFormat(instance, FF_SWAP_MODULE_NAME, 0, &instance->config.swap, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &percentage}, }); } } + +void ffInitSwapOptions(FFSwapOptions* options) +{ + options->moduleName = FF_SWAP_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_SWAP_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroySwapOptions(FFSwapOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseSwapJsonObject(FFinstance* instance, json_object* module) +{ + FFSwapOptions __attribute__((__cleanup__(ffDestroySwapOptions))) options; + ffInitSwapOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintSwap(instance, &options); +} +#endif diff --git a/src/modules/swap/swap.h b/src/modules/swap/swap.h new file mode 100644 index 000000000..7326d14da --- /dev/null +++ b/src/modules/swap/swap.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_SWAP_MODULE_NAME "Swap" + +void ffPrintSwap(FFinstance* instance, FFSwapOptions* options); +void ffInitSwapOptions(FFSwapOptions* options); +bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value); +void ffDestroySwapOptions(FFSwapOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseSwapJsonObject(FFinstance* instance, json_object* module); +#endif From 2f5c198a81ffe46ecbcaf81bd602b41bf4ab172f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 23 May 2023 15:30:59 +0800 Subject: [PATCH 050/493] Wifi: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +-- src/fastfetch.c | 6 ++-- src/fastfetch.h | 3 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/wifi/option.h | 11 ++++++ src/modules/{ => wifi}/wifi.c | 56 +++++++++++++++++++++++++---- src/modules/wifi/wifi.h | 16 +++++++++ 10 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/modules/wifi/option.h rename src/modules/{ => wifi}/wifi.c (58%) create mode 100644 src/modules/wifi/wifi.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dba0e869..fd57c3ff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,7 +310,7 @@ set(LIBFASTFETCH_SRC src/modules/vulkan.c src/modules/wallpaper.c src/modules/weather.c - src/modules/wifi.c + src/modules/wifi/wifi.c src/modules/wm.c src/modules/wmtheme/wmtheme.c src/modules/jsonconfig/jsonconfig.c diff --git a/src/common/init.c b/src/common/init.c index 587664fe8..3c17d8207 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -93,7 +93,7 @@ static void defaultConfig(FFinstance* instance) ffInitLocalIpOptions(&instance->config.localIP); initModuleArg(&instance->config.publicIP); initModuleArg(&instance->config.weather); - initModuleArg(&instance->config.wifi); + ffInitWifiOptions(&instance->config.wifi); initModuleArg(&instance->config.player); initModuleArg(&instance->config.media); ffInitDateTimeOptions(&instance->config.dateTime); @@ -316,7 +316,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.publicIP); destroyModuleArg(&instance->config.wallpaper); destroyModuleArg(&instance->config.weather); - destroyModuleArg(&instance->config.wifi); + ffDestroyWifiOptions(&instance->config.wifi); destroyModuleArg(&instance->config.player); destroyModuleArg(&instance->config.media); ffDestroyDateTimeOptions(&instance->config.dateTime); diff --git a/src/fastfetch.c b/src/fastfetch.c index 58eca8995..7701b57e1 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -989,7 +989,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} - else if(optionParseModuleArgs(key, value, "wifi", &instance->config.wifi)) {} + else if(ffParseWifiCommandOptions(&instance->config.wifi, key, value)) {} else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} @@ -1240,8 +1240,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintLocalIp(instance, &instance->config.localIP); else if(strcasecmp(line, "publicip") == 0) ffPrintPublicIp(instance); - else if(strcasecmp(line, "wifi") == 0) - ffPrintWifi(instance); + else if(strcasecmp(line, FF_WIFI_MODULE_NAME) == 0) + ffPrintWifi(instance, &instance->config.wifi); else if(strcasecmp(line, "weather") == 0) ffPrintWeather(instance); else if(strcasecmp(line, "player") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index cf8562d86..e1f394daf 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -72,7 +72,7 @@ typedef struct FFconfig FFDisplayOptions display; FFModuleArgs de; FFModuleArgs wallpaper; - FFModuleArgs wifi; + FFWifiOptions wifi; FFModuleArgs wm; FFWMThemeOptions wmTheme; FFModuleArgs theme; @@ -215,7 +215,6 @@ void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); -void ffPrintWifi(FFinstance* instance); void ffPrintColors(FFinstance* instance); void ffPrintVulkan(FFinstance* instance); void ffPrintOpenGL(FFinstance* instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 7e27ddc43..6bbb99c69 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -122,6 +122,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'W': { return + tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index abf78d850..7b1011537 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -32,4 +32,5 @@ #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" +#include "modules/wifi/wifi.h" #include "modules/wmtheme/wmtheme.h" diff --git a/src/modules/options.h b/src/modules/options.h index e6fec4bd4..117bdb6e4 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,4 +29,5 @@ #include "modules/swap/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" +#include "modules/wifi/option.h" #include "modules/wmtheme/option.h" diff --git a/src/modules/wifi/option.h b/src/modules/wifi/option.h new file mode 100644 index 000000000..4d713b5d8 --- /dev/null +++ b/src/modules/wifi/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFWifiOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFWifiOptions; diff --git a/src/modules/wifi.c b/src/modules/wifi/wifi.c similarity index 58% rename from src/modules/wifi.c rename to src/modules/wifi/wifi.c index d78d750b4..cd35eb5f9 100644 --- a/src/modules/wifi.c +++ b/src/modules/wifi/wifi.c @@ -1,23 +1,23 @@ #include "fastfetch.h" #include "common/printing.h" #include "detection/wifi/wifi.h" +#include "modules/wifi/wifi.h" -#define FF_WIFI_MODULE_NAME "Wifi" #define FF_WIFI_NUM_FORMAT_ARGS 10 -void ffPrintWifi(FFinstance* instance) +void ffPrintWifi(FFinstance* instance, FFWifiOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult)); const char* error = ffDetectWifi(instance, &result); if(error) { - ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &instance->config.wifi, "%s", error); + ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(!result.length) { - ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &instance->config.wifi, "No Wifi interfaces found"); + ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found"); return; } @@ -26,9 +26,9 @@ void ffPrintWifi(FFinstance* instance) FFWifiResult* item = (FFWifiResult*)ffListGet(&result, index); uint8_t moduleIndex = result.length == 1 ? 0 : (uint8_t)(index + 1); - if(instance->config.wifi.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &instance->config.wifi.key); + ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key); if(item->conn.ssid.length) { ffStrbufWriteTo(&item->conn.ssid, stdout); @@ -45,7 +45,7 @@ void ffPrintWifi(FFinstance* instance) } else { - ffPrintFormat(instance, FF_WIFI_MODULE_NAME, moduleIndex, &instance->config.wifi, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.description}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.status}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.status}, @@ -68,3 +68,45 @@ void ffPrintWifi(FFinstance* instance) ffStrbufDestroy(&item->conn.security); } } + +void ffInitWifiOptions(FFWifiOptions* options) +{ + options->moduleName = FF_WIFI_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseWifiCommandOptions(FFWifiOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WIFI_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyWifiOptions(FFWifiOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseWifiJsonObject(FFinstance* instance, json_object* module) +{ + FFWifiOptions __attribute__((__cleanup__(ffDestroyWifiOptions))) options; + ffInitWifiOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWifi(instance, &options); +} +#endif diff --git a/src/modules/wifi/wifi.h b/src/modules/wifi/wifi.h new file mode 100644 index 000000000..bb6aa1884 --- /dev/null +++ b/src/modules/wifi/wifi.h @@ -0,0 +1,16 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/wifi/option.h" + +#define FF_WIFI_MODULE_NAME "Wifi" + +void ffPrintWifi(FFinstance* instance, FFWifiOptions* options); +void ffInitWifiOptions(FFWifiOptions* options); +bool ffParseWifiCommandOptions(FFWifiOptions* options, const char* key, const char* value); +void ffDestroyWifiOptions(FFWifiOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseWifiJsonObject(FFinstance* instance, json_object* module); +#endif From fa28529308e4f85c3e33424a5e274e3acf29c023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 26 May 2023 14:32:27 +0800 Subject: [PATCH 051/493] Packages: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 6 +++ src/modules/modules.h | 3 +- src/modules/options.h | 1 + src/modules/packages/option.h | 11 ++++++ src/modules/{ => packages}/packages.c | 54 ++++++++++++++++++++++++--- src/modules/packages/packages.h | 16 ++++++++ 11 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 src/modules/packages/option.h rename src/modules/{ => packages}/packages.c (65%) create mode 100644 src/modules/packages/packages.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fd57c3ff3..f947d1c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,7 @@ set(LIBFASTFETCH_SRC src/modules/opencl.c src/modules/opengl.c src/modules/os/os.c - src/modules/packages.c + src/modules/packages/packages.c src/modules/player.c src/modules/poweradapter.c src/modules/processes.c diff --git a/src/common/init.c b/src/common/init.c index 3c17d8207..20b5f0945 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -69,7 +69,7 @@ static void defaultConfig(FFinstance* instance) ffInitKernelOptions(&instance->config.kernel); ffInitUptimeOptions(&instance->config.uptime); initModuleArg(&instance->config.processes); - initModuleArg(&instance->config.packages); + ffInitPackagesOptions(&instance->config.packages); initModuleArg(&instance->config.shell); ffInitDisplayOptions(&instance->config.display); initModuleArg(&instance->config.de); @@ -291,7 +291,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyKernelOptions(&instance->config.kernel); ffDestroyUptimeOptions(&instance->config.uptime); destroyModuleArg(&instance->config.processes); - destroyModuleArg(&instance->config.packages); + ffDestroyPackagesOptions(&instance->config.packages); destroyModuleArg(&instance->config.shell); ffDestroyDisplayOptions(&instance->config.display); destroyModuleArg(&instance->config.de); diff --git a/src/fastfetch.c b/src/fastfetch.c index 7701b57e1..46189fcb2 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -984,7 +984,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} else if(ffParseUptimeCommandOptions(&instance->config.uptime, key, value)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} - else if(optionParseModuleArgs(key, value, "packages", &instance->config.packages)) {} + else if(ffParsePackagesCommandOptions(&instance->config.packages, key, value)) {} else if(optionParseModuleArgs(key, value, "shell", &instance->config.shell)) {} else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} @@ -1190,8 +1190,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintProcesses(instance); else if(strcasecmp(line, FF_UPTIME_MODULE_NAME) == 0) ffPrintUptime(instance, &instance->config.uptime); - else if(strcasecmp(line, "packages") == 0) - ffPrintPackages(instance); + else if(strcasecmp(line, FF_PACKAGES_MODULE_NAME) == 0) + ffPrintPackages(instance, &instance->config.packages); else if(strcasecmp(line, "shell") == 0) ffPrintShell(instance); else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index e1f394daf..94aa5d436 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -67,7 +67,7 @@ typedef struct FFconfig FFKernelOptions kernel; FFUptimeOptions uptime; FFModuleArgs processes; - FFModuleArgs packages; + FFPackagesOptions packages; FFModuleArgs shell; FFDisplayOptions display; FFModuleArgs de; @@ -201,7 +201,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); -void ffPrintPackages(FFinstance* instance); void ffPrintShell(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 7d91d9eec..be0016643 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -30,7 +30,7 @@ int main(int argc, char** argv) ffPrintKernel(&instance, &instance.config.kernel); //ffPrintProcesses(&instance); ffPrintUptime(&instance, &instance.config.uptime); - ffPrintPackages(&instance); + ffPrintPackages(&instance, &instance.config.packages); ffPrintShell(&instance); ffPrintDisplay(&instance, &instance.config.display); // ffPrintBrightness(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 6bbb99c69..fdf5cdc18 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -100,6 +100,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'P': { + return + tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || + false; + } + case 'S': { return tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 7b1011537..3357c1f1d 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -2,7 +2,6 @@ // For "fastfetch.c" and "flashfetch.c" -#include "modules/os/os.h" #include "modules/battery/battery.h" #include "modules/bios/bios.h" #include "modules/bluetooth/bluetooth.h" @@ -26,6 +25,8 @@ #include "modules/locale/locale.h" #include "modules/localip/localip.h" #include "modules/memory/memory.h" +#include "modules/os/os.h" +#include "modules/packages/packages.h" #include "modules/separator/separator.h" #include "modules/sound/sound.h" #include "modules/swap/swap.h" diff --git a/src/modules/options.h b/src/modules/options.h index 117bdb6e4..fe13e1cc1 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -24,6 +24,7 @@ #include "modules/localip/option.h" #include "modules/memory/option.h" #include "modules/os/option.h" +#include "modules/packages/option.h" #include "modules/separator/option.h" #include "modules/sound/option.h" #include "modules/swap/option.h" diff --git a/src/modules/packages/option.h b/src/modules/packages/option.h new file mode 100644 index 000000000..e06b8403b --- /dev/null +++ b/src/modules/packages/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFPackagesOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFPackagesOptions; diff --git a/src/modules/packages.c b/src/modules/packages/packages.c similarity index 65% rename from src/modules/packages.c rename to src/modules/packages/packages.c index a869fa678..dfcaf8249 100644 --- a/src/modules/packages.c +++ b/src/modules/packages/packages.c @@ -1,24 +1,24 @@ #include "fastfetch.h" #include "common/printing.h" #include "detection/packages/packages.h" +#include "modules/packages/packages.h" -#define FF_PACKAGES_MODULE_NAME "Packages" #define FF_PACKAGES_NUM_FORMAT_ARGS 21 -void ffPrintPackages(FFinstance* instance) +void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) { const FFPackagesResult* counts = ffDetectPackages(instance); uint32_t all = counts->all; //Copy it, so we can substract from it in FF_PRINT_PACKAGE if(all == 0) { - ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, "No packages from known package managers found"); + ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "No packages from known package managers found"); return; } - if(instance->config.packages.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages.key); + ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key); #define FF_PRINT_PACKAGE_NAME(var, name) \ if(counts->var > 0) \ @@ -65,7 +65,7 @@ void ffPrintPackages(FFinstance* instance) } else { - ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT, &all}, {FF_FORMAT_ARG_TYPE_UINT, &counts->pacman}, {FF_FORMAT_ARG_TYPE_STRBUF, &counts->pacmanBranch}, @@ -90,3 +90,45 @@ void ffPrintPackages(FFinstance* instance) }); } } + +void ffInitPackagesOptions(FFPackagesOptions* options) +{ + options->moduleName = FF_PACKAGES_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PACKAGES_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyPackagesOptions(FFPackagesOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParsePackagesJsonObject(FFinstance* instance, json_object* module) +{ + FFPackagesOptions __attribute__((__cleanup__(ffDestroyPackagesOptions))) options; + ffInitPackagesOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPackages(instance, &options); +} +#endif diff --git a/src/modules/packages/packages.h b/src/modules/packages/packages.h new file mode 100644 index 000000000..5557da0b3 --- /dev/null +++ b/src/modules/packages/packages.h @@ -0,0 +1,16 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/packages/option.h" + +#define FF_PACKAGES_MODULE_NAME "Packages" + +void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options); +void ffInitPackagesOptions(FFPackagesOptions* options); +bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value); +void ffDestroyPackagesOptions(FFPackagesOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParsePackagesJsonObject(FFinstance* instance, json_object* module); +#endif From 786d538276f7fbc5de55123f7c8cf618a5792279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 1 Jun 2023 11:37:52 +0800 Subject: [PATCH 052/493] Shell: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 5 +- .../terminalshell/terminalshell_linux.c | 2 +- .../terminalshell/terminalshell_windows.c | 2 +- src/fastfetch.c | 8 +- src/fastfetch.h | 4 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/shell.c | 43 -------- src/modules/shell/option.h | 13 +++ src/modules/shell/shell.c | 99 +++++++++++++++++++ src/modules/shell/shell.h | 15 +++ 14 files changed, 140 insertions(+), 58 deletions(-) delete mode 100644 src/modules/shell.c create mode 100644 src/modules/shell/option.h create mode 100644 src/modules/shell/shell.c create mode 100644 src/modules/shell/shell.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f947d1c40..c85e70f42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,7 +297,7 @@ set(LIBFASTFETCH_SRC src/modules/publicip.c src/modules/display/display.c src/modules/separator/separator.c - src/modules/shell.c + src/modules/shell/shell.c src/modules/sound/sound.c src/modules/swap/swap.c src/modules/media.c diff --git a/src/common/init.c b/src/common/init.c index 20b5f0945..cb2352155 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -70,7 +70,7 @@ static void defaultConfig(FFinstance* instance) ffInitUptimeOptions(&instance->config.uptime); initModuleArg(&instance->config.processes); ffInitPackagesOptions(&instance->config.packages); - initModuleArg(&instance->config.shell); + ffInitShellOptions(&instance->config.shell); ffInitDisplayOptions(&instance->config.display); initModuleArg(&instance->config.de); initModuleArg(&instance->config.wm); @@ -133,7 +133,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.shellVersion = true; instance->config.terminalVersion = true; instance->config.publicIpTimeout = 0; @@ -292,7 +291,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyUptimeOptions(&instance->config.uptime); destroyModuleArg(&instance->config.processes); ffDestroyPackagesOptions(&instance->config.packages); - destroyModuleArg(&instance->config.shell); + ffDestroyShellOptions(&instance->config.shell); ffDestroyDisplayOptions(&instance->config.display); destroyModuleArg(&instance->config.de); destroyModuleArg(&instance->config.wm); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 45bf0091e..931ffdee2 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -353,7 +353,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getUserShellFromEnv(instance, &result); ffStrbufClear(&result.shellVersion); - if(instance->config.shellVersion) + if(instance->config.shell.version) { getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 9af70f8ca..6b5c9b9c1 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -152,7 +152,7 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* } ffStrbufClear(&result->shellVersion); - if(instance->config.shellVersion) + if(instance->config.shell.version) fftsGetShellVersion(&result->shellExe, result->shellPrettyName.chars, &result->shellVersion); result->shellPid = pid; diff --git a/src/fastfetch.c b/src/fastfetch.c index 46189fcb2..da2526d74 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -985,7 +985,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseUptimeCommandOptions(&instance->config.uptime, key, value)) {} else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} else if(ffParsePackagesCommandOptions(&instance->config.packages, key, value)) {} - else if(optionParseModuleArgs(key, value, "shell", &instance->config.shell)) {} + else if(ffParseShellCommandOptions(&instance->config.shell, key, value)) {} else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} @@ -1088,8 +1088,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--shell-version") == 0) - instance->config.shellVersion = optionParseBoolean(value); else if(strcasecmp(key, "--terminal-version") == 0) instance->config.terminalVersion = optionParseBoolean(value); else if(strcasecmp(key, "--player-name") == 0) @@ -1192,8 +1190,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintUptime(instance, &instance->config.uptime); else if(strcasecmp(line, FF_PACKAGES_MODULE_NAME) == 0) ffPrintPackages(instance, &instance->config.packages); - else if(strcasecmp(line, "shell") == 0) - ffPrintShell(instance); + else if(strcasecmp(line, FF_SHELL_MODULE_NAME) == 0) + ffPrintShell(instance, &instance->config.shell); else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0) ffPrintDisplay(instance, &instance->config.display); else if(strcasecmp(line, "desktopenvironment") == 0 || strcasecmp(line, "de") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 94aa5d436..1a3498521 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -68,7 +68,7 @@ typedef struct FFconfig FFUptimeOptions uptime; FFModuleArgs processes; FFPackagesOptions packages; - FFModuleArgs shell; + FFShellOptions shell; FFDisplayOptions display; FFModuleArgs de; FFModuleArgs wallpaper; @@ -132,7 +132,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - bool shellVersion; bool terminalVersion; FFstrbuf publicIpUrl; @@ -201,7 +200,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); -void ffPrintShell(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index be0016643..49b48fc71 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -31,7 +31,7 @@ int main(int argc, char** argv) //ffPrintProcesses(&instance); ffPrintUptime(&instance, &instance.config.uptime); ffPrintPackages(&instance, &instance.config.packages); - ffPrintShell(&instance); + ffPrintShell(&instance, &instance.config.shell); ffPrintDisplay(&instance, &instance.config.display); // ffPrintBrightness(&instance); ffPrintDesktopEnvironment(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index fdf5cdc18..3b15bacd3 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -109,6 +109,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'S': { return tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || + tryModule(instance, type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) || tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || tryModule(instance, type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index 3357c1f1d..08c4a8598 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -28,6 +28,7 @@ #include "modules/os/os.h" #include "modules/packages/packages.h" #include "modules/separator/separator.h" +#include "modules/shell/shell.h" #include "modules/sound/sound.h" #include "modules/swap/swap.h" #include "modules/title/title.h" diff --git a/src/modules/options.h b/src/modules/options.h index fe13e1cc1..522036be8 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -26,6 +26,7 @@ #include "modules/os/option.h" #include "modules/packages/option.h" #include "modules/separator/option.h" +#include "modules/shell/option.h" #include "modules/sound/option.h" #include "modules/swap/option.h" #include "modules/title/option.h" diff --git a/src/modules/shell.c b/src/modules/shell.c deleted file mode 100644 index 607f5ec69..000000000 --- a/src/modules/shell.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/terminalshell/terminalshell.h" - -#define FF_SHELL_MODULE_NAME "Shell" -#define FF_SHELL_NUM_FORMAT_ARGS 7 - -void ffPrintShell(FFinstance* instance) -{ - const FFTerminalShellResult* result = ffDetectTerminalShell(instance); - - if(result->shellProcessName.length == 0) - { - ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &instance->config.shell, "Couldn't detect shell"); - return; - } - - if(instance->config.shell.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &instance->config.shell.key); - ffStrbufWriteTo(&result->shellPrettyName, stdout); - - if(result->shellVersion.length > 0) - { - putchar(' '); - ffStrbufWriteTo(&result->shellVersion, stdout); - } - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_SHELL_MODULE_NAME, 0, &instance->config.shell, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe}, - {FF_FORMAT_ARG_TYPE_STRING, result->shellExeName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellExe}, - {FF_FORMAT_ARG_TYPE_STRING, result->userShellExeName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellVersion} - }); - } -} diff --git a/src/modules/shell/option.h b/src/modules/shell/option.h new file mode 100644 index 000000000..dd6223a36 --- /dev/null +++ b/src/modules/shell/option.h @@ -0,0 +1,13 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFShellOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + bool version; +} FFShellOptions; diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c new file mode 100644 index 000000000..ca5a22cab --- /dev/null +++ b/src/modules/shell/shell.c @@ -0,0 +1,99 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/terminalshell/terminalshell.h" +#include "modules/shell/shell.h" + +#define FF_SHELL_NUM_FORMAT_ARGS 7 + +void ffPrintShell(FFinstance* instance, FFShellOptions* options) +{ + const FFTerminalShellResult* result = ffDetectTerminalShell(instance); + + if(result->shellProcessName.length == 0) + { + ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufWriteTo(&result->shellPrettyName, stdout); + + if(result->shellVersion.length > 0) + { + putchar(' '); + ffStrbufWriteTo(&result->shellVersion, stdout); + } + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe}, + {FF_FORMAT_ARG_TYPE_STRING, result->shellExeName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellExe}, + {FF_FORMAT_ARG_TYPE_STRING, result->userShellExeName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellVersion} + }); + } +} + +void ffInitShellOptions(FFShellOptions* options) +{ + options->moduleName = FF_SHELL_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + options->version = true; +} + +bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_SHELL_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "version") == 0) + { + options->version = ffOptionParseBoolean(value); + return true; + } + + return false; +} + +void ffDestroyShellOptions(FFShellOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseShellJsonObject(FFinstance* instance, json_object* module) +{ + FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options; + ffInitShellOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "version") == 0) + { + options.version = (bool) json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintShell(instance, &options); +} +#endif diff --git a/src/modules/shell/shell.h b/src/modules/shell/shell.h new file mode 100644 index 000000000..210d17dbf --- /dev/null +++ b/src/modules/shell/shell.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_SHELL_MODULE_NAME "Shell" + +void ffPrintShell(FFinstance* instance, FFShellOptions* options); +void ffInitShellOptions(FFShellOptions* options); +bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value); +void ffDestroyShellOptions(FFShellOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseShellJsonObject(FFinstance* instance, json_object* module); +#endif From 13ae9aff44af0e194631392ca4e12332a80ee31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 2 Jun 2023 16:07:01 +0800 Subject: [PATCH 053/493] Terminal: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 6 +- .../terminalshell/terminalshell_linux.c | 2 +- .../terminalshell/terminalshell_windows.c | 2 +- src/fastfetch.c | 8 +- src/fastfetch.h | 5 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/terminal.c | 44 -------- src/modules/terminal/option.h | 13 +++ src/modules/terminal/terminal.c | 100 ++++++++++++++++++ src/modules/terminal/terminal.h | 15 +++ 14 files changed, 141 insertions(+), 61 deletions(-) delete mode 100644 src/modules/terminal.c create mode 100644 src/modules/terminal/option.h create mode 100644 src/modules/terminal/terminal.c create mode 100644 src/modules/terminal/terminal.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c85e70f42..0faf474aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,7 +301,7 @@ set(LIBFASTFETCH_SRC src/modules/sound/sound.c src/modules/swap/swap.c src/modules/media.c - src/modules/terminal.c + src/modules/terminal/terminal.c src/modules/terminalfont.c src/modules/theme.c src/modules/title/title.c diff --git a/src/common/init.c b/src/common/init.c index cb2352155..916e95de8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -79,7 +79,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.icons); ffInitFontOptions(&instance->config.font); ffInitCursorOptions(&instance->config.cursor); - initModuleArg(&instance->config.terminal); + ffInitTerminalOptions(&instance->config.terminal); initModuleArg(&instance->config.terminalFont); ffInitCPUOptions(&instance->config.cpu); ffInitCPUUsageOptions(&instance->config.cpuUsage); @@ -133,8 +133,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.terminalVersion = true; - instance->config.publicIpTimeout = 0; ffStrbufInit(&instance->config.publicIpUrl); @@ -300,7 +298,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.icons); ffDestroyFontOptions(&instance->config.font); ffDestroyCursorOptions(&instance->config.cursor); - destroyModuleArg(&instance->config.terminal); + ffDestroyTerminalOptions(&instance->config.terminal); destroyModuleArg(&instance->config.terminalFont); ffDestroyCPUOptions(&instance->config.cpu); ffDestroyCPUUsageOptions(&instance->config.cpuUsage); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 931ffdee2..9bb488e0f 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -390,7 +390,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInit(&result.terminalVersion); - if(instance->config.terminalVersion) + if(instance->config.terminal.version) fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); ffThreadMutexUnlock(&mutex); diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 6b5c9b9c1..a20cfc11a 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -351,7 +351,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getTerminalFromEnv(&result); ffStrbufInit(&result.terminalVersion); - if(instance->config.terminalVersion) + if(instance->config.terminal.version) fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); exit: diff --git a/src/fastfetch.c b/src/fastfetch.c index da2526d74..f0eda06af 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -997,7 +997,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} - else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {} + else if(ffParseTerminalCommandOptions(&instance->config.terminal, key, value)) {} else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} @@ -1088,8 +1088,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--terminal-version") == 0) - instance->config.terminalVersion = optionParseBoolean(value); else if(strcasecmp(key, "--player-name") == 0) optionParseString(key, value, &instance->config.playerName); else if(strcasecmp(key, "--publicip-url") == 0) @@ -1210,8 +1208,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintFont(instance, &instance->config.font); else if(strcasecmp(line, FF_CURSOR_MODULE_NAME) == 0) ffPrintCursor(instance, &instance->config.cursor); - else if(strcasecmp(line, "terminal") == 0) - ffPrintTerminal(instance); + else if(strcasecmp(line, FF_TERMINAL_MODULE_NAME) == 0) + ffPrintTerminal(instance, &instance->config.terminal); else if(strcasecmp(line, "terminalfont") == 0) ffPrintTerminalFont(instance); else if(strcasecmp(line, FF_CPU_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 1a3498521..fa226c008 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -79,7 +79,7 @@ typedef struct FFconfig FFModuleArgs icons; FFFontOptions font; FFCursorOptions cursor; - FFModuleArgs terminal; + FFTerminalOptions terminal; FFModuleArgs terminalFont; FFCPUOptions cpu; FFCPUUsageOptions cpuUsage; @@ -132,8 +132,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - bool terminalVersion; - FFstrbuf publicIpUrl; uint32_t publicIpTimeout; @@ -205,7 +203,6 @@ void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); -void ffPrintTerminal(FFinstance* instance); void ffPrintTerminalFont(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 49b48fc71..94a16fa54 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -41,7 +41,7 @@ int main(int argc, char** argv) ffPrintIcons(&instance); ffPrintFont(&instance, &instance.config.font); ffPrintCursor(&instance, &instance.config.cursor); - ffPrintTerminal(&instance); + ffPrintTerminal(&instance, &instance.config.terminal); ffPrintTerminalFont(&instance); ffPrintCPU(&instance, &instance.config.cpu); ffPrintGPU(&instance, &instance.config.gpu); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 3b15bacd3..d9aaf2a85 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -117,6 +117,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'T': { return + tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 08c4a8598..090d45fcd 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -31,6 +31,7 @@ #include "modules/shell/shell.h" #include "modules/sound/sound.h" #include "modules/swap/swap.h" +#include "modules/terminal/terminal.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 522036be8..6a9690343 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,6 +29,7 @@ #include "modules/shell/option.h" #include "modules/sound/option.h" #include "modules/swap/option.h" +#include "modules/terminal/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" #include "modules/wifi/option.h" diff --git a/src/modules/terminal.c b/src/modules/terminal.c deleted file mode 100644 index 28e8d14a5..000000000 --- a/src/modules/terminal.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/terminalshell/terminalshell.h" - -#include - -#define FF_TERMINAL_MODULE_NAME "Terminal" -#define FF_TERMINAL_NUM_FORMAT_ARGS 10 - -void ffPrintTerminal(FFinstance* instance) -{ - const FFTerminalShellResult* result = ffDetectTerminalShell(instance); - - if(result->terminalProcessName.length == 0) - { - ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminal, "Couldn't detect terminal"); - return; - } - - if(instance->config.terminal.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminal.key); - - if(result->terminalVersion.length) - printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); - else - ffStrbufPutTo(&result->terminalPrettyName, stdout); - } - else - { - ffPrintFormat(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminal, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalProcessName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalExe}, - {FF_FORMAT_ARG_TYPE_STRING, result->terminalExeName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe}, - {FF_FORMAT_ARG_TYPE_STRING, result->shellExeName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellExe}, - {FF_FORMAT_ARG_TYPE_STRING, result->userShellExeName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellVersion} - }); - } -} diff --git a/src/modules/terminal/option.h b/src/modules/terminal/option.h new file mode 100644 index 000000000..46c9c96fa --- /dev/null +++ b/src/modules/terminal/option.h @@ -0,0 +1,13 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFTerminalOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + bool version; +} FFTerminalOptions; diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c new file mode 100644 index 000000000..23c2f8460 --- /dev/null +++ b/src/modules/terminal/terminal.c @@ -0,0 +1,100 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/terminalshell/terminalshell.h" +#include "modules/terminal/terminal.h" + +#include + +#define FF_TERMINAL_NUM_FORMAT_ARGS 10 + +void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options) +{ + const FFTerminalShellResult* result = ffDetectTerminalShell(instance); + + if(result->terminalProcessName.length == 0) + { + ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key); + + if(result->terminalVersion.length) + printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); + else + ffStrbufPutTo(&result->terminalPrettyName, stdout); + } + else + { + ffPrintFormat(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalProcessName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalExe}, + {FF_FORMAT_ARG_TYPE_STRING, result->terminalExeName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe}, + {FF_FORMAT_ARG_TYPE_STRING, result->shellExeName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellExe}, + {FF_FORMAT_ARG_TYPE_STRING, result->userShellExeName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellVersion} + }); + } +} + +void ffInitTerminalOptions(FFTerminalOptions* options) +{ + options->moduleName = FF_TERMINAL_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + options->version = true; +} + +bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_TERMINAL_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "version") == 0) + { + options->version = ffOptionParseBoolean(value); + return true; + } + + return false; +} + +void ffDestroyTerminalOptions(FFTerminalOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseTerminalJsonObject(FFinstance* instance, json_object* module) +{ + FFTerminalOptions __attribute__((__cleanup__(ffDestroyTerminalOptions))) options; + ffInitTerminalOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "version") == 0) + { + options.version = (bool) json_object_get_boolean(val); + continue; + } + + ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintTerminal(instance, &options); +} +#endif diff --git a/src/modules/terminal/terminal.h b/src/modules/terminal/terminal.h new file mode 100644 index 000000000..56a7dc0be --- /dev/null +++ b/src/modules/terminal/terminal.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_TERMINAL_MODULE_NAME "Terminal" + +void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options); +void ffInitTerminalOptions(FFTerminalOptions* options); +bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value); +void ffDestroyTerminalOptions(FFTerminalOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseTerminalJsonObject(FFinstance* instance, json_object* module); +#endif From 100ce5844db2d7c58b05da6ec2a7c6eaabaad045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 2 Jun 2023 16:28:58 +0800 Subject: [PATCH 054/493] TerminalFont: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/terminalfont.c | 32 ----------- src/modules/terminalfont/option.h | 11 ++++ src/modules/terminalfont/terminalfont.c | 75 +++++++++++++++++++++++++ src/modules/terminalfont/terminalfont.h | 15 +++++ 12 files changed, 112 insertions(+), 41 deletions(-) delete mode 100644 src/modules/terminalfont.c create mode 100644 src/modules/terminalfont/option.h create mode 100644 src/modules/terminalfont/terminalfont.c create mode 100644 src/modules/terminalfont/terminalfont.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0faf474aa..db2b4a4d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -302,7 +302,7 @@ set(LIBFASTFETCH_SRC src/modules/swap/swap.c src/modules/media.c src/modules/terminal/terminal.c - src/modules/terminalfont.c + src/modules/terminalfont/terminalfont.c src/modules/theme.c src/modules/title/title.c src/modules/uptime/uptime.c diff --git a/src/common/init.c b/src/common/init.c index 916e95de8..ae90b2406 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -80,7 +80,7 @@ static void defaultConfig(FFinstance* instance) ffInitFontOptions(&instance->config.font); ffInitCursorOptions(&instance->config.cursor); ffInitTerminalOptions(&instance->config.terminal); - initModuleArg(&instance->config.terminalFont); + ffInitTerminalFontOptions(&instance->config.terminalFont); ffInitCPUOptions(&instance->config.cpu); ffInitCPUUsageOptions(&instance->config.cpuUsage); ffInitGPUOptions(&instance->config.gpu); @@ -299,7 +299,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyFontOptions(&instance->config.font); ffDestroyCursorOptions(&instance->config.cursor); ffDestroyTerminalOptions(&instance->config.terminal); - destroyModuleArg(&instance->config.terminalFont); + ffDestroyTerminalFontOptions(&instance->config.terminalFont); ffDestroyCPUOptions(&instance->config.cpu); ffDestroyCPUUsageOptions(&instance->config.cpuUsage); ffDestroyGPUOptions(&instance->config.gpu); diff --git a/src/fastfetch.c b/src/fastfetch.c index f0eda06af..4596d3fac 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -998,7 +998,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} else if(ffParseTerminalCommandOptions(&instance->config.terminal, key, value)) {} - else if(optionParseModuleArgs(key, value, "terminal-font", &instance->config.terminalFont)) {} + else if(ffParseTerminalFontCommandOptions(&instance->config.terminalFont, key, value)) {} else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {} @@ -1210,8 +1210,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintCursor(instance, &instance->config.cursor); else if(strcasecmp(line, FF_TERMINAL_MODULE_NAME) == 0) ffPrintTerminal(instance, &instance->config.terminal); - else if(strcasecmp(line, "terminalfont") == 0) - ffPrintTerminalFont(instance); + else if(strcasecmp(line, FF_TERMINALFONT_MODULE_NAME) == 0) + ffPrintTerminalFont(instance, &instance->config.terminalFont); else if(strcasecmp(line, FF_CPU_MODULE_NAME) == 0) ffPrintCPU(instance, &instance->config.cpu); else if(strcasecmp(line, FF_CPUUSAGE_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index fa226c008..694dbce09 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -80,7 +80,7 @@ typedef struct FFconfig FFFontOptions font; FFCursorOptions cursor; FFTerminalOptions terminal; - FFModuleArgs terminalFont; + FFTerminalFontOptions terminalFont; FFCPUOptions cpu; FFCPUUsageOptions cpuUsage; FFCustomOptions custom; @@ -203,7 +203,6 @@ void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); -void ffPrintTerminalFont(FFinstance* instance); void ffPrintPowerAdapter(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 94a16fa54..aa27f20e7 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -42,7 +42,7 @@ int main(int argc, char** argv) ffPrintFont(&instance, &instance.config.font); ffPrintCursor(&instance, &instance.config.cursor); ffPrintTerminal(&instance, &instance.config.terminal); - ffPrintTerminalFont(&instance); + ffPrintTerminalFont(&instance, &instance.config.terminalFont); ffPrintCPU(&instance, &instance.config.cpu); ffPrintGPU(&instance, &instance.config.gpu); ffPrintMemory(&instance, &instance.config.memory); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index d9aaf2a85..336bc606a 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -118,6 +118,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'T': { return tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || + tryModule(instance, type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 090d45fcd..b1f06153d 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -32,6 +32,7 @@ #include "modules/sound/sound.h" #include "modules/swap/swap.h" #include "modules/terminal/terminal.h" +#include "modules/terminalfont/terminalfont.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 6a9690343..99c69dd4b 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -30,6 +30,7 @@ #include "modules/sound/option.h" #include "modules/swap/option.h" #include "modules/terminal/option.h" +#include "modules/terminalfont/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" #include "modules/wifi/option.h" diff --git a/src/modules/terminalfont.c b/src/modules/terminalfont.c deleted file mode 100644 index 1809c4f39..000000000 --- a/src/modules/terminalfont.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/terminalfont/terminalfont.h" - -#define FF_TERMFONT_MODULE_NAME "Terminal Font" -#define FF_TERMFONT_NUM_FORMAT_ARGS 4 - -void ffPrintTerminalFont(FFinstance* instance) -{ - const FFTerminalFontResult* terminalFont = ffDetectTerminalFont(instance); - - if(terminalFont->error.length > 0) - { - ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont, "%s", terminalFont->error.chars); - return; - } - - if(instance->config.terminalFont.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont.key); - ffStrbufPutTo(&terminalFont->font.pretty, stdout); - } - else - { - ffPrintFormat(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont, FF_TERMFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.pretty}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.size}, - {FF_FORMAT_ARG_TYPE_LIST, &terminalFont->font.styles} - }); - } -} diff --git a/src/modules/terminalfont/option.h b/src/modules/terminalfont/option.h new file mode 100644 index 000000000..ba62efbb5 --- /dev/null +++ b/src/modules/terminalfont/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFTerminalFontOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFTerminalFontOptions; diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c new file mode 100644 index 000000000..afeb46919 --- /dev/null +++ b/src/modules/terminalfont/terminalfont.c @@ -0,0 +1,75 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/terminalfont/terminalfont.h" +#include "modules/terminalfont/terminalfont.h" + +#define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font" +#define FF_TERMINALFONT_NUM_FORMAT_ARGS 4 + +void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options) +{ + const FFTerminalFontResult* terminalFont = ffDetectTerminalFont(instance); + + if(terminalFont->error.length > 0) + { + ffPrintError(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont->error.chars); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&terminalFont->font.pretty, stdout); + } + else + { + ffPrintFormat(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.pretty}, + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.size}, + {FF_FORMAT_ARG_TYPE_LIST, &terminalFont->font.styles} + }); + } +} + +void ffInitTerminalFontOptions(FFTerminalFontOptions* options) +{ + options->moduleName = FF_TERMINALFONT_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_TERMINALFONT_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module) +{ + FFTerminalFontOptions __attribute__((__cleanup__(ffDestroyTerminalFontOptions))) options; + ffInitTerminalFontOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_TERMINALFONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintTerminalFont(instance, &options); +} +#endif diff --git a/src/modules/terminalfont/terminalfont.h b/src/modules/terminalfont/terminalfont.h new file mode 100644 index 000000000..336732917 --- /dev/null +++ b/src/modules/terminalfont/terminalfont.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_TERMINALFONT_MODULE_NAME "TerminalFont" + +void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options); +void ffInitTerminalFontOptions(FFTerminalFontOptions* options); +bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value); +void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module); +#endif From d5557976d5e875a2b0eca1a7774e1fdcfeff6529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 4 Jun 2023 01:30:01 +0800 Subject: [PATCH 055/493] JSON: inline json-c function wrappers --- src/common/json.c | 98 ---------------------------------------- src/common/json.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 98 deletions(-) diff --git a/src/common/json.c b/src/common/json.c index 053854675..8ca285d5b 100644 --- a/src/common/json.c +++ b/src/common/json.c @@ -2,28 +2,8 @@ #ifdef FF_HAVE_JSONC -#include "common/library.h" #include "common/thread.h" -#include - -typedef struct FFJsonLibrary -{ - FF_LIBRARY_SYMBOL(json_tokener_parse) - FF_LIBRARY_SYMBOL(json_object_is_type) - FF_LIBRARY_SYMBOL(json_object_get_array) - FF_LIBRARY_SYMBOL(json_object_get_boolean) - FF_LIBRARY_SYMBOL(json_object_get_double) - FF_LIBRARY_SYMBOL(json_object_get_int) - FF_LIBRARY_SYMBOL(json_object_get_string_len) - FF_LIBRARY_SYMBOL(json_object_get_string) - FF_LIBRARY_SYMBOL(json_object_get_object) - FF_LIBRARY_SYMBOL(json_object_object_del) - FF_LIBRARY_SYMBOL(json_object_object_get) - FF_LIBRARY_SYMBOL(json_object_object_length) - FF_LIBRARY_SYMBOL(json_object_put) -} FFJsonLibrary; - static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance) { assert(instance); @@ -74,82 +54,4 @@ bool ffJsonLoadLibrary(const FFinstance* instance) return !!ffJsonLib; } -struct json_object *json_tokener_parse(const char *str) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_tokener_parse(str); -} - -int json_object_is_type(const json_object *obj, enum json_type type) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_is_type(obj, type); -} - -struct array_list *json_object_get_array(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_array(obj); -} - -json_bool json_object_get_boolean(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_boolean(obj); -} - -double json_object_get_double(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_double(obj); -} - -int32_t json_object_get_int(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_int(obj); -} - -int json_object_get_string_len(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_string_len(obj); -} - -const char *json_object_get_string(json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_string(obj); -} - -struct lh_table *json_object_get_object(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_object(obj); -} - -void json_object_object_del(struct json_object *obj, const char *key) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_del(obj, key); -} - -struct json_object *json_object_object_get(const json_object *obj, const char *key) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_get(obj, key); -} - -int json_object_object_length(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_length(obj); -} - -int json_object_put(json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_put(obj); -} - #endif diff --git a/src/common/json.h b/src/common/json.h index e1bb3ad59..cf4ffe14f 100644 --- a/src/common/json.h +++ b/src/common/json.h @@ -3,9 +3,30 @@ #ifdef FF_HAVE_JSONC #include "fastfetch.h" +#include "common/library.h" +#include #include +typedef struct FFJsonLibrary +{ + FF_LIBRARY_SYMBOL(json_tokener_parse) + FF_LIBRARY_SYMBOL(json_object_is_type) + FF_LIBRARY_SYMBOL(json_object_get_array) + FF_LIBRARY_SYMBOL(json_object_get_boolean) + FF_LIBRARY_SYMBOL(json_object_get_double) + FF_LIBRARY_SYMBOL(json_object_get_int) + FF_LIBRARY_SYMBOL(json_object_get_string_len) + FF_LIBRARY_SYMBOL(json_object_get_string) + FF_LIBRARY_SYMBOL(json_object_get_object) + FF_LIBRARY_SYMBOL(json_object_object_del) + FF_LIBRARY_SYMBOL(json_object_object_get) + FF_LIBRARY_SYMBOL(json_object_object_length) + FF_LIBRARY_SYMBOL(json_object_put) +} FFJsonLibrary; + +extern const FFJsonLibrary* ffJsonLib; + bool ffJsonLoadLibrary(const FFinstance* instance); static inline void wrapJsoncFree(json_object** root) @@ -15,4 +36,95 @@ static inline void wrapJsoncFree(json_object** root) json_object_put(*root); } +extern inline __attribute__((__gnu_inline__, __always_inline__)) +struct json_object *json_tokener_parse(const char *str) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_tokener_parse(str); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +int json_object_is_type(const json_object *obj, enum json_type type) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_is_type(obj, type); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +struct array_list *json_object_get_array(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_array(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +json_bool json_object_get_boolean(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_boolean(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +double json_object_get_double(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_double(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +int32_t json_object_get_int(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_int(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +int json_object_get_string_len(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_string_len(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +const char *json_object_get_string(json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_string(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +struct lh_table *json_object_get_object(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_get_object(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +void json_object_object_del(struct json_object *obj, const char *key) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_del(obj, key); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +struct json_object *json_object_object_get(const json_object *obj, const char *key) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_get(obj, key); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +int json_object_object_length(const json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_object_length(obj); +} + +extern inline __attribute__((__gnu_inline__, __always_inline__)) +int json_object_put(json_object *obj) +{ + assert(ffJsonLib); + return ffJsonLib->ffjson_object_put(obj); +} + #endif From 823f773e267d4a22b83cc15393061a55f67a8068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 5 Jun 2023 16:57:55 +0800 Subject: [PATCH 056/493] PowerAdapter: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/detection/poweradapter/poweradapter.h | 4 +- .../poweradapter/poweradapter_apple.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/poweradapter.c | 66 ----------- src/modules/poweradapter/option.h | 11 ++ src/modules/poweradapter/poweradapter.c | 105 ++++++++++++++++++ src/modules/poweradapter/poweradapter.h | 15 +++ 14 files changed, 146 insertions(+), 79 deletions(-) delete mode 100644 src/modules/poweradapter.c create mode 100644 src/modules/poweradapter/option.h create mode 100644 src/modules/poweradapter/poweradapter.c create mode 100644 src/modules/poweradapter/poweradapter.h diff --git a/CMakeLists.txt b/CMakeLists.txt index db2b4a4d7..342f305f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,8 +292,8 @@ set(LIBFASTFETCH_SRC src/modules/os/os.c src/modules/packages/packages.c src/modules/player.c - src/modules/poweradapter.c src/modules/processes.c + src/modules/poweradapter/poweradapter.c src/modules/publicip.c src/modules/display/display.c src/modules/separator/separator.c diff --git a/src/common/init.c b/src/common/init.c index ae90b2406..c73d7dfb5 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -88,7 +88,7 @@ static void defaultConfig(FFinstance* instance) ffInitSwapOptions(&instance->config.swap); ffInitDiskOptions(&instance->config.disk); ffInitBatteryOptions(&instance->config.battery); - initModuleArg(&instance->config.powerAdapter); + ffInitPowerAdapterOptions(&instance->config.powerAdapter); ffInitLocaleOptions(&instance->config.locale); ffInitLocalIpOptions(&instance->config.localIP); initModuleArg(&instance->config.publicIP); @@ -307,7 +307,7 @@ static void destroyConfig(FFinstance* instance) ffDestroySwapOptions(&instance->config.swap); ffDestroyDiskOptions(&instance->config.disk); ffDestroyBatteryOptions(&instance->config.battery); - destroyModuleArg(&instance->config.powerAdapter); + ffDestroyPowerAdapterOptions(&instance->config.powerAdapter); ffDestroyLocaleOptions(&instance->config.locale); ffDestroyLocalIpOptions(&instance->config.localIP); destroyModuleArg(&instance->config.publicIP); diff --git a/src/detection/poweradapter/poweradapter.h b/src/detection/poweradapter/poweradapter.h index c7f5ee7dc..1b9abd513 100644 --- a/src/detection/poweradapter/poweradapter.h +++ b/src/detection/poweradapter/poweradapter.h @@ -16,7 +16,7 @@ typedef struct PowerAdapterResult const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results); -#define FF_POWER_ADAPTER_UNSET -2 -#define FF_POWER_ADAPTER_NOT_CONNECTED -1 +#define FF_POWERADAPTER_UNSET -2 +#define FF_POWERADAPTER_NOT_CONNECTED -1 #endif diff --git a/src/detection/poweradapter/poweradapter_apple.c b/src/detection/poweradapter/poweradapter_apple.c index c14ff8c4e..9c550d95d 100644 --- a/src/detection/poweradapter/poweradapter_apple.c +++ b/src/detection/poweradapter/poweradapter_apple.c @@ -32,14 +32,14 @@ const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results) ffStrbufInit(&adapter->description); ffStrbufInit(&adapter->manufacturer); ffStrbufInit(&adapter->modelName); - adapter->watts = FF_POWER_ADAPTER_UNSET; + adapter->watts = FF_POWERADAPTER_UNSET; CFDictionaryRef adapterDict; if(!ffCfDictGetDict(properties, CFSTR("AdapterDetails"), &adapterDict)) { if (ffCfDictGetInt(adapterDict, CFSTR("Watts"), &adapter->watts)) { - adapter->watts = FF_POWER_ADAPTER_NOT_CONNECTED; + adapter->watts = FF_POWERADAPTER_NOT_CONNECTED; continue; } ffCfDictGetString(adapterDict, CFSTR("Name"), &adapter->name); diff --git a/src/fastfetch.c b/src/fastfetch.c index 4596d3fac..94b530a4a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1006,7 +1006,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseSwapCommandOptions(&instance->config.swap, key, value)) {} else if(ffParseDiskCommandOptions(&instance->config.disk, key, value)) {} else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} - else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {} + else if(ffParsePowerAdapterCommandOptions(&instance->config.powerAdapter, key, value)) {} else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} @@ -1228,8 +1228,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintDisk(instance, &instance->config.disk); else if(strcasecmp(line, FF_BATTERY_MODULE_NAME) == 0) ffPrintBattery(instance, &instance->config.battery); - else if(strcasecmp(line, "poweradapter") == 0) - ffPrintPowerAdapter(instance); + else if(strcasecmp(line, FF_POWERADAPTER_MODULE_NAME) == 0) + ffPrintPowerAdapter(instance, &instance->config.powerAdapter); else if(strcasecmp(line, FF_LOCALE_MODULE_NAME) == 0) ffPrintLocale(instance, &instance->config.locale); else if(strcasecmp(line, "localip") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 694dbce09..27f68e15a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -89,7 +89,7 @@ typedef struct FFconfig FFSwapOptions swap; FFDiskOptions disk; FFBatteryOptions battery; - FFModuleArgs powerAdapter; + FFPowerAdapterOptions powerAdapter; FFLocaleOptions locale; FFLocalIpOptions localIP; FFModuleArgs publicIP; @@ -203,7 +203,6 @@ void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); -void ffPrintPowerAdapter(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index aa27f20e7..cc5579d8f 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -49,7 +49,7 @@ int main(int argc, char** argv) ffPrintSwap(&instance, &instance.config.swap); ffPrintDisk(&instance, &instance.config.disk); ffPrintBattery(&instance, &instance.config.battery); - ffPrintPowerAdapter(&instance); + ffPrintPowerAdapter(&instance, &instance.config.powerAdapter); //ffPrintPlayer(&instance); //ffPrintMedia(&instance); //ffPrintLocalIp(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 336bc606a..de9ea27e6 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -103,6 +103,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'P': { return tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || + tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index b1f06153d..1df0a9293 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -27,6 +27,7 @@ #include "modules/memory/memory.h" #include "modules/os/os.h" #include "modules/packages/packages.h" +#include "modules/poweradapter/poweradapter.h" #include "modules/separator/separator.h" #include "modules/shell/shell.h" #include "modules/sound/sound.h" diff --git a/src/modules/options.h b/src/modules/options.h index 99c69dd4b..f89032fa5 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -25,6 +25,7 @@ #include "modules/memory/option.h" #include "modules/os/option.h" #include "modules/packages/option.h" +#include "modules/poweradapter/option.h" #include "modules/separator/option.h" #include "modules/shell/option.h" #include "modules/sound/option.h" diff --git a/src/modules/poweradapter.c b/src/modules/poweradapter.c deleted file mode 100644 index c2cd7550d..000000000 --- a/src/modules/poweradapter.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/poweradapter/poweradapter.h" - -#define FF_POWER_ADAPTER_MODULE_NAME "Power Adapter" -#define FF_POWER_ADAPTER_MODULE_ARGS 5 - -static void printPowerAdapter(FFinstance* instance, const PowerAdapterResult* result, uint8_t index) -{ - if(result->watts != FF_POWER_ADAPTER_UNSET) - { - if(instance->config.powerAdapter.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_POWER_ADAPTER_MODULE_NAME, index, &instance->config.powerAdapter.key); - - if(result->name.length > 0) - puts(result->name.chars); - else if(result->watts == FF_POWER_ADAPTER_NOT_CONNECTED) - puts("not connected"); - else - printf("%dW\n", result->watts); - } - else - { - ffPrintFormat(instance, FF_POWER_ADAPTER_MODULE_NAME, index, &instance->config.powerAdapter, FF_POWER_ADAPTER_MODULE_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_INT, &result->watts}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->description}, - }); - } - } -} - -void ffPrintPowerAdapter(FFinstance* instance) -{ - FFlist results; - ffListInitA(&results, sizeof(PowerAdapterResult), 0); - - const char* error = ffDetectPowerAdapterImpl(instance, &results); - - if (error) - { - ffPrintError(instance, FF_POWER_ADAPTER_MODULE_NAME, 0, &instance->config.powerAdapter, "%s", error); - } - else if(results.length == 0) - { - ffPrintError(instance, FF_POWER_ADAPTER_MODULE_NAME, 0, &instance->config.powerAdapter, "No power adapters found"); - } - else - { - for(uint8_t i = 0; i < (uint8_t) results.length; i++) - { - PowerAdapterResult* result = ffListGet(&results, i); - printPowerAdapter(instance, result, i); - - ffStrbufDestroy(&result->manufacturer); - ffStrbufDestroy(&result->description); - ffStrbufDestroy(&result->modelName); - ffStrbufDestroy(&result->name); - } - } - - ffListDestroy(&results); -} diff --git a/src/modules/poweradapter/option.h b/src/modules/poweradapter/option.h new file mode 100644 index 000000000..7acaf29ee --- /dev/null +++ b/src/modules/poweradapter/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFPowerAdapterOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFPowerAdapterOptions; diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c new file mode 100644 index 000000000..12e78395b --- /dev/null +++ b/src/modules/poweradapter/poweradapter.c @@ -0,0 +1,105 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/poweradapter/poweradapter.h" +#include "modules/poweradapter/poweradapter.h" + +#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter" +#define FF_POWERADAPTER_MODULE_ARGS 5 + +void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options) +{ + FFlist results; + ffListInit(&results, sizeof(PowerAdapterResult)); + + const char* error = ffDetectPowerAdapterImpl(instance, &results); + + if (error) + { + ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + } + else if(results.length == 0) + { + ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found"); + } + else + { + for(uint8_t i = 0; i < (uint8_t) results.length; i++) + { + PowerAdapterResult* result = ffListGet(&results, i); + + if(result->watts != FF_POWERADAPTER_UNSET) + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key); + + if(result->name.length > 0) + puts(result->name.chars); + else if(result->watts == FF_POWERADAPTER_NOT_CONNECTED) + puts("not connected"); + else + printf("%dW\n", result->watts); + } + else + { + ffPrintFormat(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_INT, &result->watts}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->description}, + }); + } + } + + ffStrbufDestroy(&result->manufacturer); + ffStrbufDestroy(&result->description); + ffStrbufDestroy(&result->modelName); + ffStrbufDestroy(&result->name); + } + } + + ffListDestroy(&results); +} + +void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options) +{ + options->moduleName = FF_POWERADAPTER_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_POWERADAPTER_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module) +{ + FFPowerAdapterOptions __attribute__((__cleanup__(ffDestroyPowerAdapterOptions))) options; + ffInitPowerAdapterOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_POWERADAPTER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPowerAdapter(instance, &options); +} +#endif diff --git a/src/modules/poweradapter/poweradapter.h b/src/modules/poweradapter/poweradapter.h new file mode 100644 index 000000000..4c11d1976 --- /dev/null +++ b/src/modules/poweradapter/poweradapter.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_POWERADAPTER_MODULE_NAME "PowerAdapter" + +void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options); +void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options); +bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value); +void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module); +#endif From a3524c3af1b7a70a41e73ff933fe4ea8526fd4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 09:49:38 +0800 Subject: [PATCH 057/493] Icons: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/icons.c | 30 ------------ src/modules/icons/icons.c | 72 +++++++++++++++++++++++++++++ src/modules/icons/icons.h | 15 ++++++ src/modules/icons/option.h | 11 +++++ src/modules/jsonconfig/jsonconfig.c | 6 +++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 114 insertions(+), 39 deletions(-) delete mode 100644 src/modules/icons.c create mode 100644 src/modules/icons/icons.c create mode 100644 src/modules/icons/icons.h create mode 100644 src/modules/icons/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 342f305f2..255eefbb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,7 +281,7 @@ set(LIBFASTFETCH_SRC src/modules/font/font.c src/modules/gpu/gpu.c src/modules/host/host.c - src/modules/icons.c + src/modules/icons/icons.c src/modules/gamepad/gamepad.c src/modules/kernel/kernel.c src/modules/locale/locale.c diff --git a/src/common/init.c b/src/common/init.c index c73d7dfb5..926f779ce 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -76,7 +76,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.wm); ffInitWMThemeOptions(&instance->config.wmTheme); initModuleArg(&instance->config.theme); - initModuleArg(&instance->config.icons); + ffInitIconsOptions(&instance->config.icons); ffInitFontOptions(&instance->config.font); ffInitCursorOptions(&instance->config.cursor); ffInitTerminalOptions(&instance->config.terminal); @@ -295,7 +295,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.wm); ffDestroyWMThemeOptions(&instance->config.wmTheme); destroyModuleArg(&instance->config.theme); - destroyModuleArg(&instance->config.icons); + ffDestroyIconsOptions(&instance->config.icons); ffDestroyFontOptions(&instance->config.font); ffDestroyCursorOptions(&instance->config.cursor); ffDestroyTerminalOptions(&instance->config.terminal); diff --git a/src/fastfetch.c b/src/fastfetch.c index 94b530a4a..78787d5c5 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -993,7 +993,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} - else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {} + else if(ffParseIconsCommandOptions(&instance->config.icons, key, value)) {} else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} @@ -1200,8 +1200,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintTheme(instance); else if(strcasecmp(line, FF_WMTHEME_MODULE_NAME) == 0) ffPrintWMTheme(instance, &instance->config.wmTheme); - else if(strcasecmp(line, "icons") == 0) - ffPrintIcons(instance); + else if(strcasecmp(line, FF_ICONS_MODULE_NAME) == 0) + ffPrintIcons(instance, &instance->config.icons); else if(strcasecmp(line, "wallpaper") == 0) ffPrintWallpaper(instance); else if(strcasecmp(line, FF_FONT_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 27f68e15a..28201a36e 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -76,7 +76,7 @@ typedef struct FFconfig FFModuleArgs wm; FFWMThemeOptions wmTheme; FFModuleArgs theme; - FFModuleArgs icons; + FFIconsOptions icons; FFFontOptions font; FFCursorOptions cursor; FFTerminalOptions terminal; @@ -201,7 +201,6 @@ void ffPrintProcesses(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); -void ffPrintIcons(FFinstance* instance); void ffPrintWallpaper(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index cc5579d8f..f676da276 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -38,7 +38,7 @@ int main(int argc, char** argv) ffPrintWM(&instance); ffPrintWMTheme(&instance, &instance.config.wmTheme); ffPrintTheme(&instance); - ffPrintIcons(&instance); + ffPrintIcons(&instance, &instance.config.icons); ffPrintFont(&instance, &instance.config.font); ffPrintCursor(&instance, &instance.config.cursor); ffPrintTerminal(&instance, &instance.config.terminal); diff --git a/src/modules/icons.c b/src/modules/icons.c deleted file mode 100644 index 02bc10368..000000000 --- a/src/modules/icons.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/icons/icons.h" - -#define FF_ICONS_MODULE_NAME "Icons" -#define FF_ICONS_NUM_FORMAT_ARGS 1 - -void ffPrintIcons(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate(); - const char* error = ffDetectIcons(instance, &icons); - - if(error) - { - ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "%s", error); - return; - } - - if(instance->config.icons.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons.key); - ffStrbufPutTo(&icons, stdout); - } - else - { - ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &icons} - }); - } -} diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c new file mode 100644 index 000000000..e6ebbb8e2 --- /dev/null +++ b/src/modules/icons/icons.c @@ -0,0 +1,72 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/icons/icons.h" +#include "modules/icons/icons.h" + +#define FF_ICONS_NUM_FORMAT_ARGS 1 + +void ffPrintIcons(FFinstance* instance, FFIconsOptions* options) +{ + FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate(); + const char* error = ffDetectIcons(instance, &icons); + + if(error) + { + ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&icons, stdout); + } + else + { + ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &icons} + }); + } +} + +void ffInitIconsOptions(FFIconsOptions* options) +{ + options->moduleName = FF_ICONS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_ICONS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyIconsOptions(FFIconsOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseIconsJsonObject(FFinstance* instance, json_object* module) +{ + FFIconsOptions __attribute__((__cleanup__(ffDestroyIconsOptions))) options; + ffInitIconsOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintIcons(instance, &options); +} +#endif diff --git a/src/modules/icons/icons.h b/src/modules/icons/icons.h new file mode 100644 index 000000000..780f9c352 --- /dev/null +++ b/src/modules/icons/icons.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_ICONS_MODULE_NAME "Icons" + +void ffPrintIcons(FFinstance* instance, FFIconsOptions* options); +void ffInitIconsOptions(FFIconsOptions* options); +bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value); +void ffDestroyIconsOptions(FFIconsOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseIconsJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/icons/option.h b/src/modules/icons/option.h new file mode 100644 index 000000000..fc6427aa4 --- /dev/null +++ b/src/modules/icons/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFIconsOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFIconsOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index de9ea27e6..334bdb17d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -75,6 +75,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'I': { + return + tryModule(instance, type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) || + false; + } + case 'K': { return tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 1df0a9293..ef6750ecd 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -21,6 +21,7 @@ #include "modules/gamepad/gamepad.h" #include "modules/gpu/gpu.h" #include "modules/host/host.h" +#include "modules/icons/icons.h" #include "modules/kernel/kernel.h" #include "modules/locale/locale.h" #include "modules/localip/localip.h" diff --git a/src/modules/options.h b/src/modules/options.h index f89032fa5..06f7bffc5 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -19,6 +19,7 @@ #include "modules/host/option.h" #include "modules/gamepad/option.h" #include "modules/gpu/option.h" +#include "modules/icons/option.h" #include "modules/kernel/option.h" #include "modules/locale/option.h" #include "modules/localip/option.h" From 54a1890aca2d10d5c2055a2a8a930bc235cc1939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 10:14:08 +0800 Subject: [PATCH 058/493] Wallpaper: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/wallpaper.c | 30 ------------ src/modules/wallpaper/option.h | 11 +++++ src/modules/wallpaper/wallpaper.c | 72 +++++++++++++++++++++++++++++ src/modules/wallpaper/wallpaper.h | 15 ++++++ 11 files changed, 108 insertions(+), 38 deletions(-) delete mode 100644 src/modules/wallpaper.c create mode 100644 src/modules/wallpaper/option.h create mode 100644 src/modules/wallpaper/wallpaper.c create mode 100644 src/modules/wallpaper/wallpaper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 255eefbb0..2e1dfe677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,7 +308,7 @@ set(LIBFASTFETCH_SRC src/modules/uptime/uptime.c src/modules/users.c src/modules/vulkan.c - src/modules/wallpaper.c + src/modules/wallpaper/wallpaper.c src/modules/weather.c src/modules/wifi/wifi.c src/modules/wm.c diff --git a/src/common/init.c b/src/common/init.c index 926f779ce..32392623a 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -98,7 +98,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.media); ffInitDateTimeOptions(&instance->config.dateTime); initModuleArg(&instance->config.vulkan); - initModuleArg(&instance->config.wallpaper); + ffInitWallpaperOptions(&instance->config.wallpaper); initModuleArg(&instance->config.openGL); initModuleArg(&instance->config.openCL); initModuleArg(&instance->config.users); @@ -311,7 +311,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyLocaleOptions(&instance->config.locale); ffDestroyLocalIpOptions(&instance->config.localIP); destroyModuleArg(&instance->config.publicIP); - destroyModuleArg(&instance->config.wallpaper); + ffDestroyWallpaperOptions(&instance->config.wallpaper); destroyModuleArg(&instance->config.weather); ffDestroyWifiOptions(&instance->config.wifi); destroyModuleArg(&instance->config.player); diff --git a/src/fastfetch.c b/src/fastfetch.c index 78787d5c5..532656160 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -994,7 +994,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} else if(ffParseIconsCommandOptions(&instance->config.icons, key, value)) {} - else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {} + else if(ffParseWallpaperCommandOptions(&instance->config.wallpaper, key, value)) {} else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} else if(ffParseTerminalCommandOptions(&instance->config.terminal, key, value)) {} @@ -1202,8 +1202,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintWMTheme(instance, &instance->config.wmTheme); else if(strcasecmp(line, FF_ICONS_MODULE_NAME) == 0) ffPrintIcons(instance, &instance->config.icons); - else if(strcasecmp(line, "wallpaper") == 0) - ffPrintWallpaper(instance); + else if(strcasecmp(line, FF_WALLPAPER_MODULE_NAME) == 0) + ffPrintWallpaper(instance, &instance->config.wallpaper); else if(strcasecmp(line, FF_FONT_MODULE_NAME) == 0) ffPrintFont(instance, &instance->config.font); else if(strcasecmp(line, FF_CURSOR_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 28201a36e..684417b8a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -71,7 +71,7 @@ typedef struct FFconfig FFShellOptions shell; FFDisplayOptions display; FFModuleArgs de; - FFModuleArgs wallpaper; + FFWallpaperOptions wallpaper; FFWifiOptions wifi; FFModuleArgs wm; FFWMThemeOptions wmTheme; @@ -201,7 +201,6 @@ void ffPrintProcesses(FFinstance* instance); void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); -void ffPrintWallpaper(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 334bdb17d..bde0382d7 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -138,6 +138,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'W': { return + tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index ef6750ecd..fcde11156 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -38,5 +38,6 @@ #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" +#include "modules/wallpaper/wallpaper.h" #include "modules/wifi/wifi.h" #include "modules/wmtheme/wmtheme.h" diff --git a/src/modules/options.h b/src/modules/options.h index 06f7bffc5..2e3eab4f3 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -35,5 +35,6 @@ #include "modules/terminalfont/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" +#include "modules/wallpaper/option.h" #include "modules/wifi/option.h" #include "modules/wmtheme/option.h" diff --git a/src/modules/wallpaper.c b/src/modules/wallpaper.c deleted file mode 100644 index d17aef323..000000000 --- a/src/modules/wallpaper.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/wallpaper/wallpaper.h" - -#define FF_WALLPAPER_MODULE_NAME "Wallpaper" -#define FF_WALLPAPER_NUM_FORMAT_ARGS 1 - -void ffPrintWallpaper(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY wallpaper = ffStrbufCreate(); - const char* error = ffDetectWallpaper(instance, &wallpaper); - - if(error) - { - ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, "%s", error); - return; - } - - if(instance->config.wallpaper.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper.key); - ffStrbufPutTo(&wallpaper, stdout); - } - else - { - ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &wallpaper} - }); - } -} diff --git a/src/modules/wallpaper/option.h b/src/modules/wallpaper/option.h new file mode 100644 index 000000000..ff7aa55fe --- /dev/null +++ b/src/modules/wallpaper/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFWallpaperOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFWallpaperOptions; diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c new file mode 100644 index 000000000..aeff9eb30 --- /dev/null +++ b/src/modules/wallpaper/wallpaper.c @@ -0,0 +1,72 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/wallpaper/wallpaper.h" +#include "modules/wallpaper/wallpaper.h" + +#define FF_WALLPAPER_NUM_FORMAT_ARGS 1 + +void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) +{ + FF_STRBUF_AUTO_DESTROY wallpaper = ffStrbufCreate(); + const char* error = ffDetectWallpaper(instance, &wallpaper); + + if(error) + { + ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&wallpaper, stdout); + } + else + { + ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &wallpaper} + }); + } +} + +void ffInitWallpaperOptions(FFWallpaperOptions* options) +{ + options->moduleName = FF_WALLPAPER_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WALLPAPER_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyWallpaperOptions(FFWallpaperOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseWallpaperJsonObject(FFinstance* instance, json_object* module) +{ + FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options; + ffInitWallpaperOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWallpaper(instance, &options); +} +#endif diff --git a/src/modules/wallpaper/wallpaper.h b/src/modules/wallpaper/wallpaper.h new file mode 100644 index 000000000..efb0f17c0 --- /dev/null +++ b/src/modules/wallpaper/wallpaper.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_WALLPAPER_MODULE_NAME "Wallpaper" + +void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options); +void ffInitWallpaperOptions(FFWallpaperOptions* options); +bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value); +void ffDestroyWallpaperOptions(FFWallpaperOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseWallpaperJsonObject(FFinstance* instance, json_object* module); +#endif From 11d8142cea991f2be3ed4f395aacf329006694c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 10:39:53 +0800 Subject: [PATCH 059/493] DE: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/de.c | 45 ---------------- src/modules/de/de.c | 82 +++++++++++++++++++++++++++++ src/modules/de/de.h | 15 ++++++ src/modules/de/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 119 insertions(+), 54 deletions(-) delete mode 100644 src/modules/de.c create mode 100644 src/modules/de/de.c create mode 100644 src/modules/de/de.h create mode 100644 src/modules/de/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e1dfe677..67e4808d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,7 +276,7 @@ set(LIBFASTFETCH_SRC src/modules/custom/custom.c src/modules/command/command.c src/modules/datetime/datetime.c - src/modules/de.c + src/modules/de/de.c src/modules/disk/disk.c src/modules/font/font.c src/modules/gpu/gpu.c diff --git a/src/common/init.c b/src/common/init.c index 32392623a..25407f2e8 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -72,7 +72,7 @@ static void defaultConfig(FFinstance* instance) ffInitPackagesOptions(&instance->config.packages); ffInitShellOptions(&instance->config.shell); ffInitDisplayOptions(&instance->config.display); - initModuleArg(&instance->config.de); + ffInitDEOptions(&instance->config.de); initModuleArg(&instance->config.wm); ffInitWMThemeOptions(&instance->config.wmTheme); initModuleArg(&instance->config.theme); @@ -291,7 +291,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyPackagesOptions(&instance->config.packages); ffDestroyShellOptions(&instance->config.shell); ffDestroyDisplayOptions(&instance->config.display); - destroyModuleArg(&instance->config.de); + ffDestroyDEOptions(&instance->config.de); destroyModuleArg(&instance->config.wm); ffDestroyWMThemeOptions(&instance->config.wmTheme); destroyModuleArg(&instance->config.theme); diff --git a/src/fastfetch.c b/src/fastfetch.c index 532656160..310c26881 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -988,7 +988,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseShellCommandOptions(&instance->config.shell, key, value)) {} else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} - else if(optionParseModuleArgs(key, value, "de", &instance->config.de)) {} + else if(ffParseDECommandOptions(&instance->config.de, key, value)) {} else if(ffParseWifiCommandOptions(&instance->config.wifi, key, value)) {} else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} @@ -1192,8 +1192,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintShell(instance, &instance->config.shell); else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0) ffPrintDisplay(instance, &instance->config.display); - else if(strcasecmp(line, "desktopenvironment") == 0 || strcasecmp(line, "de") == 0) - ffPrintDesktopEnvironment(instance); + else if(strcasecmp(line, FF_DE_MODULE_NAME) == 0) + ffPrintDE(instance, &instance->config.de); else if(strcasecmp(line, "windowmanager") == 0 || strcasecmp(line, "wm") == 0) ffPrintWM(instance); else if(strcasecmp(line, "theme") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 684417b8a..53a43d80a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -70,7 +70,7 @@ typedef struct FFconfig FFPackagesOptions packages; FFShellOptions shell; FFDisplayOptions display; - FFModuleArgs de; + FFDEOptions de; FFWallpaperOptions wallpaper; FFWifiOptions wifi; FFModuleArgs wm; @@ -198,7 +198,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); -void ffPrintDesktopEnvironment(FFinstance* instance); void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index f676da276..320357e65 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -34,7 +34,7 @@ int main(int argc, char** argv) ffPrintShell(&instance, &instance.config.shell); ffPrintDisplay(&instance, &instance.config.display); // ffPrintBrightness(&instance); - ffPrintDesktopEnvironment(&instance); + ffPrintDE(&instance, &instance.config.de); ffPrintWM(&instance); ffPrintWMTheme(&instance, &instance.config.wmTheme); ffPrintTheme(&instance); diff --git a/src/modules/de.c b/src/modules/de.c deleted file mode 100644 index eb2cb5062..000000000 --- a/src/modules/de.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/displayserver/displayserver.h" - -#define FF_DE_MODULE_NAME "DE" -#define FF_DE_NUM_FORMAT_ARGS 3 - -void ffPrintDesktopEnvironment(FFinstance* instance) -{ - #ifdef __ANDROID__ - ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "DE detection is not supported on Android"); - return; - #endif - - const FFDisplayServerResult* result = ffConnectDisplayServer(instance); - - if(result->dePrettyName.length == 0) - { - ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "No DE found"); - return; - } - - if(instance->config.de.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &instance->config.de.key); - - ffStrbufWriteTo(&result->dePrettyName, stdout); - - if(result->deVersion.length > 0) - { - putchar(' '); - ffStrbufWriteTo(&result->deVersion, stdout); - } - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion} - }); - } -} diff --git a/src/modules/de/de.c b/src/modules/de/de.c new file mode 100644 index 000000000..1a0310a33 --- /dev/null +++ b/src/modules/de/de.c @@ -0,0 +1,82 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/displayserver/displayserver.h" +#include "modules/de/de.h" + +#define FF_DE_NUM_FORMAT_ARGS 3 + +void ffPrintDE(FFinstance* instance, FFDEOptions* options) +{ + const FFDisplayServerResult* result = ffConnectDisplayServer(instance); + + if(result->dePrettyName.length == 0) + { + ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs.key); + + ffStrbufWriteTo(&result->dePrettyName, stdout); + + if(result->deVersion.length > 0) + { + putchar(' '); + ffStrbufWriteTo(&result->deVersion, stdout); + } + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion} + }); + } +} + +void ffInitDEOptions(FFDEOptions* options) +{ + options->moduleName = FF_DE_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_DE_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyDEOptions(FFDEOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseDEJsonObject(FFinstance* instance, json_object* module) +{ + FFDEOptions __attribute__((__cleanup__(ffDestroyDEOptions))) options; + ffInitDEOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintDE(instance, &options); +} +#endif diff --git a/src/modules/de/de.h b/src/modules/de/de.h new file mode 100644 index 000000000..ee393e225 --- /dev/null +++ b/src/modules/de/de.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_DE_MODULE_NAME "DE" + +void ffPrintDE(FFinstance* instance, FFDEOptions* options); +void ffInitDEOptions(FFDEOptions* options); +bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value); +void ffDestroyDEOptions(FFDEOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseDEJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/de/option.h b/src/modules/de/option.h new file mode 100644 index 000000000..52b8954e7 --- /dev/null +++ b/src/modules/de/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFDEOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFDEOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index bde0382d7..5c0769dc9 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -53,6 +53,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || tryModule(instance, type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || + tryModule(instance, type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index fcde11156..d6dd4eb6c 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -17,6 +17,7 @@ #include "modules/datetime/datetime.h" #include "modules/disk/disk.h" #include "modules/display/display.h" +#include "modules/de/de.h" #include "modules/font/font.h" #include "modules/gamepad/gamepad.h" #include "modules/gpu/gpu.h" diff --git a/src/modules/options.h b/src/modules/options.h index 2e3eab4f3..01d13a26c 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -13,6 +13,7 @@ #include "modules/custom/option.h" #include "modules/command/option.h" #include "modules/datetime/option.h" +#include "modules/de/option.h" #include "modules/disk/option.h" #include "modules/display/option.h" #include "modules/font/option.h" From d731051cb73233fb1dc284655c81680fe4f8d846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 10:50:52 +0800 Subject: [PATCH 060/493] WM: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/wm.c | 46 ---------------- src/modules/wm/option.h | 11 ++++ src/modules/wm/wm.c | 83 +++++++++++++++++++++++++++++ src/modules/wm/wm.h | 15 ++++++ 12 files changed, 120 insertions(+), 55 deletions(-) delete mode 100644 src/modules/wm.c create mode 100644 src/modules/wm/option.h create mode 100644 src/modules/wm/wm.c create mode 100644 src/modules/wm/wm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 67e4808d9..b908fcaf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,7 +311,7 @@ set(LIBFASTFETCH_SRC src/modules/wallpaper/wallpaper.c src/modules/weather.c src/modules/wifi/wifi.c - src/modules/wm.c + src/modules/wm/wm.c src/modules/wmtheme/wmtheme.c src/modules/jsonconfig/jsonconfig.c src/util/FFlist.c diff --git a/src/common/init.c b/src/common/init.c index 25407f2e8..4e952ca26 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -73,7 +73,7 @@ static void defaultConfig(FFinstance* instance) ffInitShellOptions(&instance->config.shell); ffInitDisplayOptions(&instance->config.display); ffInitDEOptions(&instance->config.de); - initModuleArg(&instance->config.wm); + ffInitWMOptions(&instance->config.wm); ffInitWMThemeOptions(&instance->config.wmTheme); initModuleArg(&instance->config.theme); ffInitIconsOptions(&instance->config.icons); @@ -292,7 +292,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyShellOptions(&instance->config.shell); ffDestroyDisplayOptions(&instance->config.display); ffDestroyDEOptions(&instance->config.de); - destroyModuleArg(&instance->config.wm); + ffDestroyWMOptions(&instance->config.wm); ffDestroyWMThemeOptions(&instance->config.wmTheme); destroyModuleArg(&instance->config.theme); ffDestroyIconsOptions(&instance->config.icons); diff --git a/src/fastfetch.c b/src/fastfetch.c index 310c26881..b0714a9c8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -990,7 +990,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} else if(ffParseDECommandOptions(&instance->config.de, key, value)) {} else if(ffParseWifiCommandOptions(&instance->config.wifi, key, value)) {} - else if(optionParseModuleArgs(key, value, "wm", &instance->config.wm)) {} + else if(ffParseWMCommandOptions(&instance->config.wm, key, value)) {} else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} else if(ffParseIconsCommandOptions(&instance->config.icons, key, value)) {} @@ -1194,8 +1194,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintDisplay(instance, &instance->config.display); else if(strcasecmp(line, FF_DE_MODULE_NAME) == 0) ffPrintDE(instance, &instance->config.de); - else if(strcasecmp(line, "windowmanager") == 0 || strcasecmp(line, "wm") == 0) - ffPrintWM(instance); + else if(strcasecmp(line, FF_WM_MODULE_NAME) == 0) + ffPrintWM(instance, &instance->config.wm); else if(strcasecmp(line, "theme") == 0) ffPrintTheme(instance); else if(strcasecmp(line, FF_WMTHEME_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 53a43d80a..e3941f719 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -73,7 +73,7 @@ typedef struct FFconfig FFDEOptions de; FFWallpaperOptions wallpaper; FFWifiOptions wifi; - FFModuleArgs wm; + FFWMOptions wm; FFWMThemeOptions wmTheme; FFModuleArgs theme; FFIconsOptions icons; @@ -198,7 +198,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); -void ffPrintWM(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 320357e65..0af047407 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -35,7 +35,7 @@ int main(int argc, char** argv) ffPrintDisplay(&instance, &instance.config.display); // ffPrintBrightness(&instance); ffPrintDE(&instance, &instance.config.de); - ffPrintWM(&instance); + ffPrintWM(&instance, &instance.config.wm); ffPrintWMTheme(&instance, &instance.config.wmTheme); ffPrintTheme(&instance); ffPrintIcons(&instance, &instance.config.icons); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 5c0769dc9..7e6253da9 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -140,6 +140,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'W': { return tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || + tryModule(instance, type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index d6dd4eb6c..48a7ee415 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -41,4 +41,5 @@ #include "modules/uptime/uptime.h" #include "modules/wallpaper/wallpaper.h" #include "modules/wifi/wifi.h" +#include "modules/wm/wm.h" #include "modules/wmtheme/wmtheme.h" diff --git a/src/modules/options.h b/src/modules/options.h index 01d13a26c..40cef1062 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -38,4 +38,5 @@ #include "modules/uptime/option.h" #include "modules/wallpaper/option.h" #include "modules/wifi/option.h" +#include "modules/wm/option.h" #include "modules/wmtheme/option.h" diff --git a/src/modules/wm.c b/src/modules/wm.c deleted file mode 100644 index 38cf9f5a3..000000000 --- a/src/modules/wm.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/displayserver/displayserver.h" - -#define FF_WM_MODULE_NAME "WM" -#define FF_WM_NUM_FORMAT_ARGS 3 - -void ffPrintWM(FFinstance* instance) -{ - #ifdef __ANDROID__ - ffPrintError(instance, FF_WM_MODULE_NAME, 0, &instance->config.wm, "WM detection is not supported on Android"); - return; - #endif - - const FFDisplayServerResult* result = ffConnectDisplayServer(instance); - - if(result->wmPrettyName.length == 0) - { - ffPrintError(instance, FF_WM_MODULE_NAME, 0, &instance->config.wm, "No WM found"); - return; - } - - if(instance->config.wm.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &instance->config.wm.key); - - ffStrbufWriteTo(&result->wmPrettyName, stdout); - - if(result->wmProtocolName.length > 0) - { - fputs(" (", stdout); - ffStrbufWriteTo(&result->wmProtocolName, stdout); - putchar(')'); - } - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_WM_MODULE_NAME, 0, &instance->config.wm, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProcessName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName} - }); - } -} diff --git a/src/modules/wm/option.h b/src/modules/wm/option.h new file mode 100644 index 000000000..fcc7b0231 --- /dev/null +++ b/src/modules/wm/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFWMOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFWMOptions; diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c new file mode 100644 index 000000000..172066fe8 --- /dev/null +++ b/src/modules/wm/wm.c @@ -0,0 +1,83 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/displayserver/displayserver.h" +#include "modules/wm/wm.h" + +#define FF_WM_NUM_FORMAT_ARGS 3 + +void ffPrintWM(FFinstance* instance, FFWMOptions* options) +{ + const FFDisplayServerResult* result = ffConnectDisplayServer(instance); + + if(result->wmPrettyName.length == 0) + { + ffPrintError(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs, "No WM found"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs.key); + + ffStrbufWriteTo(&result->wmPrettyName, stdout); + + if(result->wmProtocolName.length > 0) + { + fputs(" (", stdout); + ffStrbufWriteTo(&result->wmProtocolName, stdout); + putchar(')'); + } + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProcessName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName} + }); + } +} + +void ffInitWMOptions(FFWMOptions* options) +{ + options->moduleName = FF_WM_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseWMCommandOptions(FFWMOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WM_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyWMOptions(FFWMOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseWMJsonObject(FFinstance* instance, json_object* module) +{ + FFWMOptions __attribute__((__cleanup__(ffDestroyWMOptions))) options; + ffInitWMOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_WM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWM(instance, &options); +} +#endif diff --git a/src/modules/wm/wm.h b/src/modules/wm/wm.h new file mode 100644 index 000000000..86214a3dc --- /dev/null +++ b/src/modules/wm/wm.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_WM_MODULE_NAME "WM" + +void ffPrintWM(FFinstance* instance, FFWMOptions* options); +void ffInitWMOptions(FFWMOptions* options); +bool ffParseWMCommandOptions(FFWMOptions* options, const char* key, const char* value); +void ffDestroyWMOptions(FFWMOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseWMJsonObject(FFinstance* instance, json_object* module); +#endif From e484c6cdfc2cc485a0fc4ede398b62fab2cd29f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 14:44:27 +0800 Subject: [PATCH 061/493] OpenGL: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 5 +- src/detection/opengl/opengl_linux.c | 6 +- src/fastfetch.c | 16 +--- src/fastfetch.h | 12 +-- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/opengl.c | 42 ---------- src/modules/opengl/opengl.c | 117 ++++++++++++++++++++++++++++ src/modules/opengl/opengl.h | 15 ++++ src/modules/opengl/option.h | 25 ++++++ src/modules/options.h | 1 + 13 files changed, 171 insertions(+), 74 deletions(-) delete mode 100644 src/modules/opengl.c create mode 100644 src/modules/opengl/opengl.c create mode 100644 src/modules/opengl/opengl.h create mode 100644 src/modules/opengl/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b908fcaf8..41a6aa113 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,7 @@ set(LIBFASTFETCH_SRC src/modules/localip/localip.c src/modules/memory/memory.c src/modules/opencl.c - src/modules/opengl.c + src/modules/opengl/opengl.c src/modules/os/os.c src/modules/packages/packages.c src/modules/player.c diff --git a/src/common/init.c b/src/common/init.c index 4e952ca26..a96984042 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -52,7 +52,6 @@ static void defaultConfig(FFinstance* instance) instance->config.hideCursor = true; instance->config.escapeBedrock = true; instance->config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; - instance->config.glType = FF_GL_TYPE_AUTO; instance->config.pipe = false; instance->config.multithreading = true; instance->config.stat = false; @@ -99,7 +98,7 @@ static void defaultConfig(FFinstance* instance) ffInitDateTimeOptions(&instance->config.dateTime); initModuleArg(&instance->config.vulkan); ffInitWallpaperOptions(&instance->config.wallpaper); - initModuleArg(&instance->config.openGL); + ffInitOpenGLOptions(&instance->config.openGL); initModuleArg(&instance->config.openCL); initModuleArg(&instance->config.users); ffInitBluetoothOptions(&instance->config.bluetooth); @@ -318,7 +317,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.media); ffDestroyDateTimeOptions(&instance->config.dateTime); destroyModuleArg(&instance->config.vulkan); - destroyModuleArg(&instance->config.openGL); + ffDestroyOpenGLOptions(&instance->config.openGL); destroyModuleArg(&instance->config.openCL); destroyModuleArg(&instance->config.users); ffDestroyBluetoothOptions(&instance->config.bluetooth); diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index a959578f8..8a274e68f 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -315,7 +315,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) { #if FF_HAVE_GL - if(instance->config.glType == FF_GL_TYPE_GLX) + if(instance->config.openGL.type == FF_OPENGL_TYPE_GLX) { #ifdef FF_HAVE_GLX return glxPrint(instance, result); @@ -324,7 +324,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.glType == FF_GL_TYPE_EGL) + if(instance->config.openGL.type == FF_OPENGL_TYPE_EGL) { #ifdef FF_HAVE_EGL return eglPrint(instance, result); @@ -333,7 +333,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.glType == FF_GL_TYPE_OSMESA) + if(instance->config.openGL.type == FF_OPENGL_TYPE_OSMESA) { #ifdef FF_HAVE_OSMESA return osMesaPrint(instance, result); diff --git a/src/fastfetch.c b/src/fastfetch.c index b0714a9c8..1ae686a41 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1015,7 +1015,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "media", &instance->config.media)) {} else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} else if(optionParseModuleArgs(key, value, "vulkan", &instance->config.vulkan)) {} - else if(optionParseModuleArgs(key, value, "opengl", &instance->config.openGL)) {} + else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} else if(optionParseModuleArgs(key, value, "opencl", &instance->config.openCL)) {} else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} @@ -1098,16 +1098,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseString(key, value, &instance->config.weatherOutputFormat); else if(strcasecmp(key, "--weather-timeout") == 0) instance->config.weatherTimeout = optionParseUInt32(key, value); - else if(strcasecmp(key, "--gl") == 0) - { - optionParseEnum(key, value, &instance->config.glType, - "auto", FF_GL_TYPE_AUTO, - "egl", FF_GL_TYPE_EGL, - "glx", FF_GL_TYPE_GLX, - "osmesa", FF_GL_TYPE_OSMESA, - NULL - ); - } else if(strcasecmp(key, "--percent-type") == 0) instance->config.percentType = optionParseUInt32(key, value); @@ -1250,8 +1240,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintColors(instance); else if(strcasecmp(line, "vulkan") == 0) ffPrintVulkan(instance); - else if(strcasecmp(line, "opengl") == 0) - ffPrintOpenGL(instance); + else if(strcasecmp(line, FF_OPENGL_MODULE_NAME) == 0) + ffPrintOpenGL(instance, &instance->config.openGL); else if(strcasecmp(line, "opencl") == 0) ffPrintOpenCL(instance); else if(strcasecmp(line, "users") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index e3941f719..a7d9f90c6 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -26,14 +26,6 @@ typedef enum FFBinaryPrefixType FF_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 kB, 1024 K = 1 MB, ... } FFBinaryPrefixType; -typedef enum FFGLType -{ - FF_GL_TYPE_AUTO, - FF_GL_TYPE_EGL, - FF_GL_TYPE_GLX, - FF_GL_TYPE_OSMESA -} FFGLType; - typedef struct FFconfig { FFLogoOptions logo; @@ -51,7 +43,6 @@ typedef struct FFconfig bool hideCursor; bool escapeBedrock; FFBinaryPrefixType binaryPrefixType; - FFGLType glType; bool pipe; //disables logo and all escape sequences bool multithreading; bool stat; @@ -98,7 +89,7 @@ typedef struct FFconfig FFModuleArgs media; FFDateTimeOptions dateTime; FFModuleArgs vulkan; - FFModuleArgs openGL; + FFOpenGLOptions openGL; FFModuleArgs openCL; FFModuleArgs users; FFBluetoothOptions bluetooth; @@ -205,7 +196,6 @@ void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintColors(FFinstance* instance); void ffPrintVulkan(FFinstance* instance); -void ffPrintOpenGL(FFinstance* instance); void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 0af047407..bd876fb9c 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -61,7 +61,7 @@ int main(int argc, char** argv) //ffPrintDate(&instance); //ffPrintTime(&instance); //ffPrintVulkan(&instance); - //ffPrintOpenGL(&instance); + //ffPrintOpenGL(&instance, &instance.config.openGL); //ffPrintOpenCL(&instance); //ffPrintUsers(&instance); //ffPrintWeather(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 7e6253da9..d6f4a6060 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -103,6 +103,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'O': { return + tryModule(instance, type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 48a7ee415..e05b959a2 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -27,6 +27,7 @@ #include "modules/locale/locale.h" #include "modules/localip/localip.h" #include "modules/memory/memory.h" +#include "modules/opengl/opengl.h" #include "modules/os/os.h" #include "modules/packages/packages.h" #include "modules/poweradapter/poweradapter.h" diff --git a/src/modules/opengl.c b/src/modules/opengl.c deleted file mode 100644 index 61e78451b..000000000 --- a/src/modules/opengl.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/opengl/opengl.h" - -#define FF_OPENGL_MODULE_NAME "OpenGL" -#define FF_OPENGL_NUM_FORMAT_ARGS 4 - -void ffPrintOpenGL(FFinstance* instance) -{ - FFOpenGLResult result; - ffStrbufInit(&result.version); - ffStrbufInit(&result.renderer); - ffStrbufInit(&result.vendor); - ffStrbufInit(&result.slv); - - const char* error = ffDetectOpenGL(instance, &result); - if(error) - { - ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL, "%s", error); - return; - } - - if(instance->config.openGL.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL.key); - puts(result.version.chars); - } - else - { - ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv} - }); - } - - ffStrbufDestroy(&result.version); - ffStrbufDestroy(&result.renderer); - ffStrbufDestroy(&result.vendor); - ffStrbufDestroy(&result.slv); -} diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c new file mode 100644 index 000000000..ae551fb35 --- /dev/null +++ b/src/modules/opengl/opengl.c @@ -0,0 +1,117 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/opengl/opengl.h" +#include "modules/opengl/opengl.h" + +#define FF_OPENGL_NUM_FORMAT_ARGS 4 + +void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options) +{ + FFOpenGLResult result; + ffStrbufInit(&result.version); + ffStrbufInit(&result.renderer); + ffStrbufInit(&result.vendor); + ffStrbufInit(&result.slv); + + const char* error = ffDetectOpenGL(instance, &result); + if(error) + { + ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key); + puts(result.version.chars); + } + else + { + ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv} + }); + } + + ffStrbufDestroy(&result.version); + ffStrbufDestroy(&result.renderer); + ffStrbufDestroy(&result.vendor); + ffStrbufDestroy(&result.slv); +} + +void ffInitOpenGLOptions(FFOpenGLOptions* options) +{ + options->moduleName = FF_OPENGL_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + #if defined(__linux__) || defined(__FreeBSD__) + options->type = FF_OPENGL_TYPE_AUTO; + #endif +} + +bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_OPENGL_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + #if defined(__linux__) || defined(__FreeBSD__) + options->type = (FFOpenGLType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "auto", FF_OPENGL_TYPE_AUTO }, + { "egl", FF_OPENGL_TYPE_EGL }, + { "glx", FF_OPENGL_TYPE_GLX }, + { "osmesa", FF_OPENGL_TYPE_OSMESA }, + {} + }); + #endif + + return false; +} + +void ffDestroyOpenGLOptions(FFOpenGLOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module) +{ + FFOpenGLOptions __attribute__((__cleanup__(ffDestroyOpenGLOptions))) options; + ffInitOpenGLOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + #if defined(__linux__) || defined(__FreeBSD__) + if (strcasecmp(key, "type") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "auto", FF_OPENGL_TYPE_AUTO }, + { "egl", FF_OPENGL_TYPE_EGL }, + { "glx", FF_OPENGL_TYPE_GLX }, + { "osmesa", FF_OPENGL_TYPE_OSMESA }, + {}, + }); + if (error) + ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + else + options.type = (FFOpenGLType) value; + continue; + } + #endif + + ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintOpenGL(instance, &options); +} +#endif diff --git a/src/modules/opengl/opengl.h b/src/modules/opengl/opengl.h new file mode 100644 index 000000000..d2322addf --- /dev/null +++ b/src/modules/opengl/opengl.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_OPENGL_MODULE_NAME "OpenGL" + +void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options); +void ffInitOpenGLOptions(FFOpenGLOptions* options); +bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value); +void ffDestroyOpenGLOptions(FFOpenGLOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/opengl/option.h b/src/modules/opengl/option.h new file mode 100644 index 000000000..72e29c980 --- /dev/null +++ b/src/modules/opengl/option.h @@ -0,0 +1,25 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +#if defined(__linux__) || defined(__FreeBSD__) +typedef enum FFOpenGLType +{ + FF_OPENGL_TYPE_AUTO, + FF_OPENGL_TYPE_EGL, + FF_OPENGL_TYPE_GLX, + FF_OPENGL_TYPE_OSMESA +} FFOpenGLType; +#endif + +typedef struct FFOpenGLOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + #if defined(__linux__) || defined(__FreeBSD__) + FFOpenGLType type; + #endif +} FFOpenGLOptions; diff --git a/src/modules/options.h b/src/modules/options.h index 40cef1062..fa40194dc 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -25,6 +25,7 @@ #include "modules/locale/option.h" #include "modules/localip/option.h" #include "modules/memory/option.h" +#include "modules/opengl/option.h" #include "modules/os/option.h" #include "modules/packages/option.h" #include "modules/poweradapter/option.h" From 692dd841e36a192f673ae8eb6efb79715d2c1156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 15:10:44 +0800 Subject: [PATCH 062/493] OpenCL: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/opencl.c | 39 -------------- src/modules/opencl/opencl.c | 81 +++++++++++++++++++++++++++++ src/modules/opencl/opencl.h | 15 ++++++ src/modules/opencl/option.h | 11 ++++ src/modules/options.h | 1 + 12 files changed, 118 insertions(+), 48 deletions(-) delete mode 100644 src/modules/opencl.c create mode 100644 src/modules/opencl/opencl.c create mode 100644 src/modules/opencl/opencl.h create mode 100644 src/modules/opencl/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 41a6aa113..47e2fd6af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,7 +287,7 @@ set(LIBFASTFETCH_SRC src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c - src/modules/opencl.c + src/modules/opencl/opencl.c src/modules/opengl/opengl.c src/modules/os/os.c src/modules/packages/packages.c diff --git a/src/common/init.c b/src/common/init.c index a96984042..c5e9fbf60 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -99,7 +99,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.vulkan); ffInitWallpaperOptions(&instance->config.wallpaper); ffInitOpenGLOptions(&instance->config.openGL); - initModuleArg(&instance->config.openCL); + ffInitOpenCLOptions(&instance->config.openCL); initModuleArg(&instance->config.users); ffInitBluetoothOptions(&instance->config.bluetooth); ffInitSoundOptions(&instance->config.sound); @@ -318,7 +318,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyDateTimeOptions(&instance->config.dateTime); destroyModuleArg(&instance->config.vulkan); ffDestroyOpenGLOptions(&instance->config.openGL); - destroyModuleArg(&instance->config.openCL); + ffDestroyOpenCLOptions(&instance->config.openCL); destroyModuleArg(&instance->config.users); ffDestroyBluetoothOptions(&instance->config.bluetooth); ffDestroySeparatorOptions(&instance->config.separator); diff --git a/src/fastfetch.c b/src/fastfetch.c index 1ae686a41..d7fb796a8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1016,7 +1016,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} else if(optionParseModuleArgs(key, value, "vulkan", &instance->config.vulkan)) {} else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} - else if(optionParseModuleArgs(key, value, "opencl", &instance->config.openCL)) {} + else if(ffParseOpenCLCommandOptions(&instance->config.openCL, key, value)) {} else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} @@ -1242,8 +1242,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintVulkan(instance); else if(strcasecmp(line, FF_OPENGL_MODULE_NAME) == 0) ffPrintOpenGL(instance, &instance->config.openGL); - else if(strcasecmp(line, "opencl") == 0) - ffPrintOpenCL(instance); + else if(strcasecmp(line, FF_OPENCL_MODULE_NAME) == 0) + ffPrintOpenCL(instance, &instance->config.openCL); else if(strcasecmp(line, "users") == 0) ffPrintUsers(instance); else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index a7d9f90c6..50dcc11d9 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -90,7 +90,7 @@ typedef struct FFconfig FFDateTimeOptions dateTime; FFModuleArgs vulkan; FFOpenGLOptions openGL; - FFModuleArgs openCL; + FFOpenCLOptions openCL; FFModuleArgs users; FFBluetoothOptions bluetooth; FFSeparatorOptions separator; @@ -196,7 +196,6 @@ void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintColors(FFinstance* instance); void ffPrintVulkan(FFinstance* instance); -void ffPrintOpenCL(FFinstance* instance); void ffPrintUsers(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index bd876fb9c..74ebbeb53 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -62,7 +62,7 @@ int main(int argc, char** argv) //ffPrintTime(&instance); //ffPrintVulkan(&instance); //ffPrintOpenGL(&instance, &instance.config.openGL); - //ffPrintOpenCL(&instance); + //ffPrintOpenCL(&instance, &instance.config.openCL); //ffPrintUsers(&instance); //ffPrintWeather(&instance); //ffPrintBluetooth(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index d6f4a6060..b3f24d48d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -103,6 +103,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'O': { return + tryModule(instance, type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || tryModule(instance, type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || false; diff --git a/src/modules/modules.h b/src/modules/modules.h index e05b959a2..990d190b2 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -28,6 +28,7 @@ #include "modules/localip/localip.h" #include "modules/memory/memory.h" #include "modules/opengl/opengl.h" +#include "modules/opencl/opencl.h" #include "modules/os/os.h" #include "modules/packages/packages.h" #include "modules/poweradapter/poweradapter.h" diff --git a/src/modules/opencl.c b/src/modules/opencl.c deleted file mode 100644 index c9d33b10d..000000000 --- a/src/modules/opencl.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/opencl/opencl.h" - -#define FF_OPENCL_MODULE_NAME "OpenCL" -#define FF_OPENCL_NUM_FORMAT_ARGS 3 - -void ffPrintOpenCL(FFinstance* instance) -{ - FFOpenCLResult opencl; - ffStrbufInit(&opencl.version); - ffStrbufInit(&opencl.device); - ffStrbufInit(&opencl.vendor); - - const char* error = ffDetectOpenCL(instance, &opencl); - - if(error != NULL) - ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL, "%s", error); - else - { - if(instance->config.openCL.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL.key); - ffStrbufPutTo(&opencl.version, stdout); - } - else - { - ffPrintFormat(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version}, - {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device}, - {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor}, - }); - } - } - - ffStrbufDestroy(&opencl.version); - ffStrbufDestroy(&opencl.device); - ffStrbufDestroy(&opencl.vendor); -} diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c new file mode 100644 index 000000000..169aaec7f --- /dev/null +++ b/src/modules/opencl/opencl.c @@ -0,0 +1,81 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/opencl/opencl.h" +#include "modules/opencl/opencl.h" + +#define FF_OPENCL_NUM_FORMAT_ARGS 3 + +void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options) +{ + FFOpenCLResult opencl; + ffStrbufInit(&opencl.version); + ffStrbufInit(&opencl.device); + ffStrbufInit(&opencl.vendor); + + const char* error = ffDetectOpenCL(instance, &opencl); + + if(error != NULL) + ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + else + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&opencl.version, stdout); + } + else + { + ffPrintFormat(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version}, + {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device}, + {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor}, + }); + } + } + + ffStrbufDestroy(&opencl.version); + ffStrbufDestroy(&opencl.device); + ffStrbufDestroy(&opencl.vendor); +} + +void ffInitOpenCLOptions(FFOpenCLOptions* options) +{ + options->moduleName = FF_OPENCL_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_OPENCL_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyOpenCLOptions(FFOpenCLOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module) +{ + FFOpenCLOptions __attribute__((__cleanup__(ffDestroyOpenCLOptions))) options; + ffInitOpenCLOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintOpenCL(instance, &options); +} +#endif diff --git a/src/modules/opencl/opencl.h b/src/modules/opencl/opencl.h new file mode 100644 index 000000000..21843c41d --- /dev/null +++ b/src/modules/opencl/opencl.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_OPENCL_MODULE_NAME "OpenCL" + +void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options); +void ffInitOpenCLOptions(FFOpenCLOptions* options); +bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value); +void ffDestroyOpenCLOptions(FFOpenCLOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/opencl/option.h b/src/modules/opencl/option.h new file mode 100644 index 000000000..addac5245 --- /dev/null +++ b/src/modules/opencl/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFOpenCLOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFOpenCLOptions; diff --git a/src/modules/options.h b/src/modules/options.h index fa40194dc..5a5d9fb4a 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -26,6 +26,7 @@ #include "modules/localip/option.h" #include "modules/memory/option.h" #include "modules/opengl/option.h" +#include "modules/opencl/option.h" #include "modules/os/option.h" #include "modules/packages/option.h" #include "modules/poweradapter/option.h" From 748a67d47a4477fbcb54687c3f70a8877cd6721a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 15:16:09 +0800 Subject: [PATCH 063/493] Vulkan: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 6 ++ src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/vulkan.c | 43 --------------- src/modules/vulkan/option.h | 11 ++++ src/modules/vulkan/vulkan.c | 85 +++++++++++++++++++++++++++++ src/modules/vulkan/vulkan.h | 15 +++++ 12 files changed, 127 insertions(+), 52 deletions(-) delete mode 100644 src/modules/vulkan.c create mode 100644 src/modules/vulkan/option.h create mode 100644 src/modules/vulkan/vulkan.c create mode 100644 src/modules/vulkan/vulkan.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 47e2fd6af..80f5d4b97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -307,7 +307,7 @@ set(LIBFASTFETCH_SRC src/modules/title/title.c src/modules/uptime/uptime.c src/modules/users.c - src/modules/vulkan.c + src/modules/vulkan/vulkan.c src/modules/wallpaper/wallpaper.c src/modules/weather.c src/modules/wifi/wifi.c diff --git a/src/common/init.c b/src/common/init.c index c5e9fbf60..6113f56b1 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -96,7 +96,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.player); initModuleArg(&instance->config.media); ffInitDateTimeOptions(&instance->config.dateTime); - initModuleArg(&instance->config.vulkan); + ffInitVulkanOptions(&instance->config.vulkan); ffInitWallpaperOptions(&instance->config.wallpaper); ffInitOpenGLOptions(&instance->config.openGL); ffInitOpenCLOptions(&instance->config.openCL); @@ -316,7 +316,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.player); destroyModuleArg(&instance->config.media); ffDestroyDateTimeOptions(&instance->config.dateTime); - destroyModuleArg(&instance->config.vulkan); + ffDestroyVulkanOptions(&instance->config.vulkan); ffDestroyOpenGLOptions(&instance->config.openGL); ffDestroyOpenCLOptions(&instance->config.openCL); destroyModuleArg(&instance->config.users); diff --git a/src/fastfetch.c b/src/fastfetch.c index d7fb796a8..0e0994b29 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1014,7 +1014,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {} else if(optionParseModuleArgs(key, value, "media", &instance->config.media)) {} else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} - else if(optionParseModuleArgs(key, value, "vulkan", &instance->config.vulkan)) {} + else if(ffParseVulkanCommandOptions(&instance->config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} else if(ffParseOpenCLCommandOptions(&instance->config.openCL, key, value)) {} else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} @@ -1238,8 +1238,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintDateTime(instance, &instance->config.dateTime); else if(strcasecmp(line, FF_COLORS_MODULE_NAME) == 0) ffPrintColors(instance); - else if(strcasecmp(line, "vulkan") == 0) - ffPrintVulkan(instance); + else if(strcasecmp(line, FF_VULKAN_MODULE_NAME) == 0) + ffPrintVulkan(instance, &instance->config.vulkan); else if(strcasecmp(line, FF_OPENGL_MODULE_NAME) == 0) ffPrintOpenGL(instance, &instance->config.openGL); else if(strcasecmp(line, FF_OPENCL_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 50dcc11d9..f40833a9a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -88,7 +88,7 @@ typedef struct FFconfig FFModuleArgs player; FFModuleArgs media; FFDateTimeOptions dateTime; - FFModuleArgs vulkan; + FFVulkanOptions vulkan; FFOpenGLOptions openGL; FFOpenCLOptions openCL; FFModuleArgs users; @@ -195,7 +195,6 @@ void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintColors(FFinstance* instance); -void ffPrintVulkan(FFinstance* instance); void ffPrintUsers(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index 74ebbeb53..e17cef0a3 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -60,7 +60,7 @@ int main(int argc, char** argv) //ffPrintDateTime(&instance); //ffPrintDate(&instance); //ffPrintTime(&instance); - //ffPrintVulkan(&instance); + //ffPrintVulkan(&instance, &instance.config.vulkan); //ffPrintOpenGL(&instance, &instance.config.openGL); //ffPrintOpenCL(&instance, &instance.config.openCL); //ffPrintUsers(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index b3f24d48d..d5fc55ea2 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -139,6 +139,12 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o false; } + case 'V': { + return + tryModule(instance, type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) || + false; + } + case 'W': { return tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 990d190b2..6f80f8bdf 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -41,6 +41,7 @@ #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" +#include "modules/vulkan/vulkan.h" #include "modules/wallpaper/wallpaper.h" #include "modules/wifi/wifi.h" #include "modules/wm/wm.h" diff --git a/src/modules/options.h b/src/modules/options.h index 5a5d9fb4a..c591a3953 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -38,6 +38,7 @@ #include "modules/terminalfont/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" +#include "modules/vulkan/option.h" #include "modules/wallpaper/option.h" #include "modules/wifi/option.h" #include "modules/wm/option.h" diff --git a/src/modules/vulkan.c b/src/modules/vulkan.c deleted file mode 100644 index 23c6f60df..000000000 --- a/src/modules/vulkan.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/vulkan/vulkan.h" - -#define FF_VULKAN_MODULE_NAME "Vulkan" -#define FF_VULKAN_NUM_FORMAT_ARGS 3 - -void ffPrintVulkan(FFinstance* instance) -{ - const FFVulkanResult* vulkan = ffDetectVulkan(instance); - - if(vulkan->error) - { - ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &instance->config.vulkan, "%s", vulkan->error); - return; - } - - if(instance->config.vulkan.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &instance->config.vulkan.key); - - if(vulkan->apiVersion.length > 0) - { - ffStrbufWriteTo(&vulkan->apiVersion, stdout); - - if(vulkan->driver.length > 0) - fputs(" - ", stdout); - } - - if(vulkan->driver.length > 0) - ffStrbufWriteTo(&vulkan->driver, stdout); - - putchar('\n'); - } - else - { - ffPrintFormat(instance, FF_VULKAN_MODULE_NAME, 0, &instance->config.vulkan, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->driver}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion} - }); - } -} diff --git a/src/modules/vulkan/option.h b/src/modules/vulkan/option.h new file mode 100644 index 000000000..c5efd077b --- /dev/null +++ b/src/modules/vulkan/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFVulkanOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFVulkanOptions; diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c new file mode 100644 index 000000000..a33c40553 --- /dev/null +++ b/src/modules/vulkan/vulkan.c @@ -0,0 +1,85 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/vulkan/vulkan.h" +#include "modules/vulkan/vulkan.h" + +#define FF_VULKAN_NUM_FORMAT_ARGS 3 + +void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options) +{ + const FFVulkanResult* vulkan = ffDetectVulkan(instance); + + if(vulkan->error) + { + ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key); + + if(vulkan->apiVersion.length > 0) + { + ffStrbufWriteTo(&vulkan->apiVersion, stdout); + + if(vulkan->driver.length > 0) + fputs(" - ", stdout); + } + + if(vulkan->driver.length > 0) + ffStrbufWriteTo(&vulkan->driver, stdout); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->driver}, + {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion} + }); + } +} + +void ffInitVulkanOptions(FFVulkanOptions* options) +{ + options->moduleName = FF_VULKAN_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseVulkanCommandOptions(FFVulkanOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_VULKAN_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyVulkanOptions(FFVulkanOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseVulkanJsonObject(FFinstance* instance, json_object* module) +{ + FFVulkanOptions __attribute__((__cleanup__(ffDestroyVulkanOptions))) options; + ffInitVulkanOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintVulkan(instance, &options); +} +#endif diff --git a/src/modules/vulkan/vulkan.h b/src/modules/vulkan/vulkan.h new file mode 100644 index 000000000..04145d678 --- /dev/null +++ b/src/modules/vulkan/vulkan.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_VULKAN_MODULE_NAME "Vulkan" + +void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options); +void ffInitVulkanOptions(FFVulkanOptions* options); +bool ffParseVulkanCommandOptions(FFVulkanOptions* options, const char* key, const char* value); +void ffDestroyVulkanOptions(FFVulkanOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseVulkanJsonObject(FFinstance* instance, json_object* module); +#endif From 969c787ff8250dd68e2a6859a6a22b8ac1b8ee2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 15:23:01 +0800 Subject: [PATCH 064/493] Users: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/users.c | 43 --------------- src/modules/users/option.h | 11 ++++ src/modules/users/users.c | 85 +++++++++++++++++++++++++++++ src/modules/users/users.h | 15 +++++ 12 files changed, 122 insertions(+), 52 deletions(-) delete mode 100644 src/modules/users.c create mode 100644 src/modules/users/option.h create mode 100644 src/modules/users/users.c create mode 100644 src/modules/users/users.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f5d4b97..329c1dfc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ set(LIBFASTFETCH_SRC src/modules/theme.c src/modules/title/title.c src/modules/uptime/uptime.c - src/modules/users.c + src/modules/users/users.c src/modules/vulkan/vulkan.c src/modules/wallpaper/wallpaper.c src/modules/weather.c diff --git a/src/common/init.c b/src/common/init.c index 6113f56b1..bc9dbb11d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -100,7 +100,7 @@ static void defaultConfig(FFinstance* instance) ffInitWallpaperOptions(&instance->config.wallpaper); ffInitOpenGLOptions(&instance->config.openGL); ffInitOpenCLOptions(&instance->config.openCL); - initModuleArg(&instance->config.users); + ffInitUsersOptions(&instance->config.users); ffInitBluetoothOptions(&instance->config.bluetooth); ffInitSoundOptions(&instance->config.sound); ffInitSeparatorOptions(&instance->config.separator); @@ -319,7 +319,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyVulkanOptions(&instance->config.vulkan); ffDestroyOpenGLOptions(&instance->config.openGL); ffDestroyOpenCLOptions(&instance->config.openCL); - destroyModuleArg(&instance->config.users); + ffDestroyUsersOptions(&instance->config.users); ffDestroyBluetoothOptions(&instance->config.bluetooth); ffDestroySeparatorOptions(&instance->config.separator); ffDestroySoundOptions(&instance->config.sound); diff --git a/src/fastfetch.c b/src/fastfetch.c index 0e0994b29..0622c78f4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1017,7 +1017,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseVulkanCommandOptions(&instance->config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} else if(ffParseOpenCLCommandOptions(&instance->config.openCL, key, value)) {} - else if(optionParseModuleArgs(key, value, "users", &instance->config.users)) {} + else if(ffParseUsersCommandOptions(&instance->config.users, key, value)) {} else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(ffParseSoundCommandOptions(&instance->config.sound, key, value)) {} @@ -1244,8 +1244,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintOpenGL(instance, &instance->config.openGL); else if(strcasecmp(line, FF_OPENCL_MODULE_NAME) == 0) ffPrintOpenCL(instance, &instance->config.openCL); - else if(strcasecmp(line, "users") == 0) - ffPrintUsers(instance); + else if(strcasecmp(line, FF_USERS_MODULE_NAME) == 0) + ffPrintUsers(instance, &instance->config.users); else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0) ffPrintCommand(instance, &instance->config.command); else if(strcasecmp(line, FF_BLUETOOTH_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index f40833a9a..9bdb73797 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -91,7 +91,7 @@ typedef struct FFconfig FFVulkanOptions vulkan; FFOpenGLOptions openGL; FFOpenCLOptions openCL; - FFModuleArgs users; + FFUsersOptions users; FFBluetoothOptions bluetooth; FFSeparatorOptions separator; FFSoundOptions sound; @@ -195,6 +195,5 @@ void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); void ffPrintColors(FFinstance* instance); -void ffPrintUsers(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index e17cef0a3..dd11217a1 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -63,7 +63,7 @@ int main(int argc, char** argv) //ffPrintVulkan(&instance, &instance.config.vulkan); //ffPrintOpenGL(&instance, &instance.config.openGL); //ffPrintOpenCL(&instance, &instance.config.openCL); - //ffPrintUsers(&instance); + //ffPrintUsers(&instance, &instance.config.users); //ffPrintWeather(&instance); //ffPrintBluetooth(&instance); //ffPrintSound(&instance, &instance.config.sound); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index d5fc55ea2..852ea6c8e 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -136,6 +136,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'U': { return tryModule(instance, type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || + tryModule(instance, type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 6f80f8bdf..2c893f5a6 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -41,6 +41,7 @@ #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" +#include "modules/users/users.h" #include "modules/vulkan/vulkan.h" #include "modules/wallpaper/wallpaper.h" #include "modules/wifi/wifi.h" diff --git a/src/modules/options.h b/src/modules/options.h index c591a3953..142aaebf8 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -38,6 +38,7 @@ #include "modules/terminalfont/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" +#include "modules/users/option.h" #include "modules/vulkan/option.h" #include "modules/wallpaper/option.h" #include "modules/wifi/option.h" diff --git a/src/modules/users.c b/src/modules/users.c deleted file mode 100644 index 87503d56b..000000000 --- a/src/modules/users.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/users/users.h" - -#define FF_USERS_MODULE_NAME "Users" -#define FF_USERS_NUM_FORMAT_ARGS 1 - -void ffPrintUsers(FFinstance* instance) -{ - FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf)); - - FF_STRBUF_AUTO_DESTROY error = ffStrbufCreate(); - - ffDetectUsers(&users, &error); - - if(error.length > 0) - { - ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &instance->config.users, "%*s", error.length, error.chars); - return; - } - - FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); - for(uint32_t i = 0; i < users.length; ++i) - { - if(i > 0) - ffStrbufAppendS(&result, ", "); - FFstrbuf* user = (FFstrbuf*)ffListGet(&users, i); - ffStrbufAppend(&result, user); - ffStrbufDestroy(user); - } - - if(instance->config.users.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &instance->config.users.key); - puts(result.chars); - } - else - { - ffPrintFormat(instance, FF_USERS_MODULE_NAME, 0, &instance->config.users, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result}, - }); - } -} diff --git a/src/modules/users/option.h b/src/modules/users/option.h new file mode 100644 index 000000000..f7f0b099e --- /dev/null +++ b/src/modules/users/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFUsersOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFUsersOptions; diff --git a/src/modules/users/users.c b/src/modules/users/users.c new file mode 100644 index 000000000..82698d6a8 --- /dev/null +++ b/src/modules/users/users.c @@ -0,0 +1,85 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/users/users.h" +#include "modules/users/users.h" + +#define FF_USERS_NUM_FORMAT_ARGS 1 + +void ffPrintUsers(FFinstance* instance, FFUsersOptions* options) +{ + FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf)); + + FF_STRBUF_AUTO_DESTROY error = ffStrbufCreate(); + + ffDetectUsers(&users, &error); + + if(error.length > 0) + { + ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%*s", error.length, error.chars); + return; + } + + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); + for(uint32_t i = 0; i < users.length; ++i) + { + if(i > 0) + ffStrbufAppendS(&result, ", "); + FFstrbuf* user = (FFstrbuf*)ffListGet(&users, i); + ffStrbufAppend(&result, user); + ffStrbufDestroy(user); + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key); + puts(result.chars); + } + else + { + ffPrintFormat(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result}, + }); + } +} + +void ffInitUsersOptions(FFUsersOptions* options) +{ + options->moduleName = FF_USERS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseUsersCommandOptions(FFUsersOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_USERS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyUsersOptions(FFUsersOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseUsersJsonObject(FFinstance* instance, json_object* module) +{ + FFUsersOptions __attribute__((__cleanup__(ffDestroyUsersOptions))) options; + ffInitUsersOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintUsers(instance, &options); +} +#endif diff --git a/src/modules/users/users.h b/src/modules/users/users.h new file mode 100644 index 000000000..233391f17 --- /dev/null +++ b/src/modules/users/users.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_USERS_MODULE_NAME "Users" + +void ffPrintUsers(FFinstance* instance, FFUsersOptions* options); +void ffInitUsersOptions(FFUsersOptions* options); +bool ffParseUsersCommandOptions(FFUsersOptions* options, const char* key, const char* value); +void ffDestroyUsersOptions(FFUsersOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseUsersJsonObject(FFinstance* instance, json_object* module); +#endif From 0adecd3cb06462535366608544913fad24a1c285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 15:23:12 +0800 Subject: [PATCH 065/493] Fastfetch: remove a useless function definition --- src/fastfetch.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fastfetch.h b/src/fastfetch.h index 9bdb73797..16c496657 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -194,6 +194,5 @@ void ffPrintPlayer(FFinstance* instance); void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); -void ffPrintColors(FFinstance* instance); #endif From fde86657f28698a7ca43a98f5faf79940a93d15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 16:10:14 +0800 Subject: [PATCH 066/493] Media: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/{ => media}/media.c | 60 ++++++++++++++++++++++++----- src/modules/media/media.h | 15 ++++++++ src/modules/media/option.h | 11 ++++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 11 files changed, 88 insertions(+), 18 deletions(-) rename src/modules/{ => media}/media.c (62%) create mode 100644 src/modules/media/media.h create mode 100644 src/modules/media/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 329c1dfc0..e2853d537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,7 +300,7 @@ set(LIBFASTFETCH_SRC src/modules/shell/shell.c src/modules/sound/sound.c src/modules/swap/swap.c - src/modules/media.c + src/modules/media/media.c src/modules/terminal/terminal.c src/modules/terminalfont/terminalfont.c src/modules/theme.c diff --git a/src/common/init.c b/src/common/init.c index bc9dbb11d..55167ad97 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -94,7 +94,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.weather); ffInitWifiOptions(&instance->config.wifi); initModuleArg(&instance->config.player); - initModuleArg(&instance->config.media); + ffInitMediaOptions(&instance->config.media); ffInitDateTimeOptions(&instance->config.dateTime); ffInitVulkanOptions(&instance->config.vulkan); ffInitWallpaperOptions(&instance->config.wallpaper); @@ -314,7 +314,7 @@ static void destroyConfig(FFinstance* instance) destroyModuleArg(&instance->config.weather); ffDestroyWifiOptions(&instance->config.wifi); destroyModuleArg(&instance->config.player); - destroyModuleArg(&instance->config.media); + ffDestroyMediaOptions(&instance->config.media); ffDestroyDateTimeOptions(&instance->config.dateTime); ffDestroyVulkanOptions(&instance->config.vulkan); ffDestroyOpenGLOptions(&instance->config.openGL); diff --git a/src/fastfetch.c b/src/fastfetch.c index 0622c78f4..89f692119 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1012,7 +1012,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {} - else if(optionParseModuleArgs(key, value, "media", &instance->config.media)) {} + else if(ffParseMediaCommandOptions(&instance->config.media, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance->config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} @@ -1232,8 +1232,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintWeather(instance); else if(strcasecmp(line, "player") == 0) ffPrintPlayer(instance); - else if(strcasecmp(line, "media") == 0) - ffPrintMedia(instance); + else if(strcasecmp(line, FF_MEDIA_MODULE_NAME) == 0) + ffPrintMedia(instance, &instance->config.media); else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) ffPrintDateTime(instance, &instance->config.dateTime); else if(strcasecmp(line, FF_COLORS_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 16c496657..3c17da838 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -86,7 +86,7 @@ typedef struct FFconfig FFModuleArgs publicIP; FFModuleArgs weather; FFModuleArgs player; - FFModuleArgs media; + FFMediaOptions media; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; FFOpenGLOptions openGL; @@ -191,7 +191,6 @@ void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintTheme(FFinstance* instance); void ffPrintPlayer(FFinstance* instance); -void ffPrintMedia(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index dd11217a1..4a286181a 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -51,7 +51,7 @@ int main(int argc, char** argv) ffPrintBattery(&instance, &instance.config.battery); ffPrintPowerAdapter(&instance, &instance.config.powerAdapter); //ffPrintPlayer(&instance); - //ffPrintMedia(&instance); + //ffPrintMedia(&instance, &instance.config.media); //ffPrintLocalIp(&instance); //ffPrintPublicIp(&instance); //ffPrintWifi(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 852ea6c8e..489d7f718 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -97,6 +97,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'M': { return + tryModule(instance, type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || tryModule(instance, type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || false; } diff --git a/src/modules/media.c b/src/modules/media/media.c similarity index 62% rename from src/modules/media.c rename to src/modules/media/media.c index 74be335e0..9021aaf7c 100644 --- a/src/modules/media.c +++ b/src/modules/media/media.c @@ -1,13 +1,13 @@ #include "fastfetch.h" #include "common/printing.h" #include "detection/media/media.h" +#include "modules/media/media.h" #include -#define FF_MEDIA_MODULE_NAME "Media" #define FF_MEDIA_NUM_FORMAT_ARGS 5 -static bool shouldIgoreChar(char c) +static inline bool shouldIgnoreChar(char c) { return isblank(c) || c == '-' || c == '.'; } @@ -19,10 +19,10 @@ static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist) while(true) { - while(shouldIgoreChar(song->chars[songIndex])) + while(shouldIgnoreChar(song->chars[songIndex])) ++songIndex; - while(shouldIgoreChar(artist->chars[artistIndex])) + while(shouldIgnoreChar(artist->chars[artistIndex])) ++artistIndex; if(artist->chars[artistIndex] == '\0') @@ -42,13 +42,13 @@ static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist) return false; } -void ffPrintMedia(FFinstance* instance) +void ffPrintMedia(FFinstance* instance, FFMediaOptions* options) { const FFMediaResult* media = ffDetectMedia(instance); if(media->error.length > 0) { - ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &instance->config.media, "%s", media->error.chars); + ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars); return; } @@ -68,7 +68,7 @@ void ffPrintMedia(FFinstance* instance) if(songPretty.length == 0) ffStrbufAppend(&songPretty, &media->song); - if(instance->config.media.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { //We don't expose artistPretty to the format, as it might be empty (when the think that the artist is already in the song title) FF_STRBUF_AUTO_DESTROY artistPretty = ffStrbufCreateCopy(&media->artist); @@ -79,7 +79,7 @@ void ffPrintMedia(FFinstance* instance) if(artistInSongTitle(&songPretty, &artistPretty)) ffStrbufClear(&artistPretty); - ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &instance->config.media.key); + ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key); if(artistPretty.length > 0) { @@ -94,7 +94,7 @@ void ffPrintMedia(FFinstance* instance) } else { - ffPrintFormat(instance, FF_MEDIA_MODULE_NAME, 0, &instance->config.media, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &songPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->song}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->artist}, @@ -103,3 +103,45 @@ void ffPrintMedia(FFinstance* instance) }); } } + +void ffInitMediaOptions(FFMediaOptions* options) +{ + options->moduleName = FF_MEDIA_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_MEDIA_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyMediaOptions(FFMediaOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseMediaJsonObject(FFinstance* instance, json_object* module) +{ + FFMediaOptions __attribute__((__cleanup__(ffDestroyMediaOptions))) options; + ffInitMediaOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintMedia(instance, &options); +} +#endif diff --git a/src/modules/media/media.h b/src/modules/media/media.h new file mode 100644 index 000000000..59c6cbb42 --- /dev/null +++ b/src/modules/media/media.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_MEDIA_MODULE_NAME "Media" + +void ffPrintMedia(FFinstance* instance, FFMediaOptions* options); +void ffInitMediaOptions(FFMediaOptions* options); +bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value); +void ffDestroyMediaOptions(FFMediaOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseMediaJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/media/option.h b/src/modules/media/option.h new file mode 100644 index 000000000..8498c6e9b --- /dev/null +++ b/src/modules/media/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFMediaOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFMediaOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index 2c893f5a6..2966d52c1 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -26,6 +26,7 @@ #include "modules/kernel/kernel.h" #include "modules/locale/locale.h" #include "modules/localip/localip.h" +#include "modules/media/media.h" #include "modules/memory/memory.h" #include "modules/opengl/opengl.h" #include "modules/opencl/opencl.h" diff --git a/src/modules/options.h b/src/modules/options.h index 142aaebf8..e20258d2d 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -24,6 +24,7 @@ #include "modules/kernel/option.h" #include "modules/locale/option.h" #include "modules/localip/option.h" +#include "modules/media/option.h" #include "modules/memory/option.h" #include "modules/opengl/option.h" #include "modules/opencl/option.h" From a4a801d83ad8e4c42a56289eb3a41f849029972a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 Jun 2023 16:19:07 +0800 Subject: [PATCH 067/493] Player: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 7 +--- src/detection/media/media_linux.c | 8 ++-- src/fastfetch.c | 8 ++-- src/fastfetch.h | 5 +-- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/player/option.h | 13 +++++++ src/modules/{ => player}/player.c | 59 ++++++++++++++++++++++++++--- src/modules/player/player.h | 16 ++++++++ 12 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 src/modules/player/option.h rename src/modules/{ => player}/player.c (55%) create mode 100644 src/modules/player/player.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e2853d537..8d7b52cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,8 +291,8 @@ set(LIBFASTFETCH_SRC src/modules/opengl/opengl.c src/modules/os/os.c src/modules/packages/packages.c - src/modules/player.c src/modules/processes.c + src/modules/player/player.c src/modules/poweradapter/poweradapter.c src/modules/publicip.c src/modules/display/display.c diff --git a/src/common/init.c b/src/common/init.c index 55167ad97..fe8388384 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -93,7 +93,7 @@ static void defaultConfig(FFinstance* instance) initModuleArg(&instance->config.publicIP); initModuleArg(&instance->config.weather); ffInitWifiOptions(&instance->config.wifi); - initModuleArg(&instance->config.player); + ffInitPlayerOptions(&instance->config.player); ffInitMediaOptions(&instance->config.media); ffInitDateTimeOptions(&instance->config.dateTime); ffInitVulkanOptions(&instance->config.vulkan); @@ -138,8 +138,6 @@ static void defaultConfig(FFinstance* instance) instance->config.weatherTimeout = 0; ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)"); - ffStrbufInit(&instance->config.playerName); - instance->config.percentType = 1; } @@ -313,7 +311,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyWallpaperOptions(&instance->config.wallpaper); destroyModuleArg(&instance->config.weather); ffDestroyWifiOptions(&instance->config.wifi); - destroyModuleArg(&instance->config.player); + ffDestroyPlayerOptions(&instance->config.player); ffDestroyMediaOptions(&instance->config.media); ffDestroyDateTimeOptions(&instance->config.dateTime); ffDestroyVulkanOptions(&instance->config.vulkan); @@ -353,7 +351,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); - ffStrbufDestroy(&instance->config.playerName); } static void destroyState(FFinstance* instance) diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index f4e8c9ea2..23564588a 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -101,14 +101,14 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul static void getCustomBus(FFDBusData* data, const FFinstance* instance, FFMediaResult* result) { - if(ffStrbufStartsWithS(&instance->config.playerName, FF_DBUS_MPRIS_PREFIX)) + if(ffStrbufStartsWithS(&instance->config.player.name, FF_DBUS_MPRIS_PREFIX)) { - getBusProperties(data, instance->config.playerName.chars, result); + getBusProperties(data, instance->config.player.name.chars, result); return; } FF_STRBUF_AUTO_DESTROY busName = ffStrbufCreateS(FF_DBUS_MPRIS_PREFIX); - ffStrbufAppend(&busName, &instance->config.playerName); + ffStrbufAppend(&busName, &instance->config.player.name); getBusProperties(data, busName.chars, result); } @@ -158,7 +158,7 @@ static const char* getMedia(const FFinstance* instance, FFMediaResult* result) if(error != NULL) return error; - if(instance->config.playerName.length > 0) + if(instance->config.player.name.length > 0) getCustomBus(&data, instance, result); else getBestBus(&data, result); diff --git a/src/fastfetch.c b/src/fastfetch.c index 89f692119..66672c322 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1011,7 +1011,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} - else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {} + else if(ffParsePlayerCommandOptions(&instance->config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance->config.media, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance->config.vulkan, key, value)) {} @@ -1088,8 +1088,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--player-name") == 0) - optionParseString(key, value, &instance->config.playerName); else if(strcasecmp(key, "--publicip-url") == 0) optionParseString(key, value, &instance->config.publicIpUrl); else if(strcasecmp(key, "--publicip-timeout") == 0) @@ -1230,8 +1228,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintWifi(instance, &instance->config.wifi); else if(strcasecmp(line, "weather") == 0) ffPrintWeather(instance); - else if(strcasecmp(line, "player") == 0) - ffPrintPlayer(instance); + else if(strcasecmp(line, FF_PLAYER_MODULE_NAME) == 0) + ffPrintPlayer(instance, &instance->config.player); else if(strcasecmp(line, FF_MEDIA_MODULE_NAME) == 0) ffPrintMedia(instance, &instance->config.media); else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 3c17da838..606ce08c3 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -85,7 +85,7 @@ typedef struct FFconfig FFLocalIpOptions localIP; FFModuleArgs publicIP; FFModuleArgs weather; - FFModuleArgs player; + FFPlayerOptions player; FFMediaOptions media; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; @@ -129,8 +129,6 @@ typedef struct FFconfig FFstrbuf weatherOutputFormat; uint32_t weatherTimeout; - FFstrbuf playerName; - uint32_t percentType; bool jsonConfig; @@ -190,7 +188,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintTheme(FFinstance* instance); -void ffPrintPlayer(FFinstance* instance); void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); diff --git a/src/flashfetch.c b/src/flashfetch.c index 4a286181a..ec2d209ec 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -50,7 +50,7 @@ int main(int argc, char** argv) ffPrintDisk(&instance, &instance.config.disk); ffPrintBattery(&instance, &instance.config.battery); ffPrintPowerAdapter(&instance, &instance.config.powerAdapter); - //ffPrintPlayer(&instance); + //ffPrintPlayer(&instance, &instance.config.player); //ffPrintMedia(&instance, &instance.config.media); //ffPrintLocalIp(&instance); //ffPrintPublicIp(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index 489d7f718..e056bf218 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -113,6 +113,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'P': { return tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || + tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index 2966d52c1..b31c2af65 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -32,6 +32,7 @@ #include "modules/opencl/opencl.h" #include "modules/os/os.h" #include "modules/packages/packages.h" +#include "modules/player/player.h" #include "modules/poweradapter/poweradapter.h" #include "modules/separator/separator.h" #include "modules/shell/shell.h" diff --git a/src/modules/options.h b/src/modules/options.h index e20258d2d..bd57642ca 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -30,6 +30,7 @@ #include "modules/opencl/option.h" #include "modules/os/option.h" #include "modules/packages/option.h" +#include "modules/player/option.h" #include "modules/poweradapter/option.h" #include "modules/separator/option.h" #include "modules/shell/option.h" diff --git a/src/modules/player/option.h b/src/modules/player/option.h new file mode 100644 index 000000000..8fa057a47 --- /dev/null +++ b/src/modules/player/option.h @@ -0,0 +1,13 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFPlayerOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFstrbuf name; +} FFPlayerOptions; diff --git a/src/modules/player.c b/src/modules/player/player.c similarity index 55% rename from src/modules/player.c rename to src/modules/player/player.c index 6f4ab0df2..f461044a1 100644 --- a/src/modules/player.c +++ b/src/modules/player/player.c @@ -1,19 +1,20 @@ #include "fastfetch.h" #include "common/printing.h" #include "detection/media/media.h" +#include "modules/player/player.h" #include -#define FF_PLAYER_MODULE_NAME "Media Player" +#define FF_PLAYER_DISPLAY_NAME "Media Player" #define FF_PLAYER_NUM_FORMAT_ARGS 4 -void ffPrintPlayer(FFinstance* instance) +void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options) { const FFMediaResult* media = ffDetectMedia(instance); if(media->error.length > 0) { - ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player, "%s", media->error.chars); + ffPrintError(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars); return; } @@ -55,14 +56,14 @@ void ffPrintPlayer(FFinstance* instance) if(playerPrettyIsCustom) ffStrbufAppendC(&playerPretty, ')'); - if(instance->config.player.outputFormat.length == 0) + if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player.key); + ffPrintLogoAndKey(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key); ffStrbufPutTo(&playerPretty, stdout); } else { - ffPrintFormat(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->player}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId}, @@ -70,3 +71,49 @@ void ffPrintPlayer(FFinstance* instance) }); } } + +void ffInitPlayerOptions(FFPlayerOptions* options) +{ + options->moduleName = FF_PLAYER_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + ffStrbufInit(&options->name); +} + +bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PLAYER_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyPlayerOptions(FFPlayerOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + + ffStrbufDestroy(&options->name); +} + +#ifdef FF_HAVE_JSONC +void ffParsePlayerJsonObject(FFinstance* instance, json_object* module) +{ + FFPlayerOptions __attribute__((__cleanup__(ffDestroyPlayerOptions))) options; + ffInitPlayerOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPlayer(instance, &options); +} +#endif diff --git a/src/modules/player/player.h b/src/modules/player/player.h new file mode 100644 index 000000000..9b19d67cd --- /dev/null +++ b/src/modules/player/player.h @@ -0,0 +1,16 @@ + +#pragma once + +#include "fastfetch.h" + +#define FF_PLAYER_MODULE_NAME "Player" + +void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options); +void ffInitPlayerOptions(FFPlayerOptions* options); +bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value); +void ffDestroyPlayerOptions(FFPlayerOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParsePlayerJsonObject(FFinstance* instance, json_object* module); +#endif From 7f9ff587ce8e2b603eb6decb4fd455fefedd4b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 8 Jun 2023 09:41:22 +0800 Subject: [PATCH 068/493] PublicIP: support JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 8 +- src/fastfetch.c | 14 +-- src/fastfetch.h | 7 +- src/flashfetch.c | 4 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/publicip.c | 65 ------------- src/modules/publicip/option.h | 14 +++ src/modules/publicip/publicip.c | 137 ++++++++++++++++++++++++++++ src/modules/publicip/publicip.h | 17 ++++ 12 files changed, 182 insertions(+), 89 deletions(-) delete mode 100644 src/modules/publicip.c create mode 100644 src/modules/publicip/option.h create mode 100644 src/modules/publicip/publicip.c create mode 100644 src/modules/publicip/publicip.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7b52cd2..2d756b71e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,7 +294,7 @@ set(LIBFASTFETCH_SRC src/modules/processes.c src/modules/player/player.c src/modules/poweradapter/poweradapter.c - src/modules/publicip.c + src/modules/publicip/publicip.c src/modules/display/display.c src/modules/separator/separator.c src/modules/shell/shell.c diff --git a/src/common/init.c b/src/common/init.c index fe8388384..20354358c 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -90,7 +90,7 @@ static void defaultConfig(FFinstance* instance) ffInitPowerAdapterOptions(&instance->config.powerAdapter); ffInitLocaleOptions(&instance->config.locale); ffInitLocalIpOptions(&instance->config.localIP); - initModuleArg(&instance->config.publicIP); + ffInitPublicIpOptions(&instance->config.publicIP); initModuleArg(&instance->config.weather); ffInitWifiOptions(&instance->config.wifi); ffInitPlayerOptions(&instance->config.player); @@ -132,9 +132,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.publicIpTimeout = 0; - ffStrbufInit(&instance->config.publicIpUrl); - instance->config.weatherTimeout = 0; ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)"); @@ -307,7 +304,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyPowerAdapterOptions(&instance->config.powerAdapter); ffDestroyLocaleOptions(&instance->config.locale); ffDestroyLocalIpOptions(&instance->config.localIP); - destroyModuleArg(&instance->config.publicIP); + ffDestroyPublicIpOptions(&instance->config.publicIP); ffDestroyWallpaperOptions(&instance->config.wallpaper); destroyModuleArg(&instance->config.weather); ffDestroyWifiOptions(&instance->config.wifi); @@ -349,7 +346,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libwlanapi); ffStrbufDestroy(&instance->config.libnm); - ffStrbufDestroy(&instance->config.publicIpUrl); ffStrbufDestroy(&instance->config.weatherOutputFormat); } diff --git a/src/fastfetch.c b/src/fastfetch.c index 66672c322..1744bd57c 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1009,7 +1009,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParsePowerAdapterCommandOptions(&instance->config.powerAdapter, key, value)) {} else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} - else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {} + else if(ffParsePublicIpCommandOptions(&instance->config.publicIP, key, value)) {} else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} else if(ffParsePlayerCommandOptions(&instance->config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance->config.media, key, value)) {} @@ -1088,10 +1088,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--publicip-url") == 0) - optionParseString(key, value, &instance->config.publicIpUrl); - else if(strcasecmp(key, "--publicip-timeout") == 0) - instance->config.publicIpTimeout = optionParseUInt32(key, value); else if(strcasecmp(key, "--weather-output-format") == 0) optionParseString(key, value, &instance->config.weatherOutputFormat); else if(strcasecmp(key, "--weather-timeout") == 0) @@ -1222,8 +1218,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintLocale(instance, &instance->config.locale); else if(strcasecmp(line, "localip") == 0) ffPrintLocalIp(instance, &instance->config.localIP); - else if(strcasecmp(line, "publicip") == 0) - ffPrintPublicIp(instance); + else if(strcasecmp(line, FF_PUBLICIP_MODULE_NAME) == 0) + ffPrintPublicIp(instance, &instance->config.publicIP); else if(strcasecmp(line, FF_WIFI_MODULE_NAME) == 0) ffPrintWifi(instance, &instance->config.wifi); else if(strcasecmp(line, "weather") == 0) @@ -1281,8 +1277,8 @@ int main(int argc, const char** argv) if(instance.config.multithreading) { - if(ffStrbufContainIgnCaseS(&data.structure, "PublicIp")) - ffPreparePublicIp(&instance); + if(ffStrbufContainIgnCaseS(&data.structure, FF_PUBLICIP_MODULE_NAME)) + ffPreparePublicIp(&instance.config.publicIP); if(ffStrbufContainIgnCaseS(&data.structure, "Weather")) ffPrepareWeather(&instance); diff --git a/src/fastfetch.h b/src/fastfetch.h index 606ce08c3..2c159059f 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -83,7 +83,7 @@ typedef struct FFconfig FFPowerAdapterOptions powerAdapter; FFLocaleOptions locale; FFLocalIpOptions localIP; - FFModuleArgs publicIP; + FFPublicIpOptions publicIP; FFModuleArgs weather; FFPlayerOptions player; FFMediaOptions media; @@ -123,9 +123,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - FFstrbuf publicIpUrl; - uint32_t publicIpTimeout; - FFstrbuf weatherOutputFormat; uint32_t weatherTimeout; @@ -180,7 +177,6 @@ void ffLogoBuiltinListAutocompletion(); //Common -void ffPreparePublicIp(FFinstance* instance); void ffPrepareWeather(FFinstance* instance); //Printing @@ -188,7 +184,6 @@ void ffPrepareWeather(FFinstance* instance); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintTheme(FFinstance* instance); -void ffPrintPublicIp(FFinstance* instance); void ffPrintWeather(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index ec2d209ec..e00d2b48b 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -13,7 +13,7 @@ int main(int argc, char** argv) //Modify instance.config here // ffPrepareCPUUsage(); - // ffPreparePublicIp(&instance); + // ffPreparePublicIp(&instance.config.publicIP); // ffPrepareWeather(&instance); //Does things like starting detection threads, disabling line wrap, etc @@ -53,7 +53,7 @@ int main(int argc, char** argv) //ffPrintPlayer(&instance, &instance.config.player); //ffPrintMedia(&instance, &instance.config.media); //ffPrintLocalIp(&instance); - //ffPrintPublicIp(&instance); + //ffPrintPublicIp(&instance, &instance.config.publicIp); //ffPrintWifi(&instance); //ffPrintCPUUsage(&instance, &instance.config.cpuUsage); ffPrintLocale(&instance, &instance.config.locale); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index e056bf218..c248d0114 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -115,6 +115,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || + tryModule(instance, type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index b31c2af65..b28e1d1e4 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -34,6 +34,7 @@ #include "modules/packages/packages.h" #include "modules/player/player.h" #include "modules/poweradapter/poweradapter.h" +#include "modules/publicip/publicip.h" #include "modules/separator/separator.h" #include "modules/shell/shell.h" #include "modules/sound/sound.h" diff --git a/src/modules/options.h b/src/modules/options.h index bd57642ca..cfdefd52b 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -32,6 +32,7 @@ #include "modules/packages/option.h" #include "modules/player/option.h" #include "modules/poweradapter/option.h" +#include "modules/publicip/option.h" #include "modules/separator/option.h" #include "modules/shell/option.h" #include "modules/sound/option.h" diff --git a/src/modules/publicip.c b/src/modules/publicip.c deleted file mode 100644 index 2483be9d9..000000000 --- a/src/modules/publicip.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "common/networking.h" - -#define FF_PUBLICIP_MODULE_NAME "Public IP" -#define FF_PUBLICIP_NUM_FORMAT_ARGS 1 - -static FFNetworkingState state; -static int status = -1; - -void ffPreparePublicIp(FFinstance* instance) -{ - if(instance->config.publicIpUrl.length == 0) - status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/ip", NULL); - else - { - FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&instance->config.publicIpUrl); - ffStrbufSubstrAfterFirstS(&host, "://"); - uint32_t pathStartIndex = ffStrbufFirstIndexC(&host, '/'); - - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); - if(pathStartIndex != host.length) - { - ffStrbufAppendNS(&path, pathStartIndex, host.chars + (host.length - pathStartIndex)); - host.length = pathStartIndex; - host.chars[pathStartIndex] = '\0'; - } - - status = ffNetworkingSendHttpRequest(&state, host.chars, path.length == 0 ? "/" : path.chars, NULL); - } -} - -void ffPrintPublicIp(FFinstance* instance) -{ - if(status == -1) - ffPreparePublicIp(instance); - - if(status == 0) - { - ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, "Failed to connect to an IP detection server"); - return; - } - - FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); - bool success = ffNetworkingRecvHttpResponse(&state, &result, instance->config.publicIpTimeout); - if(success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); - - if(!success || result.length == 0) - { - ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, "Failed to receive the server response"); - return; - } - - if(instance->config.publicIP.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP.key); - ffStrbufPutTo(&result, stdout); - } - else - { - ffPrintFormat(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result} - }); - } -} diff --git a/src/modules/publicip/option.h b/src/modules/publicip/option.h new file mode 100644 index 000000000..aef383fc5 --- /dev/null +++ b/src/modules/publicip/option.h @@ -0,0 +1,14 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFPublicIpOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFstrbuf url; + uint32_t timeout; +} FFPublicIpOptions; diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c new file mode 100644 index 000000000..a1ebc8819 --- /dev/null +++ b/src/modules/publicip/publicip.c @@ -0,0 +1,137 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "common/networking.h" +#include "modules/publicip/publicip.h" + +#define FF_PUBLICIP_DISPLAY_NAME "Public IP" +#define FF_PUBLICIP_NUM_FORMAT_ARGS 1 + +static FFNetworkingState state; +static int status = -1; + +void ffPreparePublicIp(FFPublicIpOptions* options) +{ + if (options->url.length == 0) + status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/ip", NULL); + else + { + FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&options->url); + ffStrbufSubstrAfterFirstS(&host, "://"); + uint32_t pathStartIndex = ffStrbufFirstIndexC(&host, '/'); + + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); + if(pathStartIndex != host.length) + { + ffStrbufAppendNS(&path, pathStartIndex, host.chars + (host.length - pathStartIndex)); + host.length = pathStartIndex; + host.chars[pathStartIndex] = '\0'; + } + + status = ffNetworkingSendHttpRequest(&state, host.chars, path.length == 0 ? "/" : path.chars, NULL); + } +} + +void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options) +{ + if (status == -1) + ffPreparePublicIp(options); + + if (status == 0) + { + ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to connect to an IP detection server"); + return; + } + + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); + bool success = ffNetworkingRecvHttpResponse(&state, &result, options->timeout); + if (success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); + + if (!success || result.length == 0) + { + ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); + return; + } + + if (options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&result, stdout); + } + else + { + ffPrintFormat(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result} + }); + } +} + +void ffInitPublicIpOptions(FFPublicIpOptions* options) +{ + options->moduleName = FF_PUBLICIP_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + ffStrbufInit(&options->url); + options->timeout = 0; +} + +bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PUBLICIP_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "url") == 0) + { + ffOptionParseString(key, value, &options->url); + return true; + } + + if (strcasecmp(subKey, "timeout") == 0) + { + options->timeout = ffOptionParseUInt32(key, value); + return true; + } + + return false; +} + +void ffDestroyPublicIpOptions(FFPublicIpOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + + ffStrbufDestroy(&options->url); +} + +#ifdef FF_HAVE_JSONC +void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module) +{ + FFPublicIpOptions __attribute__((__cleanup__(ffDestroyPublicIpOptions))) options; + ffInitPublicIpOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "url") == 0) + { + ffStrbufSetS(&options.url, json_object_get_string(val)); + continue; + } + + if (strcasecmp(key, "timeout") == 0) + { + options.timeout = (uint32_t) json_object_get_int(val); + continue; + } + + ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPublicIp(instance, &options); +} +#endif diff --git a/src/modules/publicip/publicip.h b/src/modules/publicip/publicip.h new file mode 100644 index 000000000..2306ddcf4 --- /dev/null +++ b/src/modules/publicip/publicip.h @@ -0,0 +1,17 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_PUBLICIP_MODULE_NAME "PublicIp" + +void ffPreparePublicIp(FFPublicIpOptions* options); + +void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options); +void ffInitPublicIpOptions(FFPublicIpOptions* options); +bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value); +void ffDestroyPublicIpOptions(FFPublicIpOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module); +#endif From db98e406c21c025c1c5b2c7235333bc311d5911f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 8 Jun 2023 11:33:33 +0800 Subject: [PATCH 069/493] Weather: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 9 +- src/fastfetch.c | 14 ++-- src/fastfetch.h | 10 +-- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/weather.c | 50 ------------ src/modules/weather/option.h | 14 ++++ src/modules/weather/weather.c | 122 ++++++++++++++++++++++++++++ src/modules/weather/weather.h | 17 ++++ 12 files changed, 166 insertions(+), 77 deletions(-) delete mode 100644 src/modules/weather.c create mode 100644 src/modules/weather/option.h create mode 100644 src/modules/weather/weather.c create mode 100644 src/modules/weather/weather.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d756b71e..83e9d6d53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,7 +309,7 @@ set(LIBFASTFETCH_SRC src/modules/users/users.c src/modules/vulkan/vulkan.c src/modules/wallpaper/wallpaper.c - src/modules/weather.c + src/modules/weather/weather.c src/modules/wifi/wifi.c src/modules/wm/wm.c src/modules/wmtheme/wmtheme.c diff --git a/src/common/init.c b/src/common/init.c index 20354358c..1437bf584 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -91,7 +91,7 @@ static void defaultConfig(FFinstance* instance) ffInitLocaleOptions(&instance->config.locale); ffInitLocalIpOptions(&instance->config.localIP); ffInitPublicIpOptions(&instance->config.publicIP); - initModuleArg(&instance->config.weather); + ffInitWeatherOptions(&instance->config.weather); ffInitWifiOptions(&instance->config.wifi); ffInitPlayerOptions(&instance->config.player); ffInitMediaOptions(&instance->config.media); @@ -132,9 +132,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); - instance->config.weatherTimeout = 0; - ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)"); - instance->config.percentType = 1; } @@ -306,7 +303,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyLocalIpOptions(&instance->config.localIP); ffDestroyPublicIpOptions(&instance->config.publicIP); ffDestroyWallpaperOptions(&instance->config.wallpaper); - destroyModuleArg(&instance->config.weather); + ffDestroyWeatherOptions(&instance->config.weather); ffDestroyWifiOptions(&instance->config.wifi); ffDestroyPlayerOptions(&instance->config.player); ffDestroyMediaOptions(&instance->config.media); @@ -345,8 +342,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libPulse); ffStrbufDestroy(&instance->config.libwlanapi); ffStrbufDestroy(&instance->config.libnm); - - ffStrbufDestroy(&instance->config.weatherOutputFormat); } static void destroyState(FFinstance* instance) diff --git a/src/fastfetch.c b/src/fastfetch.c index 1744bd57c..e52b6693b 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1010,7 +1010,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} else if(ffParsePublicIpCommandOptions(&instance->config.publicIP, key, value)) {} - else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {} + else if(ffParseWeatherCommandOptions(&instance->config.weather, key, value)) {} else if(ffParsePlayerCommandOptions(&instance->config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance->config.media, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} @@ -1088,10 +1088,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Module options// ////////////////// - else if(strcasecmp(key, "--weather-output-format") == 0) - optionParseString(key, value, &instance->config.weatherOutputFormat); - else if(strcasecmp(key, "--weather-timeout") == 0) - instance->config.weatherTimeout = optionParseUInt32(key, value); else if(strcasecmp(key, "--percent-type") == 0) instance->config.percentType = optionParseUInt32(key, value); @@ -1222,8 +1218,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintPublicIp(instance, &instance->config.publicIP); else if(strcasecmp(line, FF_WIFI_MODULE_NAME) == 0) ffPrintWifi(instance, &instance->config.wifi); - else if(strcasecmp(line, "weather") == 0) - ffPrintWeather(instance); + else if(strcasecmp(line, FF_WEATHER_MODULE_NAME) == 0) + ffPrintWeather(instance, &instance->config.weather); else if(strcasecmp(line, FF_PLAYER_MODULE_NAME) == 0) ffPrintPlayer(instance, &instance->config.player); else if(strcasecmp(line, FF_MEDIA_MODULE_NAME) == 0) @@ -1280,8 +1276,8 @@ int main(int argc, const char** argv) if(ffStrbufContainIgnCaseS(&data.structure, FF_PUBLICIP_MODULE_NAME)) ffPreparePublicIp(&instance.config.publicIP); - if(ffStrbufContainIgnCaseS(&data.structure, "Weather")) - ffPrepareWeather(&instance); + if(ffStrbufContainIgnCaseS(&data.structure, FF_WEATHER_MODULE_NAME)) + ffPrepareWeather(&instance.config.weather); } ffStart(&instance); diff --git a/src/fastfetch.h b/src/fastfetch.h index 2c159059f..1818934b6 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -84,7 +84,7 @@ typedef struct FFconfig FFLocaleOptions locale; FFLocalIpOptions localIP; FFPublicIpOptions publicIP; - FFModuleArgs weather; + FFWeatherOptions weather; FFPlayerOptions player; FFMediaOptions media; FFDateTimeOptions dateTime; @@ -123,9 +123,6 @@ typedef struct FFconfig FFstrbuf libwlanapi; FFstrbuf libnm; - FFstrbuf weatherOutputFormat; - uint32_t weatherTimeout; - uint32_t percentType; bool jsonConfig; @@ -175,15 +172,10 @@ void ffLogoBuiltinListAutocompletion(); // Module functions // ////////////////////// -//Common - -void ffPrepareWeather(FFinstance* instance); - //Printing void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); void ffPrintTheme(FFinstance* instance); -void ffPrintWeather(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index e00d2b48b..ffa0a9040 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -64,7 +64,7 @@ int main(int argc, char** argv) //ffPrintOpenGL(&instance, &instance.config.openGL); //ffPrintOpenCL(&instance, &instance.config.openCL); //ffPrintUsers(&instance, &instance.config.users); - //ffPrintWeather(&instance); + //ffPrintWeather(&instance, &instance.config.weather); //ffPrintBluetooth(&instance); //ffPrintSound(&instance, &instance.config.sound); //ffPrintGamepad(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index c248d0114..ba297c633 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -152,6 +152,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'W': { return tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || + tryModule(instance, type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) || tryModule(instance, type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index b28e1d1e4..c4b8af7b3 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -47,6 +47,7 @@ #include "modules/users/users.h" #include "modules/vulkan/vulkan.h" #include "modules/wallpaper/wallpaper.h" +#include "modules/weather/weather.h" #include "modules/wifi/wifi.h" #include "modules/wm/wm.h" #include "modules/wmtheme/wmtheme.h" diff --git a/src/modules/options.h b/src/modules/options.h index cfdefd52b..159f41e10 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -44,6 +44,7 @@ #include "modules/users/option.h" #include "modules/vulkan/option.h" #include "modules/wallpaper/option.h" +#include "modules/weather/option.h" #include "modules/wifi/option.h" #include "modules/wm/option.h" #include "modules/wmtheme/option.h" diff --git a/src/modules/weather.c b/src/modules/weather.c deleted file mode 100644 index f26cd4de9..000000000 --- a/src/modules/weather.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "common/networking.h" - -#define FF_WEATHER_MODULE_NAME "Weather" -#define FF_WEATHER_NUM_FORMAT_ARGS 1 - -static FFNetworkingState state; -static int status = -1; - -void ffPrepareWeather(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/?format="); - ffStrbufAppend(&path, &instance->config.weatherOutputFormat); - status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); -} - -void ffPrintWeather(FFinstance* instance) -{ - if(status == -1) - ffPrepareWeather(instance); - - if(status == 0) - { - ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &instance->config.weather, "Failed to connect to 'wttr.in'"); - return; - } - - FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); - bool success = ffNetworkingRecvHttpResponse(&state, &result, instance->config.weatherTimeout); - if (success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); - - if(!success || result.length == 0) - { - ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &instance->config.weather, "Failed to receive the server response"); - return; - } - - if(instance->config.weather.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &instance->config.weather.key); - ffStrbufPutTo(&result, stdout); - } - else - { - ffPrintFormat(instance, FF_WEATHER_MODULE_NAME, 0, &instance->config.weather, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result} - }); - } -} diff --git a/src/modules/weather/option.h b/src/modules/weather/option.h new file mode 100644 index 000000000..d481fb6b7 --- /dev/null +++ b/src/modules/weather/option.h @@ -0,0 +1,14 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFWeatherOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; + + FFstrbuf outputFormat; + uint32_t timeout; +} FFWeatherOptions; diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c new file mode 100644 index 000000000..579cdf1cb --- /dev/null +++ b/src/modules/weather/weather.c @@ -0,0 +1,122 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "common/networking.h" +#include "modules/weather/weather.h" + +#define FF_WEATHER_MODULE_NAME "Weather" +#define FF_WEATHER_NUM_FORMAT_ARGS 1 + +static FFNetworkingState state; +static int status = -1; + +void ffPrepareWeather(FFWeatherOptions* options) +{ + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/?format="); + ffStrbufAppend(&path, &options->outputFormat); + status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); +} + +void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options) +{ + if(status == -1) + ffPrepareWeather(options); + + if(status == 0) + { + ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to connect to 'wttr.in'"); + return; + } + + FF_STRBUF_AUTO_DESTROY result = ffStrbufCreateA(4096); + bool success = ffNetworkingRecvHttpResponse(&state, &result, options->timeout); + if (success) ffStrbufSubstrAfterFirstS(&result, "\r\n\r\n"); + + if(!success || result.length == 0) + { + ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&result, stdout); + } + else + { + ffPrintFormat(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result} + }); + } +} + +void ffInitWeatherOptions(FFWeatherOptions* options) +{ + options->moduleName = FF_WEATHER_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); + + ffStrbufInitS(&options->outputFormat, "%t+-+%C+(%l)"); + options->timeout = 0; +} + +bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WEATHER_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + if (strcasecmp(subKey, "output-format") == 0) + { + ffOptionParseString(key, value, &options->outputFormat); + return true; + } + + if (strcasecmp(subKey, "timeout") == 0) + { + options->timeout = ffOptionParseUInt32(key, value); + return true; + } + + return false; +} + +void ffDestroyWeatherOptions(FFWeatherOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); + + ffStrbufDestroy(&options->outputFormat); +} + +#ifdef FF_HAVE_JSONC +void ffParseWeatherJsonObject(FFinstance* instance, json_object* module) +{ + FFWeatherOptions __attribute__((__cleanup__(ffDestroyWeatherOptions))) options; + ffInitWeatherOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (strcasecmp(key, "outputFormat") == 0) + { + ffStrbufSetS(&options.outputFormat, json_object_get_string(val)); + continue; + } + + if (strcasecmp(key, "timeout") == 0) + { + options.timeout = (uint32_t) json_object_get_int(val); + continue; + } + + ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWeather(instance, &options); +} +#endif diff --git a/src/modules/weather/weather.h b/src/modules/weather/weather.h new file mode 100644 index 000000000..476a1586d --- /dev/null +++ b/src/modules/weather/weather.h @@ -0,0 +1,17 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_WEATHER_MODULE_NAME "Weather" + +void ffPrepareWeather(FFWeatherOptions* options); + +void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options); +void ffInitWeatherOptions(FFWeatherOptions* options); +bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, const char* value); +void ffDestroyWeatherOptions(FFWeatherOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseWeatherJsonObject(FFinstance* instance, json_object* module); +#endif From e3ec136cad51d9fdf4ad74cb0b64917c69771ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 Jun 2023 08:48:46 +0800 Subject: [PATCH 070/493] Theme: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +-- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/theme.c | 30 ------------ src/modules/theme/option.h | 11 +++++ src/modules/theme/theme.c | 72 +++++++++++++++++++++++++++++ src/modules/theme/theme.h | 15 ++++++ 12 files changed, 109 insertions(+), 39 deletions(-) delete mode 100644 src/modules/theme.c create mode 100644 src/modules/theme/option.h create mode 100644 src/modules/theme/theme.c create mode 100644 src/modules/theme/theme.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 83e9d6d53..5cf008a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,7 +303,7 @@ set(LIBFASTFETCH_SRC src/modules/media/media.c src/modules/terminal/terminal.c src/modules/terminalfont/terminalfont.c - src/modules/theme.c + src/modules/theme/theme.c src/modules/title/title.c src/modules/uptime/uptime.c src/modules/users/users.c diff --git a/src/common/init.c b/src/common/init.c index 1437bf584..7497b979d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -74,7 +74,7 @@ static void defaultConfig(FFinstance* instance) ffInitDEOptions(&instance->config.de); ffInitWMOptions(&instance->config.wm); ffInitWMThemeOptions(&instance->config.wmTheme); - initModuleArg(&instance->config.theme); + ffInitThemeOptions(&instance->config.theme); ffInitIconsOptions(&instance->config.icons); ffInitFontOptions(&instance->config.font); ffInitCursorOptions(&instance->config.cursor); @@ -285,7 +285,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyDEOptions(&instance->config.de); ffDestroyWMOptions(&instance->config.wm); ffDestroyWMThemeOptions(&instance->config.wmTheme); - destroyModuleArg(&instance->config.theme); + ffDestroyThemeOptions(&instance->config.theme); ffDestroyIconsOptions(&instance->config.icons); ffDestroyFontOptions(&instance->config.font); ffDestroyCursorOptions(&instance->config.cursor); diff --git a/src/fastfetch.c b/src/fastfetch.c index e52b6693b..a59ff5468 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -992,7 +992,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseWifiCommandOptions(&instance->config.wifi, key, value)) {} else if(ffParseWMCommandOptions(&instance->config.wm, key, value)) {} else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} - else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {} + else if(ffParseThemeCommandOptions(&instance->config.theme, key, value)) {} else if(ffParseIconsCommandOptions(&instance->config.icons, key, value)) {} else if(ffParseWallpaperCommandOptions(&instance->config.wallpaper, key, value)) {} else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} @@ -1176,8 +1176,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintDE(instance, &instance->config.de); else if(strcasecmp(line, FF_WM_MODULE_NAME) == 0) ffPrintWM(instance, &instance->config.wm); - else if(strcasecmp(line, "theme") == 0) - ffPrintTheme(instance); + else if(strcasecmp(line, FF_THEME_MODULE_NAME) == 0) + ffPrintTheme(instance, &instance->config.theme); else if(strcasecmp(line, FF_WMTHEME_MODULE_NAME) == 0) ffPrintWMTheme(instance, &instance->config.wmTheme); else if(strcasecmp(line, FF_ICONS_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 1818934b6..557e2121a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -66,7 +66,7 @@ typedef struct FFconfig FFWifiOptions wifi; FFWMOptions wm; FFWMThemeOptions wmTheme; - FFModuleArgs theme; + FFThemeOptions theme; FFIconsOptions icons; FFFontOptions font; FFCursorOptions cursor; @@ -176,6 +176,5 @@ void ffLogoBuiltinListAutocompletion(); void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); -void ffPrintTheme(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index ffa0a9040..0aad4532c 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -37,7 +37,7 @@ int main(int argc, char** argv) ffPrintDE(&instance, &instance.config.de); ffPrintWM(&instance, &instance.config.wm); ffPrintWMTheme(&instance, &instance.config.wmTheme); - ffPrintTheme(&instance); + ffPrintTheme(&instance, &instance.config.theme); ffPrintIcons(&instance, &instance.config.icons); ffPrintFont(&instance, &instance.config.font); ffPrintCursor(&instance, &instance.config.cursor); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index ba297c633..aca52158d 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -133,6 +133,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || tryModule(instance, type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || + tryModule(instance, type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index c4b8af7b3..3c9b98c3c 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -41,6 +41,7 @@ #include "modules/swap/swap.h" #include "modules/terminal/terminal.h" #include "modules/terminalfont/terminalfont.h" +#include "modules/theme/theme.h" #include "modules/title/title.h" #include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 159f41e10..392a6f1fa 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -39,6 +39,7 @@ #include "modules/swap/option.h" #include "modules/terminal/option.h" #include "modules/terminalfont/option.h" +#include "modules/theme/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" #include "modules/users/option.h" diff --git a/src/modules/theme.c b/src/modules/theme.c deleted file mode 100644 index b89f093d4..000000000 --- a/src/modules/theme.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/theme/theme.h" - -#define FF_THEME_MODULE_NAME "Theme" -#define FF_THEME_NUM_FORMAT_ARGS 1 - -void ffPrintTheme(FFinstance* instance) -{ - FF_STRBUF_AUTO_DESTROY theme; - ffStrbufInit(&theme); - const char* error = ffDetectTheme(instance, &theme); - if (error) - { - ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "%s", error); - return; - } - - if(instance->config.theme.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme.key); - ffStrbufPutTo(&theme, stdout); - } - else - { - ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &theme} - }); - } -} diff --git a/src/modules/theme/option.h b/src/modules/theme/option.h new file mode 100644 index 000000000..f322c3a62 --- /dev/null +++ b/src/modules/theme/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFThemeOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFThemeOptions; diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c new file mode 100644 index 000000000..bb348e10e --- /dev/null +++ b/src/modules/theme/theme.c @@ -0,0 +1,72 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/theme/theme.h" +#include "modules/theme/theme.h" + +#define FF_THEME_NUM_FORMAT_ARGS 1 + +void ffPrintTheme(FFinstance* instance, FFThemeOptions* options) +{ + FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate(); + const char* error = ffDetectTheme(instance, &theme); + + if(error) + { + ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&theme, stdout); + } + else + { + ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &theme} + }); + } +} + +void ffInitThemeOptions(FFThemeOptions* options) +{ + options->moduleName = FF_THEME_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_THEME_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyThemeOptions(FFThemeOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseThemeJsonObject(FFinstance* instance, json_object* module) +{ + FFThemeOptions __attribute__((__cleanup__(ffDestroyThemeOptions))) options; + ffInitThemeOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintTheme(instance, &options); +} +#endif diff --git a/src/modules/theme/theme.h b/src/modules/theme/theme.h new file mode 100644 index 000000000..3c13ca467 --- /dev/null +++ b/src/modules/theme/theme.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_THEME_MODULE_NAME "Theme" + +void ffPrintTheme(FFinstance* instance, FFThemeOptions* options); +void ffInitThemeOptions(FFThemeOptions* options); +bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value); +void ffDestroyThemeOptions(FFThemeOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseThemeJsonObject(FFinstance* instance, json_object* module); +#endif From 0021219f421496d59aefa922cb1a39f349019b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 Jun 2023 10:08:04 +0800 Subject: [PATCH 071/493] Chassis: add JSON config support --- CMakeLists.txt | 2 +- src/common/init.c | 4 +- src/fastfetch.c | 6 +- src/fastfetch.h | 3 +- src/flashfetch.c | 2 +- src/modules/chassis.c | 50 ---------------- src/modules/chassis/chassis.c | 92 +++++++++++++++++++++++++++++ src/modules/chassis/chassis.h | 15 +++++ src/modules/chassis/option.h | 11 ++++ src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + 12 files changed, 129 insertions(+), 59 deletions(-) delete mode 100644 src/modules/chassis.c create mode 100644 src/modules/chassis/chassis.c create mode 100644 src/modules/chassis/chassis.h create mode 100644 src/modules/chassis/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cf008a8b..9f4e26ad0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,7 +268,7 @@ set(LIBFASTFETCH_SRC src/modules/board/board.c src/modules/brightness/brightness.c src/modules/break/break.c - src/modules/chassis.c + src/modules/chassis/chassis.c src/modules/colors/colors.c src/modules/cpu/cpu.c src/modules/cpuusage/cpuusage.c diff --git a/src/common/init.c b/src/common/init.c index 7497b979d..e800a685d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -62,7 +62,7 @@ static void defaultConfig(FFinstance* instance) ffInitBiosOptions(&instance->config.bios); ffInitBoardOptions(&instance->config.board); ffInitBrightnessOptions(&instance->config.brightness); - initModuleArg(&instance->config.chassis); + ffInitChassisOptions(&instance->config.chassis); ffInitCommandOptions(&instance->config.command); ffInitCustomOptions(&instance->config.custom); ffInitKernelOptions(&instance->config.kernel); @@ -273,7 +273,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyBiosOptions(&instance->config.bios); ffDestroyBoardOptions(&instance->config.board); ffDestroyBrightnessOptions(&instance->config.brightness); - destroyModuleArg(&instance->config.chassis); + ffDestroyChassisOptions(&instance->config.chassis); ffDestroyCommandOptions(&instance->config.command); ffDestroyCustomOptions(&instance->config.custom); ffDestroyKernelOptions(&instance->config.kernel); diff --git a/src/fastfetch.c b/src/fastfetch.c index a59ff5468..345852989 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -978,7 +978,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} else if(ffParseBiosCommandOptions(&instance->config.bios, key, value)) {} else if(ffParseBoardCommandOptions(&instance->config.board, key, value)) {} - else if(optionParseModuleArgs(key, value, "chassis", &instance->config.chassis)) {} + else if(ffParseChassisCommandOptions(&instance->config.chassis, key, value)) {} else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} else if(ffParseCustomCommandOptions(&instance->config.custom, key, value)) {} else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} @@ -1158,8 +1158,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintBoard(instance, &instance->config.board); else if(strcasecmp(line, FF_BRIGHTNESS_MODULE_NAME) == 0) ffPrintBrightness(instance, &instance->config.brightness); - else if(strcasecmp(line, "chassis") == 0) - ffPrintChassis(instance); + else if(strcasecmp(line, FF_CHASSIS_MODULE_NAME) == 0) + ffPrintChassis(instance, &instance->config.chassis); else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0) ffPrintKernel(instance, &instance->config.kernel); else if(strcasecmp(line, "processes") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 557e2121a..2a6b5b350 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -53,7 +53,7 @@ typedef struct FFconfig FFBiosOptions bios; FFBoardOptions board; FFBrightnessOptions brightness; - FFModuleArgs chassis; + FFChassisOptions chassis; FFCommandOptions command; FFKernelOptions kernel; FFUptimeOptions uptime; @@ -174,7 +174,6 @@ void ffLogoBuiltinListAutocompletion(); //Printing -void ffPrintChassis(FFinstance* instance); void ffPrintProcesses(FFinstance* instance); #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index 0aad4532c..e6358c03f 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -26,7 +26,7 @@ int main(int argc, char** argv) ffPrintHost(&instance, &instance.config.host); //ffPrintBios(&instance, &instance.config.bios); //ffPrintBoard(&instance, &instance.config.board); - //ffPrintChassis(&instance); + //ffPrintChassis(&instance, &instance.config.chassis); ffPrintKernel(&instance, &instance.config.kernel); //ffPrintProcesses(&instance); ffPrintUptime(&instance, &instance.config.uptime); diff --git a/src/modules/chassis.c b/src/modules/chassis.c deleted file mode 100644 index 4932ecc69..000000000 --- a/src/modules/chassis.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/chassis/chassis.h" - -#define FF_CHASSIS_MODULE_NAME "Chassis" -#define FF_CHASSIS_NUM_FORMAT_ARGS 3 - -void ffPrintChassis(FFinstance* instance) -{ - FFChassisResult result; - ffDetectChassis(&result); - - if(result.error.length > 0) - { - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, "%*s", result.error.length, result.error.chars); - goto exit; - } - - if(result.chassisType.length == 0) - { - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, "chassis_type is not set by O.E.M."); - return; - } - - if(instance->config.chassis.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis.key); - - FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateCopy(&result.chassisType); - - if(result.chassisVersion.length > 0) - ffStrbufAppendF(&output, " (%s)", result.chassisVersion.chars); - - ffStrbufPutTo(&output, stdout); - } - else - { - ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisType}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVersion}, - }); - } - -exit: - ffStrbufDestroy(&result.chassisType); - ffStrbufDestroy(&result.chassisVendor); - ffStrbufDestroy(&result.chassisVersion); - ffStrbufDestroy(&result.error); -} diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c new file mode 100644 index 000000000..72beac3c0 --- /dev/null +++ b/src/modules/chassis/chassis.c @@ -0,0 +1,92 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/chassis/chassis.h" +#include "modules/chassis/chassis.h" + +#define FF_CHASSIS_NUM_FORMAT_ARGS 3 + +void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) +{ + FFChassisResult result; + ffDetectChassis(&result); + + if(result.error.length > 0) + { + ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + goto exit; + } + + if(result.chassisType.length == 0) + { + ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key); + + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateCopy(&result.chassisType); + + if(result.chassisVersion.length > 0) + ffStrbufAppendF(&output, " (%s)", result.chassisVersion.chars); + + ffStrbufPutTo(&output, stdout); + } + else + { + ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisType}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVersion}, + }); + } + +exit: + ffStrbufDestroy(&result.chassisType); + ffStrbufDestroy(&result.chassisVendor); + ffStrbufDestroy(&result.chassisVersion); + ffStrbufDestroy(&result.error); +} + +void ffInitChassisOptions(FFChassisOptions* options) +{ + options->moduleName = FF_CHASSIS_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_CHASSIS_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyChassisOptions(FFChassisOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseChassisJsonObject(FFinstance* instance, json_object* module) +{ + FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options; + ffInitChassisOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintChassis(instance, &options); +} +#endif diff --git a/src/modules/chassis/chassis.h b/src/modules/chassis/chassis.h new file mode 100644 index 000000000..2eb9af900 --- /dev/null +++ b/src/modules/chassis/chassis.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_CHASSIS_MODULE_NAME "Chassis" + +void ffPrintChassis(FFinstance* instance, FFChassisOptions* options); +void ffInitChassisOptions(FFChassisOptions* options); +bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value); +void ffDestroyChassisOptions(FFChassisOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseChassisJsonObject(FFinstance* instance, json_object* module); +#endif diff --git a/src/modules/chassis/option.h b/src/modules/chassis/option.h new file mode 100644 index 000000000..939fd165d --- /dev/null +++ b/src/modules/chassis/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFChassisOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFChassisOptions; diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index aca52158d..fa17afb29 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -39,6 +39,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o case 'C': { return + tryModule(instance, type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || diff --git a/src/modules/modules.h b/src/modules/modules.h index 3c9b98c3c..fac24537f 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -8,6 +8,7 @@ #include "modules/brightness/brightness.h" #include "modules/board/board.h" #include "modules/break/break.h" +#include "modules/chassis/chassis.h" #include "modules/cpu/cpu.h" #include "modules/cpuusage/cpuusage.h" #include "modules/command/command.h" diff --git a/src/modules/options.h b/src/modules/options.h index 392a6f1fa..62b53f4da 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -7,6 +7,7 @@ #include "modules/bluetooth/option.h" #include "modules/board/option.h" #include "modules/brightness/option.h" +#include "modules/chassis/option.h" #include "modules/cpu/option.h" #include "modules/cpuusage/option.h" #include "modules/cursor/option.h" From 3227eee0800ca57d10a6ef89ed029a4b9bee5a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 Jun 2023 10:24:20 +0800 Subject: [PATCH 072/493] Processes: add JSON config --- CMakeLists.txt | 2 +- src/common/init.c | 18 +------ src/fastfetch.c | 40 ++-------------- src/fastfetch.h | 10 +--- src/flashfetch.c | 2 +- src/modules/jsonconfig/jsonconfig.c | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/processes.c | 31 ------------ src/modules/processes/option.h | 11 +++++ src/modules/processes/processes.c | 73 +++++++++++++++++++++++++++++ src/modules/processes/processes.h | 15 ++++++ 12 files changed, 110 insertions(+), 95 deletions(-) delete mode 100644 src/modules/processes.c create mode 100644 src/modules/processes/option.h create mode 100644 src/modules/processes/processes.c create mode 100644 src/modules/processes/processes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f4e26ad0..1ee8d861c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,7 +291,7 @@ set(LIBFASTFETCH_SRC src/modules/opengl/opengl.c src/modules/os/os.c src/modules/packages/packages.c - src/modules/processes.c + src/modules/processes/processes.c src/modules/player/player.c src/modules/poweradapter/poweradapter.c src/modules/publicip/publicip.c diff --git a/src/common/init.c b/src/common/init.c index e800a685d..d478d518e 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -28,13 +28,6 @@ static void initState(FFstate* state) ffPlatformInit(&state->platform); } -static void initModuleArg(FFModuleArgs* args) -{ - ffStrbufInit(&args->key); - ffStrbufInit(&args->outputFormat); - ffStrbufInit(&args->errorFormat); -} - static void defaultConfig(FFinstance* instance) { ffInitLogoOptions(&instance->config.logo); @@ -67,7 +60,7 @@ static void defaultConfig(FFinstance* instance) ffInitCustomOptions(&instance->config.custom); ffInitKernelOptions(&instance->config.kernel); ffInitUptimeOptions(&instance->config.uptime); - initModuleArg(&instance->config.processes); + ffInitProcessesOptions(&instance->config.processes); ffInitPackagesOptions(&instance->config.packages); ffInitShellOptions(&instance->config.shell); ffInitDisplayOptions(&instance->config.display); @@ -252,13 +245,6 @@ void ffFinish(FFinstance* instance) resetConsole(); } -static void destroyModuleArg(FFModuleArgs* args) -{ - ffStrbufDestroy(&args->key); - ffStrbufDestroy(&args->outputFormat); - ffStrbufDestroy(&args->errorFormat); -} - static void destroyConfig(FFinstance* instance) { ffDestroyLogoOptions(&instance->config.logo); @@ -278,7 +264,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyCustomOptions(&instance->config.custom); ffDestroyKernelOptions(&instance->config.kernel); ffDestroyUptimeOptions(&instance->config.uptime); - destroyModuleArg(&instance->config.processes); + ffDestroyProcessesOptions(&instance->config.processes); ffDestroyPackagesOptions(&instance->config.packages); ffDestroyShellOptions(&instance->config.shell); ffDestroyDisplayOptions(&instance->config.display); diff --git a/src/fastfetch.c b/src/fastfetch.c index 345852989..66c5ae5b5 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -746,40 +746,6 @@ static void optionParseEnum(const char* argumentKey, const char* requestedKey, v exit(478); } -static bool optionParseModuleArgs(const char* argumentKey, const char* value, const char* moduleName, struct FFModuleArgs* result) -{ - const char* pkey = argumentKey; - if(!(pkey[0] == '-' && pkey[1] == '-')) - return false; - - pkey += 2; - uint32_t moduleNameLen = (uint32_t)strlen(moduleName); - if(strncasecmp(pkey, moduleName, moduleNameLen) != 0) - return false; - - pkey += moduleNameLen; - if(pkey[0] != '-') - return false; - - pkey += 1; - if(strcasecmp(pkey, "key") == 0) - { - optionParseString(argumentKey, value, &result->key); - return true; - } - else if(strcasecmp(pkey, "format") == 0) - { - optionParseString(argumentKey, value, &result->outputFormat); - return true; - } - else if(strcasecmp(pkey, "error") == 0) - { - optionParseString(argumentKey, value, &result->errorFormat); - return true; - } - return false; -} - static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value) { /////////////////////// @@ -983,7 +949,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseCustomCommandOptions(&instance->config.custom, key, value)) {} else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} else if(ffParseUptimeCommandOptions(&instance->config.uptime, key, value)) {} - else if(optionParseModuleArgs(key, value, "processes", &instance->config.processes)) {} + else if(ffParseProcessesCommandOptions(&instance->config.processes, key, value)) {} else if(ffParsePackagesCommandOptions(&instance->config.packages, key, value)) {} else if(ffParseShellCommandOptions(&instance->config.shell, key, value)) {} else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} @@ -1162,8 +1128,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintChassis(instance, &instance->config.chassis); else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0) ffPrintKernel(instance, &instance->config.kernel); - else if(strcasecmp(line, "processes") == 0) - ffPrintProcesses(instance); + else if(strcasecmp(line, FF_PROCESSES_MODULE_NAME) == 0) + ffPrintProcesses(instance, &instance->config.processes); else if(strcasecmp(line, FF_UPTIME_MODULE_NAME) == 0) ffPrintUptime(instance, &instance->config.uptime); else if(strcasecmp(line, FF_PACKAGES_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 2a6b5b350..68506ede7 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -57,7 +57,7 @@ typedef struct FFconfig FFCommandOptions command; FFKernelOptions kernel; FFUptimeOptions uptime; - FFModuleArgs processes; + FFProcessesOptions processes; FFPackagesOptions packages; FFShellOptions shell; FFDisplayOptions display; @@ -168,12 +168,4 @@ void ffLogoBuiltinPrint(FFinstance* instance); void ffLogoBuiltinList(); void ffLogoBuiltinListAutocompletion(); -////////////////////// -// Module functions // -////////////////////// - -//Printing - -void ffPrintProcesses(FFinstance* instance); - #endif diff --git a/src/flashfetch.c b/src/flashfetch.c index e6358c03f..d09a7c2f4 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -28,7 +28,7 @@ int main(int argc, char** argv) //ffPrintBoard(&instance, &instance.config.board); //ffPrintChassis(&instance, &instance.config.chassis); ffPrintKernel(&instance, &instance.config.kernel); - //ffPrintProcesses(&instance); + //ffPrintProcesses(&instance, &instance.config.processes); ffPrintUptime(&instance, &instance.config.uptime); ffPrintPackages(&instance, &instance.config.packages); ffPrintShell(&instance, &instance.config.shell); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index fa17afb29..c9f4b6efc 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -116,6 +116,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || + tryModule(instance, type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) || tryModule(instance, type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || false; } diff --git a/src/modules/modules.h b/src/modules/modules.h index fac24537f..99a2130e3 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -35,6 +35,7 @@ #include "modules/packages/packages.h" #include "modules/player/player.h" #include "modules/poweradapter/poweradapter.h" +#include "modules/processes/processes.h" #include "modules/publicip/publicip.h" #include "modules/separator/separator.h" #include "modules/shell/shell.h" diff --git a/src/modules/options.h b/src/modules/options.h index 62b53f4da..f9ae625b9 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -33,6 +33,7 @@ #include "modules/packages/option.h" #include "modules/player/option.h" #include "modules/poweradapter/option.h" +#include "modules/processes/option.h" #include "modules/publicip/option.h" #include "modules/separator/option.h" #include "modules/shell/option.h" diff --git a/src/modules/processes.c b/src/modules/processes.c deleted file mode 100644 index 70a64ad83..000000000 --- a/src/modules/processes.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "fastfetch.h" -#include "common/printing.h" -#include "detection/processes/processes.h" - -#define FF_PROCESSES_MODULE_NAME "Processes" -#define FF_PROCESSES_NUM_FORMAT_ARGS 1 - -void ffPrintProcesses(FFinstance* instance) -{ - uint32_t numProcesses = 0; - const char* error = ffDetectProcesses(&numProcesses); - - if(error) - { - ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes, "%s", error); - return; - } - - if(instance->config.processes.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes.key); - - printf("%u\n", numProcesses); - } - else - { - ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &numProcesses} - }); - } -} diff --git a/src/modules/processes/option.h b/src/modules/processes/option.h new file mode 100644 index 000000000..9d2cd8086 --- /dev/null +++ b/src/modules/processes/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFProcessesOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFProcessesOptions; diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c new file mode 100644 index 000000000..719bb45f5 --- /dev/null +++ b/src/modules/processes/processes.c @@ -0,0 +1,73 @@ +#include "fastfetch.h" +#include "common/printing.h" +#include "detection/processes/processes.h" +#include "modules/processes/processes.h" + +#define FF_PROCESSES_NUM_FORMAT_ARGS 1 + +void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options) +{ + uint32_t numProcesses = 0; + const char* error = ffDetectProcesses(&numProcesses); + + if(error) + { + ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key); + + printf("%u\n", numProcesses); + } + else + { + ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &numProcesses} + }); + } +} + +void ffInitProcessesOptions(FFProcessesOptions* options) +{ + options->moduleName = FF_PROCESSES_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PROCESSES_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyProcessesOptions(FFProcessesOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +#ifdef FF_HAVE_JSONC +void ffParseProcessesJsonObject(FFinstance* instance, json_object* module) +{ + FFProcessesOptions __attribute__((__cleanup__(ffDestroyProcessesOptions))) options; + ffInitProcessesOptions(&options); + + if (module) + { + json_object_object_foreach(module, key, val) + { + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintProcesses(instance, &options); +} +#endif diff --git a/src/modules/processes/processes.h b/src/modules/processes/processes.h new file mode 100644 index 000000000..34abb7ef8 --- /dev/null +++ b/src/modules/processes/processes.h @@ -0,0 +1,15 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_PROCESSES_MODULE_NAME "Processes" + +void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options); +void ffInitProcessesOptions(FFProcessesOptions* options); +bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value); +void ffDestroyProcessesOptions(FFProcessesOptions* options); + +#ifdef FF_HAVE_JSONC +#include "common/jsonconfig.h" +void ffParseProcessesJsonObject(FFinstance* instance, json_object* module); +#endif From 174e1f9d4b7d72485210f9bdf7410df5a50c8b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 10 Jun 2023 10:50:16 +0800 Subject: [PATCH 073/493] JSON: an attempt to switch back to yyjson yyjson is a lot faster than json-c and is more actively maintained. In addition, as JSON config is now a major feature, we'd better not depend on lib that may not exist --- CMakeLists.txt | 11 +++- src/detection/terminalfont/terminalfont.c | 79 +++++++++++------------ 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ee8d861c..f1016fdde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url +cmake_minimum_required(VERSION 3.14.0) # target_link_libraries with OBJECT libs & project homepage url & FetchContent project(fastfetch VERSION 1.11.3 @@ -40,6 +40,14 @@ endif() include(CheckIncludeFile) +include(FetchContent) +FetchContent_Declare( + yyjson + GIT_REPOSITORY https://github.com/ibireme/yyjson + GIT_TAG 0.7.0 +) +FetchContent_MakeAvailable(yyjson) + ##################### # Configure options # ##################### @@ -761,6 +769,7 @@ target_include_directories(libfastfetch target_link_libraries(libfastfetch PRIVATE ${CMAKE_DL_LIBS} + PRIVATE yyjson ) ###################### diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index cd0764247..2118c2013 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -58,68 +58,71 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) #if defined(_WIN32) || defined(__linux__) -#ifdef FF_HAVE_JSONC - #include "common/library.h" #include "common/processing.h" -#include "common/json.h" #include +#include -static const char* detectWTProfile(json_object* profile, FFstrbuf* name, double* size) +static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double* size) { - json_object* font = json_object_object_get(profile, "font"); + yyjson_val* font = yyjson_obj_get(profile, "font"); if (!font) - return "json_object_object_get(profile, \"font\"); failed"; + return "yyjson_obj_get(profile, \"font\"); failed"; - if (!json_object_is_type(font, json_type_object)) - return "json_object_is_type(font, json_type_object) returns false"; + if (!yyjson_is_obj(font)) + return "yyjson_is_obj(font) returns false"; if (name->length == 0) { - json_object* pface = json_object_object_get(font, "face"); - if(json_object_is_type(pface, json_type_string)) - ffStrbufAppendNS(name, (uint32_t) json_object_get_string_len(pface), json_object_get_string(pface)); + yyjson_val* pface = yyjson_obj_get(font, "face"); + if(yyjson_is_str(pface)) + ffStrbufAppendS(name, unsafe_yyjson_get_str(pface)); } if (*size < 0) { - json_object* psize = json_object_object_get(font, "size"); - if (json_object_is_type(psize, json_type_int) || json_object_is_type(psize, json_type_double)) - *size = json_object_get_double(psize); + yyjson_val* psize = yyjson_obj_get(font, "size"); + if (yyjson_is_num(psize)) + *size = yyjson_get_num(psize); } return NULL; } -static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, double* size) +static inline void wrapYyjsonFree(yyjson_doc** doc) { - if (!ffJsonLoadLibrary(instance)) - return "Failed to load json-c library"; + assert(doc); + if (*doc) + yyjson_doc_free(*doc); +} - json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content->chars); - if (!root) +static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size) +{ + yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL); + if (!doc) return "Failed to parse WT JSON config file"; - json_object* profiles = json_object_object_get(root, "profiles"); + yyjson_val* const root = yyjson_doc_get_root(doc); + assert(root); + + yyjson_val* profiles = yyjson_obj_get(root, "profiles"); if (!profiles) - return "json_object_object_get(root, \"profiles\") failed"; + return "yyjson_obj_get(root, \"profiles\") failed"; FF_STRBUF_AUTO_DESTROY wtProfileId = ffStrbufCreateS(getenv("WT_PROFILE_ID")); ffStrbufTrim(&wtProfileId, '\''); if (wtProfileId.length > 0) { - array_list* list = json_object_get_array(json_object_object_get(profiles, "list")); - if (list) + yyjson_val* list = yyjson_obj_get(profiles, "list"); + if (yyjson_is_arr(list)) { - for (size_t idx = 0; idx < list->length; ++idx) + yyjson_val* profile; + size_t idx, max; + yyjson_arr_foreach(list, idx, max, profile) { - json_object* profile = (json_object*) list->array[idx]; - json_object* guid = json_object_object_get(profile, "guid"); + yyjson_val* guid = yyjson_obj_get(profile, "guid"); - if (!json_object_is_type(guid, json_type_string)) - continue; - - if(ffStrbufEqualS(&wtProfileId, json_object_get_string(guid))) + if(ffStrbufEqualS(&wtProfileId, yyjson_get_str(guid))) { detectWTProfile(profile, name, size); break; @@ -128,7 +131,7 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten } } - json_object* defaults = json_object_object_get(profiles, "defaults"); + yyjson_val* defaults = yyjson_obj_get(profiles, "defaults"); if (defaults) detectWTProfile(defaults, name, size); @@ -145,7 +148,7 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten #include #endif -static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) +static void detectFromWindowsTeriminal(const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) { //https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate(); @@ -219,7 +222,7 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); double size = -1; - error = detectFromWTImpl(instance, &json, &name, &size); + error = detectFromWTImpl(&json, &name, &size); if(error) ffStrbufAppendS(&terminalFont->error, error); @@ -231,15 +234,7 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu } } -#else //FF_HAVE_JSONC -static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont) -{ - FF_UNUSED(instance, terminalExe, terminalFont); - ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without json-c support"); -} - -#endif //FF_HAVE_JSONC #endif //defined(_WIN32) || defined(__linux__) @@ -370,7 +365,7 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina //Used by both Linux (WSL) and Windows else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "Windows Terminal") || ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "WindowsTerminal.exe")) - detectFromWindowsTeriminal(instance, &terminalShell->terminalExe, terminalFont); + detectFromWindowsTeriminal(&terminalShell->terminalExe, terminalFont); #endif else From abe0d2ca78b088e9826059798d073c9b26df5534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 10 Jun 2023 15:01:54 +0800 Subject: [PATCH 074/493] Global: drop json-c and switch to yyjson --- .github/workflows/push.yml | 12 +-- CHANGELOG.md | 10 +- CMakeLists.txt | 8 +- README.md | 4 +- src/common/init.c | 5 - src/common/json.c | 57 ----------- src/common/json.h | 130 ------------------------ src/common/jsonconfig.c | 22 ++-- src/common/jsonconfig.h | 10 +- src/data/config_user.txt | 1 - src/data/help.txt | 1 - src/fastfetch.c | 5 - src/fastfetch.h | 1 - src/modules/battery/battery.c | 19 ++-- src/modules/battery/battery.h | 7 +- src/modules/bios/bios.c | 14 ++- src/modules/bios/bios.h | 7 +- src/modules/bluetooth/bluetooth.c | 15 ++- src/modules/bluetooth/bluetooth.h | 7 +- src/modules/board/board.c | 14 ++- src/modules/board/board.h | 7 +- src/modules/break/break.c | 5 +- src/modules/break/break.h | 7 +- src/modules/brightness/brightness.c | 14 ++- src/modules/brightness/brightness.h | 7 +- src/modules/chassis/chassis.c | 14 ++- src/modules/chassis/chassis.h | 7 +- src/modules/colors/colors.c | 6 +- src/modules/colors/colors.h | 7 +- src/modules/command/command.c | 19 ++-- src/modules/command/command.h | 7 +- src/modules/cpu/cpu.c | 16 +-- src/modules/cpu/cpu.h | 7 +- src/modules/cpuusage/cpuusage.c | 14 ++- src/modules/cpuusage/cpuusage.h | 9 +- src/modules/cursor/cursor.c | 15 +-- src/modules/cursor/cursor.h | 7 +- src/modules/custom/custom.c | 14 ++- src/modules/custom/custom.h | 7 +- src/modules/datetime/datetime.c | 14 ++- src/modules/datetime/datetime.h | 7 +- src/modules/de/de.c | 14 ++- src/modules/de/de.h | 7 +- src/modules/disk/disk.c | 24 +++-- src/modules/disk/disk.h | 7 +- src/modules/display/display.c | 19 ++-- src/modules/display/display.h | 7 +- src/modules/font/font.c | 14 ++- src/modules/font/font.h | 7 +- src/modules/gamepad/gamepad.c | 13 ++- src/modules/gamepad/gamepad.h | 7 +- src/modules/gpu/gpu.c | 18 ++-- src/modules/gpu/gpu.h | 9 +- src/modules/host/host.c | 14 ++- src/modules/host/host.h | 7 +- src/modules/icons/icons.c | 14 ++- src/modules/icons/icons.h | 7 +- src/modules/jsonconfig/jsonconfig.c | 117 ++++++++------------- src/modules/kernel/kernel.c | 14 ++- src/modules/kernel/kernel.h | 8 +- src/modules/locale/locale.c | 14 ++- src/modules/locale/locale.h | 7 +- src/modules/localip/localip.c | 26 +++-- src/modules/localip/localip.h | 7 +- src/modules/media/media.c | 14 ++- src/modules/media/media.h | 7 +- src/modules/memory/memory.c | 14 ++- src/modules/memory/memory.h | 7 +- src/modules/opencl/opencl.c | 14 ++- src/modules/opencl/opencl.h | 7 +- src/modules/opengl/opengl.c | 14 ++- src/modules/opengl/opengl.h | 7 +- src/modules/os/os.c | 16 +-- src/modules/os/os.h | 8 +- src/modules/packages/packages.c | 14 ++- src/modules/packages/packages.h | 8 +- src/modules/player/player.c | 14 ++- src/modules/player/player.h | 7 +- src/modules/poweradapter/poweradapter.c | 14 ++- src/modules/poweradapter/poweradapter.h | 7 +- src/modules/processes/processes.c | 14 ++- src/modules/processes/processes.h | 7 +- src/modules/publicip/publicip.c | 18 ++-- src/modules/publicip/publicip.h | 7 +- src/modules/separator/separator.c | 16 +-- src/modules/separator/separator.h | 8 +- src/modules/shell/shell.c | 16 +-- src/modules/shell/shell.h | 7 +- src/modules/sound/sound.c | 13 ++- src/modules/sound/sound.h | 8 +- src/modules/swap/swap.c | 14 ++- src/modules/swap/swap.h | 7 +- src/modules/terminal/terminal.c | 16 +-- src/modules/terminal/terminal.h | 7 +- src/modules/terminalfont/terminalfont.c | 14 ++- src/modules/terminalfont/terminalfont.h | 7 +- src/modules/theme/theme.c | 14 ++- src/modules/theme/theme.h | 7 +- src/modules/title/title.c | 16 +-- src/modules/title/title.h | 8 +- src/modules/uptime/uptime.c | 11 +- src/modules/uptime/uptime.h | 8 +- src/modules/users/users.c | 14 ++- src/modules/users/users.h | 7 +- src/modules/vulkan/vulkan.c | 14 ++- src/modules/vulkan/vulkan.h | 7 +- src/modules/wallpaper/wallpaper.c | 14 ++- src/modules/wallpaper/wallpaper.h | 7 +- src/modules/weather/weather.c | 19 ++-- src/modules/weather/weather.h | 7 +- src/modules/wifi/wifi.c | 14 ++- src/modules/wifi/wifi.h | 8 +- src/modules/wm/wm.c | 14 ++- src/modules/wm/wm.h | 7 +- src/modules/wmtheme/wmtheme.c | 14 ++- src/modules/wmtheme/wmtheme.h | 8 +- 116 files changed, 650 insertions(+), 859 deletions(-) delete mode 100644 src/common/json.c delete mode 100644 src/common/json.h diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index cb4355dc6..985b60bfe 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: configure project env: @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: Initialize CodeQL uses: github/codeql-action/init@v2 @@ -183,7 +183,7 @@ jobs: with: msystem: CLANG64 update: true - install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-json-c + install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd - name: print msys version run: uname -a @@ -203,7 +203,7 @@ jobs: uses: github/codeql-action/analyze@v2 - name: copy necessary dlls - run: cp /clang64/bin/{libjson-c*,OpenCL,vulkan-1}.dll . + run: cp /clang64/bin/{OpenCL,vulkan-1}.dll . - name: list features run: ./fastfetch --list-features @@ -244,7 +244,7 @@ jobs: with: msystem: CLANG32 update: true - install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd mingw-w64-clang-i686-json-c + install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd - name: print msys version run: uname -a @@ -264,7 +264,7 @@ jobs: uses: github/codeql-action/analyze@v2 - name: copy necessary dlls - run: cp /clang32/bin/{libjson-c*,OpenCL,vulkan-1}.dll . + run: cp /clang32/bin/{OpenCL,vulkan-1}.dll . - name: run fastfetch run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all diff --git a/CHANGELOG.md b/CHANGELOG.md index fb38752aa..5888b1abd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 2.0.0 + +This release introduces a new configuration file format: JSON config + +Changes: +* Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. + # 1.11.3 Bugfixes: @@ -68,9 +75,6 @@ Bugfixes: * Don't exit if libpci is failed to init (GPU, Linux, #433) * Names of most well-known gamepads are correctly printed instead of `Wireless Controller` on Windows -Changes: -* Use json-c to parse JSON strings for comments support, instead of using unmaintained cJSON - Logo: * Small update for nobara logo (#435, @regulargvy13) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1016fdde..13c3c3e06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,6 @@ cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) -cmake_dependent_option(ENABLE_JSONC "Enable json-c" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) @@ -239,7 +238,6 @@ set(LIBFASTFETCH_SRC src/common/font.c src/common/format.c src/common/init.c - src/common/json.c src/common/jsonconfig.c src/common/library.c src/common/option.c @@ -710,10 +708,6 @@ ff_lib_enable(PULSE "libpulse" "Pulse" ) -ff_lib_enable(JSONC - "json-c" - "json-c" -) if(ENABLE_THREADS) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS) @@ -784,6 +778,7 @@ target_compile_definitions(fastfetch ) target_link_libraries(fastfetch PRIVATE libfastfetch + PRIVATE yyjson ) add_executable(flashfetch @@ -794,6 +789,7 @@ target_compile_definitions(flashfetch ) target_link_libraries(flashfetch PRIVATE libfastfetch + PRIVATE yyjson ) if(ENABLE_BUFFER) # FF_ENABLE_BUFFER is used in fastfetch.c diff --git a/README.md b/README.md index a5a153ee8..a6cb9d2aa 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,6 @@ The following libraries are used if present at runtime: * [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font. * [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count. * [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE. -* [`json-c`](https://github.com/json-c/json-c): Needed for Windows Terminal font ( WSL ). * [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection. * [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection. @@ -71,7 +70,6 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal ### Windows * [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection. -* [`json-c`](https://github.com/json-c/json-c): Used for Windows Terminal font detection. [`json-c`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-json-c) * [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers) * [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd) @@ -138,7 +136,7 @@ Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 s 1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime) 1. Install dependencies ```bash -pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-json-c mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd +pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd ``` Follow the building instructions of Linux next. diff --git a/src/common/init.c b/src/common/init.c index d478d518e..f812d8b7b 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -119,7 +119,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libGLX); ffStrbufInit(&instance->config.libOSMesa); ffStrbufInit(&instance->config.libOpenCL); - ffStrbufInit(&instance->config.libJSONC); ffStrbufInit(&instance->config.libfreetype); ffStrbufInit(&instance->config.libPulse); ffStrbufInit(&instance->config.libwlanapi); @@ -323,7 +322,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libGLX); ffStrbufDestroy(&instance->config.libOSMesa); ffStrbufDestroy(&instance->config.libOpenCL); - ffStrbufDestroy(&instance->config.libJSONC); ffStrbufDestroy(&instance->config.libfreetype); ffStrbufDestroy(&instance->config.libPulse); ffStrbufDestroy(&instance->config.libwlanapi); @@ -411,9 +409,6 @@ void ffListFeatures() #ifdef FF_HAVE_OPENCL "opencl\n" #endif - #ifdef FF_HAVE_LIBJSONC - "json-c\n" - #endif #ifdef FF_HAVE_FREETYPE "freetype\n" #endif diff --git a/src/common/json.c b/src/common/json.c deleted file mode 100644 index 8ca285d5b..000000000 --- a/src/common/json.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "common/json.h" - -#ifdef FF_HAVE_JSONC - -#include "common/thread.h" - -static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance) -{ - assert(instance); - - static FFJsonLibrary lib; - FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, NULL, - #ifdef _WIN32 - "libjson-c-5" FF_LIBRARY_EXTENSION, -1 - #else - "libjson-c" FF_LIBRARY_EXTENSION, 5 - #endif - ) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_tokener_parse, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_is_type, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_array, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_boolean, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_double, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_int, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string_len, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_object, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_del, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_get, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_length, NULL) - FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_put, NULL) - libjsonc = NULL; // don't dlclose automatically - return &lib; -} - -const FFJsonLibrary* ffJsonLib = NULL; -bool ffJsonLoadLibrary(const FFinstance* instance) -{ - static bool loaded = false; - static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; - - if (!loaded) - { - ffThreadMutexLock(&mutex); - - if(!loaded) - { - loaded = true; - ffJsonLib = loadLibSymbols(instance); - } - - ffThreadMutexUnlock(&mutex); - } - return !!ffJsonLib; -} - -#endif diff --git a/src/common/json.h b/src/common/json.h deleted file mode 100644 index cf4ffe14f..000000000 --- a/src/common/json.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once - -#ifdef FF_HAVE_JSONC - -#include "fastfetch.h" -#include "common/library.h" - -#include -#include - -typedef struct FFJsonLibrary -{ - FF_LIBRARY_SYMBOL(json_tokener_parse) - FF_LIBRARY_SYMBOL(json_object_is_type) - FF_LIBRARY_SYMBOL(json_object_get_array) - FF_LIBRARY_SYMBOL(json_object_get_boolean) - FF_LIBRARY_SYMBOL(json_object_get_double) - FF_LIBRARY_SYMBOL(json_object_get_int) - FF_LIBRARY_SYMBOL(json_object_get_string_len) - FF_LIBRARY_SYMBOL(json_object_get_string) - FF_LIBRARY_SYMBOL(json_object_get_object) - FF_LIBRARY_SYMBOL(json_object_object_del) - FF_LIBRARY_SYMBOL(json_object_object_get) - FF_LIBRARY_SYMBOL(json_object_object_length) - FF_LIBRARY_SYMBOL(json_object_put) -} FFJsonLibrary; - -extern const FFJsonLibrary* ffJsonLib; - -bool ffJsonLoadLibrary(const FFinstance* instance); - -static inline void wrapJsoncFree(json_object** root) -{ - assert(root); - if (*root) - json_object_put(*root); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -struct json_object *json_tokener_parse(const char *str) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_tokener_parse(str); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -int json_object_is_type(const json_object *obj, enum json_type type) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_is_type(obj, type); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -struct array_list *json_object_get_array(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_array(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -json_bool json_object_get_boolean(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_boolean(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -double json_object_get_double(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_double(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -int32_t json_object_get_int(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_int(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -int json_object_get_string_len(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_string_len(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -const char *json_object_get_string(json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_string(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -struct lh_table *json_object_get_object(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_get_object(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -void json_object_object_del(struct json_object *obj, const char *key) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_del(obj, key); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -struct json_object *json_object_object_get(const json_object *obj, const char *key) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_get(obj, key); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -int json_object_object_length(const json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_object_length(obj); -} - -extern inline __attribute__((__gnu_inline__, __always_inline__)) -int json_object_put(json_object *obj) -{ - assert(ffJsonLib); - return ffJsonLib->ffjson_object_put(obj); -} - -#endif diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 151e058e5..17828077b 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -1,33 +1,31 @@ #include "fastfetch.h" #include "common/jsonconfig.h" -#ifdef FF_HAVE_JSONC - -bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs) +bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs) { if(strcasecmp(key, "key") == 0) { - ffStrbufSetNS(&moduleArgs->key, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } else if(strcasecmp(key, "format") == 0) { - ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } else if(strcasecmp(key, "error") == 0) { - ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val)); + ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } return false; } -const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[]) +const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]) { - if (json_object_is_type(val, json_type_int)) + if (yyjson_is_int(val)) { - int intVal = json_object_get_int(val); + int intVal = yyjson_get_int(val); for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { @@ -40,9 +38,9 @@ const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair return "Invalid enum integer"; } - else if (json_object_is_type(val, json_type_string)) + else if (yyjson_is_str(val)) { - const char* strVal = json_object_get_string(val); + const char* strVal = yyjson_get_str(val); for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { if (strcasecmp(strVal, pPair->key) == 0) @@ -57,5 +55,3 @@ const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair else return "Invalid enum value type; must be a string or integer"; } - -#endif diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h index 76a72c304..395fbd397 100644 --- a/src/common/jsonconfig.h +++ b/src/common/jsonconfig.h @@ -1,10 +1,6 @@ #pragma once -#ifdef FF_HAVE_JSONC +#include -#include "common/json.h" - -bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs); -const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[]); - -#endif +bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs); +const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index a0b91d92f..fcac284d5 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -456,6 +456,5 @@ #--lib-glx /usr/lib/libGLX.so #--lib-osmesa /usr/lib/libOSMesa.so #--lib-opencl /usr/lib/libOpenCL.so -#--lib-jsonc /usr/lib/libjson-c.so #--lib-freetype /data/data/com.termux/files/usr/lib #--lib-pulse /usr/lib/libpulse.so diff --git a/src/data/help.txt b/src/data/help.txt index 30fedcdfd..48109de86 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -97,7 +97,6 @@ Library options: Set the path of a library to load --lib-glx --lib-osmesa --lib-opencl - --lib-jsonc --lib-pulse --lib-freetype diff --git a/src/fastfetch.c b/src/fastfetch.c index 66c5ae5b5..301caeddc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -15,9 +15,6 @@ #include "util/windows/getline.h" #endif -#pragma GCC diagnostic ignored "-Wsign-conversion" - -#include "common/jsonconfig.h" #include "modules/modules.h" typedef struct CustomValue @@ -1038,8 +1035,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con optionParseString(key, value, &instance->config.libOSMesa); else if(strcasecmp(subkey, "-opencl") == 0) optionParseString(key, value, &instance->config.libOpenCL); - else if(strcasecmp(subkey, "-jsonc") == 0) - optionParseString(key, value, &instance->config.libJSONC); else if(strcasecmp(subkey, "-wlanapi") == 0) optionParseString(key, value, &instance->config.libwlanapi); else if(strcasecmp(key, "-pulse") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 68506ede7..4bdeac603 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -117,7 +117,6 @@ typedef struct FFconfig FFstrbuf libGLX; FFstrbuf libOSMesa; FFstrbuf libOpenCL; - FFstrbuf libJSONC; FFstrbuf libfreetype; FFstrbuf libPulse; FFstrbuf libwlanapi; diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 92f5dea6f..c41e185a8 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/bar.h" #include "detection/battery/battery.h" #include "modules/battery/battery.h" @@ -139,35 +139,41 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co void ffDestroyBatteryOptions(FFBatteryOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); + #ifdef __linux__ ffStrbufDestroy(&options->dir); #endif } -#ifdef FF_HAVE_JSONC -void ffParseBatteryJsonObject(FFinstance* instance, json_object* module) +void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module) { FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; ffInitBatteryOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; #ifdef __linux__ if (strcasecmp(key, "dir") == 0) { - ffStrbufSetS(&options.dir, json_object_get_string(val)); + ffStrbufSetS(&options.dir, yyjson_get_str(val)); continue; } #endif if (strcasecmp(key, "temp") == 0) { - options.temp = (bool) json_object_get_boolean(val); + options.temp = yyjson_get_bool(val); continue; } @@ -177,4 +183,3 @@ void ffParseBatteryJsonObject(FFinstance* instance, json_object* module) ffPrintBattery(instance, &options); } -#endif diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index efe7f9132..524a265d0 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_BATTERY_MODULE_NAME "Battery" @@ -9,8 +10,4 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); void ffInitBatteryOptions(FFBatteryOptions* options); bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value); void ffDestroyBatteryOptions(FFBatteryOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBatteryJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 12e79e048..139cd2740 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/bios/bios.h" #include "modules/bios/bios.h" @@ -66,16 +66,21 @@ void ffDestroyBiosOptions(FFBiosOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseBiosJsonObject(FFinstance* instance, json_object* module) +void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module) { FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; ffInitBiosOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -85,4 +90,3 @@ void ffParseBiosJsonObject(FFinstance* instance, json_object* module) ffPrintBios(instance, &options); } -#endif diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h index 8ff5c7837..990a432d5 100644 --- a/src/modules/bios/bios.h +++ b/src/modules/bios/bios.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_BIOS_MODULE_NAME "Bios" @@ -8,8 +9,4 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options); void ffInitBiosOptions(FFBiosOptions* options); bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value); void ffDestroyBiosOptions(FFBiosOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBiosJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 2318336b5..7d512cf2a 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -1,4 +1,5 @@ #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/bluetooth/bluetooth.h" #include "modules/bluetooth/bluetooth.h" @@ -84,22 +85,27 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module) +void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module) { FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; ffInitBluetoothOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "showConnected") == 0) { - options.showDisconnected = json_object_get_boolean(val); + options.showDisconnected = yyjson_get_bool(val); continue; } @@ -109,4 +115,3 @@ void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module) ffPrintBluetooth(instance, &options); } -#endif diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h index 5c72b0ec7..230ab5c0a 100644 --- a/src/modules/bluetooth/bluetooth.h +++ b/src/modules/bluetooth/bluetooth.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_BLUETOOTH_MODULE_NAME "Bluetooth" @@ -8,8 +9,4 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options); void ffInitBluetoothOptions(FFBluetoothOptions* options); bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value); void ffDestroyBluetoothOptions(FFBluetoothOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 39c1fab01..a984e9427 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/board/board.h" #include "modules/board/board.h" @@ -64,16 +64,21 @@ void ffDestroyBoardOptions(FFBoardOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseBoardJsonObject(FFinstance* instance, json_object* module) +void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module) { FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; ffInitBoardOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -83,4 +88,3 @@ void ffParseBoardJsonObject(FFinstance* instance, json_object* module) ffPrintBoard(instance, &options); } -#endif diff --git a/src/modules/board/board.h b/src/modules/board/board.h index 10b9c6f5c..d2afbfd82 100644 --- a/src/modules/board/board.h +++ b/src/modules/board/board.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_BOARD_MODULE_NAME "Board" @@ -8,8 +9,4 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options); void ffInitBoardOptions(FFBoardOptions* options); bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value); void ffDestroyBoardOptions(FFBoardOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBoardJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 59d205210..55b671c19 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -1,4 +1,3 @@ -#include "fastfetch.h" #include "common/printing.h" #include "modules/break/break.h" @@ -8,9 +7,7 @@ void ffPrintBreak(FFinstance* instance) putchar('\n'); } -#ifdef FF_HAVE_JSONC -void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module) +void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module) { return ffPrintBreak(instance); } -#endif diff --git a/src/modules/break/break.h b/src/modules/break/break.h index a7b34957d..f313774fe 100644 --- a/src/modules/break/break.h +++ b/src/modules/break/break.h @@ -1,12 +1,9 @@ #pragma once #include "fastfetch.h" +#include #define FF_BREAK_MODULE_NAME "Break" void ffPrintBreak(FFinstance* instance); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBreakJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBreakJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 34ae9f8f1..8dde00757 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/brightness/brightness.h" #include "modules/brightness/brightness.h" @@ -77,16 +77,21 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module) +void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module) { FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; ffInitBrightnessOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -96,4 +101,3 @@ void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module) ffPrintBrightness(instance, &options); } -#endif diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h index 58fbbf302..00c5f13f7 100644 --- a/src/modules/brightness/brightness.h +++ b/src/modules/brightness/brightness.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_BRIGHTNESS_MODULE_NAME "Brightness" @@ -8,8 +9,4 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options); void ffInitBrightnessOptions(FFBrightnessOptions* options); bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value); void ffDestroyBrightnessOptions(FFBrightnessOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 72beac3c0..7d8e771aa 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/chassis/chassis.h" #include "modules/chassis/chassis.h" @@ -70,16 +70,21 @@ void ffDestroyChassisOptions(FFChassisOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseChassisJsonObject(FFinstance* instance, json_object* module) +void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module) { FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options; ffInitChassisOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -89,4 +94,3 @@ void ffParseChassisJsonObject(FFinstance* instance, json_object* module) ffPrintChassis(instance, &options); } -#endif diff --git a/src/modules/chassis/chassis.h b/src/modules/chassis/chassis.h index 2eb9af900..566198e17 100644 --- a/src/modules/chassis/chassis.h +++ b/src/modules/chassis/chassis.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_CHASSIS_MODULE_NAME "Chassis" @@ -8,8 +9,4 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options); void ffInitChassisOptions(FFChassisOptions* options); bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value); void ffDestroyChassisOptions(FFChassisOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseChassisJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index a355844c5..54b7a0d1d 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "util/textModifier.h" #include "modules/colors/colors.h" @@ -30,9 +30,7 @@ void ffPrintColors(FFinstance* instance) puts(FASTFETCH_TEXT_MODIFIER_RESET); } -#ifdef FF_HAVE_JSONC -void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module) +void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module) { return ffPrintColors(instance); } -#endif diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index 11887735d..cfd7860e4 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -1,12 +1,9 @@ #pragma once #include "fastfetch.h" +#include #define FF_COLORS_MODULE_NAME "Colors" void ffPrintColors(FFinstance* instance); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseColorsJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 49177119d..69d0729aa 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -1,6 +1,5 @@ -#include "fastfetch.h" - #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/processing.h" #include "modules/command/command.h" @@ -81,28 +80,33 @@ void ffDestroyCommandOptions(FFCommandOptions* options) ffStrbufDestroy(&options->text); } -#ifdef FF_HAVE_JSONC -void ffParseCommandJsonObject(FFinstance* instance, json_object* module) +void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module) { FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; ffInitCommandOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "shell") == 0) { - ffStrbufSetS(&options.shell, json_object_get_string(val)); + ffStrbufSetS(&options.shell, yyjson_get_str(val)); continue; } if (strcasecmp(key, "text") == 0) { - ffStrbufSetS(&options.text, json_object_get_string(val)); + ffStrbufSetS(&options.text, yyjson_get_str(val)); continue; } @@ -112,4 +116,3 @@ void ffParseCommandJsonObject(FFinstance* instance, json_object* module) ffPrintCommand(instance, &options); } -#endif diff --git a/src/modules/command/command.h b/src/modules/command/command.h index 9944b9bd7..fd1a8705f 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_COMMAND_MODULE_NAME "Command" @@ -8,8 +9,4 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); void ffInitCommandOptions(FFCommandOptions* options); bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value); void ffDestroyCommandOptions(FFCommandOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseCommandJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 07c16c28a..efb467835 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/cpu/cpu.h" #include "modules/cpu/cpu.h" @@ -83,22 +83,27 @@ void ffDestroyCPUOptions(FFCPUOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseCPUJsonObject(FFinstance* instance, json_object* module) +void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module) { FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options; ffInitCPUOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "temp") == 0) { - options.temp = (bool) json_object_get_boolean(val); + options.temp = yyjson_get_bool(val); continue; } @@ -108,4 +113,3 @@ void ffParseCPUJsonObject(FFinstance* instance, json_object* module) ffPrintCPU(instance, &options); } -#endif diff --git a/src/modules/cpu/cpu.h b/src/modules/cpu/cpu.h index 04c5c6f7a..de9cb9c41 100644 --- a/src/modules/cpu/cpu.h +++ b/src/modules/cpu/cpu.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_CPU_MODULE_NAME "CPU" @@ -8,8 +9,4 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options); void ffInitCPUOptions(FFCPUOptions* options); bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value); void ffDestroyCPUOptions(FFCPUOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseCPUJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index 74a078d34..9df218d8f 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/bar.h" #include "detection/cpuusage/cpuusage.h" #include "modules/cpuusage/cpuusage.h" @@ -62,16 +62,21 @@ void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module) +void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module) { FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options; ffInitCPUUsageOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -81,4 +86,3 @@ void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module) ffPrintCPUUsage(instance, &options); } -#endif diff --git a/src/modules/cpuusage/cpuusage.h b/src/modules/cpuusage/cpuusage.h index 941c7ab84..2bde09f0d 100644 --- a/src/modules/cpuusage/cpuusage.h +++ b/src/modules/cpuusage/cpuusage.h @@ -1,5 +1,8 @@ #pragma once +#include "fastfetch.h" +#include + #define FF_CPUUSAGE_MODULE_NAME "CPUUsage" void ffPrepareCPUUsage(); @@ -8,8 +11,4 @@ void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options); void ffInitCPUUsageOptions(FFCPUUsageOptions* options); bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value); void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 1845fac3b..095dc7dba 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -1,6 +1,5 @@ -#include "fastfetch.h" - #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/cursor/cursor.h" #include "modules/cursor/cursor.h" @@ -71,16 +70,21 @@ void ffDestroyCursorOptions(FFCursorOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseCursorJsonObject(FFinstance* instance, json_object* module) +void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module) { FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options; ffInitCursorOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -90,4 +94,3 @@ void ffParseCursorJsonObject(FFinstance* instance, json_object* module) ffPrintCursor(instance, &options); } -#endif diff --git a/src/modules/cursor/cursor.h b/src/modules/cursor/cursor.h index 913e0668e..210915883 100644 --- a/src/modules/cursor/cursor.h +++ b/src/modules/cursor/cursor.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_CURSOR_MODULE_NAME "Cursor" @@ -8,8 +9,4 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options); void ffInitCursorOptions(FFCursorOptions* options); bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value); void ffDestroyCursorOptions(FFCursorOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseCursorJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index b90f96be4..ce57e5c5e 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "modules/custom/custom.h" #include "util/textModifier.h" @@ -37,16 +37,21 @@ void ffDestroyCustomOptions(FFCustomOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseCustomJsonObject(FFinstance* instance, json_object* module) +void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module) { FFCustomOptions __attribute__((__cleanup__(ffDestroyCustomOptions))) options; ffInitCustomOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -56,4 +61,3 @@ void ffParseCustomJsonObject(FFinstance* instance, json_object* module) ffPrintCustom(instance, &options); } -#endif diff --git a/src/modules/custom/custom.h b/src/modules/custom/custom.h index ab3873549..7be41c0a6 100644 --- a/src/modules/custom/custom.h +++ b/src/modules/custom/custom.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_CUSTOM_MODULE_NAME "Custom" @@ -8,8 +9,4 @@ void ffPrintCustom(FFinstance* instance, FFCustomOptions* options); void ffInitCustomOptions(FFCustomOptions* options); bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value); void ffDestroyCustomOptions(FFCustomOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseCustomJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 654060f77..03ac5b92d 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/datetime/datetime.h" #include "modules/datetime/datetime.h" @@ -69,16 +69,21 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module) +void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module) { FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; ffInitDateTimeOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -88,4 +93,3 @@ void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module) ffPrintDateTime(instance, &options); } -#endif diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index 737646611..c845a8e6f 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_DATETIME_MODULE_NAME "DateTime" @@ -8,8 +9,4 @@ void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); void ffInitDateTimeOptions(FFDateTimeOptions* options); bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value); void ffDestroyDateTimeOptions(FFDateTimeOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 1a0310a33..b0f709a29 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/de/de.h" @@ -60,16 +60,21 @@ void ffDestroyDEOptions(FFDEOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseDEJsonObject(FFinstance* instance, json_object* module) +void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module) { FFDEOptions __attribute__((__cleanup__(ffDestroyDEOptions))) options; ffInitDEOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -79,4 +84,3 @@ void ffParseDEJsonObject(FFinstance* instance, json_object* module) ffPrintDE(instance, &options); } -#endif diff --git a/src/modules/de/de.h b/src/modules/de/de.h index ee393e225..8530bf6e3 100644 --- a/src/modules/de/de.h +++ b/src/modules/de/de.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_DE_MODULE_NAME "DE" @@ -8,8 +9,4 @@ void ffPrintDE(FFinstance* instance, FFDEOptions* options); void ffInitDEOptions(FFDEOptions* options); bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value); void ffDestroyDEOptions(FFDEOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseDEJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index eb4c90da1..6dd112216 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/parsing.h" #include "common/bar.h" #include "detection/disk/disk.h" @@ -222,28 +222,33 @@ void ffDestroyDiskOptions(FFDiskOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseDiskJsonObject(FFinstance* instance, json_object* module) +void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) { FFDiskOptions __attribute__((__cleanup__(ffDestroyDiskOptions))) options; ffInitDiskOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "folders") == 0) { - ffStrbufSetS(&options.folders, json_object_get_string(val)); + ffStrbufSetS(&options.folders, yyjson_get_str(val)); continue; } if (strcasecmp(key, "showRemovable") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; else options.showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT; @@ -252,7 +257,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "showHidden") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_HIDDEN_BIT; else options.showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT; @@ -261,7 +266,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "showSubvolumes") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; else options.showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT; @@ -270,7 +275,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "show-unknown") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; else options.showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT; @@ -283,4 +288,3 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module) ffPrintDisk(instance, &options); } -#endif diff --git a/src/modules/disk/disk.h b/src/modules/disk/disk.h index 5d3fc05ba..efba1e7fc 100644 --- a/src/modules/disk/disk.h +++ b/src/modules/disk/disk.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_DISK_MODULE_NAME "Disk" @@ -8,8 +9,4 @@ void ffPrintDisk(FFinstance* instance, FFDiskOptions* options); void ffInitDiskOptions(FFDiskOptions* options); bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value); void ffDestroyDiskOptions(FFDiskOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseDiskJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 40045c6e5..53ccf74aa 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/display/display.h" @@ -155,17 +155,21 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); } - -#ifdef FF_HAVE_JSONC -void ffParseDisplayJsonObject(FFinstance* instance, json_object* module) +void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) { FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; ffInitDisplayOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -187,13 +191,13 @@ void ffParseDisplayJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "detectName") == 0) { - options.detectName = json_object_get_boolean(val); + options.detectName = yyjson_get_bool(val); continue; } if (strcasecmp(key, "preciseRefreshRate") == 0) { - options.preciseRefreshRate = json_object_get_boolean(val); + options.preciseRefreshRate = yyjson_get_bool(val); continue; } @@ -203,4 +207,3 @@ void ffParseDisplayJsonObject(FFinstance* instance, json_object* module) ffPrintDisplay(instance, &options); } -#endif diff --git a/src/modules/display/display.h b/src/modules/display/display.h index f5f31627c..8781d4e41 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_DISPLAY_MODULE_NAME "Display" @@ -8,8 +9,4 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options); void ffInitDisplayOptions(FFDisplayOptions* options); bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value); void ffDestroyDisplayOptions(FFDisplayOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseDisplayJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/font/font.c b/src/modules/font/font.c index be9159c6f..70da28872 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/font/font.h" #include "modules/font/font.h" @@ -53,16 +53,21 @@ void ffDestroyFontOptions(FFFontOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseFontJsonObject(FFinstance* instance, json_object* module) +void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module) { FFFontOptions __attribute__((__cleanup__(ffDestroyFontOptions))) options; ffInitFontOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -72,4 +77,3 @@ void ffParseFontJsonObject(FFinstance* instance, json_object* module) ffPrintFont(instance, &options); } -#endif diff --git a/src/modules/font/font.h b/src/modules/font/font.h index 36627b72f..ba1c8fade 100644 --- a/src/modules/font/font.h +++ b/src/modules/font/font.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_FONT_MODULE_NAME "Font" @@ -8,8 +9,4 @@ void ffPrintFont(FFinstance* instance, FFFontOptions* options); void ffInitFontOptions(FFFontOptions* options); bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value); void ffDestroyFontOptions(FFFontOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseFontJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 6d4b37c53..86edbb683 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -1,4 +1,5 @@ #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/gamepad/gamepad.h" #include "modules/gamepad/gamepad.h" @@ -68,16 +69,21 @@ void ffDestroyGamepadOptions(FFGamepadOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseGamepadJsonObject(FFinstance* instance, json_object* module) +void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module) { FFGamepadOptions __attribute__((__cleanup__(ffDestroyGamepadOptions))) options; ffInitGamepadOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -87,4 +93,3 @@ void ffParseGamepadJsonObject(FFinstance* instance, json_object* module) ffPrintGamepad(instance, &options); } -#endif diff --git a/src/modules/gamepad/gamepad.h b/src/modules/gamepad/gamepad.h index 2ada4ad2f..0c4c96ddb 100644 --- a/src/modules/gamepad/gamepad.h +++ b/src/modules/gamepad/gamepad.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_GAMEPAD_MODULE_NAME "Gamepad" @@ -8,8 +9,4 @@ void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options); void ffInitGamepadOptions(FFGamepadOptions* options); bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value); void ffDestroyGamepadOptions(FFGamepadOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseGamepadJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 1e3fd17ee..e5dfb7fe3 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -1,7 +1,7 @@ -#include "fastfetch.h" #include "common/bar.h" #include "common/parsing.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/host/host.h" #include "detection/gpu/gpu.h" #include "modules/gpu/gpu.h" @@ -145,28 +145,33 @@ void ffDestroyGPUOptions(FFGPUOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseGPUJsonObject(FFinstance* instance, json_object* module) +void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module) { FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options; ffInitGPUOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "temp") == 0) { - options.temp = (bool) json_object_get_boolean(val); + options.temp = yyjson_get_bool(val); continue; } if (strcasecmp(key, "forceVulkan") == 0) { - options.forceVulkan = (bool) json_object_get_boolean(val); + options.forceVulkan = yyjson_get_bool(val); continue; } @@ -192,4 +197,3 @@ void ffParseGPUJsonObject(FFinstance* instance, json_object* module) ffPrintGPU(instance, &options); } -#endif diff --git a/src/modules/gpu/gpu.h b/src/modules/gpu/gpu.h index 156e6ba89..aa9c11374 100644 --- a/src/modules/gpu/gpu.h +++ b/src/modules/gpu/gpu.h @@ -1,13 +1,12 @@ #pragma once +#include "fastfetch.h" +#include + #define FF_GPU_MODULE_NAME "GPU" void ffPrintGPU(FFinstance* instance, FFGPUOptions* options); void ffInitGPUOptions(FFGPUOptions* options); bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value); void ffDestroyGPUOptions(FFGPUOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseGPUJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index e6d18874e..b63a1bb87 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/host/host.h" #include "modules/host/host.h" @@ -72,16 +72,21 @@ void ffDestroyHostOptions(FFHostOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseHostJsonObject(FFinstance* instance, json_object* module) +void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module) { FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; ffInitHostOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -91,4 +96,3 @@ void ffParseHostJsonObject(FFinstance* instance, json_object* module) ffPrintHost(instance, &options); } -#endif diff --git a/src/modules/host/host.h b/src/modules/host/host.h index 9801d8010..8bbc53f41 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_HOST_MODULE_NAME "Host" @@ -8,8 +9,4 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options); void ffInitHostOptions(FFHostOptions* options); bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value); void ffDestroyHostOptions(FFHostOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseHostJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index e6ebbb8e2..b917e6857 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/icons/icons.h" #include "modules/icons/icons.h" @@ -50,16 +50,21 @@ void ffDestroyIconsOptions(FFIconsOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseIconsJsonObject(FFinstance* instance, json_object* module) +void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module) { FFIconsOptions __attribute__((__cleanup__(ffDestroyIconsOptions))) options; ffInitIconsOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseIconsJsonObject(FFinstance* instance, json_object* module) ffPrintIcons(instance, &options); } -#endif diff --git a/src/modules/icons/icons.h b/src/modules/icons/icons.h index 780f9c352..46867bd23 100644 --- a/src/modules/icons/icons.h +++ b/src/modules/icons/icons.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_ICONS_MODULE_NAME "Icons" @@ -8,8 +9,4 @@ void ffPrintIcons(FFinstance* instance, FFIconsOptions* options); void ffInitIconsOptions(FFIconsOptions* options); bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value); void ffDestroyIconsOptions(FFIconsOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseIconsJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index c9f4b6efc..fa4a5768a 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -1,28 +1,23 @@ -#include "modules/jsonconfig/jsonconfig.h" -#include "common/jsonconfig.h" #include "common/printing.h" - -#ifdef FF_HAVE_JSONC - +#include "common/jsonconfig.h" #include "common/io/io.h" -#include "common/json.h" +#include "modules/jsonconfig/jsonconfig.h" #include "modules/modules.h" #include #include -static inline bool tryModule(FFinstance* instance, const char* type, json_object* module, const char* moduleName, void (*const f)(FFinstance *instance, json_object *module)) +static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module)) { if (strcasecmp(type, moduleName) == 0) { - if (module) json_object_object_del(module, "type"); // this line frees `type` f(instance, module); return true; } return false; } -static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module) +static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson_val* module) { switch (toupper(type[0])) { @@ -167,26 +162,52 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o } } -static const char* parseModules(FFinstance* instance, json_object* modules) +static inline void wrapYyjsonFree(yyjson_doc** doc) { - array_list* list = json_object_get_array(modules); - if (!list) return "modules must be an array of strings or objects"; + assert(doc); + if (*doc) + yyjson_doc_free(*doc); +} - for (size_t idx = 0; idx < list->length; ++idx) +static const char* printJsonConfig(FFinstance* instance) +{ + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); + FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) { - json_object* module = (json_object*) list->array[idx]; - const char* type = NULL; - if (json_object_is_type(module, json_type_string)) - { - type = json_object_get_string(module); + uint32_t oldLength = filename->length; + ffStrbufAppendS(filename, "fastfetch/config.jsonc"); + bool success = ffAppendFileBuffer(filename->chars, &content); + ffStrbufSubstrBefore(filename, oldLength); + if (success) break; + } + + yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content.chars, content.length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL); + if (!doc) + return "Failed to parse JSON config file"; + + yyjson_val* const root = yyjson_doc_get_root(doc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* modules = yyjson_obj_get(root, "modules"); + if (!modules) return "Property 'modules' is not found"; + if (!yyjson_is_arr(modules)) return "modules must be an array of strings or objects"; + + yyjson_val* item; + size_t idx, max; + yyjson_arr_foreach(modules, idx, max, item) + { + yyjson_val* module = item; + const char* type = yyjson_get_str(module); + if (type) module = NULL; - } - else if (json_object_is_type(module, json_type_object)) + else if (yyjson_is_obj(module)) { - json_object* object = json_object_object_get(module, "type"); - type = json_object_get_string(object); + type = yyjson_get_str(yyjson_obj_get(module, "type")); if (!type) return "module object must contain a \"type\" key ( case sensitive )"; - if (json_object_object_length(module) == 1) // contains only Property type + if (yyjson_obj_size(module) == 1) // contains only Property type module = NULL; } else @@ -199,56 +220,6 @@ static const char* parseModules(FFinstance* instance, json_object* modules) return NULL; } -static const char* printJsonConfig(FFinstance* instance) -{ - if (!ffJsonLoadLibrary(instance)) - return "Failed to load json-c library"; - - FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) - { - uint32_t oldLength = filename->length; - ffStrbufAppendS(filename, "fastfetch/config.jsonc"); - bool success = ffAppendFileBuffer(filename->chars, &content); - ffStrbufSubstrBefore(filename, oldLength); - if (success) break; - } - - json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content.chars); - if (!root) - return "Failed to parse JSON config file"; - - lh_table* rootObject = json_object_get_object(root); - if (!rootObject) - return "Invalid JSON config format. Root value must be an object"; - - struct lh_entry* entry; - lh_foreach(rootObject, entry) - { - const char* key = (const char *)lh_entry_k(entry); - json_object* val = (json_object *)lh_entry_v(entry); - - if (strcmp(key, "modules") == 0) - { - const char* error = parseModules(instance, val); - if (error) return error; - } - else - return "Unknown JSON config key in root object"; - } - - return NULL; -} - -#else - -static const char* printJsonConfig(FF_MAYBE_UNUSED FFinstance* instance) -{ - return "Fastfetch was compiled without json-c support"; -} - -#endif - void ffPrintJsonConfig(FFinstance* instance) { const char* error = printJsonConfig(instance); diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 36b5e8545..9cce738ea 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "modules/kernel/kernel.h" #define FF_KERNEL_NUM_FORMAT_ARGS 4 @@ -50,16 +50,21 @@ void ffDestroyKernelOptions(FFKernelOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseKernelJsonObject(FFinstance* instance, json_object* module) +void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module) { FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; ffInitKernelOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseKernelJsonObject(FFinstance* instance, json_object* module) ffPrintKernel(instance, &options); } -#endif diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h index ee0d78300..25d840cc6 100644 --- a/src/modules/kernel/kernel.h +++ b/src/modules/kernel/kernel.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/kernel/option.h" +#include #define FF_KERNEL_MODULE_NAME "Kernel" @@ -9,8 +9,4 @@ void ffPrintKernel(FFinstance* instance, FFKernelOptions* options); void ffInitKernelOptions(FFKernelOptions* options); bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value); void ffDestroyKernelOptions(FFKernelOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseKernelJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 9a2f99f6d..d8d7abe72 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/locale/locale.h" #include "modules/locale/locale.h" @@ -50,16 +50,21 @@ void ffDestroyLocaleOptions(FFLocaleOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseLocaleJsonObject(FFinstance* instance, json_object* module) +void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module) { FFLocaleOptions __attribute__((__cleanup__(ffDestroyLocaleOptions))) options; ffInitLocaleOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseLocaleJsonObject(FFinstance* instance, json_object* module) ffPrintLocale(instance, &options); } -#endif diff --git a/src/modules/locale/locale.h b/src/modules/locale/locale.h index e02f91154..c41290b9f 100644 --- a/src/modules/locale/locale.h +++ b/src/modules/locale/locale.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_LOCALE_MODULE_NAME "Locale" @@ -8,8 +9,4 @@ void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options); void ffInitLocaleOptions(FFLocaleOptions* options); bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value); void ffDestroyLocaleOptions(FFLocaleOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseLocaleJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 9b27da159..06dc74189 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/localip/localip.h" #include "modules/localip/localip.h" @@ -194,22 +194,27 @@ void ffDestroyLocalIpOptions(FFLocalIpOptions* options) ffStrbufDestroy(&options->namePrefix); } -#ifdef FF_HAVE_JSONC -void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) +void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) { FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options; ffInitLocalIpOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "showIpv4") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_IPV4_BIT; else options.showType &= ~FF_LOCALIP_TYPE_IPV4_BIT; @@ -218,7 +223,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "showIpv6") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_IPV6_BIT; else options.showType &= ~FF_LOCALIP_TYPE_IPV6_BIT; @@ -227,7 +232,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "showMac") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_MAC_BIT; else options.showType &= ~FF_LOCALIP_TYPE_MAC_BIT; @@ -236,7 +241,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "showLoop") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_LOOP_BIT; else options.showType &= ~FF_LOCALIP_TYPE_LOOP_BIT; @@ -245,7 +250,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "compact") == 0) { - if (json_object_get_boolean(val)) + if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_COMPACT_BIT; else options.showType &= ~FF_LOCALIP_TYPE_COMPACT_BIT; @@ -254,7 +259,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) if (strcasecmp(key, "namePrefix") == 0) { - ffStrbufSetS(&options.namePrefix, json_object_get_string(val)); + ffStrbufSetS(&options.namePrefix, yyjson_get_str(val)); continue; } @@ -264,4 +269,3 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module) ffPrintLocalIp(instance, &options); } -#endif diff --git a/src/modules/localip/localip.h b/src/modules/localip/localip.h index e27babe41..7ab4fd1fa 100644 --- a/src/modules/localip/localip.h +++ b/src/modules/localip/localip.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_LOCALIP_MODULE_NAME "LocalIp" @@ -8,8 +9,4 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options); void ffInitLocalIpOptions(FFLocalIpOptions* options); bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value); void ffDestroyLocalIpOptions(FFLocalIpOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/media/media.c b/src/modules/media/media.c index 9021aaf7c..ac5ce83b3 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/media/media.h" #include "modules/media/media.h" @@ -125,16 +125,21 @@ void ffDestroyMediaOptions(FFMediaOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseMediaJsonObject(FFinstance* instance, json_object* module) +void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module) { FFMediaOptions __attribute__((__cleanup__(ffDestroyMediaOptions))) options; ffInitMediaOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -144,4 +149,3 @@ void ffParseMediaJsonObject(FFinstance* instance, json_object* module) ffPrintMedia(instance, &options); } -#endif diff --git a/src/modules/media/media.h b/src/modules/media/media.h index 59c6cbb42..f7a43bac4 100644 --- a/src/modules/media/media.h +++ b/src/modules/media/media.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_MEDIA_MODULE_NAME "Media" @@ -8,8 +9,4 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options); void ffInitMediaOptions(FFMediaOptions* options); bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value); void ffDestroyMediaOptions(FFMediaOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseMediaJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 552a0dc44..3e175eea6 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/parsing.h" #include "common/bar.h" #include "detection/memory/memory.h" @@ -84,16 +84,21 @@ void ffDestroyMemoryOptions(FFMemoryOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseMemoryJsonObject(FFinstance* instance, json_object* module) +void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module) { FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options; ffInitMemoryOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -103,4 +108,3 @@ void ffParseMemoryJsonObject(FFinstance* instance, json_object* module) ffPrintMemory(instance, &options); } -#endif diff --git a/src/modules/memory/memory.h b/src/modules/memory/memory.h index e500d8532..4a7fbba98 100644 --- a/src/modules/memory/memory.h +++ b/src/modules/memory/memory.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_MEMORY_MODULE_NAME "Memory" @@ -8,8 +9,4 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options); void ffInitMemoryOptions(FFMemoryOptions* options); bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value); void ffDestroyMemoryOptions(FFMemoryOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseMemoryJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 169aaec7f..469b59cb2 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/opencl/opencl.h" #include "modules/opencl/opencl.h" @@ -59,16 +59,21 @@ void ffDestroyOpenCLOptions(FFOpenCLOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module) +void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module) { FFOpenCLOptions __attribute__((__cleanup__(ffDestroyOpenCLOptions))) options; ffInitOpenCLOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -78,4 +83,3 @@ void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module) ffPrintOpenCL(instance, &options); } -#endif diff --git a/src/modules/opencl/opencl.h b/src/modules/opencl/opencl.h index 21843c41d..633929889 100644 --- a/src/modules/opencl/opencl.h +++ b/src/modules/opencl/opencl.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_OPENCL_MODULE_NAME "OpenCL" @@ -8,8 +9,4 @@ void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options); void ffInitOpenCLOptions(FFOpenCLOptions* options); bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value); void ffDestroyOpenCLOptions(FFOpenCLOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index ae551fb35..7272cd31d 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/opengl/opengl.h" #include "modules/opengl/opengl.h" @@ -76,16 +76,21 @@ void ffDestroyOpenGLOptions(FFOpenGLOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module) +void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) { FFOpenGLOptions __attribute__((__cleanup__(ffDestroyOpenGLOptions))) options; ffInitOpenGLOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -114,4 +119,3 @@ void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module) ffPrintOpenGL(instance, &options); } -#endif diff --git a/src/modules/opengl/opengl.h b/src/modules/opengl/opengl.h index d2322addf..2c85af45c 100644 --- a/src/modules/opengl/opengl.h +++ b/src/modules/opengl/opengl.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_OPENGL_MODULE_NAME "OpenGL" @@ -8,8 +9,4 @@ void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options); void ffInitOpenGLOptions(FFOpenGLOptions* options); bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value); void ffDestroyOpenGLOptions(FFOpenGLOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 55a0552e8..41ec29ae6 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/option.h" #include "detection/os/os.h" #include "modules/os/os.h" @@ -172,23 +172,28 @@ void ffDestroyOSOptions(FFOSOptions* options) #endif } -#ifdef FF_HAVE_JSONC -void ffParseOSJsonObject(FFinstance* instance, json_object* module) +void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) { FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; ffInitOSOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; #if defined(__linux__) || defined(__FreeBSD__) if (strcasecmp(key, "file") == 0) { - ffStrbufSetS(&options.file, json_object_get_string(val)); + ffStrbufSetS(&options.file, yyjson_get_str(val)); continue; } #endif @@ -199,4 +204,3 @@ void ffParseOSJsonObject(FFinstance* instance, json_object* module) ffPrintOS(instance, &options); } -#endif diff --git a/src/modules/os/os.h b/src/modules/os/os.h index 90e9c5981..3f5299fc1 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/os/option.h" +#include #define FF_OS_MODULE_NAME "OS" @@ -9,8 +9,4 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options); void ffInitOSOptions(FFOSOptions* options); bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value); void ffDestroyOSOptions(FFOSOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseOSJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index dfcaf8249..79f4d1a4a 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/packages/packages.h" #include "modules/packages/packages.h" @@ -112,16 +112,21 @@ void ffDestroyPackagesOptions(FFPackagesOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParsePackagesJsonObject(FFinstance* instance, json_object* module) +void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module) { FFPackagesOptions __attribute__((__cleanup__(ffDestroyPackagesOptions))) options; ffInitPackagesOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -131,4 +136,3 @@ void ffParsePackagesJsonObject(FFinstance* instance, json_object* module) ffPrintPackages(instance, &options); } -#endif diff --git a/src/modules/packages/packages.h b/src/modules/packages/packages.h index 5557da0b3..6798d26e5 100644 --- a/src/modules/packages/packages.h +++ b/src/modules/packages/packages.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/packages/option.h" +#include #define FF_PACKAGES_MODULE_NAME "Packages" @@ -9,8 +9,4 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options); void ffInitPackagesOptions(FFPackagesOptions* options); bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value); void ffDestroyPackagesOptions(FFPackagesOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParsePackagesJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/player/player.c b/src/modules/player/player.c index f461044a1..5178d3746 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/media/media.h" #include "modules/player/player.h" @@ -97,16 +97,21 @@ void ffDestroyPlayerOptions(FFPlayerOptions* options) ffStrbufDestroy(&options->name); } -#ifdef FF_HAVE_JSONC -void ffParsePlayerJsonObject(FFinstance* instance, json_object* module) +void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module) { FFPlayerOptions __attribute__((__cleanup__(ffDestroyPlayerOptions))) options; ffInitPlayerOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -116,4 +121,3 @@ void ffParsePlayerJsonObject(FFinstance* instance, json_object* module) ffPrintPlayer(instance, &options); } -#endif diff --git a/src/modules/player/player.h b/src/modules/player/player.h index 9b19d67cd..c480366d6 100644 --- a/src/modules/player/player.h +++ b/src/modules/player/player.h @@ -2,6 +2,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_PLAYER_MODULE_NAME "Player" @@ -9,8 +10,4 @@ void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options); void ffInitPlayerOptions(FFPlayerOptions* options); bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value); void ffDestroyPlayerOptions(FFPlayerOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParsePlayerJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 12e78395b..3c858942c 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/poweradapter/poweradapter.h" #include "modules/poweradapter/poweradapter.h" @@ -83,16 +83,21 @@ void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module) +void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module) { FFPowerAdapterOptions __attribute__((__cleanup__(ffDestroyPowerAdapterOptions))) options; ffInitPowerAdapterOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -102,4 +107,3 @@ void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module) ffPrintPowerAdapter(instance, &options); } -#endif diff --git a/src/modules/poweradapter/poweradapter.h b/src/modules/poweradapter/poweradapter.h index 4c11d1976..f8762fb38 100644 --- a/src/modules/poweradapter/poweradapter.h +++ b/src/modules/poweradapter/poweradapter.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_POWERADAPTER_MODULE_NAME "PowerAdapter" @@ -8,8 +9,4 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options); void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options); bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value); void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 719bb45f5..c09792537 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/processes/processes.h" #include "modules/processes/processes.h" @@ -51,16 +51,21 @@ void ffDestroyProcessesOptions(FFProcessesOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseProcessesJsonObject(FFinstance* instance, json_object* module) +void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module) { FFProcessesOptions __attribute__((__cleanup__(ffDestroyProcessesOptions))) options; ffInitProcessesOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -70,4 +75,3 @@ void ffParseProcessesJsonObject(FFinstance* instance, json_object* module) ffPrintProcesses(instance, &options); } -#endif diff --git a/src/modules/processes/processes.h b/src/modules/processes/processes.h index 34abb7ef8..1dd195d78 100644 --- a/src/modules/processes/processes.h +++ b/src/modules/processes/processes.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_PROCESSES_MODULE_NAME "Processes" @@ -8,8 +9,4 @@ void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options); void ffInitProcessesOptions(FFProcessesOptions* options); bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value); void ffDestroyProcessesOptions(FFProcessesOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseProcessesJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index a1ebc8819..464acb5c4 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/networking.h" #include "modules/publicip/publicip.h" @@ -103,28 +103,33 @@ void ffDestroyPublicIpOptions(FFPublicIpOptions* options) ffStrbufDestroy(&options->url); } -#ifdef FF_HAVE_JSONC -void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module) +void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module) { FFPublicIpOptions __attribute__((__cleanup__(ffDestroyPublicIpOptions))) options; ffInitPublicIpOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "url") == 0) { - ffStrbufSetS(&options.url, json_object_get_string(val)); + ffStrbufSetS(&options.url, yyjson_get_str(val)); continue; } if (strcasecmp(key, "timeout") == 0) { - options.timeout = (uint32_t) json_object_get_int(val); + options.timeout = (uint32_t) yyjson_get_uint(val); continue; } @@ -134,4 +139,3 @@ void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module) ffPrintPublicIp(instance, &options); } -#endif diff --git a/src/modules/publicip/publicip.h b/src/modules/publicip/publicip.h index 2306ddcf4..98b3083d4 100644 --- a/src/modules/publicip/publicip.h +++ b/src/modules/publicip/publicip.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_PUBLICIP_MODULE_NAME "PublicIp" @@ -10,8 +11,4 @@ void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options); void ffInitPublicIpOptions(FFPublicIpOptions* options); bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value); void ffDestroyPublicIpOptions(FFPublicIpOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index d693dc398..71e80835d 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "modules/separator/separator.h" void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) @@ -58,19 +58,24 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options) ffStrbufDestroy(&options->string); } -#ifdef FF_HAVE_JSONC -void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module) +void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module) { FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; ffInitSeparatorOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (strcasecmp(key, "string") == 0) { - ffStrbufSetS(&options.string, json_object_get_string(val)); + ffStrbufSetS(&options.string, yyjson_get_str(val)); continue; } @@ -80,4 +85,3 @@ void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module) ffPrintSeparator(instance, &options); } -#endif diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h index de26799bc..46ca7f80a 100644 --- a/src/modules/separator/separator.h +++ b/src/modules/separator/separator.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/separator/option.h" +#include #define FF_SEPARATOR_MODULE_NAME "Separator" @@ -9,8 +9,4 @@ void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options); void ffInitSeparatorOptions(FFSeparatorOptions* options); bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value); void ffDestroySeparatorOptions(FFSeparatorOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index ca5a22cab..d5023c443 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/terminalshell/terminalshell.h" #include "modules/shell/shell.h" @@ -71,22 +71,27 @@ void ffDestroyShellOptions(FFShellOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseShellJsonObject(FFinstance* instance, json_object* module) +void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module) { FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options; ffInitShellOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "version") == 0) { - options.version = (bool) json_object_get_boolean(val); + options.version = yyjson_get_bool(val); continue; } @@ -96,4 +101,3 @@ void ffParseShellJsonObject(FFinstance* instance, json_object* module) ffPrintShell(instance, &options); } -#endif diff --git a/src/modules/shell/shell.h b/src/modules/shell/shell.h index 210d17dbf..f3e75bcbd 100644 --- a/src/modules/shell/shell.h +++ b/src/modules/shell/shell.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_SHELL_MODULE_NAME "Shell" @@ -8,8 +9,4 @@ void ffPrintShell(FFinstance* instance, FFShellOptions* options); void ffInitShellOptions(FFShellOptions* options); bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value); void ffDestroyShellOptions(FFShellOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseShellJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 9f5e1c5a4..c5deab69a 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -1,4 +1,5 @@ #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/sound/sound.h" #include "modules/sound/sound.h" @@ -115,16 +116,21 @@ void ffDestroySoundOptions(FFSoundOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseSoundJsonObject(FFinstance* instance, json_object* module) +void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module) { FFSoundOptions __attribute__((__cleanup__(ffDestroySoundOptions))) options; ffInitSoundOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -150,4 +156,3 @@ void ffParseSoundJsonObject(FFinstance* instance, json_object* module) ffPrintSound(instance, &options); } -#endif diff --git a/src/modules/sound/sound.h b/src/modules/sound/sound.h index fa9d8dc87..f0ba01b9b 100644 --- a/src/modules/sound/sound.h +++ b/src/modules/sound/sound.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/title/option.h" +#include #define FF_SOUND_MODULE_NAME "Sound" @@ -9,8 +9,4 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options); void ffInitSoundOptions(FFSoundOptions* options); bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value); void ffDestroySoundOptions(FFSoundOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseSoundJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index d3029878e..af788bbe8 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/parsing.h" #include "common/bar.h" #include "detection/swap/swap.h" @@ -84,16 +84,21 @@ void ffDestroySwapOptions(FFSwapOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseSwapJsonObject(FFinstance* instance, json_object* module) +void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module) { FFSwapOptions __attribute__((__cleanup__(ffDestroySwapOptions))) options; ffInitSwapOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -103,4 +108,3 @@ void ffParseSwapJsonObject(FFinstance* instance, json_object* module) ffPrintSwap(instance, &options); } -#endif diff --git a/src/modules/swap/swap.h b/src/modules/swap/swap.h index 7326d14da..b561f146b 100644 --- a/src/modules/swap/swap.h +++ b/src/modules/swap/swap.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_SWAP_MODULE_NAME "Swap" @@ -8,8 +9,4 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options); void ffInitSwapOptions(FFSwapOptions* options); bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value); void ffDestroySwapOptions(FFSwapOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseSwapJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 23c2f8460..f90f9bead 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/terminalshell/terminalshell.h" #include "modules/terminal/terminal.h" @@ -72,22 +72,27 @@ void ffDestroyTerminalOptions(FFTerminalOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseTerminalJsonObject(FFinstance* instance, json_object* module) +void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module) { FFTerminalOptions __attribute__((__cleanup__(ffDestroyTerminalOptions))) options; ffInitTerminalOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "version") == 0) { - options.version = (bool) json_object_get_boolean(val); + options.version = yyjson_get_bool(val); continue; } @@ -97,4 +102,3 @@ void ffParseTerminalJsonObject(FFinstance* instance, json_object* module) ffPrintTerminal(instance, &options); } -#endif diff --git a/src/modules/terminal/terminal.h b/src/modules/terminal/terminal.h index 56a7dc0be..02c350255 100644 --- a/src/modules/terminal/terminal.h +++ b/src/modules/terminal/terminal.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_TERMINAL_MODULE_NAME "Terminal" @@ -8,8 +9,4 @@ void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options); void ffInitTerminalOptions(FFTerminalOptions* options); bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value); void ffDestroyTerminalOptions(FFTerminalOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseTerminalJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index afeb46919..eff1c5e5a 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/terminalfont/terminalfont.h" #include "modules/terminalfont/terminalfont.h" @@ -53,16 +53,21 @@ void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module) +void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module) { FFTerminalFontOptions __attribute__((__cleanup__(ffDestroyTerminalFontOptions))) options; ffInitTerminalFontOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -72,4 +77,3 @@ void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module) ffPrintTerminalFont(instance, &options); } -#endif diff --git a/src/modules/terminalfont/terminalfont.h b/src/modules/terminalfont/terminalfont.h index 336732917..d7c1be2b8 100644 --- a/src/modules/terminalfont/terminalfont.h +++ b/src/modules/terminalfont/terminalfont.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_TERMINALFONT_MODULE_NAME "TerminalFont" @@ -8,8 +9,4 @@ void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options); void ffInitTerminalFontOptions(FFTerminalFontOptions* options); bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value); void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index bb348e10e..63d16ba56 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/theme/theme.h" #include "modules/theme/theme.h" @@ -50,16 +50,21 @@ void ffDestroyThemeOptions(FFThemeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseThemeJsonObject(FFinstance* instance, json_object* module) +void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module) { FFThemeOptions __attribute__((__cleanup__(ffDestroyThemeOptions))) options; ffInitThemeOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseThemeJsonObject(FFinstance* instance, json_object* module) ffPrintTheme(instance, &options); } -#endif diff --git a/src/modules/theme/theme.h b/src/modules/theme/theme.h index 3c13ca467..ee9b2cc16 100644 --- a/src/modules/theme/theme.h +++ b/src/modules/theme/theme.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_THEME_MODULE_NAME "Theme" @@ -8,8 +9,4 @@ void ffPrintTheme(FFinstance* instance, FFThemeOptions* options); void ffInitThemeOptions(FFThemeOptions* options); bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value); void ffDestroyThemeOptions(FFThemeOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseThemeJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index fcdcdd3a1..58d398d3a 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "util/textModifier.h" #include "modules/title/title.h" @@ -58,19 +58,24 @@ void ffDestroyTitleOptions(FFTitleOptions* options) FF_UNUSED(options); } -#ifdef FF_HAVE_JSONC -void ffParseTitleJsonObject(FFinstance* instance, json_object* module) +void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module) { FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; ffInitTitleOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (strcasecmp(key, "fdqn") == 0) { - options.fdqn = json_object_get_boolean(val); + options.fdqn = yyjson_get_bool(val); continue; } @@ -80,4 +85,3 @@ void ffParseTitleJsonObject(FFinstance* instance, json_object* module) ffPrintTitle(instance, &options); } -#endif diff --git a/src/modules/title/title.h b/src/modules/title/title.h index ab6e07eae..e67fe8f3c 100644 --- a/src/modules/title/title.h +++ b/src/modules/title/title.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/title/option.h" +#include #define FF_TITLE_MODULE_NAME "Title" @@ -9,8 +9,4 @@ void ffPrintTitle(FFinstance* instance, FFTitleOptions* options); void ffInitTitleOptions(FFTitleOptions* options); bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value); void ffDestroyTitleOptions(FFTitleOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseTitleJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index f7fd7959c..5218c7a6a 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/uptime/uptime.h" #include "modules/uptime/uptime.h" @@ -99,16 +99,18 @@ void ffDestroyUptimeOptions(FFUptimeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseUptimeJsonObject(FFinstance* instance, json_object* module) +void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module) { FFUptimeOptions __attribute__((__cleanup__(ffDestroyUptimeOptions))) options; ffInitUptimeOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -118,4 +120,3 @@ void ffParseUptimeJsonObject(FFinstance* instance, json_object* module) ffPrintUptime(instance, &options); } -#endif diff --git a/src/modules/uptime/uptime.h b/src/modules/uptime/uptime.h index 35cc0365a..b9f909759 100644 --- a/src/modules/uptime/uptime.h +++ b/src/modules/uptime/uptime.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/title/option.h" +#include #define FF_UPTIME_MODULE_NAME "Uptime" @@ -9,8 +9,4 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options); void ffInitUptimeOptions(FFUptimeOptions* options); bool ffParseUptimeCommandOptions(FFUptimeOptions* options, const char* key, const char* value); void ffDestroyUptimeOptions(FFUptimeOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseUptimeJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 82698d6a8..b3ed8389a 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/users/users.h" #include "modules/users/users.h" @@ -63,16 +63,21 @@ void ffDestroyUsersOptions(FFUsersOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseUsersJsonObject(FFinstance* instance, json_object* module) +void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module) { FFUsersOptions __attribute__((__cleanup__(ffDestroyUsersOptions))) options; ffInitUsersOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -82,4 +87,3 @@ void ffParseUsersJsonObject(FFinstance* instance, json_object* module) ffPrintUsers(instance, &options); } -#endif diff --git a/src/modules/users/users.h b/src/modules/users/users.h index 233391f17..d17b685d6 100644 --- a/src/modules/users/users.h +++ b/src/modules/users/users.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_USERS_MODULE_NAME "Users" @@ -8,8 +9,4 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options); void ffInitUsersOptions(FFUsersOptions* options); bool ffParseUsersCommandOptions(FFUsersOptions* options, const char* key, const char* value); void ffDestroyUsersOptions(FFUsersOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseUsersJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index a33c40553..c9786cf2a 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/vulkan/vulkan.h" #include "modules/vulkan/vulkan.h" @@ -63,16 +63,21 @@ void ffDestroyVulkanOptions(FFVulkanOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseVulkanJsonObject(FFinstance* instance, json_object* module) +void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module) { FFVulkanOptions __attribute__((__cleanup__(ffDestroyVulkanOptions))) options; ffInitVulkanOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -82,4 +87,3 @@ void ffParseVulkanJsonObject(FFinstance* instance, json_object* module) ffPrintVulkan(instance, &options); } -#endif diff --git a/src/modules/vulkan/vulkan.h b/src/modules/vulkan/vulkan.h index 04145d678..751c29722 100644 --- a/src/modules/vulkan/vulkan.h +++ b/src/modules/vulkan/vulkan.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_VULKAN_MODULE_NAME "Vulkan" @@ -8,8 +9,4 @@ void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options); void ffInitVulkanOptions(FFVulkanOptions* options); bool ffParseVulkanCommandOptions(FFVulkanOptions* options, const char* key, const char* value); void ffDestroyVulkanOptions(FFVulkanOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseVulkanJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index aeff9eb30..936442c6c 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/wallpaper/wallpaper.h" #include "modules/wallpaper/wallpaper.h" @@ -50,16 +50,21 @@ void ffDestroyWallpaperOptions(FFWallpaperOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseWallpaperJsonObject(FFinstance* instance, json_object* module) +void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) { FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options; ffInitWallpaperOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseWallpaperJsonObject(FFinstance* instance, json_object* module) ffPrintWallpaper(instance, &options); } -#endif diff --git a/src/modules/wallpaper/wallpaper.h b/src/modules/wallpaper/wallpaper.h index efb0f17c0..7e77f49df 100644 --- a/src/modules/wallpaper/wallpaper.h +++ b/src/modules/wallpaper/wallpaper.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_WALLPAPER_MODULE_NAME "Wallpaper" @@ -8,8 +9,4 @@ void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options); void ffInitWallpaperOptions(FFWallpaperOptions* options); bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value); void ffDestroyWallpaperOptions(FFWallpaperOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseWallpaperJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 579cdf1cb..ae6c73f3b 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -1,9 +1,8 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "common/networking.h" #include "modules/weather/weather.h" -#define FF_WEATHER_MODULE_NAME "Weather" #define FF_WEATHER_NUM_FORMAT_ARGS 1 static FFNetworkingState state; @@ -88,28 +87,33 @@ void ffDestroyWeatherOptions(FFWeatherOptions* options) ffStrbufDestroy(&options->outputFormat); } -#ifdef FF_HAVE_JSONC -void ffParseWeatherJsonObject(FFinstance* instance, json_object* module) +void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module) { FFWeatherOptions __attribute__((__cleanup__(ffDestroyWeatherOptions))) options; ffInitWeatherOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; if (strcasecmp(key, "outputFormat") == 0) { - ffStrbufSetS(&options.outputFormat, json_object_get_string(val)); + ffStrbufSetS(&options.outputFormat, yyjson_get_str(val)); continue; } if (strcasecmp(key, "timeout") == 0) { - options.timeout = (uint32_t) json_object_get_int(val); + options.timeout = (uint32_t) yyjson_get_uint(val); continue; } @@ -119,4 +123,3 @@ void ffParseWeatherJsonObject(FFinstance* instance, json_object* module) ffPrintWeather(instance, &options); } -#endif diff --git a/src/modules/weather/weather.h b/src/modules/weather/weather.h index 476a1586d..2cbba0e1c 100644 --- a/src/modules/weather/weather.h +++ b/src/modules/weather/weather.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_WEATHER_MODULE_NAME "Weather" @@ -10,8 +11,4 @@ void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options); void ffInitWeatherOptions(FFWeatherOptions* options); bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, const char* value); void ffDestroyWeatherOptions(FFWeatherOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseWeatherJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index cd35eb5f9..2511a8857 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/wifi/wifi.h" #include "modules/wifi/wifi.h" @@ -90,16 +90,21 @@ void ffDestroyWifiOptions(FFWifiOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseWifiJsonObject(FFinstance* instance, json_object* module) +void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module) { FFWifiOptions __attribute__((__cleanup__(ffDestroyWifiOptions))) options; ffInitWifiOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -109,4 +114,3 @@ void ffParseWifiJsonObject(FFinstance* instance, json_object* module) ffPrintWifi(instance, &options); } -#endif diff --git a/src/modules/wifi/wifi.h b/src/modules/wifi/wifi.h index bb6aa1884..a9e21d1e8 100644 --- a/src/modules/wifi/wifi.h +++ b/src/modules/wifi/wifi.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/wifi/option.h" +#include #define FF_WIFI_MODULE_NAME "Wifi" @@ -9,8 +9,4 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options); void ffInitWifiOptions(FFWifiOptions* options); bool ffParseWifiCommandOptions(FFWifiOptions* options, const char* key, const char* value); void ffDestroyWifiOptions(FFWifiOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseWifiJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 172066fe8..4e04b0c71 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/wm/wm.h" @@ -61,16 +61,21 @@ void ffDestroyWMOptions(FFWMOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseWMJsonObject(FFinstance* instance, json_object* module) +void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module) { FFWMOptions __attribute__((__cleanup__(ffDestroyWMOptions))) options; ffInitWMOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -80,4 +85,3 @@ void ffParseWMJsonObject(FFinstance* instance, json_object* module) ffPrintWM(instance, &options); } -#endif diff --git a/src/modules/wm/wm.h b/src/modules/wm/wm.h index 86214a3dc..74e999ad2 100644 --- a/src/modules/wm/wm.h +++ b/src/modules/wm/wm.h @@ -1,6 +1,7 @@ #pragma once #include "fastfetch.h" +#include #define FF_WM_MODULE_NAME "WM" @@ -8,8 +9,4 @@ void ffPrintWM(FFinstance* instance, FFWMOptions* options); void ffInitWMOptions(FFWMOptions* options); bool ffParseWMCommandOptions(FFWMOptions* options, const char* key, const char* value); void ffDestroyWMOptions(FFWMOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseWMJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 4a2ffbcd2..d0273975a 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -1,5 +1,5 @@ -#include "fastfetch.h" #include "common/printing.h" +#include "common/jsonconfig.h" #include "detection/wmtheme/wmtheme.h" #include "modules/wmtheme/wmtheme.h" @@ -50,16 +50,21 @@ void ffDestroyWMThemeOptions(FFWMThemeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -#ifdef FF_HAVE_JSONC -void ffParseWMThemeJsonObject(FFinstance* instance, json_object* module) +void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module) { FFWMThemeOptions __attribute__((__cleanup__(ffDestroyWMThemeOptions))) options; ffInitWMThemeOptions(&options); if (module) { - json_object_object_foreach(module, key, val) + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; @@ -69,4 +74,3 @@ void ffParseWMThemeJsonObject(FFinstance* instance, json_object* module) ffPrintWMTheme(instance, &options); } -#endif diff --git a/src/modules/wmtheme/wmtheme.h b/src/modules/wmtheme/wmtheme.h index c1f95312d..34fcfe6ab 100644 --- a/src/modules/wmtheme/wmtheme.h +++ b/src/modules/wmtheme/wmtheme.h @@ -1,7 +1,7 @@ #pragma once #include "fastfetch.h" -#include "modules/wmtheme/option.h" +#include #define FF_WMTHEME_MODULE_NAME "WMTheme" @@ -9,8 +9,4 @@ void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options); void ffInitWMThemeOptions(FFWMThemeOptions* options); bool ffParseWMThemeCommandOptions(FFWMThemeOptions* options, const char* key, const char* value); void ffDestroyWMThemeOptions(FFWMThemeOptions* options); - -#ifdef FF_HAVE_JSONC -#include "common/jsonconfig.h" -void ffParseWMThemeJsonObject(FFinstance* instance, json_object* module); -#endif +void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module); From 6d6eee99684d52b5107f88a721af0b159b614835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 10 Jun 2023 21:34:41 +0800 Subject: [PATCH 075/493] JsonConfig: support Logo config (WIP) --- src/common/init.c | 1 + src/common/option.c | 9 +- src/common/option.h | 2 +- src/fastfetch.c | 109 ++++++++++------- src/fastfetch.h | 2 + src/logo/logo.h | 1 + src/logo/option.c | 154 +++++++++++++++++++++++- src/modules/battery/battery.h | 1 - src/modules/bios/bios.h | 1 - src/modules/bluetooth/bluetooth.h | 1 - src/modules/board/board.h | 1 - src/modules/break/break.h | 1 - src/modules/brightness/brightness.h | 1 - src/modules/chassis/chassis.h | 1 - src/modules/colors/colors.h | 1 - src/modules/command/command.h | 1 - src/modules/cpu/cpu.h | 1 - src/modules/cpuusage/cpuusage.h | 1 - src/modules/cursor/cursor.h | 1 - src/modules/custom/custom.h | 1 - src/modules/datetime/datetime.h | 1 - src/modules/de/de.h | 1 - src/modules/disk/disk.h | 1 - src/modules/display/display.h | 1 - src/modules/font/font.h | 1 - src/modules/gamepad/gamepad.h | 1 - src/modules/gpu/gpu.h | 1 - src/modules/host/host.h | 1 - src/modules/icons/icons.h | 1 - src/modules/jsonconfig/jsonconfig.c | 25 +--- src/modules/kernel/kernel.h | 1 - src/modules/locale/locale.h | 1 - src/modules/localip/localip.h | 1 - src/modules/media/media.h | 1 - src/modules/memory/memory.h | 1 - src/modules/opencl/opencl.h | 1 - src/modules/opengl/opengl.h | 1 - src/modules/os/os.h | 1 - src/modules/packages/packages.h | 1 - src/modules/player/player.h | 1 - src/modules/poweradapter/poweradapter.h | 1 - src/modules/processes/processes.h | 1 - src/modules/publicip/publicip.h | 1 - src/modules/separator/separator.h | 1 - src/modules/shell/shell.h | 1 - src/modules/sound/sound.h | 1 - src/modules/swap/swap.h | 1 - src/modules/terminal/terminal.h | 1 - src/modules/terminalfont/terminalfont.h | 1 - src/modules/theme/theme.h | 1 - src/modules/title/title.h | 1 - src/modules/uptime/uptime.h | 1 - src/modules/users/users.h | 1 - src/modules/vulkan/vulkan.h | 1 - src/modules/wallpaper/wallpaper.h | 1 - src/modules/weather/weather.h | 1 - src/modules/wifi/wifi.h | 1 - src/modules/wm/wm.h | 1 - src/modules/wmtheme/wmtheme.h | 1 - 59 files changed, 224 insertions(+), 130 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index f812d8b7b..326d571d0 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -331,6 +331,7 @@ static void destroyConfig(FFinstance* instance) static void destroyState(FFinstance* instance) { ffPlatformDestroy(&instance->state.platform); + yyjson_doc_free(instance->state.configDoc); } void ffDestroyInstance(FFinstance* instance) diff --git a/src/common/option.c b/src/common/option.c index e151788be..f9bdbcff6 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -105,19 +105,14 @@ bool ffOptionParseBoolean(const char* str) ); } -void ffOptionParseColor(const char* key, const char* value, FFstrbuf* buffer) +void ffOptionParseColor(const char* value, FFstrbuf* buffer) { - if(value == NULL) - { - fprintf(stderr, "Error: usage: %s \n", key); - exit(477); - } ffStrbufEnsureFree(buffer, 63); while(*value != '\0') { #define FF_APPEND_COLOR_CODE_COND(prefix, code) \ - if(strncasecmp(value, #prefix, strlen(#prefix))) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); } + if(strncasecmp(value, #prefix, strlen(#prefix)) == 0) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); } FF_APPEND_COLOR_CODE_COND(reset_, "0;") else FF_APPEND_COLOR_CODE_COND(bright_, "1;") diff --git a/src/common/option.h b/src/common/option.h index 0c8d29b1b..e0ca7feca 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -21,6 +21,6 @@ void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* b FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); FF_C_NODISCARD bool ffOptionParseBoolean(const char* str); -void ffOptionParseColor(const char* key, const char* value, FFstrbuf* buffer); +void ffOptionParseColor(const char* value, FFstrbuf* buffer); void ffOptionInitModuleArg(FFModuleArgs* args); void ffOptionDestroyModuleArg(FFModuleArgs* args); diff --git a/src/fastfetch.c b/src/fastfetch.c index 301caeddc..685e6c1d6 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -496,8 +496,16 @@ static void listConfigPaths(FFinstance* instance) { FF_LIST_FOR_EACH(FFstrbuf, folder, instance->state.platform.configDirs) { - ffStrbufAppendS(folder, "fastfetch/config.conf"); - printf("%s%s\n", folder->chars, ffPathExists(folder->chars, FF_PATHTYPE_FILE) ? " (*)" : ""); + bool exists = false; + ffStrbufAppendS(folder, "fastfetch/config.jsonc"); + exists = ffPathExists(folder->chars, FF_PATHTYPE_FILE); + if (!exists) + { + ffStrbufSubstrBefore(folder, folder->length - (uint32_t) strlen("jsonc")); + ffStrbufAppendS(folder, "conf"); + exists = ffPathExists(folder->chars, FF_PATHTYPE_FILE); + } + printf("%s%s\n", folder->chars, exists ? " (*)" : ""); } } @@ -512,6 +520,23 @@ static void listDataPaths(FFinstance* instance) static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value); +static bool parseJsoncFile(FFinstance* instance, const char* path) +{ + yyjson_doc* doc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL); + if (doc) + { + instance->state.configDoc = doc; + const char* error = ffParseLogoJsonConfig(instance); + if (error) + { + fputs(error, stderr); + exit(477); + } + return true; + } + return false; +} + static bool parseConfigFile(FFinstance* instance, FFdata* data, const char* path) { FILE* file = fopen(path, "r"); @@ -662,35 +687,6 @@ static inline bool startsWith(const char* str, const char* compareTo) return strncasecmp(str, compareTo, strlen(compareTo)) == 0; } -static void optionParseColor(const char* key, const char* value, FFstrbuf* buffer) -{ - optionCheckString(key, value, buffer); - - while(*value != '\0') - { - #define FF_APPEND_COLOR_CODE_COND(prefix, code) \ - if(startsWith(value, #prefix)) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); } - - FF_APPEND_COLOR_CODE_COND(reset_, "0;") - else FF_APPEND_COLOR_CODE_COND(bright_, "1;") - else FF_APPEND_COLOR_CODE_COND(black, "30") - else FF_APPEND_COLOR_CODE_COND(red, "31") - else FF_APPEND_COLOR_CODE_COND(green, "32") - else FF_APPEND_COLOR_CODE_COND(yellow, "33") - else FF_APPEND_COLOR_CODE_COND(blue, "34") - else FF_APPEND_COLOR_CODE_COND(magenta, "35") - else FF_APPEND_COLOR_CODE_COND(cyan, "36") - else FF_APPEND_COLOR_CODE_COND(white, "37") - else - { - ffStrbufAppendC(buffer, *value); - ++value; - } - - #undef FF_APPEND_COLOR_CODE_COND - } -} - static uint32_t optionParseUInt32(const char* key, const char* value) { if(value == NULL) @@ -914,12 +910,19 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "--separator") == 0) optionParseString(key, value, &instance->config.keyValueSeparator); else if(strcasecmp(key, "--color-keys") == 0) - optionParseColor(key, value, &instance->config.colorKeys); + { + optionCheckString(key, value, &instance->config.colorKeys); + ffOptionParseColor(value, &instance->config.colorKeys); + } else if(strcasecmp(key, "--color-title") == 0) - optionParseColor(key, value, &instance->config.colorTitle); + { + optionCheckString(key, value, &instance->config.colorTitle); + ffOptionParseColor(value, &instance->config.colorTitle); + } else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0) { - optionParseColor(key, value, &instance->config.colorKeys); + optionCheckString(key, value, &instance->config.colorKeys); + ffOptionParseColor(value, &instance->config.colorKeys); ffStrbufSet(&instance->config.colorTitle, &instance->config.colorKeys); } else if(strcasecmp(key, "--binary-prefix") == 0) @@ -1066,6 +1069,17 @@ error: static void parseConfigFiles(FFinstance* instance, FFdata* data) { + for(uint32_t i = instance->state.platform.configDirs.length; i > 0; --i) + { + FFstrbuf* dir = ffListGet(&instance->state.platform.configDirs, i - 1); + uint32_t dirLength = dir->length; + + ffStrbufAppendS(dir, "fastfetch/config.jsonc"); + bool success = parseJsoncFile(instance, dir->chars); + ffStrbufSubstrBefore(dir, dirLength); + if (success) return; + } + for(uint32_t i = instance->state.platform.configDirs.length; i > 0; --i) { if(!data->loadUserConfig) @@ -1225,20 +1239,23 @@ int main(int argc, const char** argv) parseConfigFiles(&instance, &data); parseArguments(&instance, &data, argc, argv); - //If we don't have a custom structure, use the default one - if(data.structure.length == 0) - ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE); - - if(ffStrbufContainIgnCaseS(&data.structure, FF_CPUUSAGE_MODULE_NAME)) - ffPrepareCPUUsage(); - - if(instance.config.multithreading) + if(!instance.state.configDoc) { - if(ffStrbufContainIgnCaseS(&data.structure, FF_PUBLICIP_MODULE_NAME)) - ffPreparePublicIp(&instance.config.publicIP); + //If we don't have a custom structure, use the default one + if(data.structure.length == 0) + ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE); - if(ffStrbufContainIgnCaseS(&data.structure, FF_WEATHER_MODULE_NAME)) - ffPrepareWeather(&instance.config.weather); + if(ffStrbufContainIgnCaseS(&data.structure, FF_CPUUSAGE_MODULE_NAME)) + ffPrepareCPUUsage(); + + if(instance.config.multithreading) + { + if(ffStrbufContainIgnCaseS(&data.structure, FF_PUBLICIP_MODULE_NAME)) + ffPreparePublicIp(&instance.config.publicIP); + + if(ffStrbufContainIgnCaseS(&data.structure, FF_WEATHER_MODULE_NAME)) + ffPrepareWeather(&instance.config.weather); + } } ffStart(&instance); diff --git a/src/fastfetch.h b/src/fastfetch.h index 4bdeac603..b1bfb2d52 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -7,6 +7,7 @@ #include #include +#include #include "util/FFstrbuf.h" #include "util/FFlist.h" @@ -135,6 +136,7 @@ typedef struct FFstate uint32_t titleLength; FFPlatform platform; + yyjson_doc* configDoc; } FFstate; typedef struct FFinstance diff --git a/src/logo/logo.h b/src/logo/logo.h index 9d3878c66..0bc74ea0e 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -30,5 +30,6 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type, bool printE void ffInitLogoOptions(FFLogoOptions* options); bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const char* value); void ffDestroyLogoOptions(FFLogoOptions* options); +const char* ffParseLogoJsonConfig(FFinstance* instance); #endif diff --git a/src/logo/option.c b/src/logo/option.c index 033885635..0239bf5ab 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -1,5 +1,7 @@ #include "logo/logo.h" +#include "common/jsonconfig.h" + void ffInitLogoOptions(FFLogoOptions* options) { ffStrbufInit(&options->source); @@ -72,8 +74,12 @@ logoType: fprintf(stderr, "Error: invalid --color-[1-9] index: %c\n", key[13]); exit(472); } - - ffOptionParseColor(key, value, &options->colors[index]); + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", key); + exit(477); + } + ffOptionParseColor(value, &options->colors[index]); } else if(strcasecmp(subKey, "width") == 0) options->width = ffOptionParseUInt32(key, value); @@ -181,3 +187,147 @@ void ffDestroyLogoOptions(FFLogoOptions* options) for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i) ffStrbufDestroy(&options->colors[i]); } + +const char* ffParseLogoJsonConfig(FFinstance* instance) +{ + FFLogoOptions* options = &instance->config.logo; + + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* object = yyjson_obj_get(root, "logo"); + if (!object) return NULL; + if (!yyjson_is_obj(object)) return "Property 'logo' must be an object"; + + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(object, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + + if (strcasecmp(key, "type") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "auto", FF_LOGO_TYPE_AUTO }, + { "builtin", FF_LOGO_TYPE_BUILTIN }, + { "file", FF_LOGO_TYPE_FILE }, + { "file-raw", FF_LOGO_TYPE_FILE_RAW }, + { "data", FF_LOGO_TYPE_DATA }, + { "data-raw", FF_LOGO_TYPE_DATA_RAW }, + { "sixel", FF_LOGO_TYPE_IMAGE_SIXEL }, + { "kitty", FF_LOGO_TYPE_IMAGE_KITTY }, + { "iterm", FF_LOGO_TYPE_IMAGE_ITERM }, + { "chafa", FF_LOGO_TYPE_IMAGE_CHAFA }, + { "raw", FF_LOGO_TYPE_IMAGE_RAW }, + { "none", FF_LOGO_TYPE_NONE }, + {}, + }); + + if (error) return error; + options->type = (FFLogoType) value; + continue; + } + else if (strcasecmp(key, "source") == 0) + { + ffStrbufSetS(&options->source, yyjson_get_str(val)); + continue; + } + else if (strcasecmp(key, "color") == 0) + { + if (!yyjson_is_obj(val)) + return "Property 'color' must be an object"; + + yyjson_val *key_c, *valc; + size_t idxc, maxc; + yyjson_obj_foreach(val, idxc, maxc, key_c, valc) + { + const char* keyc = yyjson_get_str(key_c); + uint32_t index = (uint32_t) strtoul(keyc, NULL, 10); + if (index < 1 || index > 9) + return "Keys of property 'color' must be a number between 1 to 9"; + + ffOptionParseColor(yyjson_get_str(valc), &options->colors[index - 1]); + } + continue; + } + else if (strcasecmp(key, "width") == 0) + { + uint32_t value = (uint32_t) yyjson_get_uint(val); + if (value == 0) + return "Logo width must be a possitive integer"; + options->width = value; + continue; + } + else if (strcasecmp(key, "height") == 0) + { + uint32_t value = (uint32_t) yyjson_get_uint(val); + if (value == 0) + return "Logo height must be a possitive integer"; + options->height = value; + continue; + } + else if (strcasecmp(key, "padding") == 0) + { + if (!yyjson_is_obj(val)) + return "Logo padding must be an object"; + + #define FF_PARSE_PADDING_POSITON(pos, paddingPos) \ + yyjson_val* pos = yyjson_obj_get(val, #pos); \ + if (pos) \ + { \ + if (!yyjson_is_uint(pos)) \ + return "Logo padding values must be possitive integers"; \ + options->paddingPos = (uint32_t) yyjson_get_uint(pos); \ + } + FF_PARSE_PADDING_POSITON(left, paddingLeft); + FF_PARSE_PADDING_POSITON(top, paddingTop); + FF_PARSE_PADDING_POSITON(right, paddingRight); + #undef FF_PARSE_PADDING_POSITON + continue; + } + else if (strcasecmp(key, "printRemaining")) + { + options->printRemaining = yyjson_get_bool(val); + continue; + } + else if (strcasecmp(key, "preserveAspectRadio")) + { + options->preserveAspectRadio = yyjson_get_bool(val); + continue; + } + else if (strcasecmp(key, "chafa")) + { + if (!yyjson_is_obj(val)) + return "Chafa config must be an object"; + + yyjson_val* fgOnly = yyjson_obj_get(val, "fgOnly"); + if (fgOnly) + options->chafaFgOnly = yyjson_get_bool(fgOnly); + + yyjson_val* symbols = yyjson_obj_get(val, "symbols"); + if (symbols) + ffStrbufAppendS(&options->chafaSymbols, yyjson_get_str(symbols)); + + yyjson_val* canvasMode = yyjson_obj_get(val, "canvasMode"); + if (canvasMode) + options->chafaCanvasMode = (uint32_t) yyjson_get_uint(canvasMode); + + yyjson_val* colorSpace = yyjson_obj_get(val, "colorSpace"); + if (colorSpace) + options->chafaColorSpace = (uint32_t) yyjson_get_uint(colorSpace); + + yyjson_val* ditherMode = yyjson_obj_get(val, "ditherMode"); + if (ditherMode) + options->chafaDitherMode = (uint32_t) yyjson_get_uint(ditherMode); + continue; + } + else + return "Unknown logo key"; + } + + return NULL; +} diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index 524a265d0..d9f39acea 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BATTERY_MODULE_NAME "Battery" diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h index 990a432d5..ca01b0902 100644 --- a/src/modules/bios/bios.h +++ b/src/modules/bios/bios.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BIOS_MODULE_NAME "Bios" diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h index 230ab5c0a..1834330e5 100644 --- a/src/modules/bluetooth/bluetooth.h +++ b/src/modules/bluetooth/bluetooth.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BLUETOOTH_MODULE_NAME "Bluetooth" diff --git a/src/modules/board/board.h b/src/modules/board/board.h index d2afbfd82..e10c4f61b 100644 --- a/src/modules/board/board.h +++ b/src/modules/board/board.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BOARD_MODULE_NAME "Board" diff --git a/src/modules/break/break.h b/src/modules/break/break.h index f313774fe..2c534d341 100644 --- a/src/modules/break/break.h +++ b/src/modules/break/break.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BREAK_MODULE_NAME "Break" diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h index 00c5f13f7..b4c089424 100644 --- a/src/modules/brightness/brightness.h +++ b/src/modules/brightness/brightness.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_BRIGHTNESS_MODULE_NAME "Brightness" diff --git a/src/modules/chassis/chassis.h b/src/modules/chassis/chassis.h index 566198e17..1a85b2727 100644 --- a/src/modules/chassis/chassis.h +++ b/src/modules/chassis/chassis.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_CHASSIS_MODULE_NAME "Chassis" diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index cfd7860e4..990ae4348 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_COLORS_MODULE_NAME "Colors" diff --git a/src/modules/command/command.h b/src/modules/command/command.h index fd1a8705f..63ca643fb 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_COMMAND_MODULE_NAME "Command" diff --git a/src/modules/cpu/cpu.h b/src/modules/cpu/cpu.h index de9cb9c41..1a8f32922 100644 --- a/src/modules/cpu/cpu.h +++ b/src/modules/cpu/cpu.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_CPU_MODULE_NAME "CPU" diff --git a/src/modules/cpuusage/cpuusage.h b/src/modules/cpuusage/cpuusage.h index 2bde09f0d..bd12de8a6 100644 --- a/src/modules/cpuusage/cpuusage.h +++ b/src/modules/cpuusage/cpuusage.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_CPUUSAGE_MODULE_NAME "CPUUsage" diff --git a/src/modules/cursor/cursor.h b/src/modules/cursor/cursor.h index 210915883..f36975aa7 100644 --- a/src/modules/cursor/cursor.h +++ b/src/modules/cursor/cursor.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_CURSOR_MODULE_NAME "Cursor" diff --git a/src/modules/custom/custom.h b/src/modules/custom/custom.h index 7be41c0a6..fec8099b3 100644 --- a/src/modules/custom/custom.h +++ b/src/modules/custom/custom.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_CUSTOM_MODULE_NAME "Custom" diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index c845a8e6f..01b67701b 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_DATETIME_MODULE_NAME "DateTime" diff --git a/src/modules/de/de.h b/src/modules/de/de.h index 8530bf6e3..3d7d6f729 100644 --- a/src/modules/de/de.h +++ b/src/modules/de/de.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_DE_MODULE_NAME "DE" diff --git a/src/modules/disk/disk.h b/src/modules/disk/disk.h index efba1e7fc..82886a257 100644 --- a/src/modules/disk/disk.h +++ b/src/modules/disk/disk.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_DISK_MODULE_NAME "Disk" diff --git a/src/modules/display/display.h b/src/modules/display/display.h index 8781d4e41..62a4c210e 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_DISPLAY_MODULE_NAME "Display" diff --git a/src/modules/font/font.h b/src/modules/font/font.h index ba1c8fade..c26987d29 100644 --- a/src/modules/font/font.h +++ b/src/modules/font/font.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_FONT_MODULE_NAME "Font" diff --git a/src/modules/gamepad/gamepad.h b/src/modules/gamepad/gamepad.h index 0c4c96ddb..f08b01937 100644 --- a/src/modules/gamepad/gamepad.h +++ b/src/modules/gamepad/gamepad.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_GAMEPAD_MODULE_NAME "Gamepad" diff --git a/src/modules/gpu/gpu.h b/src/modules/gpu/gpu.h index aa9c11374..ee8a61826 100644 --- a/src/modules/gpu/gpu.h +++ b/src/modules/gpu/gpu.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_GPU_MODULE_NAME "GPU" diff --git a/src/modules/host/host.h b/src/modules/host/host.h index 8bbc53f41..43d51f3d4 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_HOST_MODULE_NAME "Host" diff --git a/src/modules/icons/icons.h b/src/modules/icons/icons.h index 46867bd23..ea49656f7 100644 --- a/src/modules/icons/icons.h +++ b/src/modules/icons/icons.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_ICONS_MODULE_NAME "Icons" diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c index fa4a5768a..4f4019e11 100644 --- a/src/modules/jsonconfig/jsonconfig.c +++ b/src/modules/jsonconfig/jsonconfig.c @@ -162,30 +162,9 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson } } -static inline void wrapYyjsonFree(yyjson_doc** doc) -{ - assert(doc); - if (*doc) - yyjson_doc_free(*doc); -} - static const char* printJsonConfig(FFinstance* instance) { - FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs) - { - uint32_t oldLength = filename->length; - ffStrbufAppendS(filename, "fastfetch/config.jsonc"); - bool success = ffAppendFileBuffer(filename->chars, &content); - ffStrbufSubstrBefore(filename, oldLength); - if (success) break; - } - - yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content.chars, content.length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL); - if (!doc) - return "Failed to parse JSON config file"; - - yyjson_val* const root = yyjson_doc_get_root(doc); + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); assert(root); if (!yyjson_is_obj(root)) @@ -193,7 +172,7 @@ static const char* printJsonConfig(FFinstance* instance) yyjson_val* modules = yyjson_obj_get(root, "modules"); if (!modules) return "Property 'modules' is not found"; - if (!yyjson_is_arr(modules)) return "modules must be an array of strings or objects"; + if (!yyjson_is_arr(modules)) return "Property 'modules' must be an array of strings or objects"; yyjson_val* item; size_t idx, max; diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h index 25d840cc6..4e21eb3dd 100644 --- a/src/modules/kernel/kernel.h +++ b/src/modules/kernel/kernel.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_KERNEL_MODULE_NAME "Kernel" diff --git a/src/modules/locale/locale.h b/src/modules/locale/locale.h index c41290b9f..93d3e820c 100644 --- a/src/modules/locale/locale.h +++ b/src/modules/locale/locale.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_LOCALE_MODULE_NAME "Locale" diff --git a/src/modules/localip/localip.h b/src/modules/localip/localip.h index 7ab4fd1fa..d758f4fab 100644 --- a/src/modules/localip/localip.h +++ b/src/modules/localip/localip.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_LOCALIP_MODULE_NAME "LocalIp" diff --git a/src/modules/media/media.h b/src/modules/media/media.h index f7a43bac4..f35421504 100644 --- a/src/modules/media/media.h +++ b/src/modules/media/media.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_MEDIA_MODULE_NAME "Media" diff --git a/src/modules/memory/memory.h b/src/modules/memory/memory.h index 4a7fbba98..c5bf8e733 100644 --- a/src/modules/memory/memory.h +++ b/src/modules/memory/memory.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_MEMORY_MODULE_NAME "Memory" diff --git a/src/modules/opencl/opencl.h b/src/modules/opencl/opencl.h index 633929889..479e2e231 100644 --- a/src/modules/opencl/opencl.h +++ b/src/modules/opencl/opencl.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_OPENCL_MODULE_NAME "OpenCL" diff --git a/src/modules/opengl/opengl.h b/src/modules/opengl/opengl.h index 2c85af45c..a5b88b23d 100644 --- a/src/modules/opengl/opengl.h +++ b/src/modules/opengl/opengl.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_OPENGL_MODULE_NAME "OpenGL" diff --git a/src/modules/os/os.h b/src/modules/os/os.h index 3f5299fc1..55036fed1 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_OS_MODULE_NAME "OS" diff --git a/src/modules/packages/packages.h b/src/modules/packages/packages.h index 6798d26e5..8aec1a0fc 100644 --- a/src/modules/packages/packages.h +++ b/src/modules/packages/packages.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_PACKAGES_MODULE_NAME "Packages" diff --git a/src/modules/player/player.h b/src/modules/player/player.h index c480366d6..1825d2f9e 100644 --- a/src/modules/player/player.h +++ b/src/modules/player/player.h @@ -2,7 +2,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_PLAYER_MODULE_NAME "Player" diff --git a/src/modules/poweradapter/poweradapter.h b/src/modules/poweradapter/poweradapter.h index f8762fb38..f8cca4c6c 100644 --- a/src/modules/poweradapter/poweradapter.h +++ b/src/modules/poweradapter/poweradapter.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_POWERADAPTER_MODULE_NAME "PowerAdapter" diff --git a/src/modules/processes/processes.h b/src/modules/processes/processes.h index 1dd195d78..6aa952574 100644 --- a/src/modules/processes/processes.h +++ b/src/modules/processes/processes.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_PROCESSES_MODULE_NAME "Processes" diff --git a/src/modules/publicip/publicip.h b/src/modules/publicip/publicip.h index 98b3083d4..618d054ff 100644 --- a/src/modules/publicip/publicip.h +++ b/src/modules/publicip/publicip.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_PUBLICIP_MODULE_NAME "PublicIp" diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h index 46ca7f80a..6da53e559 100644 --- a/src/modules/separator/separator.h +++ b/src/modules/separator/separator.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_SEPARATOR_MODULE_NAME "Separator" diff --git a/src/modules/shell/shell.h b/src/modules/shell/shell.h index f3e75bcbd..0225b6291 100644 --- a/src/modules/shell/shell.h +++ b/src/modules/shell/shell.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_SHELL_MODULE_NAME "Shell" diff --git a/src/modules/sound/sound.h b/src/modules/sound/sound.h index f0ba01b9b..0ebfe328f 100644 --- a/src/modules/sound/sound.h +++ b/src/modules/sound/sound.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_SOUND_MODULE_NAME "Sound" diff --git a/src/modules/swap/swap.h b/src/modules/swap/swap.h index b561f146b..6945f854c 100644 --- a/src/modules/swap/swap.h +++ b/src/modules/swap/swap.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_SWAP_MODULE_NAME "Swap" diff --git a/src/modules/terminal/terminal.h b/src/modules/terminal/terminal.h index 02c350255..5f2045e78 100644 --- a/src/modules/terminal/terminal.h +++ b/src/modules/terminal/terminal.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_TERMINAL_MODULE_NAME "Terminal" diff --git a/src/modules/terminalfont/terminalfont.h b/src/modules/terminalfont/terminalfont.h index d7c1be2b8..25f974261 100644 --- a/src/modules/terminalfont/terminalfont.h +++ b/src/modules/terminalfont/terminalfont.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_TERMINALFONT_MODULE_NAME "TerminalFont" diff --git a/src/modules/theme/theme.h b/src/modules/theme/theme.h index ee9b2cc16..ae332f49e 100644 --- a/src/modules/theme/theme.h +++ b/src/modules/theme/theme.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_THEME_MODULE_NAME "Theme" diff --git a/src/modules/title/title.h b/src/modules/title/title.h index e67fe8f3c..1b1c9460b 100644 --- a/src/modules/title/title.h +++ b/src/modules/title/title.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_TITLE_MODULE_NAME "Title" diff --git a/src/modules/uptime/uptime.h b/src/modules/uptime/uptime.h index b9f909759..e19da5157 100644 --- a/src/modules/uptime/uptime.h +++ b/src/modules/uptime/uptime.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_UPTIME_MODULE_NAME "Uptime" diff --git a/src/modules/users/users.h b/src/modules/users/users.h index d17b685d6..fa96d0dc4 100644 --- a/src/modules/users/users.h +++ b/src/modules/users/users.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_USERS_MODULE_NAME "Users" diff --git a/src/modules/vulkan/vulkan.h b/src/modules/vulkan/vulkan.h index 751c29722..68a3b8385 100644 --- a/src/modules/vulkan/vulkan.h +++ b/src/modules/vulkan/vulkan.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_VULKAN_MODULE_NAME "Vulkan" diff --git a/src/modules/wallpaper/wallpaper.h b/src/modules/wallpaper/wallpaper.h index 7e77f49df..bd2dbbbca 100644 --- a/src/modules/wallpaper/wallpaper.h +++ b/src/modules/wallpaper/wallpaper.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_WALLPAPER_MODULE_NAME "Wallpaper" diff --git a/src/modules/weather/weather.h b/src/modules/weather/weather.h index 2cbba0e1c..70c34b61f 100644 --- a/src/modules/weather/weather.h +++ b/src/modules/weather/weather.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_WEATHER_MODULE_NAME "Weather" diff --git a/src/modules/wifi/wifi.h b/src/modules/wifi/wifi.h index a9e21d1e8..99070d07b 100644 --- a/src/modules/wifi/wifi.h +++ b/src/modules/wifi/wifi.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_WIFI_MODULE_NAME "Wifi" diff --git a/src/modules/wm/wm.h b/src/modules/wm/wm.h index 74e999ad2..2f18b1c16 100644 --- a/src/modules/wm/wm.h +++ b/src/modules/wm/wm.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_WM_MODULE_NAME "WM" diff --git a/src/modules/wmtheme/wmtheme.h b/src/modules/wmtheme/wmtheme.h index 34fcfe6ab..5bb11cb3f 100644 --- a/src/modules/wmtheme/wmtheme.h +++ b/src/modules/wmtheme/wmtheme.h @@ -1,7 +1,6 @@ #pragma once #include "fastfetch.h" -#include #define FF_WMTHEME_MODULE_NAME "WMTheme" From c7a11e050cd282fd528f9103af603dc9e29e6fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 00:51:29 +0800 Subject: [PATCH 076/493] JsonConfig: don't make it a module So that JsonConfig doesn't rely on `--structure` --- CMakeLists.txt | 1 - src/common/init.c | 1 + src/common/jsonconfig.c | 225 ++++++++++++++++++++++++++++ src/common/jsonconfig.h | 3 +- src/fastfetch.c | 62 ++++---- src/modules/jsonconfig/jsonconfig.c | 207 ------------------------- src/modules/jsonconfig/jsonconfig.h | 7 - src/modules/modules.h | 1 - 8 files changed, 262 insertions(+), 245 deletions(-) delete mode 100644 src/modules/jsonconfig/jsonconfig.c delete mode 100644 src/modules/jsonconfig/jsonconfig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 13c3c3e06..d5dc8cf66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,7 +319,6 @@ set(LIBFASTFETCH_SRC src/modules/wifi/wifi.c src/modules/wm/wm.c src/modules/wmtheme/wmtheme.c - src/modules/jsonconfig/jsonconfig.c src/util/FFlist.c src/util/FFstrbuf.c src/util/platform/FFPlatform.c diff --git a/src/common/init.c b/src/common/init.c index 326d571d0..1c9fd67bb 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -26,6 +26,7 @@ static void initState(FFstate* state) state->titleLength = 0; ffPlatformInit(&state->platform); + state->configDoc = NULL; } static void defaultConfig(FFinstance* instance) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 17828077b..75f433dd0 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -1,5 +1,13 @@ #include "fastfetch.h" #include "common/jsonconfig.h" +#include "common/printing.h" +#include "common/io/io.h" +#include "common/time.h" +#include "modules/modules.h" + +#include +#include +#include bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs) { @@ -55,3 +63,220 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p else return "Invalid enum value type; must be a string or integer"; } + +static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module)) +{ + if (strcasecmp(type, moduleName) == 0) + { + f(instance, module); + return true; + } + return false; +} + +static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson_val* module) +{ + switch (toupper(type[0])) + { + case 'B': { + return + tryModule(instance, type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) || + tryModule(instance, type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) || + tryModule(instance, type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) || + tryModule(instance, type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) || + tryModule(instance, type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) || + tryModule(instance, type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) || + false; + } + + case 'C': { + return + tryModule(instance, type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || + tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || + tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || + tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || + tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || + tryModule(instance, type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || + tryModule(instance, type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || + false; + } + + case 'D': { + return + tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || + tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || + tryModule(instance, type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || + tryModule(instance, type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || + false; + } + + case 'F': { + return + tryModule(instance, type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) || + false; + } + + case 'G': { + return + tryModule(instance, type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || + tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || + false; + } + + case 'H': { + return + tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || + false; + } + + case 'I': { + return + tryModule(instance, type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) || + false; + } + + case 'K': { + return + tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || + false; + } + + case 'L': { + return + tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || + tryModule(instance, type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || + false; + } + + case 'M': { + return + tryModule(instance, type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || + tryModule(instance, type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || + false; + } + + case 'O': { + return + tryModule(instance, type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || + tryModule(instance, type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || + tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || + false; + } + + case 'P': { + return + tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || + tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || + tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || + tryModule(instance, type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) || + tryModule(instance, type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || + false; + } + + case 'S': { + return + tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || + tryModule(instance, type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) || + tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || + tryModule(instance, type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || + false; + } + + case 'T': { + return + tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || + tryModule(instance, type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || + tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || + tryModule(instance, type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || + false; + } + + case 'U': { + return + tryModule(instance, type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || + tryModule(instance, type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) || + false; + } + + case 'V': { + return + tryModule(instance, type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) || + false; + } + + case 'W': { + return + tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || + tryModule(instance, type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) || + tryModule(instance, type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || + tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || + tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || + false; + } + + default: + return false; + } +} + +static const char* printJsonConfig(FFinstance* instance) +{ + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* modules = yyjson_obj_get(root, "modules"); + if (!modules) return "Property 'modules' is not found"; + if (!yyjson_is_arr(modules)) return "Property 'modules' must be an array of strings or objects"; + + yyjson_val* item; + size_t idx, max; + yyjson_arr_foreach(modules, idx, max, item) + { + uint64_t ms = 0; + if(__builtin_expect(instance->config.stat, false)) + ms = ffTimeGetTick(); + + yyjson_val* module = item; + const char* type = yyjson_get_str(module); + if (type) + module = NULL; + else if (yyjson_is_obj(module)) + { + type = yyjson_get_str(yyjson_obj_get(module, "type")); + if (!type) return "module object must contain a \"type\" key ( case sensitive )"; + if (yyjson_obj_size(module) == 1) // contains only Property type + module = NULL; + } + else + return "modules must be an array of strings or objects"; + + if(!parseModuleJsonObject(instance, type, module)) + return "Unknown module type"; + + if(__builtin_expect(instance->config.stat, false)) + { + char str[32]; + int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); + if(instance->config.pipe) + puts(str); + else + printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + } + + #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + fflush(stdout); + #endif + } + + return NULL; +} + +void ffPrintJsonConfig(FFinstance* instance) +{ + const char* error = printJsonConfig(instance); + if (error) + ffPrintErrorString(instance, "JsonConfig", 0, NULL, NULL, "%s", error); +} diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h index 395fbd397..8a235ae2d 100644 --- a/src/common/jsonconfig.h +++ b/src/common/jsonconfig.h @@ -1,6 +1,7 @@ #pragma once -#include +#include "fastfetch.h" bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs); const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]); +void ffPrintJsonConfig(FFinstance* instance); diff --git a/src/fastfetch.c b/src/fastfetch.c index 685e6c1d6..208c907df 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -3,6 +3,7 @@ #include "common/parsing.h" #include "common/io/io.h" #include "common/time.h" +#include "common/jsonconfig.h" #include "util/stringUtils.h" #include "logo/logo.h" @@ -1187,7 +1188,7 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintPowerAdapter(instance, &instance->config.powerAdapter); else if(strcasecmp(line, FF_LOCALE_MODULE_NAME) == 0) ffPrintLocale(instance, &instance->config.locale); - else if(strcasecmp(line, "localip") == 0) + else if(strcasecmp(line, FF_LOCALIP_MODULE_NAME) == 0) ffPrintLocalIp(instance, &instance->config.localIP); else if(strcasecmp(line, FF_PUBLICIP_MODULE_NAME) == 0) ffPrintPublicIp(instance, &instance->config.publicIP); @@ -1219,8 +1220,6 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintSound(instance, &instance->config.sound); else if(strcasecmp(line, FF_GAMEPAD_MODULE_NAME) == 0) ffPrintGamepad(instance, &instance->config.gamepad); - else if(strcasecmp(line, FF_JSONCONFIG_MODULE_NAME) == 0) - ffPrintJsonConfig(instance); else ffPrintErrorString(instance, line, 0, NULL, NULL, ""); } @@ -1264,34 +1263,41 @@ int main(int argc, const char** argv) fflush(stdout); #endif - //Parse the structure and call the modules - uint32_t startIndex = 0; - while (startIndex < data.structure.length) + if (instance.state.configDoc) { - uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); - data.structure.chars[colonIndex] = '\0'; - - uint64_t ms = 0; - if(__builtin_expect(instance.config.stat, false)) - ms = ffTimeGetTick(); - - parseStructureCommand(&instance, data.structure.chars + startIndex); - - if(__builtin_expect(instance.config.stat, false)) + ffPrintJsonConfig(&instance); + } + else + { + //Parse the structure and call the modules + uint32_t startIndex = 0; + while (startIndex < data.structure.length) { - char str[32]; - int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); - if(instance.config.pipe) - puts(str); - else - printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + uint32_t colonIndex = ffStrbufNextIndexC(&data.structure, startIndex, ':'); + data.structure.chars[colonIndex] = '\0'; + + uint64_t ms = 0; + if(__builtin_expect(instance.config.stat, false)) + ms = ffTimeGetTick(); + + parseStructureCommand(&instance, data.structure.chars + startIndex); + + if(__builtin_expect(instance.config.stat, false)) + { + char str[32]; + int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); + if(instance.config.pipe) + puts(str); + else + printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + } + + #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + fflush(stdout); + #endif + + startIndex = colonIndex + 1; } - - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); - #endif - - startIndex = colonIndex + 1; } ffFinish(&instance); diff --git a/src/modules/jsonconfig/jsonconfig.c b/src/modules/jsonconfig/jsonconfig.c deleted file mode 100644 index 4f4019e11..000000000 --- a/src/modules/jsonconfig/jsonconfig.c +++ /dev/null @@ -1,207 +0,0 @@ -#include "common/printing.h" -#include "common/jsonconfig.h" -#include "common/io/io.h" -#include "modules/jsonconfig/jsonconfig.h" -#include "modules/modules.h" - -#include -#include - -static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module)) -{ - if (strcasecmp(type, moduleName) == 0) - { - f(instance, module); - return true; - } - return false; -} - -static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson_val* module) -{ - switch (toupper(type[0])) - { - case 'B': { - return - tryModule(instance, type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) || - tryModule(instance, type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) || - tryModule(instance, type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) || - tryModule(instance, type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) || - tryModule(instance, type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) || - tryModule(instance, type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) || - false; - } - - case 'C': { - return - tryModule(instance, type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || - tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || - tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || - tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || - tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || - tryModule(instance, type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || - tryModule(instance, type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || - false; - } - - case 'D': { - return - tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || - tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || - tryModule(instance, type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || - tryModule(instance, type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || - false; - } - - case 'F': { - return - tryModule(instance, type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) || - false; - } - - case 'G': { - return - tryModule(instance, type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || - tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || - false; - } - - case 'H': { - return - tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || - false; - } - - case 'I': { - return - tryModule(instance, type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) || - false; - } - - case 'K': { - return - tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || - false; - } - - case 'L': { - return - tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || - tryModule(instance, type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || - false; - } - - case 'M': { - return - tryModule(instance, type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || - tryModule(instance, type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || - false; - } - - case 'O': { - return - tryModule(instance, type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || - tryModule(instance, type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || - tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || - false; - } - - case 'P': { - return - tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || - tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || - tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || - tryModule(instance, type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) || - tryModule(instance, type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || - false; - } - - case 'S': { - return - tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || - tryModule(instance, type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) || - tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || - tryModule(instance, type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || - false; - } - - case 'T': { - return - tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || - tryModule(instance, type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || - tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || - tryModule(instance, type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || - false; - } - - case 'U': { - return - tryModule(instance, type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || - tryModule(instance, type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) || - false; - } - - case 'V': { - return - tryModule(instance, type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) || - false; - } - - case 'W': { - return - tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || - tryModule(instance, type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) || - tryModule(instance, type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || - tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || - tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || - false; - } - - default: - return false; - } -} - -static const char* printJsonConfig(FFinstance* instance) -{ - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); - assert(root); - - if (!yyjson_is_obj(root)) - return "Invalid JSON config format. Root value must be an object"; - - yyjson_val* modules = yyjson_obj_get(root, "modules"); - if (!modules) return "Property 'modules' is not found"; - if (!yyjson_is_arr(modules)) return "Property 'modules' must be an array of strings or objects"; - - yyjson_val* item; - size_t idx, max; - yyjson_arr_foreach(modules, idx, max, item) - { - yyjson_val* module = item; - const char* type = yyjson_get_str(module); - if (type) - module = NULL; - else if (yyjson_is_obj(module)) - { - type = yyjson_get_str(yyjson_obj_get(module, "type")); - if (!type) return "module object must contain a \"type\" key ( case sensitive )"; - if (yyjson_obj_size(module) == 1) // contains only Property type - module = NULL; - } - else - return "modules must be an array of strings or objects"; - - if(!parseModuleJsonObject(instance, type, module)) - return "Unknown module type"; - } - - return NULL; -} - -void ffPrintJsonConfig(FFinstance* instance) -{ - const char* error = printJsonConfig(instance); - if (error) - ffPrintErrorString(instance, "JsonConfig", 0, NULL, NULL, "%s", error); -} diff --git a/src/modules/jsonconfig/jsonconfig.h b/src/modules/jsonconfig/jsonconfig.h deleted file mode 100644 index fe0b7e43a..000000000 --- a/src/modules/jsonconfig/jsonconfig.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "fastfetch.h" - -#define FF_JSONCONFIG_MODULE_NAME "JsonConfig" - -void ffPrintJsonConfig(FFinstance* instance); diff --git a/src/modules/modules.h b/src/modules/modules.h index 99a2130e3..3966b9500 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -45,7 +45,6 @@ #include "modules/terminalfont/terminalfont.h" #include "modules/theme/theme.h" #include "modules/title/title.h" -#include "modules/jsonconfig/jsonconfig.h" #include "modules/uptime/uptime.h" #include "modules/users/users.h" #include "modules/vulkan/vulkan.h" From 977da91aa694b1eb107e5b4c7cac4f08e537b4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 09:53:43 +0800 Subject: [PATCH 077/493] DE: fix KDE version detection on Fedora --- src/detection/displayserver/linux/wmde.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index a9e580cbe..49df47f78 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -132,6 +132,16 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) ffParsePropFileData(instance, "wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) ffParsePropFileData(instance, "wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + if(result->deVersion.length == 0) + { + if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ + "plasmashell", + "--version", + NULL + }) == NULL) // plasmashell 5.27.5 + ffStrbufSubstrAfterLastC(&result->deVersion, ' '); + } + applyBetterWM(result, getenv("KDEWM")); } From f65a3d1e75fbd15cf5c3295747873143af187cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 12:16:54 +0800 Subject: [PATCH 078/493] Wallpaper (Linux): support KDE --- CHANGELOG.md | 3 +++ src/detection/gtk_qt/gtk_qt.h | 1 + src/detection/gtk_qt/qt.c | 9 ++++++++- src/detection/users/users_linux.c | 4 ++-- src/detection/wallpaper/wallpaper_linux.c | 19 ++++++++++++++----- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5888b1abd..387e2bf18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ This release introduces a new configuration file format: JSON config Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. +Features: +* Support KDE wallpaper detection (Wallpaper, Linux) + # 1.11.3 Bugfixes: diff --git a/src/detection/gtk_qt/gtk_qt.h b/src/detection/gtk_qt/gtk_qt.h index 6e890fa97..8a115e5b0 100644 --- a/src/detection/gtk_qt/gtk_qt.h +++ b/src/detection/gtk_qt/gtk_qt.h @@ -21,6 +21,7 @@ typedef struct FFQtResult FFstrbuf colorScheme; FFstrbuf icons; FFstrbuf font; + FFstrbuf wallpaper; } FFQtResult; const FFGTKResult* ffDetectGTK2(const FFinstance* instance); diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index ebf36fbb9..2a29f9f46 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -13,7 +13,8 @@ static inline bool allValuesSet(const FFQtResult* result) result->widgetStyle.length > 0 && result->colorScheme.length > 0 && result->icons.length > 0 && - result->font.length > 0; + result->font.length > 0 && + result->wallpaper.length > 0; } typedef enum PlasmaCategory @@ -95,6 +96,11 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) if(detectPlasmaFromFile(baseDir.chars, result)) foundAFile = true; + ffStrbufSet(&baseDir, configDir); + ffStrbufAppendS(&baseDir, "plasma-org.kde.plasma.desktop-appletsrc"); + + ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper); + if(allValuesSet(result)) return; } @@ -144,6 +150,7 @@ const FFQtResult* ffDetectQt(const FFinstance* instance) ffStrbufInit(&result.colorScheme); ffStrbufInit(&result.icons); ffStrbufInit(&result.font); + ffStrbufInit(&result.wallpaper); const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index b1dcee8ed..421a6d5d2 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -22,9 +22,9 @@ next: if(n->ut_type != USER_PROCESS) continue; - for(uint32_t i = 0; i < users->length; ++i) + FF_LIST_FOR_EACH(FFstrbuf, user, *users) { - if(ffStrbufCompS((FFstrbuf*)ffListGet(users, i), n->ut_user) == 0) + if(ffStrbufCompS(user, n->ut_user) == 0) goto next; } diff --git a/src/detection/wallpaper/wallpaper_linux.c b/src/detection/wallpaper/wallpaper_linux.c index b1876f878..7ae5b480d 100644 --- a/src/detection/wallpaper/wallpaper_linux.c +++ b/src/detection/wallpaper/wallpaper_linux.c @@ -4,14 +4,23 @@ const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result) { + const FFstrbuf* wallpaper = NULL; const FFGTKResult* gtk = ffDetectGTK4(instance); - if (!gtk->wallpaper.length) + if (gtk->wallpaper.length) + wallpaper = >k->wallpaper; + else + { + const FFQtResult* qt = ffDetectQt(instance); + if (qt->wallpaper.length) + wallpaper = &qt->wallpaper; + } + + if (!wallpaper) return "Failed to detect the current wallpaper path"; - if (ffStrbufStartsWithS(>k->wallpaper, "file:///")) - ffStrbufAppendS(result, gtk->wallpaper.chars + strlen("file://")); + if (ffStrbufStartsWithS(wallpaper, "file:///")) + ffStrbufAppendS(result, wallpaper->chars + strlen("file://")); else - ffStrbufAppend(result, >k->wallpaper); - + ffStrbufAppend(result, wallpaper); return NULL; } From 662f081f49bbb76befb364d90c62a763c4111daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 12:19:40 +0800 Subject: [PATCH 079/493] Terminal: support qterminal version detection --- src/detection/terminalshell/terminalshell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 3117f6cb5..00aa1bc6e 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -258,6 +258,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "foot")) return getTerminalVersionFoot(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "qterminal")) + return getExeVersionRaw(exe, version); //1.2.0 + #endif #ifdef _WIN32 From aa0d1d94b2f7f40c741c6c92ed19df4737a1a07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 12:31:50 +0800 Subject: [PATCH 080/493] TerminalFont (Linux): support QTerminal --- CHANGELOG.md | 1 + README.md | 2 +- .../terminalfont/terminalfont_linux.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 387e2bf18..ff48ddd1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Changes: Features: * Support KDE wallpaper detection (Wallpaper, Linux) +* Support QTerminal version & terminal font detection # 1.11.3 diff --git a/README.md b/README.md index a6cb9d2aa..bd38a2239 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4 ##### Terminal fonts ``` -Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal +Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal ``` ## Building diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 68f096523..bb2afea2d 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -190,6 +190,23 @@ static void detectFootTerminal(const FFinstance* instance, FFTerminalFontResult* ffFontInitValues(&terminalFont->font, font.chars, &font.chars[equal + strlen("size=")]); } +static void detectQTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +{ + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); + + ffParsePropFileConfigValues(instance, "qterminal.org/qterminal.ini", 2, (FFpropquery[]) { + {"fontFamily=", &fontName}, + {"fontSize=", &fontSize}, + }); + + if (fontName.length == 0) + ffStrbufAppendS(&fontName, "monospace"); + if (fontSize.length == 0) + ffStrbufAppendS(&fontSize, "12"); + ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); +} + void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "konsole") == 0) @@ -206,4 +223,6 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh detectDeepinTerminal(instance, terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "foot") == 0) detectFootTerminal(instance, terminalFont); + else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "qterminal") == 0) + detectQTerminal(instance, terminalFont); } From ec03294ebcb9ece928eb2b67d0faa81838565d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 12:37:42 +0800 Subject: [PATCH 081/493] Wallpaper (Linux): support lxqt --- CHANGELOG.md | 2 +- src/detection/gtk_qt/qt.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff48ddd1a..bb7c5cecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. Features: -* Support KDE wallpaper detection (Wallpaper, Linux) +* Support KDE / LXQT wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection # 1.11.3 diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 2a29f9f46..7955be14c 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -130,6 +130,8 @@ static void detectLXQt(const FFinstance* instance, FFQtResult* result) {"icon_theme = ", &result->icons}, {"font = ", &result->font} }); + + ffParsePropFileConfig(instance, "pcmanfm-qt/lxqt/settings.conf", "Wallpaper=", &result->wallpaper); } const FFQtResult* ffDetectQt(const FFinstance* instance) From 4575ee0d9743455bd5835a771efe8fcf004b3bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 12:59:43 +0800 Subject: [PATCH 082/493] Wallpaper (Linux): fix xfce wallpaper detection on my laptop --- src/detection/gtk_qt/gtk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index abd5a857e..8b438d6c7 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -68,6 +68,8 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul cursorTheme = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue; wallpaper = ffSettingsGetXFConf(instance, "xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; + if (!wallpaper) // FIXME: find a way to enumerate possible properties + wallpaper = ffSettingsGetXFConf(instance, "xfce4-desktop", "/backdrop/screen0/monitoreDP-1/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; } else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_CINNAMON) == 0) { From 3f97e8195b695435ca39baed79d44948a651bfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 13:28:02 +0800 Subject: [PATCH 083/493] Terminal (Linux): support MATE terminal version detection --- src/detection/terminalshell/terminalshell.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 00aa1bc6e..b7497b775 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -203,6 +203,15 @@ FF_MAYBE_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* vers return true; } +FF_MAYBE_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* version) +{ + if(!getExeVersionRaw(exe, version)) return false; + + //MATE Terminal 1.26.1 + ffStrbufSubstrAfterLastC(version, ' '); + return version->length > 0; +} + #ifdef _WIN32 static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) @@ -261,6 +270,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "qterminal")) return getExeVersionRaw(exe, version); //1.2.0 + if(ffStrbufIgnCaseEqualS(processName, "mate-terminal")) + return getTerminalVersionMateTerminal(exe, version); + #endif #ifdef _WIN32 From 9c35e3a17a9f41d2db7d8a9cbae19abb9727f358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 14:06:23 +0800 Subject: [PATCH 084/493] TerminalFont (Linux): support MATE Terminal --- CHANGELOG.md | 1 + README.md | 2 +- .../terminalfont/terminalfont_linux.c | 30 ++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb7c5cecc..1828c34ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Changes: Features: * Support KDE / LXQT wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection +* Support MATE Terminal version & terminal font detection # 1.11.3 diff --git a/README.md b/README.md index bd38a2239..c90f944a0 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4 ##### Terminal fonts ``` -Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal +Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, MATE Terminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal ``` ## Building diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index bb2afea2d..1061ebbf3 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -10,13 +10,13 @@ static const char* getSystemMonospaceFont(const FFinstance* instance) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); - if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0) + if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Cinnamon")) { const char* systemMonospaceFont = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(systemMonospaceFont)) return systemMonospaceFont; } - else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Mate") == 0) + else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Mate")) { const char* systemMonospaceFont = ffSettingsGet(instance, "/org/mate/interface/monospace-font-name", "org.mate.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(systemMonospaceFont)) @@ -26,9 +26,9 @@ static const char* getSystemMonospaceFont(const FFinstance* instance) return ffSettingsGet(instance, "/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; } -static void detectFromGSettings(const FFinstance* instance, char* profilePath, char* profileList, char* profile, FFTerminalFontResult* terminalFont) +static void detectFromGSettings(const FFinstance* instance, const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) { - const char* defaultProfile = ffSettingsGetGSettings(instance, profileList, NULL, "default", FF_VARIANT_TYPE_STRING).strValue; + const char* defaultProfile = ffSettingsGetGSettings(instance, profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; if(!ffStrSet(defaultProfile)) { ffStrbufAppendF(&terminalFont->error, "Could not get default profile from gsettings: %s", profileList); @@ -209,20 +209,22 @@ static void detectQTerminal(const FFinstance* instance, FFTerminalFontResult* te void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { - if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "konsole") == 0) + if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "konsole")) detectKonsole(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "xfce4-terminal") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "xfce4-terminal")) detectXFCETerminal(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "lxterminal") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "lxterminal")) detectFromConfigFile(instance, "lxterminal/lxterminal.conf", "fontname =", terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "tilix") == 0) - detectFromGSettings(instance, "/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "gnome-terminal-") == 0) - detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "deepin-terminal") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "tilix")) + detectFromGSettings(instance, "/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", "default", terminalFont); + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "gnome-terminal-")) + detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", "default", terminalFont); + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "mate-terminal")) + detectFromGSettings(instance, "/org/mate/terminal/profiles/", "org.mate.terminal.global", "org.mate.terminal.profile", "default-profile", terminalFont); + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "deepin-terminal")) detectDeepinTerminal(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "foot") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "foot")) detectFootTerminal(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "qterminal") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "qterminal")) detectQTerminal(instance, terminalFont); } From a3a60176b133bde7e84774920c98c140c313b205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 14:14:23 +0800 Subject: [PATCH 085/493] Wallpaper (Linux): support MATE --- CHANGELOG.md | 2 +- src/detection/gtk_qt/gtk.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1828c34ae..9e02d320c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. Features: -* Support KDE / LXQT wallpaper detection (Wallpaper, Linux) +* Support KDE / LXQT / MATE wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection * Support MATE Terminal version & terminal font detection diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index 8b438d6c7..f38984075 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -86,6 +86,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul fontName = ffSettingsGet(instance, "/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGet(instance, "/org/mate/desktop/background", "org.mate.background", NULL, "picture-filename", FF_VARIANT_TYPE_STRING).strValue; } else if( ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME) == 0 || From bab103ff17915c5ba6a18ea68d1d0cf312f16723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 14:26:57 +0800 Subject: [PATCH 086/493] Wallpaper (Linux): support Cinnamon --- CHANGELOG.md | 2 +- src/detection/gtk_qt/gtk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e02d320c..634aeea2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. Features: -* Support KDE / LXQT / MATE wallpaper detection (Wallpaper, Linux) +* Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection * Support MATE Terminal version & terminal font detection diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index f38984075..36bf90bda 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -78,6 +78,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul fontName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; cursorTheme = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/cursor-theme", "org.cinnamon.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/cursor-size", "org.cinnamon.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGet(instance, "/org/cinnamon/desktop/background/picture-uri", "org.cinnamon.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; } else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_MATE) == 0) { @@ -99,7 +100,6 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul cursorTheme = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; wallpaper = ffSettingsGet(instance, "/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; - // TODO: support other DEs for wallpaper } ffThreadMutexUnlock(&mutex); From ac32de7bf1203926bc77c423b9d29a9cd9e15056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 18:56:40 +0800 Subject: [PATCH 087/493] WM: detect Gnome classic mode --- src/detection/displayserver/displayserver.h | 1 + src/detection/displayserver/linux/wmde.c | 7 ++++++- src/detection/gtk_qt/gtk.c | 1 + src/detection/wmtheme/wmtheme_linux.c | 5 ++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index e75181b71..be4ed37a4 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -7,6 +7,7 @@ #define FF_DE_PRETTY_PLASMA "KDE Plasma" #define FF_DE_PRETTY_GNOME "Gnome" +#define FF_DE_PRETTY_GNOME_CLASSIC "Gnome Classic" #define FF_DE_PRETTY_XFCE4 "Xfce4" #define FF_DE_PRETTY_CINNAMON "Cinnamon" #define FF_DE_PRETTY_MATE "Mate" diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 49df47f78..a1f1cfef6 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -149,7 +149,12 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) static void getGnome(const FFinstance* instance, FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "gnome-shell"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME); + const char* sessionMode = getenv("GNOME_SHELL_SESSION_MODE"); + if (sessionMode && strcmp(sessionMode, "classic") == 0) + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC); + else + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME); + ffParsePropFileData(instance, "gnome-shell/org.gnome.Extensions", "version :", &result->deVersion); if (result->deVersion.length == 0) diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index 36bf90bda..b611827f4 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -91,6 +91,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul } else if( ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME) == 0 || + ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC) == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_UNITY) == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_BUDGIE) == 0 ) { diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index 2099a3a2c..055dc91ca 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -206,7 +206,10 @@ bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_MUTTER) == 0) { - if(ffStrbufIgnCaseCompS(&wm->dePrettyName, FF_DE_PRETTY_GNOME) == 0) + if( + ffStrbufIgnCaseCompS(&wm->dePrettyName, FF_DE_PRETTY_GNOME) == 0 || + ffStrbufIgnCaseEqualS(&wm->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC) + ) return detectMutter(instance, themeOrError); else return detectGTKThemeAsWMTheme(instance, themeOrError); From e68efb184bf2b2e20e7be30908ba95817d61f481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 21:31:09 +0800 Subject: [PATCH 088/493] JsonConfig: support more non-module options --- src/common/jsonconfig.c | 180 ++++++++++++++++++++++++++++++++++++++++ src/common/jsonconfig.h | 3 + src/fastfetch.c | 21 ++--- 3 files changed, 194 insertions(+), 10 deletions(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 75f433dd0..efd192609 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -274,6 +274,186 @@ static const char* printJsonConfig(FFinstance* instance) return NULL; } +const char* ffParseGeneralJsonConfig(FFinstance* instance) +{ + FFconfig* config = &instance->config; + + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* object = yyjson_obj_get(root, "general"); + if (!object) return NULL; + if (!yyjson_is_obj(object)) return "Property 'general' must be an object"; + + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(object, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + + if (strcasecmp(key, "allowSlowOperations") == 0) + config->allowSlowOperations = yyjson_get_bool(val); + else if (strcasecmp(key, "thread") == 0 || strcasecmp(key, "multithreading") == 0) + config->multithreading = yyjson_get_bool(val); + else if (strcasecmp(key, "stat") == 0) + config->stat = yyjson_get_bool(val); + else if (strcasecmp(key, "escapeBedrock") == 0) + config->escapeBedrock = yyjson_get_bool(val); + else if (strcasecmp(key, "pipe") == 0) + config->pipe = yyjson_get_bool(val); + else + return "Unknown general property"; + } + + return NULL; +} + +const char* ffParseDisplayJsonConfig(FFinstance* instance) +{ + FFconfig* config = &instance->config; + + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* object = yyjson_obj_get(root, "display"); + if (!object) return NULL; + if (!yyjson_is_obj(object)) return "Property 'display' must be an object"; + + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(object, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + + if (strcasecmp(key, "showErrors") == 0) + config->showErrors = yyjson_get_bool(val); + else if (strcasecmp(key, "disableLinewrap") == 0) + config->disableLinewrap = yyjson_get_bool(val); + else if (strcasecmp(key, "hideCursor") == 0) + config->hideCursor = yyjson_get_bool(val); + else if (strcasecmp(key, "separator") == 0) + ffStrbufAppendS(&config->keyValueSeparator, yyjson_get_str(val)); + else if (strcasecmp(key, "color") == 0) + { + if (yyjson_is_str(val)) + { + ffOptionParseColor(yyjson_get_str(val), &config->colorKeys); + ffStrbufAppend(&config->colorTitle, &config->colorKeys); + } + else if (yyjson_is_obj(val)) + { + const char* colorKeys = yyjson_get_str(yyjson_obj_get(val, "keys")); + if (colorKeys) + ffOptionParseColor(colorKeys, &config->colorKeys); + const char* colorTitle = yyjson_get_str(yyjson_obj_get(val, "title")); + if (colorTitle) + ffOptionParseColor(colorTitle, &config->colorTitle); + } + else + return "display.color must be either a string or an object"; + } + else if (strcasecmp(key, "binaryPrefix") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "iec", FF_BINARY_PREFIX_TYPE_IEC }, + { "si", FF_BINARY_PREFIX_TYPE_SI }, + { "jedec", FF_BINARY_PREFIX_TYPE_JEDEC }, + {}, + }); + if (error) return error; + config->binaryPrefixType = (FFBinaryPrefixType) value; + } + else if (strcasecmp(key, "percentType") == 0) + config->percentType = (uint32_t) yyjson_get_uint(val); + else + return "Unknown display property"; + } + + return NULL; +} + +const char* ffParseLibraryJsonConfig(FFinstance* instance) +{ + FFconfig* config = &instance->config; + + yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + assert(root); + + if (!yyjson_is_obj(root)) + return "Invalid JSON config format. Root value must be an object"; + + yyjson_val* object = yyjson_obj_get(root, "library"); + if (!object) return NULL; + if (!yyjson_is_obj(object)) return "Property 'library' must be an object"; + + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(object, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + + if (strcasecmp(key, "pci") == 0) + ffStrbufAppendS(&config->libPCI, yyjson_get_str(val)); + else if (strcasecmp(key, "vulkan") == 0) + ffStrbufAppendS(&config->libVulkan, yyjson_get_str(val)); + else if (strcasecmp(key, "freetype") == 0) + ffStrbufAppendS(&config->libfreetype, yyjson_get_str(val)); + else if (strcasecmp(key, "wayland") == 0) + ffStrbufAppendS(&config->libWayland, yyjson_get_str(val)); + else if (strcasecmp(key, "xcbRandr") == 0) + ffStrbufAppendS(&config->libXcbRandr, yyjson_get_str(val)); + else if (strcasecmp(key, "xcb") == 0) + ffStrbufAppendS(&config->libXcb, yyjson_get_str(val)); + else if (strcasecmp(key, "Xrandr") == 0) + ffStrbufAppendS(&config->libXrandr, yyjson_get_str(val)); + else if (strcasecmp(key, "X11") == 0) + ffStrbufAppendS(&config->libX11, yyjson_get_str(val)); + else if (strcasecmp(key, "gio") == 0) + ffStrbufAppendS(&config->libGIO, yyjson_get_str(val)); + else if (strcasecmp(key, "DConf") == 0) + ffStrbufAppendS(&config->libDConf, yyjson_get_str(val)); + else if (strcasecmp(key, "dbus") == 0) + ffStrbufAppendS(&config->libDBus, yyjson_get_str(val)); + else if (strcasecmp(key, "XFConf") == 0) + ffStrbufAppendS(&config->libXFConf, yyjson_get_str(val)); + else if (strcasecmp(key, "sqlite") == 0 || strcasecmp(key, "sqlite3") == 0) + ffStrbufAppendS(&config->libSQLite3, yyjson_get_str(val)); + else if (strcasecmp(key, "rpm") == 0) + ffStrbufAppendS(&config->librpm, yyjson_get_str(val)); + else if (strcasecmp(key, "imagemagick") == 0) + ffStrbufAppendS(&config->libImageMagick, yyjson_get_str(val)); + else if (strcasecmp(key, "z") == 0) + ffStrbufAppendS(&config->libZ, yyjson_get_str(val)); + else if (strcasecmp(key, "chafa") == 0) + ffStrbufAppendS(&config->libChafa, yyjson_get_str(val)); + else if (strcasecmp(key, "egl") == 0) + ffStrbufAppendS(&config->libEGL, yyjson_get_str(val)); + else if (strcasecmp(key, "glx") == 0) + ffStrbufAppendS(&config->libGLX, yyjson_get_str(val)); + else if (strcasecmp(key, "osmesa") == 0) + ffStrbufAppendS(&config->libOSMesa, yyjson_get_str(val)); + else if (strcasecmp(key, "opencl") == 0) + ffStrbufAppendS(&config->libOpenCL, yyjson_get_str(val)); + else if (strcasecmp(key, "wlanapi") == 0) + ffStrbufAppendS(&config->libwlanapi, yyjson_get_str(val)); + else if (strcasecmp(key, "pulse") == 0) + ffStrbufAppendS(&config->libPulse, yyjson_get_str(val)); + else if (strcasecmp(key, "nm") == 0) + ffStrbufAppendS(&config->libnm, yyjson_get_str(val)); + else + return "Unknown library property"; + } + + return NULL; +} + void ffPrintJsonConfig(FFinstance* instance) { const char* error = printJsonConfig(instance); diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h index 8a235ae2d..8a72408bc 100644 --- a/src/common/jsonconfig.h +++ b/src/common/jsonconfig.h @@ -5,3 +5,6 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs); const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]); void ffPrintJsonConfig(FFinstance* instance); +const char* ffParseGeneralJsonConfig(FFinstance* instance); +const char* ffParseDisplayJsonConfig(FFinstance* instance); +const char* ffParseLibraryJsonConfig(FFinstance* instance); diff --git a/src/fastfetch.c b/src/fastfetch.c index 208c907df..2b5e5600d 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -527,9 +527,15 @@ static bool parseJsoncFile(FFinstance* instance, const char* path) if (doc) { instance->state.configDoc = doc; - const char* error = ffParseLogoJsonConfig(instance); - if (error) - { + const char* error = NULL; + + if ( + (error = ffParseLogoJsonConfig(instance)) || + (error = ffParseGeneralJsonConfig(instance)) || + (error = ffParseDisplayJsonConfig(instance)) || + (error = ffParseLibraryJsonConfig(instance)) || + false + ) { fputs(error, stderr); exit(477); } @@ -935,6 +941,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con NULL ); } + else if(strcasecmp(key, "--percent-type") == 0) + instance->config.percentType = optionParseUInt32(key, value); /////////////////////// //Module args options// @@ -1049,13 +1057,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con goto error; } - ////////////////// - //Module options// - ////////////////// - - else if(strcasecmp(key, "--percent-type") == 0) - instance->config.percentType = optionParseUInt32(key, value); - ////////////////// //Unknown option// ////////////////// From 71beb626c30c5755613d743d9349f7a95effbe6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 11 Jun 2023 21:35:18 +0800 Subject: [PATCH 089/493] Logo: fix `paddingLeft` doesn't work when `paddingTop` is set --- src/logo/image/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 4a033c2b4..fc209b4ab 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -47,8 +47,8 @@ static bool printImageIterm(FFinstance* instance) return false; } - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); ffPrintCharTimes('\n', instance->config.logo.paddingTop); + ffPrintCharTimes(' ', instance->config.logo.paddingLeft); FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&buf); instance->state.logoWidth = instance->config.logo.width + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; From 8a284ae9a12208fc26c50ea28e166aba0384aac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 09:20:39 +0800 Subject: [PATCH 090/493] Battery: use module options --- src/detection/battery/battery.h | 2 +- src/detection/battery/battery_android.c | 4 ++-- src/detection/battery/battery_apple.c | 4 ++-- src/detection/battery/battery_bsd.c | 2 +- src/detection/battery/battery_linux.c | 6 +++--- src/detection/battery/battery_nosupport.c | 4 ++-- src/detection/battery/battery_windows.c | 4 ++-- src/modules/battery/battery.c | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/detection/battery/battery.h b/src/detection/battery/battery.h index ab0021b91..e83bf78d8 100644 --- a/src/detection/battery/battery.h +++ b/src/detection/battery/battery.h @@ -17,6 +17,6 @@ typedef struct BatteryResult double temperature; } BatteryResult; -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results); +const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results); #endif diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index 0b90494fc..eb05fefe4 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -7,7 +7,7 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "BatteryStatus" -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -34,7 +34,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) ffStrbufClear(&battery->status); } - if(instance->config.battery.temp) + if(options->temp) { if(ffParsePropLines(buffer.chars, "\"temperature\": ", &battery->status)) { diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index af49b9a69..1ddec8d43 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -27,7 +27,7 @@ static double detectBatteryTemp() return result; } -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) { CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery"); if (matchDict == NULL) @@ -90,7 +90,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) else ffStrbufAppendS(&battery->status, ""); - if(instance->config.battery.temp) + if(options->temp) battery->temperature = detectBatteryTemp(); else battery->temperature = FF_BATTERY_TEMP_UNSET; diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 2cfbe4b7b..96a8cb079 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -6,7 +6,7 @@ #include #include -const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { //https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) //https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 11da6f4e9..93f09faf1 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -67,13 +67,13 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) result->temperature = FF_BATTERY_TEMP_UNSET; } -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); - if(instance->config.battery.dir.length > 0) + if(options->dir.length > 0) { - ffStrbufAppend(&baseDir, &instance->config.battery.dir); + ffStrbufAppend(&baseDir, &options->dir); ffStrbufEnsureEndsWithC(&baseDir, '/'); } else diff --git a/src/detection/battery/battery_nosupport.c b/src/detection/battery/battery_nosupport.c index 40ca05241..1cc9f79fb 100644 --- a/src/detection/battery/battery_nosupport.c +++ b/src/detection/battery/battery_nosupport.c @@ -1,8 +1,8 @@ #include "fastfetch.h" #include "battery.h" -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results) { - FF_UNUSED(instance, results) + FF_UNUSED(instance, options, results) return "Not supported on this platform"; } diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index 9268362fd..16bedad17 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -30,7 +30,7 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) SetupDiDestroyDeviceInfoList(*hdev); } -const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) +const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results) { if(instance->config.allowSlowOperations) { @@ -111,7 +111,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) } battery->temperature = 0.0/0.0; - if(instance->config.battery.temp) + if(options->temp) { bqi.InformationLevel = BatteryTemperature; ULONG temp; diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index c41e185a8..ea82b64da 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -76,7 +76,7 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options) FFlist results; ffListInitA(&results, sizeof(BatteryResult), 0); - const char* error = ffDetectBatteryImpl(instance, &results); + const char* error = ffDetectBattery(instance, options, &results); if (error) { From 56effcb1893caa9debe40ef869158013d00305dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 09:56:03 +0800 Subject: [PATCH 091/493] CPU: use module options --- src/detection/cpu/cpu.c | 19 +++++-------- src/detection/cpu/cpu.h | 2 +- src/detection/cpu/cpu_apple.c | 11 ++++---- src/detection/cpu/cpu_bsd.c | 23 ++++++++-------- src/detection/cpu/cpu_linux.c | 18 +++++++------ src/detection/cpu/cpu_windows.c | 24 ++++++++--------- src/modules/cpu/cpu.c | 47 +++++++++++++++++++-------------- 7 files changed, 73 insertions(+), 71 deletions(-) diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 62537aaa8..7410dbbee 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -1,13 +1,12 @@ #include "cpu.h" #include "detection/internal.h" -void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu); -static void detectCPU(const FFinstance* instance, FFCPUResult* cpu) -{ - ffStrbufInit(&cpu->name); - ffStrbufInit(&cpu->vendor); +const char* ffDetectCPUImpl(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu); - ffDetectCPUImpl(instance, cpu); +const char* ffDetectCPU(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +{ + const char* error = ffDetectCPUImpl(instance, options, cpu); + if (error) return error; const char* removeStrings[] = { " CPU", " FPU", " APU", " Processor", @@ -18,11 +17,5 @@ static void detectCPU(const FFinstance* instance, FFCPUResult* cpu) ffStrbufRemoveStringsA(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it -} - -const FFCPUResult* ffDetectCPU(const FFinstance* instance) -{ - FF_DETECTION_INTERNAL_GUARD(FFCPUResult, - detectCPU(instance, &result); - ); + return NULL; } diff --git a/src/detection/cpu/cpu.h b/src/detection/cpu/cpu.h index afe05909e..6c5a3188c 100644 --- a/src/detection/cpu/cpu.h +++ b/src/detection/cpu/cpu.h @@ -22,6 +22,6 @@ typedef struct FFCPUResult double temperature; } FFCPUResult; -const FFCPUResult* ffDetectCPU(const FFinstance* instance); +const char* ffDetectCPU(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu); #endif diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index fb53b60d2..51d485699 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -40,11 +40,10 @@ static double detectCpuTemp(const FFstrbuf* cpuName) return result; } -void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) +const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) { - FF_UNUSED(instance); - - ffSysctlGetString("machdep.cpu.brand_string", &cpu->name); + if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != NULL) + return "sysctlbyname(machdep.cpu.brand_string) failed"; ffSysctlGetString("machdep.cpu.vendor", &cpu->vendor); cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu_max", 1); @@ -64,8 +63,10 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) if(cpu->frequencyMax == 0.0) cpu->frequencyMax = getFrequency("hw.cpufrequency"); - if (instance->config.cpu.temp) + if (options->temp) cpu->temperature = detectCpuTemp(&cpu->name); else cpu->temperature = FF_CPU_TEMP_UNSET; + + return NULL; } diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index c3c88e440..42a377b6e 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -1,11 +1,19 @@ #include "cpu.h" #include "common/sysctl.h" -void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) +const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) { - FF_UNUSED(instance); + if (ffSysctlGetString("hw.model", &cpu->name)) + return "sysctlbyname(hw.model) failed"; - if (instance->config.cpu.temp) + cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); + cpu->coresLogical = cpu->coresPhysical; + cpu->coresOnline = cpu->coresPhysical; + + cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0; + cpu->frequencyMax = cpu->frequencyMin; + + if (options->temp) { FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate(); if(ffSysctlGetString("temperature", &cpuTemp)) @@ -16,12 +24,5 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) else cpu->temperature = FF_CPU_TEMP_UNSET; - ffSysctlGetString("hw.model", &cpu->name); - - cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); - cpu->coresLogical = cpu->coresPhysical; - cpu->coresOnline = cpu->coresPhysical; - - cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0; - cpu->frequencyMax = cpu->frequencyMin; + return NULL; } diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index bc14e2f18..f9abd1d32 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -7,11 +7,11 @@ #include #include -static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch) +static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch) { FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); if(cpuinfo == NULL) - return; + return "fopen(\"/proc/cpuinfo\", \"r\") failed"; char* line = NULL; size_t len = 0; @@ -37,6 +37,8 @@ static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrb free(line); fclose(cpuinfo); + + return NULL; } static double getGHz(const char* file) @@ -102,19 +104,17 @@ static void parseIsa(FFstrbuf* cpuIsa) } } -void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) +const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) { - if(instance->config.cpu.temp) - cpu->temperature = detectCPUTemp(); - else - cpu->temperature = FF_CPU_TEMP_UNSET; + cpu->temperature = options->temp ? detectCPUTemp() : FF_CPU_TEMP_UNSET; FF_STRBUF_AUTO_DESTROY physicalCoresBuffer = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY cpuIsa = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY cpuUarch = ffStrbufCreate(); - parseCpuInfo(cpu, &physicalCoresBuffer, &cpuMHz, &cpuIsa, &cpuUarch); + const char* error = parseCpuInfo(cpu, &physicalCoresBuffer, &cpuMHz, &cpuIsa, &cpuUarch); + if (error) return error; cpu->coresPhysical = ffStrbufToUInt16(&physicalCoresBuffer, 1); @@ -146,4 +146,6 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) ffStrbufAppendC(&cpu->name, ' '); ffStrbufAppend(&cpu->name, &cpuIsa); } + + return NULL; } diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 13413bec3..4b814ca2f 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -3,23 +3,17 @@ #include "util/windows/registry.h" #include "util/mallocHelper.h" -void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) +const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) { - FF_UNUSED(instance); - - cpu->temperature = FF_CPU_TEMP_UNSET; - cpu->coresPhysical = cpu->coresLogical = cpu->coresOnline = 0; - cpu->frequencyMax = cpu->frequencyMin = 0; - ffStrbufInit(&cpu->name); - ffStrbufInit(&cpu->vendor); - { DWORD length = 0; - GetLogicalProcessorInformationEx(RelationAll, NULL, &length); + if (GetLogicalProcessorInformationEx(RelationAll, NULL, &length) != ERROR_INSUFFICIENT_BUFFER) + return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed"; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length); - if(pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length)) + if (pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length)) { for( SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo; @@ -36,11 +30,13 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) } } } + else + return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed"; } FF_HKEY_AUTO_DESTROY hKey; if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL)) - return; + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed"; { uint32_t mhz; @@ -51,6 +47,8 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu) ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL); ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL); - if(instance->config.cpu.temp) + if(options->temp) ffDetectSmbiosTemp(&cpu->temperature, NULL); + + return NULL; } diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index efb467835..e71d6b8d3 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -7,9 +7,16 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) { - const FFCPUResult* cpu = ffDetectCPU(instance); + FFCPUResult cpu; + cpu.temperature = FF_CPU_TEMP_UNSET; + cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0; + cpu.frequencyMax = cpu.frequencyMin = 0; + ffStrbufInit(&cpu.name); + ffStrbufInit(&cpu.vendor); - if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1) + ffDetectCPU(instance, options, &cpu); + + if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) { ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); return; @@ -19,38 +26,38 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) { ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key); - if(cpu->name.length > 0) - ffStrbufWriteTo(&cpu->name, stdout); - else if(cpu->vendor.length > 0) + if(cpu.name.length > 0) + ffStrbufWriteTo(&cpu.name, stdout); + else if(cpu.vendor.length > 0) { - ffStrbufWriteTo(&cpu->vendor, stdout); + ffStrbufWriteTo(&cpu.vendor, stdout); fputs(" CPU", stdout); } else fputs("CPU", stdout); - if(cpu->coresOnline > 1) - printf(" (%u)", cpu->coresOnline); + if(cpu.coresOnline > 1) + printf(" (%u)", cpu.coresOnline); - if(cpu->frequencyMax > 0.0) - printf(" @ %.9g GHz", cpu->frequencyMax); + if(cpu.frequencyMax > 0.0) + printf(" @ %.9g GHz", cpu.frequencyMax); - if(cpu->temperature == cpu->temperature) //FF_CPU_TEMP_UNSET - printf(" - %.1f°C", cpu->temperature); + if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET + printf(" - %.1f°C", cpu.temperature); putchar('\n'); } else { ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature} + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.temperature} }); } } From 6f9167c725161a701696984ca4d5c7881625733b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 10:35:28 +0800 Subject: [PATCH 092/493] Display: detect screen rotation --- src/detection/displayserver/displayserver.c | 2 + src/detection/displayserver/displayserver.h | 2 + .../displayserver/displayserver_apple.c | 7 ++- .../displayserver/displayserver_windows.c | 55 ++++++++++++------- src/detection/displayserver/linux/wayland.c | 42 +++++++++----- src/detection/displayserver/linux/xcb.c | 5 ++ src/detection/displayserver/linux/xlib.c | 5 ++ src/fastfetch.c | 7 ++- src/modules/display/display.c | 5 +- 9 files changed, 89 insertions(+), 41 deletions(-) diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index 270f4a93c..062f3be12 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -8,6 +8,7 @@ bool ffdsAppendDisplay( double refreshRate, uint32_t scaledWidth, uint32_t scaledHeight, + uint32_t rotation, FFstrbuf* name, FFDisplayType type) { @@ -20,6 +21,7 @@ bool ffdsAppendDisplay( display->refreshRate = refreshRate; display->scaledWidth = scaledWidth; display->scaledHeight = scaledHeight; + display->rotation = rotation; ffStrbufInitMove(&display->name, name); display->type = type; diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index be4ed37a4..52d0f34c9 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -50,6 +50,7 @@ typedef struct FFDisplayResult uint32_t scaledHeight; FFstrbuf name; FFDisplayType type; + uint32_t rotation; } FFDisplayResult; typedef struct FFDisplayServerResult @@ -72,6 +73,7 @@ bool ffdsAppendDisplay( double refreshRate, uint32_t scaledWidth, uint32_t scaledHeight, + uint32_t rotation, FFstrbuf* name, FFDisplayType type); diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index e2ae57c5d..a49e5f74b 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -12,7 +12,7 @@ extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); -static void detectDisplays(FFDisplayServerResult* ds, bool detectName) +static void detectDisplays(FFDisplayServerResult* ds) { CGDirectDisplayID screens[128]; uint32_t screenCount; @@ -41,7 +41,7 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) } FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); - if(detectName && CoreDisplay_DisplayCreateInfoDictionary) + if(CoreDisplay_DisplayCreateInfoDictionary) { CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); if(displayInfo) @@ -58,6 +58,7 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) refreshRate, (uint32_t)CGDisplayModeGetWidth(mode), (uint32_t)CGDisplayModeGetHeight(mode), + (uint32_t)CGDisplayRotation(screen), &name, CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL ); @@ -120,5 +121,5 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufAppendS(&ds->dePrettyName, "Aqua"); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); - detectDisplays(ds, instance->config.display.detectName); + detectDisplays(ds); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 9b7bec99b..12921f4e7 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -5,7 +5,7 @@ #include #include -static void detectDisplays(FFDisplayServerResult* ds, bool detectName) +static void detectDisplays(FFDisplayServerResult* ds) { DISPLAYCONFIG_PATH_INFO paths[128]; uint32_t pathCount = sizeof(paths) / sizeof(paths[0]); @@ -44,26 +44,23 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); - if (detectName) + DISPLAYCONFIG_TARGET_DEVICE_NAME targetName = { + .header = { + .type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME, + .size = sizeof(targetName), + .adapterId = path->targetInfo.adapterId, + .id = path->targetInfo.id, + }, + }; + if(DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS) { - DISPLAYCONFIG_TARGET_DEVICE_NAME targetName = { - .header = { - .type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME, - .size = sizeof(targetName), - .adapterId = path->targetInfo.adapterId, - .id = path->targetInfo.id, - }, - }; - if(DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS) + if (targetName.flags.friendlyNameFromEdid) + ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName); + else { - if (targetName.flags.friendlyNameFromEdid) - ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName); - else - { - ffStrbufSetWS(&name, targetName.monitorDevicePath); - ffStrbufSubstrAfterFirstC(&name, '#'); - ffStrbufSubstrBeforeFirstC(&name, '#'); - } + ffStrbufSetWS(&name, targetName.monitorDevicePath); + ffStrbufSubstrAfterFirstC(&name, '#'); + ffStrbufSubstrBeforeFirstC(&name, '#'); } } @@ -77,12 +74,30 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) height = temp; } + uint32_t rotation; + switch (path->targetInfo.rotation) + { + case DISPLAYCONFIG_ROTATION_ROTATE90: + rotation = 90; + break; + case DISPLAYCONFIG_ROTATION_ROTATE180: + rotation = 180; + break; + case DISPLAYCONFIG_ROTATION_ROTATE270: + rotation = 270; + break; + default: + rotation = 0; + break; + } + ffdsAppendDisplay(ds, width, height, path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator, scaledWidth, scaledHeight, + rotation, &name, path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || @@ -112,7 +127,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufInit(&ds->deVersion); ffListInit(&ds->displays, sizeof(FFDisplayResult)); - detectDisplays(ds, instance->config.display.detectName); + detectDisplays(ds); //https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067 const FFOSResult* os = ffDetectOS(instance); diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index b4e31f77e..9e95eb1c5 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -19,7 +19,6 @@ typedef struct WaylandData FF_LIBRARY_SYMBOL(wl_display_roundtrip) struct wl_display* display; const struct wl_interface* ffwl_output_interface; - bool detectName; } WaylandData; typedef struct WaylandDisplay @@ -31,7 +30,6 @@ typedef struct WaylandDisplay enum wl_output_transform transform; FFDisplayType type; FFstrbuf name; - bool detectName; } WaylandDisplay; #ifndef __FreeBSD__ @@ -92,16 +90,14 @@ static void waylandOutputGeometryListener(void *data, { WaylandDisplay* display = data; display->transform = (enum wl_output_transform) transform; - if(display->detectName) + + if(make && strcmp(make, "unknown") != 0) + ffStrbufAppendS(&display->name, make); + if(model && strcmp(model, "unknown") != 0) { - if(make && strcmp(make, "unknown") != 0) - ffStrbufAppendS(&display->name, make); - if(model && strcmp(model, "unknown") != 0) - { - if(display->name.length > 0) - ffStrbufAppendC(&display->name, '-'); - ffStrbufAppendS(&display->name, model); - } + if(display->name.length > 0) + ffStrbufAppendC(&display->name, '-'); + ffStrbufAppendS(&display->name, model); } } @@ -123,7 +119,6 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist return; WaylandDisplay display = { - .detectName = wldata->detectName, .width = 0, .height = 0, .refreshRate = 0, @@ -179,12 +174,33 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist break; } + uint32_t rotation; + switch(display.transform) + { + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_90: + rotation = 90; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_180: + case WL_OUTPUT_TRANSFORM_180: + rotation = 180; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + case WL_OUTPUT_TRANSFORM_270: + rotation = 270; + break; + default: + rotation = 0; + break; + } + ffdsAppendDisplay(wldata->result, (uint32_t) display.width, (uint32_t) display.height, display.refreshRate / 1000.0, (uint32_t) (display.width / display.scale), (uint32_t) (display.height / display.scale), + rotation, &display.name, display.type ); @@ -223,8 +239,6 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) if(data.display == NULL) return false; - data.detectName = instance->config.display.detectName; - waylandDetectWM(ffwl_display_get_fd(data.display), result); struct wl_proxy* registry = ffwl_proxy_marshal_constructor((struct wl_proxy*) data.display, WL_DISPLAY_GET_REGISTRY, ffwl_registry_interface, NULL); diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 447c76bb2..c81bf46db 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -118,6 +118,7 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) 0, (uint32_t) iterator.data->width_in_pixels, (uint32_t) iterator.data->height_in_pixels, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -184,6 +185,7 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo refreshRate == 0 ? data->defaultRefreshRate : refreshRate, (uint32_t) modeInfo->width, (uint32_t) modeInfo->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -223,6 +225,7 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc) data->defaultRefreshRate, (uint32_t) crtcInfoReply->width, (uint32_t) crtcInfoReply->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -270,6 +273,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* data->defaultRefreshRate, (uint32_t) monitor->width, (uint32_t) monitor->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -332,6 +336,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) data->defaultRefreshRate, (uint32_t) screen->width_in_pixels, (uint32_t) screen->height_in_pixels, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 13a08b2a5..56a72ddf5 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -83,6 +83,7 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) 0, (uint32_t) WidthOfScreen(screen), (uint32_t) HeightOfScreen(screen), + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -143,6 +144,7 @@ static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo) refreshRate == 0 ? data->defaultRefreshRate : refreshRate, (uint32_t) modeInfo->width, (uint32_t) modeInfo->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -176,6 +178,7 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) data->defaultRefreshRate, (uint32_t) crtcInfo->width, (uint32_t) crtcInfo->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -214,6 +217,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) data->defaultRefreshRate, (uint32_t) monitorInfo->width, (uint32_t) monitorInfo->height, + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); @@ -270,6 +274,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) data->defaultRefreshRate, (uint32_t) WidthOfScreen(screen), (uint32_t) HeightOfScreen(screen), + 0, NULL, FF_DISPLAY_TYPE_UNKNOWN ); diff --git a/src/fastfetch.c b/src/fastfetch.c index 2b5e5600d..cfd9e7190 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -177,12 +177,15 @@ static inline void printCommandHelp(const char* command) } else if(strcasecmp(command, "display-format") == 0) { - constructAndPrintCommandHelpFormat("display", "{}x{} @ {}Hz", 5, + constructAndPrintCommandHelpFormat("display", "{}x{} @ {}Hz", 7, "Screen width", "Screen height", "Screen refresh rate", "Screen scaled width", - "Screen scaled height" + "Screen scaled height", + "Screen name", + "Screen type", + "Screen rotation" ); } else if(strcasecmp(command, "de-format") == 0) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 53ccf74aa..f97f130ec 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -3,7 +3,7 @@ #include "detection/displayserver/displayserver.h" #include "modules/display/display.h" -#define FF_DISPLAY_NUM_FORMAT_ARGS 7 +#define FF_DISPLAY_NUM_FORMAT_ARGS 8 void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) { @@ -53,7 +53,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - if(result->name.length || (moduleIndex > 0 && displayType)) + if((options->detectName && result->name.length) || (moduleIndex > 0 && displayType)) { ffStrbufClear(&key); if(options->moduleArgs.key.length == 0) @@ -102,6 +102,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRING, displayType}, + {FF_FORMAT_ARG_TYPE_UINT, &result->rotation}, }); } From 74e61369f255f0cfa2c6d22adcaec426ff2aae9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 11:30:04 +0800 Subject: [PATCH 093/493] FFlist / FFstrbuf: add InitMove functions --- src/util/FFlist.h | 17 +++++++++++++++++ src/util/FFstrbuf.c | 13 ------------- src/util/FFstrbuf.h | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index eccd30b55..ce045be98 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -58,6 +58,23 @@ static inline void ffListSort(FFlist* list, int(*compar)(const void*, const void qsort(list->data, list->length, list->elementSize, compar); } +// Move the contents of `src` into `list`, and left `src` empty +static inline void ffListInitMove(FFlist* list, FFlist* src) +{ + if (src) + { + list->elementSize = src->elementSize; + list->capacity = src->capacity; + list->length = src->length; + list->data = list->data; + ffListInit(src, list->elementSize); + } + else + { + ffListInit(list, 0); + } +} + static inline void ffListDestroy(FFlist* list) { if (!list->data) return; diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index eccea2341..c05a7fa36 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -22,19 +22,6 @@ void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src) ffStrbufAppend(strbuf, src); } -void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) -{ - if (src) - { - strbuf->allocated = src->allocated; - strbuf->chars = src->chars; - strbuf->length = src->length; - ffStrbufInit(src); - } - else - ffStrbufInit(strbuf); -} - void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) { assert(format != NULL); diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index 32eb3da8c..c47719679 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -28,9 +28,9 @@ typedef struct FFstrbuf char* chars; } FFstrbuf; +static inline void ffStrbufInit(FFstrbuf* strbuf); void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate); void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src); -void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src); void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments); void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free); @@ -104,6 +104,20 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) return strbuf; } +// Move the content of `src` into `strbuf`, and left `src` empty +static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) +{ + if (src) + { + strbuf->allocated = src->allocated; + strbuf->chars = src->chars; + strbuf->length = src->length; + ffStrbufInit(src); + } + else + ffStrbufInit(strbuf); +} + FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) { FFstrbuf strbuf; From c33eb8c265eb64c1e4aaa4917b13270180b1e7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 11:30:18 +0800 Subject: [PATCH 094/493] GPU: support module options --- src/detection/gpu/gpu.c | 23 ++++++++++++----------- src/detection/gpu/gpu.h | 3 ++- src/detection/gpu/gpu_apple.c | 6 ++---- src/detection/gpu/gpu_linux.c | 14 +++++++------- src/detection/gpu/gpu_nosupport.c | 4 ++-- src/detection/gpu/gpu_windows.c | 2 +- src/detection/vulkan/vulkan.c | 2 +- src/detection/vulkan/vulkan.h | 2 +- src/modules/gpu/gpu.c | 19 ++++++++++++++++--- 9 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 59ac5bf68..f78eeb433 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -2,8 +2,6 @@ #include "detection/internal.h" #include "detection/vulkan/vulkan.h" -const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance); - const char* FF_GPU_VENDOR_NAME_APPLE = "Apple"; const char* FF_GPU_VENDOR_NAME_AMD = "AMD"; const char* FF_GPU_VENDOR_NAME_INTEL = "Intel"; @@ -32,14 +30,17 @@ const char* ffGetGPUVendorString(unsigned vendorId) return NULL; } -const FFlist* ffDetectGPU(const FFinstance* instance) +const char* ffDetectGPU(const FFinstance* instance, const FFGPUOptions* options, FFlist* result) { - FF_DETECTION_INTERNAL_GUARD(FFlist, - ffListInit(&result, sizeof(FFGPUResult)); - if(instance->config.gpu.forceVulkan || ffDetectGPUImpl(&result, instance) != NULL) - { - const FFVulkanResult* vulkan = ffDetectVulkan(instance); - result = vulkan->gpus; - } - ); + if (!options->forceVulkan) + { + const char* error = ffDetectGPUImpl(instance, options, result); + if (!error) return NULL; + } + FFVulkanResult* vulkan = ffDetectVulkan(instance); + if (vulkan->error) return "GPU detection failed"; + ffListDestroy(result); + ffListInitMove(result, &vulkan->gpus); + + return NULL; } diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 2f04a440e..444e68f87 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -33,7 +33,8 @@ typedef struct FFGPUResult uint32_t vulkanDeviceId; // Only used for vulkan } FFGPUResult; -const FFlist* ffDetectGPU(const FFinstance* instance); +const char* ffDetectGPU(const FFinstance* instance, const FFGPUOptions* options, FFlist* result); +const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus); const char* ffGetGPUVendorString(unsigned vendorId); diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 2245692b5..cdb8b8f79 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -38,10 +38,8 @@ static double detectGpuTemp(const FFstrbuf* gpuName) return result; } -const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) { - FF_UNUSED(instance); - CFMutableDictionaryRef matchDict = IOServiceMatching(kIOAcceleratorClassName); io_iterator_t iterator; if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess) @@ -98,7 +96,7 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; - if(instance->config.gpu.temp) + if(options->temp) gpu->temperature = detectGpuTemp(&gpu->name); else gpu->temperature = FF_GPU_TEMP_UNSET; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 411bfd45b..9ef3a24eb 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -171,7 +171,7 @@ static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* dev gpu->type = FF_GPU_TYPE_INTEGRATED; } -static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData* pci, struct pci_dev* device) +static void pciHandleDevice(const FFinstance* instance, const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) { pci->ffpci_fill_info(device, PCI_FILL_CLASS); @@ -206,7 +206,7 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; - if(instance->config.gpu.temp) + if(options->temp) pciDetectTemperatur(gpu, device); } @@ -234,7 +234,7 @@ static void handlePciWarning(FF_MAYBE_UNUSED char *msg, ...) // noop } -static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus) +static const char* pciDetectGPUs(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) { PCIData pci; @@ -267,7 +267,7 @@ static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus) struct pci_dev* device = pci.access->devices; while(device != NULL) { - pciHandleDevice(instance, gpus, &pci, device); + pciHandleDevice(instance, options, gpus, &pci, device); device = device->next; } @@ -277,12 +277,12 @@ static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus) #endif -const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) +const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) { #ifdef FF_HAVE_LIBPCI - return pciDetectGPUs(instance, gpus); + return pciDetectGPUs(instance, options, gpus); #else - FF_UNUSED(gpus, instance); + FF_UNUSED(instance, gpus); return "fastfetch is built without libpci support"; #endif } diff --git a/src/detection/gpu/gpu_nosupport.c b/src/detection/gpu/gpu_nosupport.c index ef2d54abd..c32574c56 100644 --- a/src/detection/gpu/gpu_nosupport.c +++ b/src/detection/gpu/gpu_nosupport.c @@ -1,7 +1,7 @@ #include "gpu.h" -const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) +const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) { - FF_UNUSED(gpus, instance); + FF_UNUSED(instance, options, gpus); return "Not supported on this platform"; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 671328a1c..2866ff5f3 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -4,7 +4,7 @@ #include -const char* ffDetectGPUImpl(FFlist* gpus, FF_MAYBE_UNUSED const FFinstance* instance) +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF_MAYBE_UNUSED FFGPUOptions* options, FFlist* gpus) { DISPLAY_DEVICEW displayDevice = {.cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 878017e95..9ab2319dd 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -245,7 +245,7 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu #endif -const FFVulkanResult* ffDetectVulkan(const FFinstance* instance) +FFVulkanResult* ffDetectVulkan(const FFinstance* instance) { static FFVulkanResult result; static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; diff --git a/src/detection/vulkan/vulkan.h b/src/detection/vulkan/vulkan.h index 559dc3ff7..1da50b969 100644 --- a/src/detection/vulkan/vulkan.h +++ b/src/detection/vulkan/vulkan.h @@ -14,6 +14,6 @@ typedef struct FFVulkanResult const char* error; } FFVulkanResult; -const FFVulkanResult* ffDetectVulkan(const FFinstance* instance); +FFVulkanResult* ffDetectVulkan(const FFinstance* instance); #endif diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index e5dfb7fe3..41a8ff682 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -75,12 +75,18 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t void ffPrintGPU(FFinstance* instance, FFGPUOptions* options) { - const FFlist* gpus = ffDetectGPU(instance); + FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult)); + const char* error = ffDetectGPU(instance, options, &gpus); + if (error) + { + ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } FF_LIST_AUTO_DESTROY selectedGPUs; - ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus->length); + ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus.length); - FF_LIST_FOR_EACH(FFGPUResult, gpu, *gpus) + FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) { if(gpu->type == FF_GPU_TYPE_INTEGRATED && options->hideType == FF_GPU_TYPE_INTEGRATED) continue; @@ -96,6 +102,13 @@ void ffPrintGPU(FFinstance* instance, FFGPUOptions* options) if(selectedGPUs.length == 0) ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); + + FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) + { + ffStrbufDestroy(&gpu->vendor); + ffStrbufDestroy(&gpu->name); + ffStrbufDestroy(&gpu->driver); + } } void ffInitGPUOptions(FFGPUOptions* options) From 6a71e0fa754d4b2efee74321bcc161d6ea641996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 14:37:18 +0800 Subject: [PATCH 095/493] Media: tidy, add fixme --- src/detection/media/media_linux.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 23564588a..e9b5909d8 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -99,16 +99,16 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul return true; } -static void getCustomBus(FFDBusData* data, const FFinstance* instance, FFMediaResult* result) +static void getCustomBus(FFDBusData* data, const FFstrbuf* playerName, FFMediaResult* result) { - if(ffStrbufStartsWithS(&instance->config.player.name, FF_DBUS_MPRIS_PREFIX)) + if(ffStrbufStartsWithS(playerName, FF_DBUS_MPRIS_PREFIX)) { - getBusProperties(data, instance->config.player.name.chars, result); + getBusProperties(data, playerName->chars, result); return; } FF_STRBUF_AUTO_DESTROY busName = ffStrbufCreateS(FF_DBUS_MPRIS_PREFIX); - ffStrbufAppend(&busName, &instance->config.player.name); + ffStrbufAppend(&busName, playerName); getBusProperties(data, busName.chars, result); } @@ -158,8 +158,10 @@ static const char* getMedia(const FFinstance* instance, FFMediaResult* result) if(error != NULL) return error; + // FIXME: This is shared for both player and media module. + // However it uses an option in one specific module if(instance->config.player.name.length > 0) - getCustomBus(&data, instance, result); + getCustomBus(&data, &instance->config.player.name, result); else getBestBus(&data, result); From 40a1f758952ee30d6405e880d9b969b61e15a3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 14:52:46 +0800 Subject: [PATCH 096/493] TerminalShell: remove `--terminal-version` and `--shell-version` --- CHANGELOG.md | 1 + completions/bash | 2 -- src/data/config_user.txt | 12 ------------ src/data/help.txt | 2 -- .../terminalshell/terminalshell_linux.c | 17 ++++++----------- .../terminalshell/terminalshell_windows.c | 6 ++---- src/modules/shell/shell.c | 14 -------------- src/modules/terminal/option.h | 2 -- src/modules/terminal/terminal.c | 14 -------------- 9 files changed, 9 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 634aeea2b..39b481c75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This release introduces a new configuration file format: JSON config Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. +* Remove `--shell-version` and `--terminal-version`. They are always enabled Features: * Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux) diff --git a/completions/bash b/completions/bash index 5752ffdb5..9839ce280 100644 --- a/completions/bash +++ b/completions/bash @@ -193,8 +193,6 @@ __fastfetch_completion() "--pipe" "--title-fqdn" "--escape-bedrock" - "--shell-version" - "--terminal-version" "--disk-folders" "--disk-show-removable" "--disk-show-hidden" diff --git a/src/data/config_user.txt b/src/data/config_user.txt index fcac284d5..6aa72ef17 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -226,18 +226,6 @@ # Default is false. #--gpu-force-vulkan -# Shell option -# Sets if shell version should be detected and printed -# Must be either true or false -# Default is true. -#--shell-version true - -# Terminal option -# Sets if terminal version should be detected and printed -# Must be either true or false -# Default is true. -#--terminal-version true - # Disk show options # Sets if certain types of disk should be printed # Must be either true or false diff --git a/src/data/help.txt b/src/data/help.txt index 48109de86..e20d535d5 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -104,8 +104,6 @@ Module specific options: --title-fqdn : Set if the title should use fully qualified domain name. Default is false --separator-string : Set the string printed by the separator module --os-file : Set the path to the file containing OS information - --shell-version : Set if shell version should be detected and printed - --terminal-version : Set if terminal version should be detected and printed --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) --disk-show-regular : Set if regular volume should be printed. Default is true --disk-show-removable : Set if removable volume should be printed. Default is true diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 9bb488e0f..e69e3617d 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -353,15 +353,12 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getUserShellFromEnv(instance, &result); ffStrbufClear(&result.shellVersion); - if(instance->config.shell.version) - { - getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); + getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); - if(strcasecmp(result.shellExeName, result.userShellExeName) != 0) - getShellVersion(&result.userShellExe, result.userShellExeName, &result.userShellVersion); - else - ffStrbufSet(&result.userShellVersion, &result.shellVersion); - } + if(strcasecmp(result.shellExeName, result.userShellExeName) != 0) + getShellVersion(&result.userShellExe, result.userShellExeName, &result.userShellVersion); + else + ffStrbufSet(&result.userShellVersion, &result.shellVersion); if(ffStrbufEqualS(&result.shellProcessName, "pwsh")) ffStrbufInitS(&result.shellPrettyName, "PowerShell"); @@ -389,9 +386,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitCopy(&result.terminalPrettyName, &result.terminalProcessName); ffStrbufInit(&result.terminalVersion); - - if(instance->config.terminal.version) - fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); ffThreadMutexUnlock(&mutex); return &result; diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index a20cfc11a..35a3af0f7 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -152,8 +152,7 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* } ffStrbufClear(&result->shellVersion); - if(instance->config.shell.version) - fftsGetShellVersion(&result->shellExe, result->shellPrettyName.chars, &result->shellVersion); + fftsGetShellVersion(&result->shellExe, result->shellPrettyName.chars, &result->shellVersion); result->shellPid = pid; if(ffStrbufIgnCaseEqualS(&result->shellPrettyName, "pwsh")) @@ -351,8 +350,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getTerminalFromEnv(&result); ffStrbufInit(&result.terminalVersion); - if(instance->config.terminal.version) - fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); exit: ffThreadMutexUnlock(&mutex); diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index d5023c443..c6efb899c 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -46,8 +46,6 @@ void ffInitShellOptions(FFShellOptions* options) { options->moduleName = FF_SHELL_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); - - options->version = true; } bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value) @@ -57,12 +55,6 @@ bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "version") == 0) - { - options->version = ffOptionParseBoolean(value); - return true; - } - return false; } @@ -89,12 +81,6 @@ void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "version") == 0) - { - options.version = yyjson_get_bool(val); - continue; - } - ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } diff --git a/src/modules/terminal/option.h b/src/modules/terminal/option.h index 46c9c96fa..151129e13 100644 --- a/src/modules/terminal/option.h +++ b/src/modules/terminal/option.h @@ -8,6 +8,4 @@ typedef struct FFTerminalOptions { const char* moduleName; FFModuleArgs moduleArgs; - - bool version; } FFTerminalOptions; diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index f90f9bead..4d7db5b46 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -47,8 +47,6 @@ void ffInitTerminalOptions(FFTerminalOptions* options) { options->moduleName = FF_TERMINAL_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); - - options->version = true; } bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value) @@ -58,12 +56,6 @@ bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "version") == 0) - { - options->version = ffOptionParseBoolean(value); - return true; - } - return false; } @@ -90,12 +82,6 @@ void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "version") == 0) - { - options.version = yyjson_get_bool(val); - continue; - } - ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } From 9b9d03947d97dc4459f3581a15899047c5740557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 15:23:15 +0800 Subject: [PATCH 097/493] Users: silence compiler warnings --- src/detection/users/users_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index 421a6d5d2..e2fce1751 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -11,6 +11,8 @@ #define getutxent getutent #endif +#pragma GCC diagnostic ignored "-Wstringop-overread" + void ffDetectUsers(FFlist* users, FFstrbuf* error) { struct utmpx* n = NULL; From df4d6627ee6f9f9b31104017cab1628dbd6d1a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 15:22:46 +0800 Subject: [PATCH 098/493] Player: make `playerName` a global config `playerName` is used in `ffDetectMedia`, which is used in Module `media` and `player`. --- src/common/init.c | 12 +++++++++--- src/common/jsonconfig.c | 6 ++++++ src/detection/media/media_linux.c | 4 ++-- src/fastfetch.c | 5 +++++ src/fastfetch.h | 4 ++++ src/modules/player/option.h | 2 -- src/modules/player/player.c | 4 ---- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index 1c9fd67bb..726057508 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -35,9 +35,11 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.colorKeys); ffStrbufInit(&instance->config.colorTitle); - - ffStrbufInit(&instance->config.keyValueSeparator); - ffStrbufAppendS(&instance->config.keyValueSeparator, ": "); + ffStrbufInitS(&instance->config.keyValueSeparator, ": "); + + #if defined(__linux__) || defined(__FreeBSD__) + ffStrbufInit(&instance->config.playerName); + #endif instance->config.showErrors = false; instance->config.recache = false; @@ -252,6 +254,10 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.colorKeys); ffStrbufDestroy(&instance->config.colorTitle); ffStrbufDestroy(&instance->config.keyValueSeparator); + + #if defined(__linux__) || defined(__FreeBSD__) + ffStrbufDestroy(&instance->config.playerName); + #endif ffDestroyTitleOptions(&instance->config.title); ffDestroyOSOptions(&instance->config.os); diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index efd192609..61b460a89 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -304,6 +304,12 @@ const char* ffParseGeneralJsonConfig(FFinstance* instance) config->escapeBedrock = yyjson_get_bool(val); else if (strcasecmp(key, "pipe") == 0) config->pipe = yyjson_get_bool(val); + + #if defined(__linux__) || defined(__FreeBSD__) + else if (strcasecmp(key, "playerName") == 0) + ffStrbufSetS(&config->playerName, yyjson_get_str(val)); + #endif + else return "Unknown general property"; } diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index e9b5909d8..9615ee1a1 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -160,8 +160,8 @@ static const char* getMedia(const FFinstance* instance, FFMediaResult* result) // FIXME: This is shared for both player and media module. // However it uses an option in one specific module - if(instance->config.player.name.length > 0) - getCustomBus(&data, &instance->config.player.name, result); + if(instance->config.playerName.length > 0) + getCustomBus(&data, &instance->config.playerName, result); else getBestBus(&data, result); diff --git a/src/fastfetch.c b/src/fastfetch.c index cfd9e7190..0ec386abe 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -899,6 +899,11 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "--load-user-config") == 0) data->loadUserConfig = optionParseBoolean(value); + #if defined(__linux__) || defined(__FreeBSD__) + else if(strcasecmp(key, "--player-name") == 0) + optionParseString(key, value, &instance->config.playerName); + #endif + //////////////// //Logo options// //////////////// diff --git a/src/fastfetch.h b/src/fastfetch.h index b1bfb2d52..dbc87b2da 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -48,6 +48,10 @@ typedef struct FFconfig bool multithreading; bool stat; + #if defined(__linux__) || defined(__FreeBSD__) + FFstrbuf playerName; + #endif + FFTitleOptions title; FFOSOptions os; FFHostOptions host; diff --git a/src/modules/player/option.h b/src/modules/player/option.h index 8fa057a47..e27056055 100644 --- a/src/modules/player/option.h +++ b/src/modules/player/option.h @@ -8,6 +8,4 @@ typedef struct FFPlayerOptions { const char* moduleName; FFModuleArgs moduleArgs; - - FFstrbuf name; } FFPlayerOptions; diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 5178d3746..6c0644a85 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -76,8 +76,6 @@ void ffInitPlayerOptions(FFPlayerOptions* options) { options->moduleName = FF_PLAYER_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); - - ffStrbufInit(&options->name); } bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value) @@ -93,8 +91,6 @@ bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, cons void ffDestroyPlayerOptions(FFPlayerOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); - - ffStrbufDestroy(&options->name); } void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module) From d7115022e404ede130d9d9fe0e41b8cafb91e228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 15:35:48 +0800 Subject: [PATCH 099/493] OpenGL: update text files that reflects the change of `--gl` to `--opengl-type` --- completions/bash | 8 ++++---- src/data/config_user.txt | 4 ++-- src/data/help.txt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/completions/bash b/completions/bash index 9839ce280..d08a71c55 100644 --- a/completions/bash +++ b/completions/bash @@ -113,7 +113,7 @@ __fastfetch_complete_option() "${FF_OPTIONS_LOGO[@]}" "${FF_OPTIONS_LOGO_TYPE[@]}" "${FF_OPTIONS_BINARY_PREFIX[@]}" - "${FF_OPTIONS_GL[@]}" + "${FF_OPTIONS_OPENGL[@]}" ) if [[ $WORD_COUND -lt 3 ]]; then @@ -399,8 +399,8 @@ __fastfetch_completion() "--binary-prefix" ) - local FF_OPTIONS_GL=( - "--gl" + local FF_OPTIONS_OPENGL=( + "--opengl-type" ) if __fastfetch_previous_matches "${FF_OPTIONS_SINGLE[@]}"; then @@ -423,7 +423,7 @@ __fastfetch_completion() __fastfetch_complete_logo_type elif __fastfetch_previous_matches "${FF_OPTIONS_BINARY_PREFIX[@]}"; then __fastfetch_complete_binary_prefix - elif __fastfetch_previous_matches "${FF_OPTIONS_GL[@]}"; then + elif __fastfetch_previous_matches "${FF_OPTIONS_OPENGL[@]}"; then __fastfetch_complete_gl else __fastfetch_complete_option diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 6aa72ef17..58b55653a 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -206,11 +206,11 @@ # Default is true. #--escape-bedrock true -# GL option +# OpenGL option # Sets with opengl context creation library to use # Must be either auto, egl, glx or osmesa # Default is auto. -#--gl auto +#--opengl-type auto # GPU hide options # Sets weather to hide certain gpu types diff --git a/src/data/help.txt b/src/data/help.txt index e20d535d5..8c96ab9c0 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -133,7 +133,7 @@ Module specific options: --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use - --gl : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto + --opengl-type : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others --command-key : Set the module key to display, can be specified mulitple times From e9b3a799bcc6e516f06cb695f57a71bdd9fe123e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 15:42:26 +0800 Subject: [PATCH 100/493] OS: make `osFile` a global option `OS` is used by Module `Package` --- src/common/init.c | 6 ++++-- src/common/jsonconfig.c | 4 +++- src/detection/os/os_linux.c | 4 ++-- src/fastfetch.c | 2 ++ src/fastfetch.h | 2 ++ src/modules/os/option.h | 4 ---- src/modules/os/os.c | 23 ----------------------- 7 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index 726057508..f469de137 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -36,9 +36,10 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.colorKeys); ffStrbufInit(&instance->config.colorTitle); ffStrbufInitS(&instance->config.keyValueSeparator, ": "); - + #if defined(__linux__) || defined(__FreeBSD__) ffStrbufInit(&instance->config.playerName); + ffStrbufInit(&instance->config.osFile); #endif instance->config.showErrors = false; @@ -254,9 +255,10 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.colorKeys); ffStrbufDestroy(&instance->config.colorTitle); ffStrbufDestroy(&instance->config.keyValueSeparator); - + #if defined(__linux__) || defined(__FreeBSD__) ffStrbufDestroy(&instance->config.playerName); + ffStrbufDestroy(&instance->config.osFile); #endif ffDestroyTitleOptions(&instance->config.title); diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 61b460a89..f4e0ff4e9 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -304,10 +304,12 @@ const char* ffParseGeneralJsonConfig(FFinstance* instance) config->escapeBedrock = yyjson_get_bool(val); else if (strcasecmp(key, "pipe") == 0) config->pipe = yyjson_get_bool(val); - + #if defined(__linux__) || defined(__FreeBSD__) else if (strcasecmp(key, "playerName") == 0) ffStrbufSetS(&config->playerName, yyjson_get_str(val)); + else if (strcasecmp(key, "osFile") == 0) + ffStrbufSetS(&config->osFile, yyjson_get_str(val)); #endif else diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index a9db735db..063e8455b 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -96,9 +96,9 @@ static void getUbuntuFlavour(FFOSResult* result) static void detectOS(FFOSResult* os, const FFinstance* instance) { - if(instance->config.os.file.length > 0) + if(instance->config.osFile.length > 0) { - parseFile(instance->config.os.file.chars, os); + parseFile(instance->config.osFile.chars, os); return; } diff --git a/src/fastfetch.c b/src/fastfetch.c index 0ec386abe..577239ff4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -902,6 +902,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con #if defined(__linux__) || defined(__FreeBSD__) else if(strcasecmp(key, "--player-name") == 0) optionParseString(key, value, &instance->config.playerName); + else if (strcasecmp(key, "--os-file") == 0) + optionParseString(key, value, &instance->config.osFile); #endif //////////////// diff --git a/src/fastfetch.h b/src/fastfetch.h index dbc87b2da..a5e859ecc 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -48,8 +48,10 @@ typedef struct FFconfig bool multithreading; bool stat; + // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) FFstrbuf playerName; + FFstrbuf osFile; #endif FFTitleOptions title; diff --git a/src/modules/os/option.h b/src/modules/os/option.h index 7d6b4d082..be1bfda1f 100644 --- a/src/modules/os/option.h +++ b/src/modules/os/option.h @@ -8,8 +8,4 @@ typedef struct FFOSOptions { const char* moduleName; FFModuleArgs moduleArgs; - - #if defined(__linux__) || defined(__FreeBSD__) - FFstrbuf file; - #endif } FFOSOptions; diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 41ec29ae6..f057aa762 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -140,10 +140,6 @@ void ffInitOSOptions(FFOSOptions* options) { options->moduleName = FF_OS_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); - - #if defined(__linux__) || defined(__FreeBSD__) - ffStrbufInit(&options->file); - #endif } bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value) @@ -153,23 +149,12 @@ bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(subKey, "file") == 0) - { - ffOptionParseString(key, value, &options->file); - return true; - } - #endif - return false; } void ffDestroyOSOptions(FFOSOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); - #if defined(__linux__) || defined(__FreeBSD__) - ffStrbufDestroy(&options->file); - #endif } void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) @@ -190,14 +175,6 @@ void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "file") == 0) - { - ffStrbufSetS(&options.file, yyjson_get_str(val)); - continue; - } - #endif - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } From 6568cd8e0d22cb2d1a89dfa1996a6e356e06a08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 15:48:26 +0800 Subject: [PATCH 101/493] fastfetch: unify `parse` functions --- src/fastfetch.c | 159 ++++++++++++++---------------------------------- 1 file changed, 45 insertions(+), 114 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 577239ff4..47b5ebdf9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -665,17 +665,6 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char exit(414); } -static bool optionParseBoolean(const char* str) -{ - return ( - !ffStrSet(str) || - strcasecmp(str, "true") == 0 || - strcasecmp(str, "yes") == 0 || - strcasecmp(str, "on") == 0 || - strcasecmp(str, "1") == 0 - ); -} - static inline void optionCheckString(const char* key, const char* value, FFstrbuf* buffer) { if(value == NULL) @@ -686,69 +675,11 @@ static inline void optionCheckString(const char* key, const char* value, FFstrbu ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance } -static void optionParseString(const char* key, const char* value, FFstrbuf* buffer) -{ - optionCheckString(key, value, buffer); - ffStrbufSetS(buffer, value); -} - static inline bool startsWith(const char* str, const char* compareTo) { return strncasecmp(str, compareTo, strlen(compareTo)) == 0; } -static uint32_t optionParseUInt32(const char* key, const char* value) -{ - if(value == NULL) - { - fprintf(stderr, "Error: usage: %s \n", key); - exit(480); - } - - char* end; - uint32_t num = (uint32_t) strtoul(value, &end, 10); - if(*end != '\0') - { - fprintf(stderr, "Error: usage: %s \n", key); - exit(479); - } - - return num; -} - -static void optionParseEnum(const char* argumentKey, const char* requestedKey, void* result, ...) -{ - if(requestedKey == NULL) - { - fprintf(stderr, "Error: usage: %s \n", argumentKey); - exit(476); - } - - va_list args; - va_start(args, result); - - while(true) - { - const char* key = va_arg(args, const char*); - if(key == NULL) - break; - - int value = va_arg(args, int); //C standard guarantees that enumeration constants are presented as ints - - if(strcasecmp(requestedKey, key) == 0) - { - *(int*)result = value; - va_end(args); - return; - } - } - - va_end(args); - - fprintf(stderr, "Error: unknown %s value: %s\n", argumentKey, requestedKey); - exit(478); -} - static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value) { /////////////////////// @@ -876,7 +807,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con /////////////////// else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0) - instance->config.recache = optionParseBoolean(value); + instance->config.recache = ffOptionParseBoolean(value); else if(strcasecmp(key, "--load-config") == 0) optionParseConfigFile(instance, data, key, value); else if(strcasecmp(key, "--gen-config") == 0) @@ -884,26 +815,26 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "--gen-config-force") == 0) generateConfigFile(instance, true); else if(strcasecmp(key, "--thread") == 0 || strcasecmp(key, "--multithreading") == 0) - instance->config.multithreading = optionParseBoolean(value); + instance->config.multithreading = ffOptionParseBoolean(value); else if(strcasecmp(key, "--stat") == 0) { - if((instance->config.stat = optionParseBoolean(value))) + if((instance->config.stat = ffOptionParseBoolean(value))) instance->config.showErrors = true; } else if(strcasecmp(key, "--allow-slow-operations") == 0) - instance->config.allowSlowOperations = optionParseBoolean(value); + instance->config.allowSlowOperations = ffOptionParseBoolean(value); else if(strcasecmp(key, "--escape-bedrock") == 0) - instance->config.escapeBedrock = optionParseBoolean(value); + instance->config.escapeBedrock = ffOptionParseBoolean(value); else if(strcasecmp(key, "--pipe") == 0) - instance->config.pipe = optionParseBoolean(value); + instance->config.pipe = ffOptionParseBoolean(value); else if(strcasecmp(key, "--load-user-config") == 0) - data->loadUserConfig = optionParseBoolean(value); + data->loadUserConfig = ffOptionParseBoolean(value); #if defined(__linux__) || defined(__FreeBSD__) else if(strcasecmp(key, "--player-name") == 0) - optionParseString(key, value, &instance->config.playerName); + ffOptionParseString(key, value, &instance->config.playerName); else if (strcasecmp(key, "--os-file") == 0) - optionParseString(key, value, &instance->config.osFile); + ffOptionParseString(key, value, &instance->config.osFile); #endif //////////////// @@ -917,15 +848,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con /////////////////// else if(strcasecmp(key, "--show-errors") == 0) - instance->config.showErrors = optionParseBoolean(value); + instance->config.showErrors = ffOptionParseBoolean(value); else if(strcasecmp(key, "--disable-linewrap") == 0) - instance->config.disableLinewrap = optionParseBoolean(value); + instance->config.disableLinewrap = ffOptionParseBoolean(value); else if(strcasecmp(key, "--hide-cursor") == 0) - instance->config.hideCursor = optionParseBoolean(value); + instance->config.hideCursor = ffOptionParseBoolean(value); else if(strcasecmp(key, "-s") == 0 || strcasecmp(key, "--structure") == 0) - optionParseString(key, value, &data->structure); + ffOptionParseString(key, value, &data->structure); else if(strcasecmp(key, "--separator") == 0) - optionParseString(key, value, &instance->config.keyValueSeparator); + ffOptionParseString(key, value, &instance->config.keyValueSeparator); else if(strcasecmp(key, "--color-keys") == 0) { optionCheckString(key, value, &instance->config.colorKeys); @@ -944,15 +875,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(strcasecmp(key, "--binary-prefix") == 0) { - optionParseEnum(key, value, &instance->config.binaryPrefixType, - "iec", FF_BINARY_PREFIX_TYPE_IEC, - "si", FF_BINARY_PREFIX_TYPE_SI, - "jedec", FF_BINARY_PREFIX_TYPE_JEDEC, - NULL - ); + instance->config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "iec", FF_BINARY_PREFIX_TYPE_IEC }, + { "si", FF_BINARY_PREFIX_TYPE_SI }, + { "jedec", FF_BINARY_PREFIX_TYPE_JEDEC }, + {} + }); } else if(strcasecmp(key, "--percent-type") == 0) - instance->config.percentType = optionParseUInt32(key, value); + instance->config.percentType = ffOptionParseUInt32(key, value); /////////////////////// //Module args options// @@ -1016,53 +947,53 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con { const char* subkey = key + strlen("--lib"); if(strcasecmp(subkey, "-PCI") == 0) - optionParseString(key, value, &instance->config.libPCI); + ffOptionParseString(key, value, &instance->config.libPCI); else if(strcasecmp(subkey, "-vulkan") == 0) - optionParseString(key, value, &instance->config.libVulkan); + ffOptionParseString(key, value, &instance->config.libVulkan); else if(strcasecmp(subkey, "-freetype") == 0) - optionParseString(key, value, &instance->config.libfreetype); + ffOptionParseString(key, value, &instance->config.libfreetype); else if(strcasecmp(subkey, "-wayland") == 0) - optionParseString(key, value, &instance->config.libWayland); + ffOptionParseString(key, value, &instance->config.libWayland); else if(strcasecmp(subkey, "-xcb-randr") == 0) - optionParseString(key, value, &instance->config.libXcbRandr); + ffOptionParseString(key, value, &instance->config.libXcbRandr); else if(strcasecmp(subkey, "-xcb") == 0) - optionParseString(key, value, &instance->config.libXcb); + ffOptionParseString(key, value, &instance->config.libXcb); else if(strcasecmp(subkey, "-Xrandr") == 0) - optionParseString(key, value, &instance->config.libXrandr); + ffOptionParseString(key, value, &instance->config.libXrandr); else if(strcasecmp(subkey, "-X11") == 0) - optionParseString(key, value, &instance->config.libX11); + ffOptionParseString(key, value, &instance->config.libX11); else if(strcasecmp(subkey, "-gio") == 0) - optionParseString(key, value, &instance->config.libGIO); + ffOptionParseString(key, value, &instance->config.libGIO); else if(strcasecmp(subkey, "-DConf") == 0) - optionParseString(key, value, &instance->config.libDConf); + ffOptionParseString(key, value, &instance->config.libDConf); else if(strcasecmp(subkey, "-dbus") == 0) - optionParseString(key, value, &instance->config.libDBus); + ffOptionParseString(key, value, &instance->config.libDBus); else if(strcasecmp(subkey, "-XFConf") == 0) - optionParseString(key, value, &instance->config.libXFConf); + ffOptionParseString(key, value, &instance->config.libXFConf); else if(strcasecmp(subkey, "-sqlite") == 0 || strcasecmp(subkey, "-sqlite3") == 0) - optionParseString(key, value, &instance->config.libSQLite3); + ffOptionParseString(key, value, &instance->config.libSQLite3); else if(strcasecmp(subkey, "-rpm") == 0) - optionParseString(key, value, &instance->config.librpm); + ffOptionParseString(key, value, &instance->config.librpm); else if(strcasecmp(subkey, "-imagemagick") == 0) - optionParseString(key, value, &instance->config.libImageMagick); + ffOptionParseString(key, value, &instance->config.libImageMagick); else if(strcasecmp(subkey, "-z") == 0) - optionParseString(key, value, &instance->config.libZ); + ffOptionParseString(key, value, &instance->config.libZ); else if(strcasecmp(subkey, "-chafa") == 0) - optionParseString(key, value, &instance->config.libChafa); + ffOptionParseString(key, value, &instance->config.libChafa); else if(strcasecmp(subkey, "-egl") == 0) - optionParseString(key, value, &instance->config.libEGL); + ffOptionParseString(key, value, &instance->config.libEGL); else if(strcasecmp(subkey, "-glx") == 0) - optionParseString(key, value, &instance->config.libGLX); + ffOptionParseString(key, value, &instance->config.libGLX); else if(strcasecmp(subkey, "-osmesa") == 0) - optionParseString(key, value, &instance->config.libOSMesa); + ffOptionParseString(key, value, &instance->config.libOSMesa); else if(strcasecmp(subkey, "-opencl") == 0) - optionParseString(key, value, &instance->config.libOpenCL); + ffOptionParseString(key, value, &instance->config.libOpenCL); else if(strcasecmp(subkey, "-wlanapi") == 0) - optionParseString(key, value, &instance->config.libwlanapi); + ffOptionParseString(key, value, &instance->config.libwlanapi); else if(strcasecmp(key, "-pulse") == 0) - optionParseString(key, value, &instance->config.libPulse); + ffOptionParseString(key, value, &instance->config.libPulse); else if(strcasecmp(subkey, "-nm") == 0) - optionParseString(key, value, &instance->config.libnm); + ffOptionParseString(key, value, &instance->config.libnm); else goto error; } From 47bf7857524006aaf15ab5dca3719eae2aa86040 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:10:41 +0200 Subject: [PATCH 102/493] Include limits.h when needed Fixes #472 --- src/detection/brightness/brightness_linux.c | 1 + src/detection/gtk_qt/qt.c | 1 + src/logo/image/image.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 9c00f70e9..ee78bcea8 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -3,6 +3,7 @@ #include #include +#include const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) { diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 7955be14c..c4c519f8e 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -100,6 +100,7 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) ffStrbufAppendS(&baseDir, "plasma-org.kde.plasma.desktop-appletsrc"); ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper); + puts(result->wallpaper.chars); if(allValuesSet(result)) return; diff --git a/src/logo/image/image.c b/src/logo/image/image.c index fc209b4ab..6c84a9b3b 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -2,6 +2,8 @@ #include "common/io/io.h" #include "common/printing.h" +#include + #ifdef __APPLE__ #include #elif _WIN32 From c99dd3324625a2ae7282c87f26e5fa0811efa9a7 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:12:25 +0200 Subject: [PATCH 103/493] Remove debug statement --- src/detection/gtk_qt/qt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index c4c519f8e..7955be14c 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -100,7 +100,6 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) ffStrbufAppendS(&baseDir, "plasma-org.kde.plasma.desktop-appletsrc"); ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper); - puts(result->wallpaper.chars); if(allValuesSet(result)) return; From 465387fd65613fab63262eda146ff80966249f7c Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:22:42 +0200 Subject: [PATCH 104/493] CI: add musl to build test --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 985b60bfe..d74614c77 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, ubuntu-20.04] - compiler: [gcc, clang] + compiler: [gcc, clang, "musl-gcc -static"] enableFeatures: [ON, OFF] runs-on: ${{ matrix.os }} steps: @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev + run: sudo apt-get update && sudo apt-get install -y musl libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: configure project env: From 298b669ff94e279547bab0e9a6913795501acf9f Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:24:58 +0200 Subject: [PATCH 105/493] CI: Try without static --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d74614c77..9aaa89df1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, ubuntu-20.04] - compiler: [gcc, clang, "musl-gcc -static"] + compiler: [gcc, clang, "musl-gcc"] enableFeatures: [ON, OFF] runs-on: ${{ matrix.os }} steps: From b784fd266a099c4cbd0f1696b2c41cdccc049a22 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:29:11 +0200 Subject: [PATCH 106/493] CI: Install correct packages --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9aaa89df1..057daf050 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y musl libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev + run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: configure project env: From 0cf114c39909070609e76001c64bba7a241e50db Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 15:39:17 +0200 Subject: [PATCH 107/493] CI: Try to fix build with musl --- .github/workflows/push.yml | 2 +- src/detection/gpu/gpu_linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 057daf050..0b79ffc62 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev + run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: configure project env: diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 9ef3a24eb..a3f3c0bbe 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -282,7 +282,7 @@ const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* opti #ifdef FF_HAVE_LIBPCI return pciDetectGPUs(instance, options, gpus); #else - FF_UNUSED(instance, gpus); + FF_UNUSED(instance, options, gpus); return "fastfetch is built without libpci support"; #endif } From 216ae71f7f19722b3c68b9df118b9767ae5a4a53 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 16:02:56 +0200 Subject: [PATCH 108/493] Don't use linux/if_packet.h --- src/detection/localip/localip_linux.c | 2 +- src/detection/wifi/wifi_linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 29383c2ae..8ee01f7af 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -10,7 +10,7 @@ #if defined(__FreeBSD__) || defined(__APPLE__) #include #else -#include +#include #endif static void addNewIp(FFlist* list, const char* name, const char* addr, int type) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index a92fa8c2e..44ae0a2e2 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -204,7 +204,7 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul #include "common/io/io.h" #include -#include +#include //TODO: don't use kernel headers in userspace #include #include #include From 29f070fc1fb7eb386d8e889bb970d633e60d0b05 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 16:15:29 +0200 Subject: [PATCH 109/493] Wifi: Workaround: Check if header is present --- src/detection/wifi/wifi_linux.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 44ae0a2e2..191e4ad6b 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -201,13 +201,16 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul #endif +#if __has_include() +#define FF_DETECT_WIFI_WITH_IOCTLS + #include "common/io/io.h" #include -#include //TODO: don't use kernel headers in userspace #include #include #include +#include //TODO: Don't depend on kernel headers static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) { @@ -309,6 +312,8 @@ static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instan return NULL; } +#endif + const char* ffDetectWifi(const FFinstance* instance, FFlist* result) { #ifdef FF_HAVE_LIBNM @@ -316,5 +321,9 @@ const char* ffDetectWifi(const FFinstance* instance, FFlist* result) return NULL; #endif - return detectWifiWithIoctls(instance, result); + #ifdef FF_DETECT_WIFI_WITH_IOCTLS + detectWifiWithIoctls(instance, result); + #endif + + return "linux/wireless.h not found during compilation"; } From 67349354e4a4cd000273b357f12f549b05aa5db6 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 17:20:27 +0200 Subject: [PATCH 110/493] Don't build the combination of musl & features --- .github/workflows/push.yml | 8 +++++++- src/common/init.c | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0b79ffc62..a5ff38bb2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,8 +13,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, ubuntu-20.04] - compiler: [gcc, clang, "musl-gcc"] + compiler: [gcc, clang, "musl-gcc", "musl-clang"] enableFeatures: [ON, OFF] + exclude: + # The feature libraries are all build against glibc, so they can't be used with musl + - compiler: "musl-gcc" + enableFeatures: ON + - compiler: "musl-clang" + enableFeatures: ON runs-on: ${{ matrix.os }} steps: - name: checkout repository diff --git a/src/common/init.c b/src/common/init.c index f469de137..c8bb50f91 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -7,7 +7,6 @@ #include #include -#include #ifdef _WIN32 #include #include From a42e807276fb0f10a0f2b596f814934d44206464 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 17:22:25 +0200 Subject: [PATCH 111/493] Don't test musl-clang, it is broken --- .github/workflows/push.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a5ff38bb2..443a09ff3 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,14 +13,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, ubuntu-20.04] - compiler: [gcc, clang, "musl-gcc", "musl-clang"] + compiler: [gcc, clang, "musl-gcc"] enableFeatures: [ON, OFF] exclude: # The feature libraries are all build against glibc, so they can't be used with musl - compiler: "musl-gcc" enableFeatures: ON - - compiler: "musl-clang" - enableFeatures: ON runs-on: ${{ matrix.os }} steps: - name: checkout repository From fc12494ac11373f8f010f800e70febfab07157ac Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 12 Jun 2023 17:26:37 +0200 Subject: [PATCH 112/493] Adapt to new repository url --- .github/workflows/push.yml | 2 +- CMakeLists.txt | 2 +- README.md | 2 +- src/detection/packages/packages_linux.c | 2 +- src/detection/terminalshell/terminalshell_linux.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 443a09ff3..3a50a9026 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -289,7 +289,7 @@ jobs: path: ./fastfetch-*-Win32.zip release: - if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch' + if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'fastfetch-cli/fastfetch' name: Release runs-on: ubuntu-latest needs: diff --git a/CMakeLists.txt b/CMakeLists.txt index d5dc8cf66..9d55b02b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(fastfetch VERSION 1.11.3 LANGUAGES C DESCRIPTION "Fast system information tool" - HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch" + HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" ) set(PROJECT_LICENSE "MIT license") diff --git a/README.md b/README.md index c90f944a0..7a60115c5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for -There are [screenshots on different platforms](https://github.com/LinusDierheimer/fastfetch/wiki) +There are [screenshots on different platforms](https://github.com/fastfetch-cli/fastfetch/wiki) ## Customization diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 4a9c483a0..81c1be565 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -134,7 +134,7 @@ static uint32_t getNixPackagesImpl(char* path) FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(128); - //https://github.com/LinusDierheimer/fastfetch/issues/195#issuecomment-1191748222 + //https://github.com/fastfetch-cli/fastfetch/issues/195#issuecomment-1191748222 FF_STRBUF_AUTO_DESTROY command = ffStrbufCreateA(255); ffStrbufAppendS(&command, "for x in $(nix-store --query --requisites "); ffStrbufAppendS(&command, path); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index e69e3617d..1c6188601 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -368,7 +368,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitS(&result.shellPrettyName, "xonsh"); else { - // https://github.com/LinusDierheimer/fastfetch/discussions/280#discussioncomment-3831734 + // https://github.com/fastfetch-cli/fastfetch/discussions/280#discussioncomment-3831734 ffStrbufInitS(&result.shellPrettyName, result.shellExeName); } From cba352cca6cf56b217a6b78cbd09cdafb43626c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 21:18:12 +0800 Subject: [PATCH 113/493] TerminalFont: don't use singleton Singleton doesn't work well with JSON config --- src/detection/terminalfont/terminalfont.c | 20 ++++++------ src/detection/terminalfont/terminalfont.h | 2 +- src/modules/terminalfont/terminalfont.c | 37 +++++++++++++---------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 2118c2013..46c390955 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -374,20 +374,18 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina return true; } -const FFTerminalFontResult* ffDetectTerminalFont(const FFinstance* instance) +bool ffDetectTerminalFont(const FFinstance* instance, FFTerminalFontResult* result) { - FF_DETECTION_INTERNAL_GUARD(FFTerminalFontResult, - ffStrbufInit(&result.error); + const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance); - const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance); + if(terminalShell->terminalProcessName.length == 0) + ffStrbufAppendS(&result->error, "Terminal font needs successful terminal detection"); - if(terminalShell->terminalProcessName.length == 0) - ffStrbufAppendS(&result.error, "Terminal font needs successful terminal detection"); + else if(!detectTerminalFontCommon(instance, terminalShell, result)) + ffDetectTerminalFontPlatform(instance, terminalShell, result); - else if(!detectTerminalFontCommon(instance, terminalShell, &result)) - ffDetectTerminalFontPlatform(instance, terminalShell, &result); + if(result->error.length == 0 && result->font.pretty.length == 0) + ffStrbufAppendF(&result->error, "Unknown terminal: %s", terminalShell->terminalProcessName.chars); - if(result.error.length == 0 && result.font.pretty.length == 0) - ffStrbufAppendF(&result.error, "Unknown terminal: %s", terminalShell->terminalProcessName.chars); - ); + return result->error.length == 0; } diff --git a/src/detection/terminalfont/terminalfont.h b/src/detection/terminalfont/terminalfont.h index 0adc2e2aa..a542d3226 100644 --- a/src/detection/terminalfont/terminalfont.h +++ b/src/detection/terminalfont/terminalfont.h @@ -12,6 +12,6 @@ typedef struct FFTerminalFontResult FFfont font; } FFTerminalFontResult; -const FFTerminalFontResult* ffDetectTerminalFont(const FFinstance* instance); +bool ffDetectTerminalFont(const FFinstance* instance, FFTerminalFontResult* result); #endif diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index eff1c5e5a..e290cc6fc 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -8,28 +8,33 @@ void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options) { - const FFTerminalFontResult* terminalFont = ffDetectTerminalFont(instance); + FFTerminalFontResult terminalFont; + ffStrbufInit(&terminalFont.error); - if(terminalFont->error.length > 0) + if(!ffDetectTerminalFont(instance, &terminalFont)) { - ffPrintError(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont->error.chars); - return; - } - - if(options->moduleArgs.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key); - ffStrbufPutTo(&terminalFont->font.pretty, stdout); + ffPrintError(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars); } else { - ffPrintFormat(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.pretty}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont->font.size}, - {FF_FORMAT_ARG_TYPE_LIST, &terminalFont->font.styles} - }); + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&terminalFont.font.pretty, stdout); + } + else + { + ffPrintFormat(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.pretty}, + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size}, + {FF_FORMAT_ARG_TYPE_LIST, &terminalFont.font.styles} + }); + } } + + ffStrbufDestroy(&terminalFont.error); + ffFontDestroy(&terminalFont.font); } void ffInitTerminalFontOptions(FFTerminalFontOptions* options) From fa99508a6900159cd0e8a4ef6b9be7291b0797b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 21:18:22 +0800 Subject: [PATCH 114/493] CMake: make some serious warnings as errors --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d55b02b5..652ae3222 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,12 +103,14 @@ else() message(STATUS "Threads type: disabled") endif() +set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=uninitialized -Werror=return-type") + set(CMAKE_C_STANDARD 11) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") if(WIN32) set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -fno-exceptions -fno-rtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1") endif() From 88f354a8725acf650f53fd0d22b44e31bb56c82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 21:50:25 +0800 Subject: [PATCH 115/493] Bluetooth: don't use singleton --- CMakeLists.txt | 1 - src/detection/bluetooth/bluetooth.c | 15 -------------- src/detection/bluetooth/bluetooth.h | 8 +------- src/detection/bluetooth/bluetooth_apple.m | 11 +++++----- src/detection/bluetooth/bluetooth_linux.c | 20 +++++++++---------- src/detection/bluetooth/bluetooth_nosupport.c | 4 ++-- src/detection/bluetooth/bluetooth_windows.c | 8 +++++--- src/modules/bluetooth/bluetooth.c | 16 +++++++++++---- 8 files changed, 35 insertions(+), 48 deletions(-) delete mode 100644 src/detection/bluetooth/bluetooth.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 652ae3222..bea9db531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,6 @@ set(LIBFASTFETCH_SRC src/common/printing.c src/common/properties.c src/common/settings.c - src/detection/bluetooth/bluetooth.c src/detection/cpu/cpu.c src/detection/cpuusage/cpuusage.c src/detection/datetime/datetime.c diff --git a/src/detection/bluetooth/bluetooth.c b/src/detection/bluetooth/bluetooth.c deleted file mode 100644 index f254fe535..000000000 --- a/src/detection/bluetooth/bluetooth.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "bluetooth.h" - -#include "../internal.h" - -void ffDetectBluetoothImpl(const FFinstance* instance, FFBluetoothResult* bluetooth); - -const FFBluetoothResult* ffDetectBluetooth(const FFinstance* instance) -{ - FF_DETECTION_INTERNAL_GUARD(FFBluetoothResult, - ffStrbufInit(&result.error); - ffListInit(&result.devices, sizeof(FFBluetoothDevice)); - - ffDetectBluetoothImpl(instance, &result); - ) -} diff --git a/src/detection/bluetooth/bluetooth.h b/src/detection/bluetooth/bluetooth.h index ccd6ecd22..a2aad630f 100644 --- a/src/detection/bluetooth/bluetooth.h +++ b/src/detection/bluetooth/bluetooth.h @@ -14,12 +14,6 @@ typedef struct FFBluetoothDevice bool connected; } FFBluetoothDevice; -typedef struct FFBluetoothResult -{ - FFstrbuf error; - FFlist devices; // List of FFBluetoothDevice -} FFBluetoothResult; - -const FFBluetoothResult* ffDetectBluetooth(const FFinstance* instance); +const char* ffDetectBluetooth(const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */); #endif diff --git a/src/detection/bluetooth/bluetooth_apple.m b/src/detection/bluetooth/bluetooth_apple.m index 8affb9074..061bf2cf3 100644 --- a/src/detection/bluetooth/bluetooth_apple.m +++ b/src/detection/bluetooth/bluetooth_apple.m @@ -2,18 +2,15 @@ #import -void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) { NSArray* ioDevices = IOBluetoothDevice.pairedDevices; if(!ioDevices) - { - ffStrbufAppendS(&bluetooth->error, "IOBluetoothDevice.pairedDevices failed"); - return; - } + return "IOBluetoothDevice.pairedDevices failed"; for(IOBluetoothDevice* ioDevice in ioDevices) { - FFBluetoothDevice* device = ffListAdd(&bluetooth->devices); + FFBluetoothDevice* device = ffListAdd(devices); ffStrbufInitS(&device->name, ioDevice.name.UTF8String); ffStrbufInitS(&device->address, ioDevice.addressString.UTF8String); ffStrbufInit(&device->type); @@ -90,4 +87,6 @@ void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoo ffStrbufTrimRight(&device->type, ','); } } + + return NULL; } diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index bcfca6e7d..229a82a42 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -103,7 +103,7 @@ static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFB } } -static void detectBluetoothObject(FFBluetoothResult* bluetooth, FFDBusData* dbus, DBusMessageIter* iter) +static void detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter) { if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY) return; @@ -129,7 +129,7 @@ static void detectBluetoothObject(FFBluetoothResult* bluetooth, FFDBusData* dbus DBusMessageIter arrayIter; dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter); - FFBluetoothDevice* device = ffListAdd(&bluetooth->devices); + FFBluetoothDevice* device = ffListAdd(devices); ffStrbufInit(&device->name); ffStrbufInit(&device->address); ffStrbufInit(&device->type); @@ -147,11 +147,11 @@ static void detectBluetoothObject(FFBluetoothResult* bluetooth, FFDBusData* dbus ffStrbufDestroy(&device->name); ffStrbufDestroy(&device->address); ffStrbufDestroy(&device->type); - --bluetooth->devices.length; + --devices->length; } } -static void detectBluetoothRoot(FFBluetoothResult* bluetooth, FFDBusData* dbus, DBusMessageIter* iter) +static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter) { if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) return; @@ -161,12 +161,12 @@ static void detectBluetoothRoot(FFBluetoothResult* bluetooth, FFDBusData* dbus, while(true) { - detectBluetoothObject(bluetooth, dbus, &arrayIter); + detectBluetoothObject(devices, dbus, &arrayIter); FF_DBUS_ITER_CONTINUE(dbus, &arrayIter); } } -static const char* detectBluetooth(const FFinstance* instance, FFBluetoothResult* bluetooth) +static const char* detectBluetooth(const FFinstance* instance, FFlist* devices) { FFDBusData dbus; const char* error = ffDBusLoadData(instance, DBUS_BUS_SYSTEM, &dbus); @@ -184,7 +184,7 @@ static const char* detectBluetooth(const FFinstance* instance, FFBluetoothResult return "Failed to get root iterator of GetManagedObjects"; } - detectBluetoothRoot(bluetooth, &dbus, &rootIter); + detectBluetoothRoot(devices, &dbus, &rootIter); dbus.lib->ffdbus_message_unref(managedObjects); return NULL; @@ -192,12 +192,12 @@ static const char* detectBluetooth(const FFinstance* instance, FFBluetoothResult #endif -void ffDetectBluetoothImpl(const FFinstance* instance, FFBluetoothResult* bluetooth) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) { #ifdef FF_HAVE_DBUS - ffStrbufAppendS(&bluetooth->error, detectBluetooth(instance, bluetooth)); + return detectBluetooth(instance, devices); #else FF_UNUSED(instance); - ffStrbufAppendS(&bluetooth->error, "Fastfetch was compiled without DBus support"); + return "Fastfetch was compiled without DBus support"; #endif } diff --git a/src/detection/bluetooth/bluetooth_nosupport.c b/src/detection/bluetooth/bluetooth_nosupport.c index f8cafe045..4fbc5353c 100644 --- a/src/detection/bluetooth/bluetooth_nosupport.c +++ b/src/detection/bluetooth/bluetooth_nosupport.c @@ -1,6 +1,6 @@ #include "bluetooth.h" -void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothDevice */) { - ffStrbufAppendS(&bluetooth->error, "Bluetooth not supported on this platform"); + return "Not supported on this platform"; } diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index 76f0c46d9..698eb86db 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -7,7 +7,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpointer-sign" -void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) { BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { .fReturnConnected = TRUE, @@ -22,10 +22,10 @@ void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoo }; HBLUETOOTH_DEVICE_FIND hFind = BluetoothFindFirstDevice(&btsp, &btdi); if(!hFind) - ffStrbufAppendS(&bluetooth->error, "BluetoothFindFirstDevice() failed or no devices found"); + return "BluetoothFindFirstDevice() failed or no devices found"; do { - FFBluetoothDevice* device = ffListAdd(&bluetooth->devices); + FFBluetoothDevice* device = ffListAdd(devices); ffStrbufInit(&device->name); ffStrbufInit(&device->address); ffStrbufInit(&device->type); @@ -110,6 +110,8 @@ void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoo ffStrbufTrimRight(&device->type, ','); } } while (BluetoothFindNextDevice(hFind, &btdi)); + + return NULL; } #pragma GCC diagnostic pop diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 7d512cf2a..cf78eef7d 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -30,17 +30,18 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) { - const FFBluetoothResult* bluetooth = ffDetectBluetooth(instance); + FF_LIST_AUTO_DESTROY devices = ffListCreate(sizeof (FFBluetoothDevice)); + const char* error = ffDetectBluetooth(instance, &devices); - if(bluetooth->error.length > 0) + if(error) { - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", bluetooth->error.chars); + ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFBluetoothDevice*)); - FF_LIST_FOR_EACH(FFBluetoothDevice, device, bluetooth->devices) + FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) { if(!device->connected && !options->showDisconnected) continue; @@ -59,6 +60,13 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); } + + FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) + { + ffStrbufDestroy(&device->name); + ffStrbufDestroy(&device->type); + ffStrbufDestroy(&device->address); + } } void ffInitBluetoothOptions(FFBluetoothOptions* options) From d5a3802492d42531e37a3478dea289674566637a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 22:09:52 +0800 Subject: [PATCH 116/493] Disk: don't use singleton --- src/detection/disk/disk.c | 40 +++++++++++++------------------ src/detection/disk/disk.h | 10 +------- src/detection/disk/disk_bsd.c | 8 ++++--- src/detection/disk/disk_linux.c | 11 ++++----- src/detection/disk/disk_windows.c | 11 +++++---- src/modules/disk/disk.c | 26 +++++++++++++------- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/detection/disk/disk.c b/src/detection/disk/disk.c index 55cfec7de..e033f6c93 100644 --- a/src/detection/disk/disk.c +++ b/src/detection/disk/disk.c @@ -1,35 +1,29 @@ #include "disk.h" -#include "detection/internal.h" -void ffDetectDisksImpl(FFDiskResult* disks); +const char* ffDetectDisksImpl(FFlist* disks); static int compareDisks(const void* disk1, const void* disk2) { return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint); } -const FFDiskResult* ffDetectDisks() +const char* ffDetectDisks(FFlist* disks) { - FF_DETECTION_INTERNAL_GUARD(FFDiskResult, - ffStrbufInit(&result.error); - ffListInitA(&result.disks, sizeof(FFDisk), 4); + const char* error = ffDetectDisksImpl(disks); - ffDetectDisksImpl(&result); + if (error) return error; + if (disks->length == 0) return "No disks found"; - if(result.disks.length == 0 && result.error.length == 0) - ffStrbufAppendS(&result.error, "No disks found"); - else - { - //We need to sort the disks, so that we can detect, which disk a path resides on - // For example for /boot/efi/bootmgr we need to check /boot/efi before /boot - //Note that we sort alphabetically here for a better ordering when printing the list, - // so the check must be done in reverse order - ffListSort(&result.disks, compareDisks); - FF_LIST_FOR_EACH(FFDisk, disk, result.disks) - { - if(disk->bytesTotal == 0) - disk->type |= FF_DISK_TYPE_UNKNOWN_BIT; - } - } - ); + //We need to sort the disks, so that we can detect, which disk a path resides on + // For example for /boot/efi/bootmgr we need to check /boot/efi before /boot + //Note that we sort alphabetically here for a better ordering when printing the list, + // so the check must be done in reverse order + ffListSort(disks, compareDisks); + FF_LIST_FOR_EACH(FFDisk, disk, *disks) + { + if(disk->bytesTotal == 0) + disk->type |= FF_DISK_TYPE_UNKNOWN_BIT; + } + + return NULL; } diff --git a/src/detection/disk/disk.h b/src/detection/disk/disk.h index 9572f267f..b4d9e53e7 100644 --- a/src/detection/disk/disk.h +++ b/src/detection/disk/disk.h @@ -19,18 +19,10 @@ typedef struct FFDisk uint32_t filesTotal; } FFDisk; -typedef struct FFDiskResult -{ - FFstrbuf error; - FFlist disks; //List of FFDisk -} FFDiskResult; - /** * Returns a List of FFDisk, sorted alphabetically by mountpoint. * If error is not set, disks contains at least one disk. - * - * @return const FFDiskResult* */ -const FFDiskResult* ffDetectDisks(); +const char* ffDetectDisks(FFlist* result /* list of FFDisk */); #endif diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 3ff71925a..e6be77659 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -25,17 +25,17 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) void detectFsInfo(struct statfs* fs, FFDisk* disk); #endif -void ffDetectDisksImpl(FFDiskResult* disks) +const char* ffDetectDisksImpl(FFlist* disks) { struct statfs* buf; int size = getmntinfo(&buf, MNT_WAIT); if(size <= 0) - ffStrbufAppendS(&disks->error, "getmntinfo() failed"); + return "getmntinfo(&buf, MNT_WAIT) failed"; for(struct statfs* fs = buf; fs < buf + size; ++fs) { - FFDisk* disk = ffListAdd(&disks->disks); + FFDisk* disk = ffListAdd(disks); #ifdef __FreeBSD__ // f_bavail and f_ffree are signed on FreeBSD... @@ -53,4 +53,6 @@ void ffDetectDisksImpl(FFDiskResult* disks) ffStrbufInitS(&disk->filesystem, fs->f_fstypename); detectFsInfo(fs, disk); } + + return NULL; } diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 210417ef4..f2e9d71ed 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -192,14 +192,11 @@ static void detectStats(FFDisk* disk) disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree); } -void ffDetectDisksImpl(FFDiskResult* disks) +const char* ffDetectDisksImpl(FFlist* disks) { FILE* mountsFile = fopen("/proc/mounts", "r"); if(mountsFile == NULL) - { - ffStrbufAppendS(&disks->error, "fopen(\"/proc/mounts\", \"r\") == NULL"); - return; - } + return "fopen(\"/proc/mounts\", \"r\") == NULL"; FF_LIST_AUTO_DESTROY devices = ffListCreate(sizeof(FFstrbuf)); @@ -224,7 +221,7 @@ void ffDetectDisksImpl(FFDiskResult* disks) } //We have a valid device, add it to the list - FFDisk* disk = ffListAdd(&disks->disks); + FFDisk* disk = ffListAdd(disks); //detect mountpoint ffStrbufInit(&disk->mountpoint); @@ -252,4 +249,6 @@ void ffDetectDisksImpl(FFDiskResult* disks) ffStrbufDestroy(device); fclose(mountsFile); + + return NULL; } diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index d98362694..472b9730f 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -4,11 +4,12 @@ #include #include -void ffDetectDisksImpl(FFDiskResult* disks) +const char* ffDetectDisksImpl(FFlist* disks) { wchar_t buf[MAX_PATH + 1]; uint32_t length = GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf); - assert(length < sizeof(buf) / sizeof(*buf)); + if (length == 0 || length >= sizeof(buf) / sizeof(*buf)) + return "GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf) failed"; for(uint32_t i = 0; i < length; i++) { @@ -21,7 +22,7 @@ void ffDetectDisksImpl(FFDiskResult* disks) continue; } - FFDisk* disk = ffListAdd(&disks->disks); + FFDisk* disk = ffListAdd(disks); ffStrbufInitWS(&disk->mountpoint, mountpoint); uint64_t bytesFree; @@ -61,10 +62,12 @@ void ffDetectDisksImpl(FFDiskResult* disks) ffStrbufSetWS(&disk->name, diskName); } - //TODO: implement + //Unsupported disk->filesUsed = 0; disk->filesTotal = 0; i += disk->mountpoint.length; } + + return NULL; } diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 6dd112216..1bacc0bda 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -133,17 +133,27 @@ static void printAutodetected(FFinstance* instance, FFDiskOptions* options, cons void ffPrintDisk(FFinstance* instance, FFDiskOptions* options) { - const FFDiskResult* disks = ffDetectDisks(); - if(disks->error.length > 0) + FF_LIST_AUTO_DESTROY disks = ffListCreate(sizeof (FFDisk)); + const char* error = ffDetectDisks(&disks); + + if(error) { - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", disks->error.chars); - return; + ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + } + else + { + if(options->folders.length == 0) + printAutodetected(instance, options, &disks); + else + printMountpoints(instance, options, &disks); } - if(options->folders.length == 0) - printAutodetected(instance, options, &disks->disks); - else - printMountpoints(instance, options, &disks->disks); + FF_LIST_FOR_EACH(FFDisk, disk, disks) + { + ffStrbufDestroy(&disk->mountpoint); + ffStrbufDestroy(&disk->filesystem); + ffStrbufDestroy(&disk->name); + } } From 3bf83e45edc384b0f23106ac047f11b1d15ba1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 22:36:43 +0800 Subject: [PATCH 117/493] Font: don't use singleton --- src/detection/font/font.c | 26 +++++------------- src/detection/font/font.h | 4 +-- src/detection/font/font_apple.m | 5 ++-- src/detection/font/font_linux.c | 9 +++---- src/detection/font/font_nosupport.c | 6 ++--- src/detection/font/font_windows.c | 8 +++--- src/modules/font/font.c | 42 ++++++++++++++++++----------- 7 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/detection/font/font.c b/src/detection/font/font.c index 865c830d1..4455ea45f 100644 --- a/src/detection/font/font.c +++ b/src/detection/font/font.c @@ -1,33 +1,19 @@ #include "font.h" #include "detection/internal.h" -void ffDetectFontImpl(const FFinstance* instance, FFFontResult* font); +const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* font); -static void detectFont(const FFinstance* instance, FFFontResult* font) +const char* ffDetectFont(const FFinstance* instance, FFFontResult* font) { - ffStrbufInit(&font->error); + const char* error = ffDetectFontImpl(instance, font); - for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) - ffStrbufInit(&font->fonts[i]); - ffStrbufInit(&font->display); - - ffDetectFontImpl(instance, font); - - if(font->error.length > 0) - return; + if(error) return error; for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) { if(font->fonts[i].length > 0) - return; + return NULL; } - ffStrbufAppendS(&font->error, "No fonts found"); -} - -const FFFontResult* ffDetectFont(const FFinstance* instance) -{ - FF_DETECTION_INTERNAL_GUARD(FFFontResult, - detectFont(instance, &result); - ); + return "No fonts found"; } diff --git a/src/detection/font/font.h b/src/detection/font/font.h index 5922375bb..9b7e4e237 100644 --- a/src/detection/font/font.h +++ b/src/detection/font/font.h @@ -9,8 +9,6 @@ typedef struct FFFontResult { - FFstrbuf error; - /** * Linux / BSD: QT, GTK2, GTK3, GTK4 * MacOS: System, User, System Mono, User Mono @@ -21,6 +19,6 @@ typedef struct FFFontResult FFstrbuf display; } FFFontResult; -const FFFontResult* ffDetectFont(const FFinstance* instance); +const char* ffDetectFont(const FFinstance* instance, FFFontResult* font); #endif diff --git a/src/detection/font/font_apple.m b/src/detection/font/font_apple.m index 471fad430..818047a97 100644 --- a/src/detection/font/font_apple.m +++ b/src/detection/font/font_apple.m @@ -21,12 +21,13 @@ static void generateString(FFFontResult* font) } } -void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFFontResult* result) { - FF_UNUSED(instance); ffStrbufAppendS(&result->fonts[0], [NSFont systemFontOfSize:12].familyName.UTF8String); ffStrbufAppendS(&result->fonts[1], [NSFont userFontOfSize:12].familyName.UTF8String); ffStrbufAppendS(&result->fonts[2], [NSFont monospacedSystemFontOfSize:12 weight:400].familyName.UTF8String); ffStrbufAppendS(&result->fonts[3], [NSFont userFixedPitchFontOfSize:12].familyName.UTF8String); generateString(result); + + return NULL; } diff --git a/src/detection/font/font_linux.c b/src/detection/font/font_linux.c index b0d70dd25..304450c70 100644 --- a/src/detection/font/font_linux.c +++ b/src/detection/font/font_linux.c @@ -24,15 +24,12 @@ static void generateString(FFFontResult* font) ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]); } -void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) - { - ffStrbufAppendS(&result->error, "Font isn't supported in TTY"); - return; - } + return "Font isn't supported in TTY"; FFfont qt; ffFontInitQt(&qt, ffDetectQt(instance)->font.chars); @@ -55,4 +52,6 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) ffFontDestroy(>k4); generateString(result); + + return NULL; } diff --git a/src/detection/font/font_nosupport.c b/src/detection/font/font_nosupport.c index f88ad8395..c64936584 100644 --- a/src/detection/font/font_nosupport.c +++ b/src/detection/font/font_nosupport.c @@ -1,8 +1,8 @@ #include "fastfetch.h" #include "font.h" -void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) { - FF_UNUSED(instance); - ffStrbufAppendS(&result->error, "Not supported on this platform"); + FF_UNUSED(instance, result); + return "Not supported on this platform"; } diff --git a/src/detection/font/font_windows.c b/src/detection/font/font_windows.c index 6a31b07eb..202aa8b51 100644 --- a/src/detection/font/font_windows.c +++ b/src/detection/font/font_windows.c @@ -23,13 +23,11 @@ static void generateString(FFFontResult* font) ffStrbufAppendC(&font->display, ']'); } -void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFFontResult* result) { - FF_UNUSED(instance); - NONCLIENTMETRICSW info = { .cbSize = sizeof(info) }; if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0)) - ffStrbufAppendS(&result->error, "SystemParametersInfoW(SPI_GETNONCLIENTMETRICS) failed"); + return "SystemParametersInfoW(SPI_GETNONCLIENTMETRICS) failed"; LOGFONTW* fonts[4] = { &info.lfCaptionFont, &info.lfMenuFont, &info.lfMessageFont, &info.lfStatusFont }; @@ -41,4 +39,6 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) } generateString(result); + + return NULL; } diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 70da28872..59736afb8 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -7,29 +7,39 @@ void ffPrintFont(FFinstance* instance, FFFontOptions* options) { - const FFFontResult* font = ffDetectFont(instance); + FFFontResult font; + for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) + ffStrbufInit(&font.fonts[i]); + ffStrbufInit(&font.display); - if(font->error.length > 0) - { - ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", font->error.chars); - return; - } + const char* error = ffDetectFont(instance, &font); - if(options->moduleArgs.outputFormat.length == 0) + if(error) { - ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key); - ffStrbufPutTo(&font->display, stdout); + ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else { - ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[0]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[1]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[2]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->fonts[3]}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font->display}, - }); + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key); + ffStrbufPutTo(&font.display, stdout); + } + else + { + ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3]}, + {FF_FORMAT_ARG_TYPE_STRBUF, &font.display}, + }); + } } + + ffStrbufDestroy(&font.display); + for (uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) + ffStrbufDestroy(&font.fonts[i]); } void ffInitFontOptions(FFFontOptions* options) From 429d7c1ed964cccf8bf5790559be8dea7334fda2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 22:53:12 +0800 Subject: [PATCH 118/493] Host: don't use singleton --- CMakeLists.txt | 1 - src/detection/host/host.c | 11 --------- src/detection/host/host.h | 3 +-- src/detection/host/host_android.c | 9 +++---- src/detection/host/host_apple.c | 11 ++++----- src/detection/host/host_bsd.c | 6 ++--- src/detection/host/host_linux.c | 6 ++--- src/detection/host/host_windows.c | 10 ++++---- src/modules/host/host.c | 40 ++++++++++++++++++------------- 9 files changed, 45 insertions(+), 52 deletions(-) delete mode 100644 src/detection/host/host.c diff --git a/CMakeLists.txt b/CMakeLists.txt index bea9db531..3c735c21d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,7 +254,6 @@ set(LIBFASTFETCH_SRC src/detection/displayserver/displayserver.c src/detection/font/font.c src/detection/gpu/gpu.c - src/detection/host/host.c src/detection/locale/locale.c src/detection/media/media.c src/detection/opencl/opencl.c diff --git a/src/detection/host/host.c b/src/detection/host/host.c deleted file mode 100644 index ea8274dbe..000000000 --- a/src/detection/host/host.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "host.h" -#include "detection/internal.h" - -void ffDetectHostImpl(FFHostResult* host); - -const FFHostResult* ffDetectHost() -{ - FF_DETECTION_INTERNAL_GUARD(FFHostResult, - ffDetectHostImpl(&result) - ); -} diff --git a/src/detection/host/host.h b/src/detection/host/host.h index c8b47b6b2..a0fd66511 100644 --- a/src/detection/host/host.h +++ b/src/detection/host/host.h @@ -12,9 +12,8 @@ typedef struct FFHostResult FFstrbuf productVersion; FFstrbuf productSku; FFstrbuf sysVendor; - FFstrbuf error; } FFHostResult; -const FFHostResult* ffDetectHost(); +const char* ffDetectHost(FFHostResult* result); #endif diff --git a/src/detection/host/host_android.c b/src/detection/host/host_android.c index 240a65b9d..384faf736 100644 --- a/src/detection/host/host_android.c +++ b/src/detection/host/host_android.c @@ -2,10 +2,8 @@ #include "common/settings.h" #include -void ffDetectHostImpl(FFHostResult* host) +const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->error); - //Family ffStrbufInit(&host->productFamily); @@ -16,7 +14,8 @@ void ffDetectHostImpl(FFHostResult* host) ffStrbufInit(&host->productName); ffSettingsGetAndroidProperty("ro.product.brand", &host->productName); - if(host->productName.length > 0){ + if(host->productName.length > 0) + { host->productName.chars[0] = (char) toupper(host->productName.chars[0]); ffStrbufAppendC(&host->productName, ' '); } @@ -34,4 +33,6 @@ void ffDetectHostImpl(FFHostResult* host) ffStrbufInit(&host->productVersion); ffStrbufInit(&host->productSku); + + return NULL; } diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index 4f739276b..8755795d4 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -155,17 +155,16 @@ static const char* getProductName(const FFstrbuf* hwModel) return hwModel->chars; } -void ffDetectHostImpl(FFHostResult* host) +const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->error); - ffStrbufInit(&host->productName); ffStrbufInit(&host->productFamily); ffStrbufInit(&host->productVersion); ffStrbufInit(&host->productSku); ffStrbufInitS(&host->sysVendor, "Apple"); - ffStrbufAppendS(&host->error, ffSysctlGetString("hw.model", &host->productFamily)); - if(host->error.length == 0) - ffStrbufAppendS(&host->productName, getProductName(&host->productFamily)); + const char* error = ffSysctlGetString("hw.model", &host->productFamily); + if (error) return error; + ffStrbufAppendS(&host->productName, getProductName(&host->productFamily)); + return NULL; } diff --git a/src/detection/host/host_bsd.c b/src/detection/host/host_bsd.c index 8be64b6c3..d4b99e952 100644 --- a/src/detection/host/host_bsd.c +++ b/src/detection/host/host_bsd.c @@ -1,15 +1,13 @@ #include "host.h" #include "common/sysctl.h" -void ffDetectHostImpl(FFHostResult* host) +const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->error); - ffStrbufInit(&host->productName); ffStrbufInit(&host->productFamily); ffStrbufInit(&host->productVersion); ffStrbufInit(&host->productSku); ffStrbufInit(&host->sysVendor); - ffStrbufAppendS(&host->error, ffSysctlGetString("hw.fdt.model", &host->productName)); + return ffSysctlGetString("hw.fdt.model", &host->productName); } diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 766b4f47a..57e8f6caf 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -59,10 +59,8 @@ static void getHostProductName(FFstrbuf* name) ffStrbufClear(name); } -void ffDetectHostImpl(FFHostResult* host) +const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->error); - ffStrbufInit(&host->productFamily); getHostValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->productFamily); @@ -107,4 +105,6 @@ void ffDetectHostImpl(FFHostResult* host) } } } + + return NULL; } diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index 75afd0563..1a940e1ac 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -1,10 +1,8 @@ #include "host.h" #include "util/windows/registry.h" -void ffDetectHostImpl(FFHostResult* host) +const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->error); - ffStrbufInit(&host->productName); ffStrbufInit(&host->productFamily); ffStrbufInit(&host->productVersion); @@ -13,12 +11,14 @@ void ffDetectHostImpl(FFHostResult* host) FF_HKEY_AUTO_DESTROY hKey = NULL; - if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &host->error)) - return; + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; ffRegReadStrbuf(hKey, L"SystemProductName", &host->productName, NULL); ffRegReadStrbuf(hKey, L"SystemFamily", &host->productFamily, NULL); ffRegReadStrbuf(hKey, L"SystemVersion", &host->productVersion, NULL); ffRegReadStrbuf(hKey, L"SystemSKU", &host->productSku, NULL); ffRegReadStrbuf(hKey, L"SystemManufacturer", &host->sysVendor, NULL); + + return NULL; } diff --git a/src/modules/host/host.c b/src/modules/host/host.c index b63a1bb87..b6c7f5b73 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -7,18 +7,19 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) { - const FFHostResult* host = ffDetectHost(); + FFHostResult host; + const char* error = ffDetectHost(&host); - if(host->error.length > 0) + if(error) { - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%*s", host->error.length, host->error.chars); - return; + ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + goto exit; } - if(host->productFamily.length == 0 && host->productName.length == 0) + if(host.productFamily.length == 0 && host.productName.length == 0) { ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "neither product_family nor product_name is set by O.E.M."); - return; + goto exit; } if(options->moduleArgs.outputFormat.length == 0) @@ -27,14 +28,14 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); - if(host->productName.length > 0) - ffStrbufAppend(&output, &host->productName); + if(host.productName.length > 0) + ffStrbufAppend(&output, &host.productName); else - ffStrbufAppend(&output, &host->productFamily); + ffStrbufAppend(&output, &host.productFamily); - if(host->productVersion.length > 0 && !ffStrbufIgnCaseEqualS(&host->productVersion, "none")) + if(host.productVersion.length > 0 && !ffStrbufIgnCaseEqualS(&host.productVersion, "none")) { - ffStrbufAppendF(&output, " (%s)", host->productVersion.chars); + ffStrbufAppendF(&output, " (%s)", host.productVersion.chars); } ffStrbufPutTo(&output, stdout); @@ -42,13 +43,20 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) else { ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor} + {FF_FORMAT_ARG_TYPE_STRBUF, &host.productFamily}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host.productName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host.productVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host.productSku}, + {FF_FORMAT_ARG_TYPE_STRBUF, &host.sysVendor} }); } + +exit: + ffStrbufDestroy(&host.productFamily); + ffStrbufDestroy(&host.productName); + ffStrbufDestroy(&host.productVersion); + ffStrbufDestroy(&host.productSku); + ffStrbufDestroy(&host.sysVendor); } void ffInitHostOptions(FFHostOptions* options) From 2c2a231330708ad9dad86819e5314bc3f8bddddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 12 Jun 2023 23:00:37 +0800 Subject: [PATCH 119/493] CPU: fix memleaks --- src/modules/cpu/cpu.c | 78 +++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index e71d6b8d3..6fc3104bb 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -19,47 +19,51 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) { ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); - return; - } - - if(options->moduleArgs.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key); - - if(cpu.name.length > 0) - ffStrbufWriteTo(&cpu.name, stdout); - else if(cpu.vendor.length > 0) - { - ffStrbufWriteTo(&cpu.vendor, stdout); - fputs(" CPU", stdout); - } - else - fputs("CPU", stdout); - - if(cpu.coresOnline > 1) - printf(" (%u)", cpu.coresOnline); - - if(cpu.frequencyMax > 0.0) - printf(" @ %.9g GHz", cpu.frequencyMax); - - if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET - printf(" - %.1f°C", cpu.temperature); - - putchar('\n'); } else { - ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name}, - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.temperature} - }); + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key); + + if(cpu.name.length > 0) + ffStrbufWriteTo(&cpu.name, stdout); + else if(cpu.vendor.length > 0) + { + ffStrbufWriteTo(&cpu.vendor, stdout); + fputs(" CPU", stdout); + } + else + fputs("CPU", stdout); + + if(cpu.coresOnline > 1) + printf(" (%u)", cpu.coresOnline); + + if(cpu.frequencyMax > 0.0) + printf(" @ %.9g GHz", cpu.frequencyMax); + + if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET + printf(" - %.1f°C", cpu.temperature); + + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical}, + {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.temperature} + }); + } } + + ffStrbufDestroy(&cpu.name); + ffStrbufDestroy(&cpu.vendor); } void ffInitCPUOptions(FFCPUOptions* options) From ba4c18f80bd834a1e8bc2285e8dd65bc9e0a56c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 09:13:37 +0800 Subject: [PATCH 120/493] FFlist.h: fix copy / paste bug in ffListInitMove --- src/util/FFlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index ce045be98..25413dd23 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -66,7 +66,7 @@ static inline void ffListInitMove(FFlist* list, FFlist* src) list->elementSize = src->elementSize; list->capacity = src->capacity; list->length = src->length; - list->data = list->data; + list->data = src->data; ffListInit(src, list->elementSize); } else From 17b6ff1a6dd99333a42c0571a31568c8af6774aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 10:57:52 +0800 Subject: [PATCH 121/493] TerminalFont: always init `terminalFont.font` --- src/common/font.c | 15 ++++++++------- src/common/font.h | 1 + src/modules/terminalfont/terminalfont.c | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/common/font.c b/src/common/font.c index 8d79907b8..042fa74ee 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -3,12 +3,13 @@ #include -static void fontInit(FFfont* font) +void ffFontInit(FFfont* font) { + // Ensure no memory allocates ffStrbufInit(&font->pretty); ffStrbufInit(&font->name); - ffStrbufInitA(&font->size, 8); - ffListInitA(&font->styles, sizeof(FFstrbuf), 4); + ffStrbufInit(&font->size); + ffListInit(&font->styles, sizeof(FFstrbuf)); } static void fontInitPretty(FFfont* font) @@ -44,7 +45,7 @@ static void fontInitPretty(FFfont* font) void ffFontInitQt(FFfont* font, const char* data) { - fontInit(font); + ffFontInit(font); //See https://doc.qt.io/qt-5/qfont.html#toString @@ -181,7 +182,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern void ffFontInitPango(FFfont* font, const char* data) { - fontInit(font); + ffFontInit(font); while(*data != '\0' && *data != '`' && *data != '\\') fontPangoParseWord(&data, font, NULL); @@ -191,7 +192,7 @@ void ffFontInitPango(FFfont* font, const char* data) void ffFontInitValues(FFfont* font, const char* name, const char* size) { - fontInit(font); + ffFontInit(font); ffStrbufAppendS(&font->name, name); ffStrbufAppendS(&font->size, size); @@ -213,7 +214,7 @@ void ffFontInitWithSpace(FFfont* font, const char* rawName) return; } - fontInit(font); + ffFontInit(font); ffStrbufAppendNS(&font->name, (uint32_t)(pspace - rawName), rawName); ffStrbufAppendS(&font->size, pspace + 1); diff --git a/src/common/font.h b/src/common/font.h index 605f7c430..58b3841ae 100644 --- a/src/common/font.h +++ b/src/common/font.h @@ -14,6 +14,7 @@ typedef struct FFfont FFlist styles; } FFfont; +void ffFontInit(FFfont* font); void ffFontInitQt(FFfont* font, const char* data); void ffFontInitPango(FFfont* font, const char* data); void ffFontInitCopy(FFfont* font, const char* name); diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index e290cc6fc..8c56d71c2 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -9,6 +9,7 @@ void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options) { FFTerminalFontResult terminalFont; + ffFontInit(&terminalFont.font); ffStrbufInit(&terminalFont.error); if(!ffDetectTerminalFont(instance, &terminalFont)) From 043c41dfc70a7f67928bc2b4b5e34c3b03df8933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 11:08:49 +0800 Subject: [PATCH 122/493] Fastfetch: add `--no-buffer` option --- .github/workflows/push.yml | 12 ++++++------ CHANGELOG.md | 1 + CMakeLists.txt | 10 ---------- src/common/init.c | 11 ++++------- src/common/jsonconfig.c | 6 ++++-- src/data/config_user.txt | 6 ++++++ src/data/help.txt | 3 ++- src/fastfetch.c | 10 ++++++---- src/fastfetch.h | 1 + 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3a50a9026..9c46ce25a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -39,7 +39,7 @@ jobs: run: ctest - name: run fastfetch - run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all - name: run flashfetch run: ./flashfetch @@ -77,7 +77,7 @@ jobs: run: ./fastfetch --list-features - name: run fastfetch - run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all - name: run flashfetch run: time ./flashfetch @@ -126,7 +126,7 @@ jobs: run: ./fastfetch --list-features - name: run fastfetch - run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all - name: run flashfetch run: time ./flashfetch @@ -159,7 +159,7 @@ jobs: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . cmake --build . --target package ./fastfetch --list-features - time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all time ./flashfetch ctest @@ -213,7 +213,7 @@ jobs: run: ./fastfetch --list-features - name: run fastfetch - run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all - name: run flashfetch run: time ./flashfetch @@ -271,7 +271,7 @@ jobs: run: cp /clang32/bin/{OpenCL,vulkan-1}.dll . - name: run fastfetch - run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all + run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all - name: run flashfetch run: time ./flashfetch diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b481c75..5d8835339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Features: * Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection * Support MATE Terminal version & terminal font detection +* Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. # 1.11.3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c735c21d..c711b8b7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,6 @@ cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) -cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF) option(BUILD_TESTS "Build tests" OFF) # Also create test executables option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds @@ -715,10 +714,6 @@ if(ENABLE_THREADS) endif() endif() -if(ENABLE_BUFFER) - target_compile_definitions(libfastfetch PRIVATE FF_ENABLE_BUFFER) -endif() - if(APPLE) target_link_libraries(libfastfetch PRIVATE "-framework Cocoa" @@ -791,11 +786,6 @@ target_link_libraries(flashfetch PRIVATE yyjson ) -if(ENABLE_BUFFER) # FF_ENABLE_BUFFER is used in fastfetch.c - target_compile_definitions(fastfetch PRIVATE FF_ENABLE_BUFFER) - target_compile_definitions(flashfetch PRIVATE FF_ENABLE_BUFFER) -endif() - if(WIN32) set(TARGET_NAME fastfetch) target_sources(fastfetch diff --git a/src/common/init.c b/src/common/init.c index c8bb50f91..281bbbdf4 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -51,6 +51,7 @@ static void defaultConfig(FFinstance* instance) instance->config.pipe = false; instance->config.multithreading = true; instance->config.stat = false; + instance->config.noBuffer = false; ffInitTitleOptions(&instance->config.title); ffInitOSOptions(&instance->config.os); @@ -175,7 +176,7 @@ static void resetConsole() if(ffHideCursor) fputs("\033[?25h", stdout); - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + #if defined(_WIN32) fflush(stdout); #endif } @@ -207,9 +208,7 @@ void ffStart(FFinstance* instance) ffHideCursor = instance->config.hideCursor && !instance->config.pipe; #ifdef _WIN32 - #ifdef FF_ENABLE_BUFFER - setvbuf(stdout, NULL, _IOFBF, 4096); - #endif + if (!instance->config.noBuffer) setvbuf(stdout, NULL, _IOFBF, 4096); SetConsoleCtrlHandler(consoleHandler, TRUE); HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); DWORD mode = 0; @@ -217,9 +216,7 @@ void ffStart(FFinstance* instance) SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING); SetConsoleOutputCP(CP_UTF8); #else - #ifndef FF_ENABLE_BUFFER - setvbuf(stdout, NULL, _IONBF, 0); - #endif + if (instance->config.noBuffer) setvbuf(stdout, NULL, _IONBF, 0); struct sigaction action = { .sa_handler = exitSignalHandler }; sigaction(SIGINT, &action, NULL); sigaction(SIGTERM, &action, NULL); diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index f4e0ff4e9..0b41fd2da 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -266,8 +266,8 @@ static const char* printJsonConfig(FFinstance* instance) printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); + #if defined(_WIN32) + if (!instance->config.noBuffer) fflush(stdout); #endif } @@ -380,6 +380,8 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) } else if (strcasecmp(key, "percentType") == 0) config->percentType = (uint32_t) yyjson_get_uint(val); + else if (strcasecmp(key, "noBuffer") == 0) + config->noBuffer = yyjson_get_bool(val); else return "Unknown display property"; } diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 58b55653a..0c91e60e6 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -146,6 +146,12 @@ # Default is IEC. #--binary-prefix IEC +# Disable output buffer option: +# Sets if the stdout application buffer should be disabled. +# Must be true or false. +# Default is false. +#--no-buffer false + # Title FQDN option: # Sets if the title should use the fully qualified domain name. # Must be true or false. diff --git a/src/data/help.txt b/src/data/help.txt index 8c96ab9c0..462f55ac1 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -62,7 +62,8 @@ Display options: --show-errors : Print occurring errors --disable-linewrap : Whether to disable line wrap during the run --hide-cursor : Whether to hide the cursor during the run - --binary-prefix : Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC. + --binary-prefix : Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC + --no-buffer : Set if the stdout application buffer should be disabled. Default is false General module options: ---format : Set the format string to use for each specific module. diff --git a/src/fastfetch.c b/src/fastfetch.c index 47b5ebdf9..cea9b37c1 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -884,6 +884,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(strcasecmp(key, "--percent-type") == 0) instance->config.percentType = ffOptionParseUInt32(key, value); + else if(strcasecmp(key, "--no-buffer") == 0) + instance->config.noBuffer = ffOptionParseBoolean(value); /////////////////////// //Module args options// @@ -1201,8 +1203,8 @@ int main(int argc, const char** argv) ffStart(&instance); - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); + #if defined(_WIN32) + if (!instance.config.noBuffer) fflush(stdout); #endif if (instance.state.configDoc) @@ -1234,8 +1236,8 @@ int main(int argc, const char** argv) printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } - #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) - fflush(stdout); + #if defined(_WIN32) + if (!instance.config.noBuffer) fflush(stdout); #endif startIndex = colonIndex + 1; diff --git a/src/fastfetch.h b/src/fastfetch.h index a5e859ecc..0ecbcd12a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -47,6 +47,7 @@ typedef struct FFconfig bool pipe; //disables logo and all escape sequences bool multithreading; bool stat; + bool noBuffer; // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) From 9cb5375f30d27cf8dd323a0e5bc6160e57b0fa18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 11:12:31 +0800 Subject: [PATCH 123/493] GPU (Linux): always initialize variables --- src/detection/gpu/gpu_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index a3f3c0bbe..f7f9a5a34 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -46,7 +46,7 @@ static void pciDetectVendorName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) { - u8 revId; + u8 revId = 0; bool revIdSet = false; #if PCI_LIB_VERSION >= 0x030800 From 92d234fb3ed755fbab43c0b83428eeb47fa24959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 18:29:17 +0800 Subject: [PATCH 124/493] Display (Linux): try fixing musl --- src/modules/display/display.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index f97f130ec..72e1fd9bd 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -37,7 +37,6 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) if (index++) putchar(' '); printf("%ix%i", result->scaledWidth, result->scaledHeight); } - ffStrbufDestroy(&result->name); } putchar('\n'); return; @@ -105,8 +104,6 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_UINT, &result->rotation}, }); } - - ffStrbufDestroy(&result->name); } } From 679622bac0a49e02b361a940b0281c8a8f6a7961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 21:38:06 +0800 Subject: [PATCH 125/493] Packages: don't use singleton --- src/detection/packages/packages.c | 16 +++---- src/detection/packages/packages.h | 2 +- src/modules/packages/packages.c | 76 ++++++++++++++++--------------- 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/detection/packages/packages.c b/src/detection/packages/packages.c index 2404f74e3..b820be2ba 100644 --- a/src/detection/packages/packages.c +++ b/src/detection/packages/packages.c @@ -5,15 +5,15 @@ void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result); -const FFPackagesResult* ffDetectPackages(const FFinstance* instance) +const char* ffDetectPackages(const FFinstance* instance, FFPackagesResult* result) { - FF_DETECTION_INTERNAL_GUARD(FFPackagesResult, - memset(&result, 0, sizeof(FFPackagesResult)); - ffStrbufInit(&result.pacmanBranch); + ffDetectPackagesImpl(instance, result); - ffDetectPackagesImpl(instance, &result); + for(uint32_t i = 0; i < offsetof(FFPackagesResult, all) / sizeof(uint32_t); ++i) + result->all += ((uint32_t *)result)[i]; - for(uint32_t i = 0; i < offsetof(FFPackagesResult, all) / sizeof(uint32_t); ++i) - result.all += ((uint32_t *)&result)[i]; - ); + if (result->all == 0) + return "No packages from known package managers found"; + + return NULL; } diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index 5d806a238..1a83645e9 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -32,6 +32,6 @@ typedef struct FFPackagesResult FFstrbuf pacmanBranch; } FFPackagesResult; -const FFPackagesResult* ffDetectPackages(const FFinstance* instance); +const char* ffDetectPackages(const FFinstance* instance, FFPackagesResult* result); #endif diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 79f4d1a4a..6f369fa42 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -7,12 +7,14 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) { - const FFPackagesResult* counts = ffDetectPackages(instance); - uint32_t all = counts->all; //Copy it, so we can substract from it in FF_PRINT_PACKAGE + FFPackagesResult counts = {}; + ffStrbufInit(&counts.pacmanBranch); - if(all == 0) + const char* error = ffDetectPackages(instance, &counts); + + if(error) { - ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "No packages from known package managers found"); + ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -21,21 +23,22 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key); #define FF_PRINT_PACKAGE_NAME(var, name) \ - if(counts->var > 0) \ + if(counts.var > 0) \ { \ - printf("%u (%s)", counts->var, (name)); \ - if((all -= counts->var) > 0) \ + printf("%u (%s)", counts.var, (name)); \ + if((all -= counts.var) > 0) \ printf(", "); \ }; #define FF_PRINT_PACKAGE(name) FF_PRINT_PACKAGE_NAME(name, #name) - if(counts->pacman > 0) + uint32_t all = counts.all; + if(counts.pacman > 0) { - printf("%u (pacman)", counts->pacman); - if(counts->pacmanBranch.length > 0) - printf("[%s]", counts->pacmanBranch.chars); - if((all -= counts->pacman) > 0) + printf("%u (pacman)", counts.pacman); + if(counts.pacmanBranch.length > 0) + printf("[%s]", counts.pacmanBranch.chars); + if((all -= counts.pacman) > 0) printf(", "); }; @@ -49,7 +52,7 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) FF_PRINT_PACKAGE_NAME(nixDefault, "nix-default") FF_PRINT_PACKAGE(apk) FF_PRINT_PACKAGE(pkg) - FF_PRINT_PACKAGE_NAME(flatpakSystem, counts->flatpakUser ? "flatpak-system" : "flatpak") + FF_PRINT_PACKAGE_NAME(flatpakSystem, counts.flatpakUser ? "flatpak-system" : "flatpak") FF_PRINT_PACKAGE_NAME(flatpakUser, "flatpak-user") FF_PRINT_PACKAGE(snap) FF_PRINT_PACKAGE(brew) @@ -58,37 +61,36 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) FF_PRINT_PACKAGE(scoop) FF_PRINT_PACKAGE(choco) - //Fix linter warning of unused value of all - (void) all; - putchar('\n'); } else { ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &all}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->pacman}, - {FF_FORMAT_ARG_TYPE_STRBUF, &counts->pacmanBranch}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->dpkg}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->rpm}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->emerge}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->eopkg}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->xbps}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->nixSystem}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->nixUser}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->nixDefault}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->apk}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->pkg}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->flatpakSystem}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->flatpakUser}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->snap}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->brew}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->brewCask}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->port}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->scoop}, - {FF_FORMAT_ARG_TYPE_UINT, &counts->choco}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.all}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.pacman}, + {FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.dpkg}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.rpm}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.emerge}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.eopkg}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.xbps}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.nixSystem}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.nixUser}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.nixDefault}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.apk}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.pkg}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.flatpakSystem}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.flatpakUser}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.snap}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.brew}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.brewCask}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.port}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.scoop}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.choco}, }); } + + ffStrbufDestroy(&counts.pacmanBranch); } void ffInitPackagesOptions(FFPackagesOptions* options) From be40894bbd96ab94693adafd2571e66493e3e378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jun 2023 22:03:29 +0800 Subject: [PATCH 126/493] DisplayServer: fix typos. --- src/detection/displayserver/displayserver_apple.c | 1 - src/detection/displayserver/displayserver_windows.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index a49e5f74b..2ab624a39 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -117,7 +117,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufInit(&ds->deProcessName); ffStrbufInit(&ds->dePrettyName); ffStrbufInit(&ds->deVersion); - ffStrbufInit(&ds->deProcessName); ffStrbufAppendS(&ds->dePrettyName, "Aqua"); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 12921f4e7..907438e9d 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -140,7 +140,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ) ffStrbufSetS(&ds->dePrettyName, "Fluent"); else if( ffStrbufEqualS(&os->version, "8") || - ffStrbufEqualS(&os->version, "81.") || + ffStrbufEqualS(&os->version, "8.1") || ffStrbufEqualS(&os->version, "2012 R2") || ffStrbufEqualS(&os->version, "2012") ) ffStrbufSetS(&ds->dePrettyName, "Metro"); From b87997caa2ad9d035f4e0d89613503b03447d296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 14 Jun 2023 16:17:38 +0800 Subject: [PATCH 127/493] Logo: parse chafa options as enum --- src/logo/option.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/logo/option.c b/src/logo/option.c index 0239bf5ab..86574b680 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -314,15 +314,52 @@ const char* ffParseLogoJsonConfig(FFinstance* instance) yyjson_val* canvasMode = yyjson_obj_get(val, "canvasMode"); if (canvasMode) - options->chafaCanvasMode = (uint32_t) yyjson_get_uint(canvasMode); + { + int value; + const char* error = ffJsonConfigParseEnum(canvasMode, &value, (FFKeyValuePair[]) { + { "TRUECOLOR", 0 }, + { "INDEXED_256", 1 }, + { "INDEXED_240", 2 }, + { "INDEXED_16", 3 }, + { "FGBG_BGFG", 4 }, + { "FGBG", 5 }, + { "INDEXED_8", 6 }, + { "INDEXED_16_8", 7 }, + {}, + }); + + if (error) return error; + options->chafaCanvasMode = (uint32_t) value; + } yyjson_val* colorSpace = yyjson_obj_get(val, "colorSpace"); if (colorSpace) - options->chafaColorSpace = (uint32_t) yyjson_get_uint(colorSpace); + { + int value; + const char* error = ffJsonConfigParseEnum(colorSpace, &value, (FFKeyValuePair[]) { + { "RGB", 0 }, + { "DIN99D", 1 }, + {}, + }); + + if (error) return error; + options->chafaColorSpace = (uint32_t) value; + } yyjson_val* ditherMode = yyjson_obj_get(val, "ditherMode"); if (ditherMode) - options->chafaDitherMode = (uint32_t) yyjson_get_uint(ditherMode); + { + int value; + const char* error = ffJsonConfigParseEnum(ditherMode, &value, (FFKeyValuePair[]) { + { "NONE", 0 }, + { "ORDERED", 1 }, + { "DIFFUSION", 2 }, + {}, + }); + + if (error) return error; + options->chafaDitherMode = (uint32_t) value; + } continue; } else From 257a97ed55235cfe40f3d51cb5ac4f18852a3ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 14 Jun 2023 16:18:24 +0800 Subject: [PATCH 128/493] JsonConfig: add JSON schema definition file (WIP) --- src/data/help.txt | 2 +- src/data/json_schema.jsonc | 377 +++++++++++++++++++++++++++++++++++++ 2 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 src/data/json_schema.jsonc diff --git a/src/data/help.txt b/src/data/help.txt index 462f55ac1..c4132cf83 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -63,6 +63,7 @@ Display options: --disable-linewrap : Whether to disable line wrap during the run --hide-cursor : Whether to hide the cursor during the run --binary-prefix : Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC + --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --no-buffer : Set if the stdout application buffer should be disabled. Default is false General module options: @@ -135,7 +136,6 @@ Module specific options: --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use --opengl-type : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto - --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others --command-key : Set the module key to display, can be specified mulitple times --command-text : Set the command text to be executed, can be specified mulitple times diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc new file mode 100644 index 000000000..33fbd3f9d --- /dev/null +++ b/src/data/json_schema.jsonc @@ -0,0 +1,377 @@ +{ + "$schema": "http://json-schema.org/schema", + "type": "object", + "properties": { + "logo": { + "title": "Fastfetch logo configurations", + "type": "object", + "properties": { + "type": { + "title": "Set the type of the logo given", + "enum": [ + "auto", + "builtin", + "file", + "file-raw", + "data", + "data-raw", + "sixel", + "kitty", + "iterm", + "chafa", + "raw", + "none" + ], + "default": "auto" + }, + "source": { + "type": "string", + "title": "Set the source file of the logo" + }, + "color": { + "type": "object", + "title": "Overwrite a color in the logo", + "properties": { + "1": { + "type": "string", + "title": "Color 1", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "2": { + "type": "string", + "title": "Color 2", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "3": { + "type": "string", + "title": "Color 3", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "4": { + "type": "string", + "title": "Color 4", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "5": { + "type": "string", + "title": "Color 5", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "6": { + "type": "string", + "title": "Color 6", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "7": { + "type": "string", + "title": "Color 7", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "8": { + "type": "string", + "title": "Color 8", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "9": { + "type": "string", + "title": "Color 9", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + } + } + }, + "width": { + "type": "integer", + "title": "Set the width of the logo (in characters). Required for iTerm image protocol", + "minimum": 1 + }, + "height": { + "type": "integer", + "title": "Set the height of the logo (in characters). Required for iTerm image protocol", + "minimum": 1 + }, + "padding": { + "type": "object", + "title": "Set the padding of the logo", + "properties": { + "top": { + "type": "integer", + "title": "Set the top padding of the logo", + "minimum": 0 + }, + "left": { + "type": "integer", + "title": "Set the left padding of the logo", + "minimum": 0 + }, + "right": { + "type": "integer", + "title": "Set the right padding of the logo", + "minimum": 0 + } + } + }, + "printRemaining": { + "type": "boolean", + "title": "Whether to print the remaining logo, if it has more lines than modules to display", + "default": false + }, + "preserveAspectRadio": { + "type": "boolean", + "title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", + "default": false + }, + "chafa": { + "type": "object", + "title": "Chafa configuration. See chafa document for details", + "properties": { + "fgOnly": { + "type": "boolean", + "title": "Produce character-cell output using foreground colors only", + "default": false + }, + "symbols": { + "type": "string", + "title": "Specify character symbols to employ in final output" + }, + "canvasMode": { + "type": "string", + "title": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", + "enum": [ + "TRUECOLOR", + "INDEXED_256", + "INDEXED_240", + "INDEXED_16", + "FGBG_BGFG", + "FGBG", + "INDEXED_8", + "INDEXED_16_8" + ] + }, + "colorSpace": { + "type": "string", + "title": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", + "enum": [ + "RGB", + "DIN99D" + ] + }, + "ditherMode": { + "type": "string", + "title": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", + "enum": [ + "NONE", + "ORDERED", + "DIFFUSION" + ] + } + } + } + } + }, + "general": { + "title": "Fastfetch general configurations", + "type": "object", + "properties": { + "allowSlowOperations": { + "type": "boolean", + "title": "Allow operations that can be very slow for more detailed output", + "default": false + }, + "multithreading": { + "type": "boolean", + "title": "Use multiple threads to detect values", + "default": true + }, + "stat": { + "type": "boolean", + "title": "Show time usage (in ms) for individual modules", + "default": false + }, + "escapeBedrock": { + "type": "boolean", + "title": "On Bedrock Linux, whether to escape the bedrock jail", + "default": true + }, + "pipe": { + "type": "boolean", + "title": "Whether to enable pipe mode (disable logo and all escape sequences)", + "default": false + }, + "playerName": { + "type": "string", + "title": "The name of the player to use for module Media and Player. Linux only" + }, + "osFile": { + "type": "string", + "title": "Set the path to the file containing OS information. Linux only" + } + } + }, + "display": { + "title": "Fastfetch general configurations", + "type": "object", + "properties": { + "showErrors": { + "type": "boolean", + "title": "Print occurring errors to the console. False to ignore errored modules", + "default": false + }, + "disableLinewrap": { + "type": "boolean", + "title": "Whether to disable line wrap during the run", + "default": true + }, + "hideCursor": { + "type": "boolean", + "title": "Whether to hide the cursor during the run", + "default": true + }, + "separator": { + "type": "string", + "title": "Set the separator between key and value", + "default": ": " + }, + "color": { + "title": "Set the color of the keys and title", + "anyOf": [ + { + "type": "string", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + { + "type": "object", + "properties": { + "keys": { + "type": "string", + "title": "Set the color of the keys", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "title": { + "type": "string", + "title": "Set the color of the title", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + } + } + } + ] + }, + "binaryPrefix": { + "type": "string", + "title": "Set the binary prefix to used when printing bytes", + "enum": [ + "iec", + "si", + "jedec" + ] + }, + "percentType": { + "type": "number", + "title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", + "minimum": 0, + "maximum": 9, + "default": 1 + }, + "noBuffer": { + "type": "boolean", + "title": "Whether to disable the stdout application buffer", + "default": false + } + } + }, + "library": { + "title": "Set the path of a library to load", + "type": "object", + "properties": { + "pci": { + "type": "string" + }, + "vulkan": { + "type": "string" + }, + "freetype": { + "type": "string" + }, + "wayland": { + "type": "string" + }, + "xcbRandr": { + "type": "string" + }, + "xcb": { + "type": "string" + }, + "Xrandr": { + "type": "string" + }, + "X11": { + "type": "string" + }, + "gio": { + "type": "string" + }, + "DConf": { + "type": "string" + }, + "dbus": { + "type": "string" + }, + "XFConf": { + "type": "string" + }, + "sqlite3": { + "type": "string" + }, + "rpm": { + "type": "string" + }, + "imagemagick": { + "type": "string" + }, + "z": { + "title": "zlib", + "type": "string" + }, + "chafa": { + "type": "string" + }, + "egl": { + "type": "string" + }, + "glx": { + "type": "string" + }, + "osmesa": { + "type": "string" + }, + "opencl": { + "type": "string" + }, + "wlanapi": { + "type": "string" + }, + "pulse": { + "title": "pulseaudio", + "type": "string" + }, + "nm": { + "title": "NetworkManager", + "type": "string" + } + } + }, + "modules": { + "title": "Fastfetch modules to run", + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object" + } + ] + } + } + } +} From 592ff603ca8985c4c3b565e5b126a8b0d5ddbc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 14 Jun 2023 17:36:24 +0800 Subject: [PATCH 129/493] CMake: don't install yyjson Fix #474 --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c711b8b7c..9213817a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14.0) # target_link_libraries with OBJECT libs & project homepage url & FetchContent +cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url & FetchContent project(fastfetch VERSION 1.11.3 @@ -46,7 +46,11 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/ibireme/yyjson GIT_TAG 0.7.0 ) -FetchContent_MakeAvailable(yyjson) +FetchContent_GetProperties(yyjson) +if(NOT yyjson_POPULATED) + FetchContent_Populate(yyjson) + add_subdirectory(${yyjson_SOURCE_DIR} ${yyjson_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() ##################### # Configure options # From 05a8bd7f74de49e94a3c5c9dbd80d8ba23a3f27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 14 Jun 2023 22:41:40 +0800 Subject: [PATCH 130/493] Disk (Linux): don't detect WSL drives as subvolumes --- src/detection/disk/disk_linux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index f2e9d71ed..446e93b15 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -146,20 +146,23 @@ static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDis static bool isSubvolume(const FFlist* devices) { - const FFstrbuf* currentDevie = ffListGet(devices, devices->length - 1); + const FFstrbuf* current = ffListGet(devices, devices->length - 1); + + if(ffStrbufEqualS(current, "drvfs")) // WSL Windows drives + return false; //Filter all disks which device was already found. This catches BTRFS subvolumes. for(uint32_t i = 0; i < devices->length - 1; i++) { const FFstrbuf* otherDevice = ffListGet(devices, i); - if(ffStrbufEqual(currentDevie, otherDevice)) + if(ffStrbufEqual(current, otherDevice)) return true; } //ZFS subvolumes: rpool///. //Test if the third slash is present. - if(strncmp(currentDevie->chars, "rpool/", 6) == 0 && ffStrHasNChars(currentDevie->chars, '/', 3)) + if(ffStrbufStartsWithS(current, "rpool/") && ffStrHasNChars(current->chars, '/', 3)) return true; return false; From 3c8688345f4e44e66efb075b60ee654b409949f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 00:30:27 +0800 Subject: [PATCH 131/493] Disk: change `removable` to `external`; print filesystem by default --- completions/bash | 2 +- presets/verbose | 2 +- src/data/config_user.txt | 4 ++-- src/data/help.txt | 2 +- src/fastfetch.c | 2 +- src/modules/disk/disk.c | 17 +++++++++++++---- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/completions/bash b/completions/bash index d08a71c55..3a30c9b30 100644 --- a/completions/bash +++ b/completions/bash @@ -194,7 +194,7 @@ __fastfetch_completion() "--title-fqdn" "--escape-bedrock" "--disk-folders" - "--disk-show-removable" + "--disk-show-external" "--disk-show-hidden" "--disk-show-subvolumes" "--gpu-hide-integrated" diff --git a/presets/verbose b/presets/verbose index 78314b7b3..eefd2f3bd 100644 --- a/presets/verbose +++ b/presets/verbose @@ -19,7 +19,7 @@ --cpu-usage-format Percentage: {} --gpu-format Vendor: {}; Name: {}; Driver: {}; Temperature: {}; CoreCount: {}; Type: {} --memory-format Used: {}; Total: {}; Percentage: {} ---disk-format SizeUsed: {}; SizeTotal: {}; SizePercentage: {}; FilesUsed: {}; FilesTotal: {}; FilesPercentage: {}; Removable: {}; Hidden: {}; Filesystem: {}; Name: {} +--disk-format SizeUsed: {}; SizeTotal: {}; SizePercentage: {}; FilesUsed: {}; FilesTotal: {}; FilesPercentage: {}; External: {}; Hidden: {}; Filesystem: {}; Name: {} --battery-format Manufactor: {}; Model: {}; Technology: {}; Capacity: {}; Status: {} --poweradapter-format Watts: {}; Name: {}; Manufactor: {}; Model: {}; Description: {} --player-format Pretty: {}; Name: {}; Bus: {}; Url: {} diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 0c91e60e6..2ccb2e8b9 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -235,8 +235,8 @@ # Disk show options # Sets if certain types of disk should be printed # Must be either true or false -# Default is false except for --disk-show-removable. -#--disk-show-removable true +# Default is false except for --disk-show-external. +#--disk-show-external true #--disk-show-hidden false #--disk-show-subvolumes false #--disk-show-unknown false diff --git a/src/data/help.txt b/src/data/help.txt index c4132cf83..3008888b7 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -108,7 +108,7 @@ Module specific options: --os-file : Set the path to the file containing OS information --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) --disk-show-regular : Set if regular volume should be printed. Default is true - --disk-show-removable : Set if removable volume should be printed. Default is true + --disk-show-external : Set if external volume should be printed. Default is true --disk-show-hidden : Set if hidden volumes should be printed. Default is false --disk-show-subvolumes : Set if subvolumes should be printed. Default is false --disk-show-unknown : Set if unknown (unable to detect sizes) volumes should be printed. Default is false diff --git a/src/fastfetch.c b/src/fastfetch.c index cea9b37c1..fb548178b 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -323,7 +323,7 @@ static inline void printCommandHelp(const char* command) "Files used", "Files total", "Files percentage", - "True if removable volume", + "True if external volume", "True if hidden volume", "Filesystem" ); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 1bacc0bda..4ff74d129 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -57,8 +57,17 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk else ffStrbufAppendS(&str, "Unknown "); - if((disk->type & FF_DISK_TYPE_EXTERNAL_BIT) && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) - ffStrbufAppendS(&str, "[Removable]"); + if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + { + ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); + + if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT) + ffStrbufAppendS(&str, "[External]"); + else if(disk->type & FF_DISK_TYPE_SUBVOLUME_BIT) + ffStrbufAppendS(&str, "[Subvolume]"); + else if(disk->type & FF_DISK_TYPE_HIDDEN_BIT) + ffStrbufAppendS(&str, "[Hidden]"); + } ffStrbufTrimRight(&str, ' '); ffStrbufPutTo(&str, stdout); @@ -188,7 +197,7 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } - if (strcasecmp(subKey, "show-removable") == 0) + if (strcasecmp(subKey, "show-external") == 0) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; @@ -256,7 +265,7 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showRemovable") == 0) + if (strcasecmp(key, "showExternal") == 0) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; From a18073f5de4c0559927a33089bf819e378a46d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 09:35:47 +0800 Subject: [PATCH 132/493] FreeBSD (CPU): fix temperature detection --- src/detection/cpu/cpu_bsd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 42a377b6e..8f6ca0956 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -16,7 +16,7 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF if (options->temp) { FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate(); - if(ffSysctlGetString("temperature", &cpuTemp)) + if(ffSysctlGetString("hw.acpi.thermal.tz0.temperature", &cpuTemp)) cpu->temperature = FF_CPU_TEMP_UNSET; else cpu->temperature = ffStrbufToDouble(&cpuTemp); From 16181b7272745bb5cb74f806a653e320cc5d4975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 10:03:12 +0800 Subject: [PATCH 133/493] Bios (FreeBSD): code refactor --- src/common/settings.c | 21 ++++++++++++++++++--- src/common/settings.h | 2 ++ src/detection/bios/bios_bsd.c | 19 +++++-------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/common/settings.c b/src/common/settings.c index 09cf723ee..f8e88b10a 100644 --- a/src/common/settings.c +++ b/src/common/settings.c @@ -403,9 +403,24 @@ bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, #ifdef __ANDROID__ #include -void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) { +bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) { ffStrbufEnsureFree(result, PROP_VALUE_MAX); - result->length += (uint32_t) __system_property_get(propName, result->chars + result->length); + int len = __system_property_get(propName, result->chars + result->length); + if (len <= 0) return false; + result->length += (uint32_t) len; result->chars[result->length] = '\0'; + return true; } -#endif //__ANDROID__ +#elif defined(__FreeBSD__) +#include +bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) +{ + //https://wiki.ghostbsd.org/index.php/Kenv + ffStrbufEnsureFree(result, KENV_MVALLEN); + int len = kenv(KENV_GET, propName, result->chars + result->length, KENV_MVALLEN); + if (len <= 0) return false; + result->length += (uint32_t) len; + result->chars[result->length] = '\0'; + return true; +} +#endif diff --git a/src/common/settings.h b/src/common/settings.h index 57fbf5673..e85f51068 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -35,6 +35,8 @@ bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, #ifdef __ANDROID__ void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result); +#elif defined(__FreeBSD__) +bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result); #endif #endif diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 8c993f0a9..5699b3372 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -1,14 +1,6 @@ #include "bios.h" -#include - -static void kenvLookup(const char* name, FFstrbuf* result) -{ - ffStrbufEnsureFree(result, 255); - int len = kenv(KENV_GET, name, result->chars, 256); - if(len > 0) - result->length = (uint32_t) len; -} +#include "common/settings.h" void ffDetectBios(FFBiosResult* bios) { @@ -18,9 +10,8 @@ void ffDetectBios(FFBiosResult* bios) ffStrbufInit(&bios->biosVendor); ffStrbufInit(&bios->biosVersion); - //https://wiki.ghostbsd.org/index.php/Kenv - kenvLookup("smbios.bios.reldate", &bios->biosDate); - kenvLookup("smbios.system.product", &bios->biosRelease); - kenvLookup("smbios.bios.vendor", &bios->biosVendor); - kenvLookup("smbios.bios.version", &bios->biosVersion); + ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &bios->biosDate); + ffSettingsGetFreeBSDKenv("smbios.bios.revision", &bios->biosRelease); + ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &bios->biosVendor); + ffSettingsGetFreeBSDKenv("smbios.bios.version", &bios->biosVersion); } From 2e22b5f601becb7be140a7442f842ed550f7c6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 10:08:10 +0800 Subject: [PATCH 134/493] Host (FreeBSD): actually support --- src/detection/host/host_bsd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/detection/host/host_bsd.c b/src/detection/host/host_bsd.c index d4b99e952..dcbd5006b 100644 --- a/src/detection/host/host_bsd.c +++ b/src/detection/host/host_bsd.c @@ -1,5 +1,5 @@ #include "host.h" -#include "common/sysctl.h" +#include "common/settings.h" const char* ffDetectHost(FFHostResult* host) { @@ -8,6 +8,11 @@ const char* ffDetectHost(FFHostResult* host) ffStrbufInit(&host->productVersion); ffStrbufInit(&host->productSku); ffStrbufInit(&host->sysVendor); + ffSettingsGetFreeBSDKenv("smbios.system.product", &host->productName); + ffSettingsGetFreeBSDKenv("smbios.system.family", &host->productFamily); + ffSettingsGetFreeBSDKenv("smbios.system.version", &host->productVersion); + ffSettingsGetFreeBSDKenv("smbios.system.sku", &host->productSku); + ffSettingsGetFreeBSDKenv("smbios.system.maker", &host->sysVendor); - return ffSysctlGetString("hw.fdt.model", &host->productName); + return NULL; } From b5da20357168af1f279bfe8333722d0b00dac9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 10:12:05 +0800 Subject: [PATCH 135/493] Board (FreeBSD): add support --- CMakeLists.txt | 2 +- src/detection/board/board_bsd.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/detection/board/board_bsd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 9213817a0..37797921b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -429,7 +429,7 @@ elseif(BSD) src/detection/battery/battery_bsd.c src/detection/bios/bios_bsd.c src/detection/bluetooth/bluetooth_linux.c - src/detection/board/board_nosupport.c + src/detection/board/board_bsd.c src/detection/brightness/brightness_nosupport.c src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_bsd.c diff --git a/src/detection/board/board_bsd.c b/src/detection/board/board_bsd.c new file mode 100644 index 000000000..a10821ac6 --- /dev/null +++ b/src/detection/board/board_bsd.c @@ -0,0 +1,12 @@ +#include "board.h" +#include "common/settings.h" + +void ffDetectBoard(FFBoardResult* board) +{ + ffStrbufInit(&board->boardName); + ffStrbufInit(&board->boardVendor); + ffStrbufInit(&board->boardVersion); + ffSettingsGetFreeBSDKenv("smbios.planar.product", &board->boardName); + ffSettingsGetFreeBSDKenv("smbios.planar.maker", &board->boardVendor); + ffSettingsGetFreeBSDKenv("smbios.planar.version", &board->boardVersion); +} From 10a39b88d7f40e4ca84cfcb9293d18c364db9867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 10:15:31 +0800 Subject: [PATCH 136/493] Chassis (FreeBSD): add support --- CMakeLists.txt | 2 +- src/detection/chassis/chassis_bsd.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/detection/chassis/chassis_bsd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 37797921b..d0168ed4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -431,7 +431,7 @@ elseif(BSD) src/detection/bluetooth/bluetooth_linux.c src/detection/board/board_bsd.c src/detection/brightness/brightness_nosupport.c - src/detection/chassis/chassis_nosupport.c + src/detection/chassis/chassis_bsd.c src/detection/cpu/cpu_bsd.c src/detection/cpuusage/cpuusage_bsd.c src/detection/cursor/cursor_linux.c diff --git a/src/detection/chassis/chassis_bsd.c b/src/detection/chassis/chassis_bsd.c new file mode 100644 index 000000000..e6475c2eb --- /dev/null +++ b/src/detection/chassis/chassis_bsd.c @@ -0,0 +1,13 @@ +#include "chassis.h" +#include "common/settings.h" + +void ffDetectChassis(FFChassisResult* result) +{ + ffStrbufInit(&result->error); + ffStrbufInit(&result->chassisType); + ffStrbufInit(&result->chassisVendor); + ffStrbufInit(&result->chassisVersion); + ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->chassisType); + ffSettingsGetFreeBSDKenv("smbios.chassis.maker", &result->chassisVendor); + ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->chassisVersion); +} From 464768a4604b1882a186c8319bc17d27d7f46606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 15 Jun 2023 11:19:53 +0800 Subject: [PATCH 137/493] Memory (FreeBSD): count cached memory as free memory As what neofetch did --- src/detection/memory/memory_bsd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/detection/memory/memory_bsd.c b/src/detection/memory/memory_bsd.c index 05c74172f..e856b1256 100644 --- a/src/detection/memory/memory_bsd.c +++ b/src/detection/memory/memory_bsd.c @@ -3,19 +3,21 @@ const char* ffDetectMemory(FFMemoryResult* ram) { + uint64_t length = sizeof(ram->bytesTotal); + if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) + return "Failed to read hw.physmem"; + uint32_t pageSize; - uint64_t length = sizeof(pageSize); + length = sizeof(pageSize); if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0)) return "Failed to read hw.pagesize"; - ram->bytesTotal = (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_page_count", 0) * pageSize; - if(ram->bytesTotal == 0) - return "Failed to read vm.stats.vm.v_page_count"; + // vm.stats.vm.* are int values + int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0) + + ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0) + + ffSysctlGetInt("vm.stats.vm.v_cache_count", 0); - ram->bytesUsed = ram->bytesTotal - - (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_free_count", 0) * pageSize - - (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_inactive_count", 0) * pageSize - ; + ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * pageSize; return NULL; } From 9c6673259318711e421e55681c9a2504368bc5c2 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 15 Jun 2023 12:43:16 +0000 Subject: [PATCH 138/493] Battery (FreeBSD): truly support FreeBSD --- src/detection/battery/battery_bsd.c | 40 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 96a8cb079..0430f2c33 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -1,4 +1,5 @@ #include "fastfetch.h" +#include "common/sysctl.h" #include "battery.h" #include @@ -11,23 +12,23 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FF_MAYBE_UNUSE //https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) //https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c + int units = ffSysctlGetInt("hw.acpi.battery.units", -100); + if (units < 0) + return "sysctlbyname(\"hw.acpi.battery.units\") failed"; + + if(units == 0) + return NULL; + int acpifd = open("/dev/acpi", O_RDONLY); if(acpifd < 0) return "open(\"/dev/acpi\", O_RDONLY) failed"; - int units = ioctl(acpifd, ACPIIO_BATT_GET_UNITS, 0); - if(units < 0) - { - close(acpifd); - return "No acpiio battery units found"; - } - for(int i = 0; i < units; ++i) { union acpi_battery_ioctl_arg battio; battio.unit = i; - if(ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) < 0 || (battio.battinfo.state & ACPI_BATT_STAT_NOT_PRESENT)) + if(ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) < 0 || (battio.battinfo.state == ACPI_BATT_STAT_NOT_PRESENT)) continue; BatteryResult* battery = ffListAdd(results); @@ -38,9 +39,9 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FF_MAYBE_UNUSE ffStrbufInit(&battery->technology); battery->capacity = battio.battinfo.cap; - if(battio.battinfo.state & ACPI_BATT_STAT_INVALID) + if(battio.battinfo.state == ACPI_BATT_STAT_INVALID) { - ffStrbufAppendS(&battery->status, "Invalid"); + ffStrbufAppendS(&battery->status, "Unknown, "); } else { @@ -49,10 +50,27 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FF_MAYBE_UNUSE else if(battio.battinfo.state & ACPI_BATT_STAT_CHARGING) ffStrbufAppendS(&battery->status, "Charging, "); if(battio.battinfo.state & ACPI_BATT_STAT_CRITICAL) - ffStrbufAppendS(&battery->status, "Ctritical"); + ffStrbufAppendS(&battery->status, "Ctritical, "); + } + + int acadStatus; + if (ioctl(acpifd, ACPIIO_ACAD_GET_STATUS, &acadStatus) >= 0 && acadStatus) + { + ffStrbufAppendS(&battery->status, "AC connected"); + } + else + { ffStrbufTrimRight(&battery->status, ' '); ffStrbufTrimRight(&battery->status, ','); } + + battio.unit = i; + if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) >= 0) + { + ffStrbufAppendS(&battery->manufacturer, battio.bix.oeminfo); + ffStrbufAppendS(&battery->modelName, battio.bix.model); + ffStrbufAppendS(&battery->technology, battio.bix.type); + } } close(acpifd); return NULL; From 0685c7afd6f1d0154aa7a0d3c41262a85ade3268 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 15 Jun 2023 13:12:10 +0000 Subject: [PATCH 139/493] OpenGL (FreeBSD): remove possible error messages --- src/detection/opengl/opengl_linux.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 8a274e68f..e1127700b 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -30,6 +30,8 @@ static const char* glHandleResult(FFOpenGLResult* result, const GLData* data) #endif // FF_HAVE_GL #ifdef FF_HAVE_EGL +#include "common/io/io.h" + #include typedef struct EGLData @@ -133,6 +135,7 @@ static const char* eglPrint(FFinstance* instance, FFOpenGLResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglDestroySurface); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglTerminate); + FF_SUPPRESS_IO(); return eglHandleData(result, &eglData); } From 592354b449be091f83a4670b29dcd85416d87d67 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 15 Jun 2023 14:22:47 +0000 Subject: [PATCH 140/493] Gamepad (FreeBSD): add support --- CMakeLists.txt | 6 +++- src/detection/gamepad/gamepad_bsd.c | 54 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/detection/gamepad/gamepad_bsd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d0168ed4a..8d80bfc08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -447,7 +447,7 @@ elseif(BSD) src/detection/host/host_bsd.c src/detection/icons/icons_linux.c src/detection/localip/localip_linux.c - src/detection/gamepad/gamepad_nosupport.c + src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c src/detection/memory/memory_bsd.c src/detection/opengl/opengl_linux.c @@ -752,6 +752,10 @@ elseif(WIN32) PRIVATE "wtsapi32" PRIVATE "powrprof" ) +elseif(BSD) + target_link_libraries(libfastfetch + PRIVATE "usbhid" + ) endif() target_include_directories(libfastfetch diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c new file mode 100644 index 000000000..95b5b1769 --- /dev/null +++ b/src/detection/gamepad/gamepad_bsd.c @@ -0,0 +1,54 @@ +#include "gamepad.h" +#include "common/io/io.h" + +#include +#include +#include +#include + +#define MAX_UHID_JOYS 64 + +const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */) +{ + char path[16]; + for (int i = 0; i < MAX_UHID_JOYS; i++) + { + snprintf(path, sizeof(path), "/dev/uhid%d", i); + FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC); + if (fd < 0) continue; + + report_desc_t repDesc = hid_get_report_desc(fd); + if (!repDesc) continue; + + int repId = hid_get_report_id(fd); + + struct hid_data* hData = hid_start_parse(repDesc, 0, repId); + if (hData) + { + struct hid_item hItem; + while (hid_get_item(hData, &hItem) > 0) + { + switch (HID_PAGE(hItem.usage)) + { + case 1: // FreeBSD returns 1 for my Pro Controller for some reason + case 5: + break; + default: + continue; + } + + struct usb_device_info di; + if (ioctl(fd, USB_GET_DEVICEINFO, &di) != -1) + { + FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices); + ffStrbufInitS(&device->identifier, di.udi_serial); + ffStrbufInitF(&device->name, "%s %s", di.udi_vendor, di.udi_product); + } + } + } + + hid_dispose_report_desc(repDesc); + } + + return NULL; +} From 7d28409f8d1a2f2149aff58f3c291ff8af0dcb4b Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 15 Jun 2023 14:53:31 +0000 Subject: [PATCH 141/493] Presets: fix keys in `verbose` --- presets/verbose | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presets/verbose b/presets/verbose index eefd2f3bd..2afad13ea 100644 --- a/presets/verbose +++ b/presets/verbose @@ -8,7 +8,7 @@ --display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {} --de-format Process name: {}; Pretty name: {}; Version: {} --wm-format Process name: {}; Pretty name: {}; Protocol: {} ---wm-theme-format Name: {} +--wmtheme-format Name: {} --theme-format Plasma: {}; Plasma colors: {}; Plasma colors pretty: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {} --icons-format Plasma: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {} --font-format Font1: {}; Font2: {}; Font3: {}; Font4: {} From 2896ea0437c50e1884627b698fd7621acdd669f4 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 15 Jun 2023 15:55:02 +0000 Subject: [PATCH 142/493] Wifi (FreeBSD): add dirty support --- CMakeLists.txt | 2 +- src/detection/wifi/wifi_bsd.c | 60 +++++++++++++++++++++++++++++ src/detection/wifi/wifi_nosupport.c | 7 ---- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 src/detection/wifi/wifi_bsd.c delete mode 100644 src/detection/wifi/wifi_nosupport.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d80bfc08..a2295395d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,7 +465,7 @@ elseif(BSD) src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_linux.c - src/detection/wifi/wifi_nosupport.c + src/detection/wifi/wifi_bsd.c src/detection/wmtheme/wmtheme_linux.c src/util/platform/FFPlatform_unix.c ) diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c new file mode 100644 index 000000000..85c5bb166 --- /dev/null +++ b/src/detection/wifi/wifi_bsd.c @@ -0,0 +1,60 @@ +#include "wifi.h" +#include "common/processing.h" +#include "common/properties.h" + +#include +#include +#include + +const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) +{ + struct if_nameindex* infs = if_nameindex(); + if(!infs) + return "if_nameindex() failed"; + + for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) + { + if (strncmp(i->if_name, "wlan", strlen("wlan")) != 0) continue; + FF_STRBUF_AUTO_DESTROY ifconfig = ffStrbufCreate(); + if (ffProcessAppendStdOut(&ifconfig, (char* const[]) { + "ifconfig", + i->if_name, + NULL + }) == NULL) + { + FFWifiResult* item = (FFWifiResult*) ffListAdd(result); + ffStrbufInitS(&item->inf.description, i->if_name); + ffStrbufInit(&item->inf.status); + ffStrbufInit(&item->conn.status); + ffStrbufInit(&item->conn.ssid); + ffStrbufInit(&item->conn.macAddress); + ffStrbufInit(&item->conn.protocol); + ffStrbufInit(&item->conn.security); + item->conn.signalQuality = 0.0/0.0; + item->conn.rxRate = 0.0/0.0; + item->conn.txRate = 0.0/0.0; + + ffParsePropLines(ifconfig.chars, "ssid ", &item->conn.ssid); + if (item->conn.ssid.length) ffStrbufSubstrBeforeFirstC(&item->conn.ssid, ' '); + + ffParsePropLines(ifconfig.chars, "ether ", &item->conn.macAddress); + + ffParsePropLines(ifconfig.chars, "media: ", &item->conn.protocol); + if (item->conn.protocol.length) + { + uint32_t index = ffStrbufFirstIndexS(&item->conn.protocol, " mode "); + if (index == item->conn.protocol.length) + ffStrbufClear(&item->conn.protocol); + else + { + ffStrbufSubstrAfter(&item->conn.protocol, index + strlen(" mode ") - 1); + ffStrbufPrependS(&item->conn.protocol, "802."); + } + } + + ffParsePropLines(ifconfig.chars, "status: ", &item->conn.macAddress); + } + } + + return NULL; +} diff --git a/src/detection/wifi/wifi_nosupport.c b/src/detection/wifi/wifi_nosupport.c deleted file mode 100644 index d09116c9b..000000000 --- a/src/detection/wifi/wifi_nosupport.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "wifi.h" - -const char* ffDetectWifi(const FFinstance* instance, FFlist* result) -{ - FF_UNUSED(instance, result); - return "Not supported on this platform"; -} From 2486e68fe32a932f2ff83653ff292759733e9f0a Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Thu, 15 Jun 2023 19:11:04 +0200 Subject: [PATCH 143/493] Less strictly wm name matching Fixes #475 --- src/detection/displayserver/linux/wmde.c | 52 +++++++++++------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index a1f1cfef6..67d8a5c27 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -55,53 +55,47 @@ static const char* parseEnv() return NULL; } -static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* processName) +static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) { - if(!ffStrSet(processName)) + if(!ffStrSet(name)) return; - if( - strcasecmp(processName, "kwin_wayland") == 0 || - strcasecmp(processName, "kwin_wayland_wrapper") == 0 || - strcasecmp(processName, "kwin_x11") == 0 || - strcasecmp(processName, "kwin_x11_wrapper") == 0 || - strcasecmp(processName, "kwin") == 0 - ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_KWIN); + if(strcasestr(name, "kwin") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_KWIN); else if( - strcasecmp(processName, "gnome-shell") == 0 || - strcasecmp(processName, "gnome shell") == 0 || - strcasecmp(processName, "gnome-session-binary") == 0 || - strcasecmp(processName, "Mutter") == 0 + strcasecmp(name, "gnome-shell") == 0 || + strcasecmp(name, "gnome shell") == 0 || + strcasecmp(name, "gnome-session-binary") == 0 || + strcasestr(name, "mutter") != NULL ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUTTER); else if( - strcasecmp(processName, "cinnamon-session") == 0 || - strcasecmp(processName, "Muffin") == 0 || - strcasecmp(processName, "Mutter (Muffin)") == 0 + strcasecmp(name, "cinnamon-session") == 0 || + strcasestr(name, "muffin") != NULL ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUFFIN); - else if(strcasecmp(processName, "sway") == 0) + else if(strcasestr(name, "sway") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_SWAY); - else if(strcasecmp(processName, "weston") == 0) + else if(strcasestr(name, "weston") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WESTON); - else if(strcasecmp(processName, "wayfire") == 0) + else if(strcasestr(name, "wayfire") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WAYFIRE); - else if(strcasecmp(processName, "openbox") == 0) + else if(strcasestr(name, "openbox") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_OPENBOX); - else if(strcasecmp(processName, "xfwm4") == 0) + else if(strcasestr(name, "xfwm4") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XFWM4); - else if(strcasecmp(processName, "Marco") == 0) + else if(strcasestr(name, "marco") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MARCO); - else if(strcasecmp(processName, "xmonad") == 0) + else if(strcasestr(name, "xmonad") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XMONAD); - else if(strcasecmp(processName, "WSLg") == 0) + else if(strcasestr(name, "wslg") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WSLG); else if( // WMs where the pretty name matches the process name - strcasecmp(processName, "dwm") == 0 || - strcasecmp(processName, "bspwm") == 0 || - strcasecmp(processName, "tinywm") == 0 - ) ffStrbufSetS(&result->wmPrettyName, processName); + strcasestr(name, "dwm") != NULL || + strcasestr(name, "bspwm") != NULL || + strcasestr(name, "tinywm") != NULL + ) ffStrbufSetS(&result->wmPrettyName, name); if(result->wmPrettyName.length > 0 && result->wmProcessName.length == 0) - ffStrbufSetS(&result->wmProcessName, processName); + ffStrbufSetS(&result->wmProcessName, name); } static void applyBetterWM(FFDisplayServerResult* result, const char* processName) From 46de2ec047f46d5b72c1f0ed9b35edd7feb261bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 09:15:50 +0800 Subject: [PATCH 144/493] TerminalFont: fix more memleaks --- src/detection/terminalfont/terminalfont_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 1061ebbf3..1a32692cb 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -4,6 +4,7 @@ #include "common/parsing.h" #include "detection/terminalshell/terminalshell.h" #include "detection/displayserver/displayserver.h" +#include "util/mallocHelper.h" #include "util/stringUtils.h" static const char* getSystemMonospaceFont(const FFinstance* instance) @@ -28,7 +29,7 @@ static const char* getSystemMonospaceFont(const FFinstance* instance) static void detectFromGSettings(const FFinstance* instance, const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) { - const char* defaultProfile = ffSettingsGetGSettings(instance, profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(instance, profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; if(!ffStrSet(defaultProfile)) { ffStrbufAppendF(&terminalFont->error, "Could not get default profile from gsettings: %s", profileList); @@ -42,7 +43,7 @@ static void detectFromGSettings(const FFinstance* instance, const char* profileP if(!ffSettingsGetGSettings(instance, profile, path.chars, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { - const char* fontName = ffSettingsGetGSettings(instance, profile, path.chars, "font", FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* fontName = ffSettingsGetGSettings(instance, profile, path.chars, "font", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(fontName)) ffFontInitPango(&terminalFont->font, fontName); else From 2647d04da3e9f1faee6a1c580b502b68cdd8cbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 09:18:07 +0800 Subject: [PATCH 145/493] Android: fix compiling --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/settings.h b/src/common/settings.h index e85f51068..7cb4fd46e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -34,7 +34,7 @@ int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, cons bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result); #ifdef __ANDROID__ -void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result); +bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result); #elif defined(__FreeBSD__) bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result); #endif From 59ec3ca69754aab6b0e79a11e01e7cda3a6500f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 10:21:53 +0800 Subject: [PATCH 146/493] Display (X11): detect rotation and name --- src/detection/displayserver/linux/xcb.c | 67 ++++++++++++++++++------ src/detection/displayserver/linux/xlib.c | 50 +++++++++--------- 2 files changed, 77 insertions(+), 40 deletions(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index c81bf46db..96ed13b40 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -1,4 +1,5 @@ #include "displayserver_linux.h" +#include "util/mallocHelper.h" #ifdef FF_HAVE_XCB #include "common/library.h" @@ -14,6 +15,9 @@ typedef struct XcbPropertyData FF_LIBRARY_SYMBOL(xcb_get_property_reply) FF_LIBRARY_SYMBOL(xcb_get_property_value) FF_LIBRARY_SYMBOL(xcb_get_property_value_length) + FF_LIBRARY_SYMBOL(xcb_get_atom_name) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_name) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_reply) } XcbPropertyData; static bool xcbInitPropertyData(void* libraryHandle, XcbPropertyData* propertyData) @@ -24,6 +28,9 @@ static bool xcbInitPropertyData(void* libraryHandle, XcbPropertyData* propertyDa FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_reply, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_value, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_value_length, false) + FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name, false) + FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_name, false) + FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_reply, false) return true; } @@ -164,17 +171,19 @@ typedef struct XcbRandrData FF_LIBRARY_SYMBOL(xcb_randr_get_output_info_reply) FF_LIBRARY_SYMBOL(xcb_randr_get_crtc_info) FF_LIBRARY_SYMBOL(xcb_randr_get_crtc_info_reply) + FF_LIBRARY_SYMBOL(xcb_get_atom_name) //init once xcb_connection_t* connection; FFDisplayServerResult* result; + XcbPropertyData propData; //init per screen uint32_t defaultRefreshRate; xcb_randr_get_screen_resources_reply_t* screenResources; } XcbRandrData; -static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo) +static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation) { double refreshRate = (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal); @@ -185,13 +194,13 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo refreshRate == 0 ? data->defaultRefreshRate : refreshRate, (uint32_t) modeInfo->width, (uint32_t) modeInfo->height, - 0, - NULL, + rotation, + name, FF_DISPLAY_TYPE_UNKNOWN ); } -static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode) +static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation) { //We do the check here, because we want the best fallback display if this call failed if(data->screenResources == NULL) @@ -202,7 +211,7 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode) while(modesIterator.rem > 0) { if(modesIterator.data->id == mode) - return xcbRandrHandleModeInfo(data, modesIterator.data); + return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation); data->ffxcb_randr_mode_info_next(&modesIterator); } @@ -210,14 +219,30 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode) return false; } -static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc) +static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name) { xcb_randr_get_crtc_info_cookie_t crtcInfoCookie = data->ffxcb_randr_get_crtc_info(data->connection, crtc, XCB_CURRENT_TIME); xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, NULL); if(crtcInfoReply == NULL) return false; - bool res = xcbRandrHandleMode(data, crtcInfoReply->mode); + uint32_t rotation; + switch (crtcInfoReply->rotation) + { + case XCB_RANDR_ROTATION_ROTATE_90: + rotation = 90; + break; + case XCB_RANDR_ROTATION_ROTATE_180: + rotation = 180; + break; + case XCB_RANDR_ROTATION_ROTATE_270: + rotation = 270; + break; + default: + rotation = 0; + break; + } + bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation); res = res ? true : ffdsAppendDisplay( data->result, (uint32_t) crtcInfoReply->width, @@ -225,8 +250,8 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc) data->defaultRefreshRate, (uint32_t) crtcInfoReply->width, (uint32_t) crtcInfoReply->height, - 0, - NULL, + rotation, + name, FF_DISPLAY_TYPE_UNKNOWN ); @@ -234,14 +259,14 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc) return res; } -static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output) +static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name) { xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME); xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL); if(outputInfoReply == NULL) return false; - bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc); + bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name); free(outputInfoReply); @@ -257,11 +282,22 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* .rem = data->ffxcb_randr_monitor_info_outputs_length(monitor) }; + FF_AUTO_FREE xcb_get_atom_name_reply_t* nameReply = data->propData.ffxcb_get_atom_name_reply( + data->connection, + data->propData.ffxcb_get_atom_name(data->connection, monitor->name), + NULL + ); + char* buf = data->propData.ffxcb_get_atom_name_name(nameReply); + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(buf); + // name.chars = buf; + // name.allocated = (uint32_t) strlen(buf); + // name.length = name.allocated; + bool foundOutput = false; while(outputIterator.rem > 0) { - if(xcbRandrHandleOutput(data, *outputIterator.data)) + if(xcbRandrHandleOutput(data, *outputIterator.data, &name)) foundOutput = true; data->ffxcb_randr_output_next(&outputIterator); }; @@ -274,7 +310,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* (uint32_t) monitor->width, (uint32_t) monitor->height, 0, - NULL, + &name, FF_DISPLAY_TYPE_UNKNOWN ); } @@ -371,8 +407,7 @@ void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* resu FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info_reply,) - XcbPropertyData propertyData; - bool propertyDataInitialized = xcbInitPropertyData(xcbRandr, &propertyData); + bool propertyDataInitialized = xcbInitPropertyData(xcbRandr, &data.propData); data.connection = ffxcb_connect(NULL, NULL); if(data.connection == NULL) @@ -383,7 +418,7 @@ void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* resu xcb_screen_iterator_t iterator = ffxcb_setup_roots_iterator(ffxcb_get_setup(data.connection)); if(iterator.rem > 0 && propertyDataInitialized) - xcbDetectWMfromEWMH(&propertyData, data.connection, iterator.data->root, result); + xcbDetectWMfromEWMH(&data.propData, data.connection, iterator.data->root, result); while(iterator.rem > 0) { diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 56a72ddf5..69b9f55a1 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -133,31 +133,17 @@ typedef struct XrandrData XRRScreenResources* screenResources; } XrandrData; -static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo) -{ - double refreshRate = (double) modeInfo->dotClock / (double) (modeInfo->hTotal * modeInfo->vTotal); - - return ffdsAppendDisplay( - data->result, - (uint32_t) modeInfo->width, - (uint32_t) modeInfo->height, - refreshRate == 0 ? data->defaultRefreshRate : refreshRate, - (uint32_t) modeInfo->width, - (uint32_t) modeInfo->height, - 0, - NULL, - FF_DISPLAY_TYPE_UNKNOWN - ); -} - -static bool xrandrHandleMode(XrandrData* data, RRMode mode) +static double xrandrHandleMode(XrandrData* data, RRMode mode) { for(int i = 0; i < data->screenResources->nmode; i++) { if(data->screenResources->modes[i].id == mode) - return xrandrHandleModeInfo(data, &data->screenResources->modes[i]); + { + XRRModeInfo* modeInfo = &data->screenResources->modes[i]; + return (double) modeInfo->dotClock / (double) (modeInfo->hTotal * modeInfo->vTotal); + } } - return false; + return data->defaultRefreshRate; } static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) @@ -170,15 +156,31 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) if(crtcInfo == NULL) return false; - bool res = xrandrHandleMode(data, crtcInfo->mode); - res = res ? true : ffdsAppendDisplay( + uint32_t rotation; + switch (crtcInfo->rotation) + { + case RR_Rotate_90: + rotation = 90; + break; + case RR_Rotate_180: + rotation = 180; + break; + case RR_Rotate_270: + rotation = 270; + break; + default: + rotation = 0; + break; + } + + bool res = ffdsAppendDisplay( data->result, (uint32_t) crtcInfo->width, (uint32_t) crtcInfo->height, - data->defaultRefreshRate, + xrandrHandleMode(data, crtcInfo->mode), (uint32_t) crtcInfo->width, (uint32_t) crtcInfo->height, - 0, + rotation, NULL, FF_DISPLAY_TYPE_UNKNOWN ); From eea02ffb800782c5fc689295515d669406a1d196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 13:51:00 +0800 Subject: [PATCH 147/493] Display (macOS): detect primary display --- src/detection/displayserver/displayserver.c | 4 +++- src/detection/displayserver/displayserver.h | 4 +++- src/detection/displayserver/displayserver_apple.c | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index 062f3be12..b535012d2 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -10,7 +10,8 @@ bool ffdsAppendDisplay( uint32_t scaledHeight, uint32_t rotation, FFstrbuf* name, - FFDisplayType type) + FFDisplayType type, + bool primary) { if(width == 0 || height == 0) return false; @@ -24,6 +25,7 @@ bool ffdsAppendDisplay( display->rotation = rotation; ffStrbufInitMove(&display->name, name); display->type = type; + display->primary = primary; return true; } diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index 52d0f34c9..5ffd5a30d 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -51,6 +51,7 @@ typedef struct FFDisplayResult FFstrbuf name; FFDisplayType type; uint32_t rotation; + bool primary; } FFDisplayResult; typedef struct FFDisplayServerResult @@ -75,6 +76,7 @@ bool ffdsAppendDisplay( uint32_t scaledHeight, uint32_t rotation, FFstrbuf* name, - FFDisplayType type); + FFDisplayType type, + bool primary); #endif diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 2ab624a39..15e423330 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -19,6 +19,8 @@ static void detectDisplays(FFDisplayServerResult* ds) if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess) return; + CGDirectDisplayID primary = CGMainDisplayID(); + for(uint32_t i = 0; i < screenCount; i++) { CGDirectDisplayID screen = screens[i]; @@ -60,7 +62,8 @@ static void detectDisplays(FFDisplayServerResult* ds) (uint32_t)CGDisplayModeGetHeight(mode), (uint32_t)CGDisplayRotation(screen), &name, - CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL + CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL, + screen == primary ); CGDisplayModeRelease(mode); } From 4360450ac600631cbabc2e85513c3de897b884a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 14:28:31 +0800 Subject: [PATCH 148/493] Display (Linux): detect primary display --- src/detection/displayserver/linux/wayland.c | 3 +- src/detection/displayserver/linux/xcb.c | 31 ++++++++++++--------- src/detection/displayserver/linux/xlib.c | 20 +++++++------ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 9e95eb1c5..b5df76656 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -202,7 +202,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist (uint32_t) (display.height / display.scale), rotation, &display.name, - display.type + display.type, + false ); ffThreadMutexUnlock(&mutex); diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 96ed13b40..8812e1b98 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -127,7 +127,8 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) (uint32_t) iterator.data->height_in_pixels, 0, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + false ); ffxcb_screen_next(&iterator); } @@ -183,7 +184,7 @@ typedef struct XcbRandrData xcb_randr_get_screen_resources_reply_t* screenResources; } XcbRandrData; -static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation) +static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation, bool primary) { double refreshRate = (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal); @@ -196,11 +197,12 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo (uint32_t) modeInfo->height, rotation, name, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + primary ); } -static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation) +static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation, bool primary) { //We do the check here, because we want the best fallback display if this call failed if(data->screenResources == NULL) @@ -211,7 +213,7 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrb while(modesIterator.rem > 0) { if(modesIterator.data->id == mode) - return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation); + return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation, primary); data->ffxcb_randr_mode_info_next(&modesIterator); } @@ -219,7 +221,7 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrb return false; } -static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name) +static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name, bool primary) { xcb_randr_get_crtc_info_cookie_t crtcInfoCookie = data->ffxcb_randr_get_crtc_info(data->connection, crtc, XCB_CURRENT_TIME); xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, NULL); @@ -242,7 +244,7 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb rotation = 0; break; } - bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation); + bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation, primary); res = res ? true : ffdsAppendDisplay( data->result, (uint32_t) crtcInfoReply->width, @@ -252,21 +254,22 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb (uint32_t) crtcInfoReply->height, rotation, name, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + primary ); free(crtcInfoReply); return res; } -static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name) +static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary) { xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME); xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL); if(outputInfoReply == NULL) return false; - bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name); + bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary); free(outputInfoReply); @@ -297,7 +300,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* while(outputIterator.rem > 0) { - if(xcbRandrHandleOutput(data, *outputIterator.data, &name)) + if(xcbRandrHandleOutput(data, *outputIterator.data, &name, monitor->primary)) foundOutput = true; data->ffxcb_randr_output_next(&outputIterator); }; @@ -311,7 +314,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* (uint32_t) monitor->height, 0, &name, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + !!monitor->primary ); } @@ -374,7 +378,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) (uint32_t) screen->height_in_pixels, 0, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + false ); } diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 69b9f55a1..9045a7e53 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -85,7 +85,8 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) (uint32_t) HeightOfScreen(screen), 0, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + false ); } @@ -146,7 +147,7 @@ static double xrandrHandleMode(XrandrData* data, RRMode mode) return data->defaultRefreshRate; } -static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) +static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary) { //We do the check here, because we want the best fallback display if this call failed if(data->screenResources == NULL) @@ -182,20 +183,21 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) (uint32_t) crtcInfo->height, rotation, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + primary ); data->ffXRRFreeCrtcInfo(crtcInfo); return res; } -static bool xrandrHandleOutput(XrandrData* data, RROutput output) +static bool xrandrHandleOutput(XrandrData* data, RROutput output, bool primary) { XRROutputInfo* outputInfo = data->ffXRRGetOutputInfo(data->display, data->screenResources, output); if(outputInfo == NULL) return false; - bool res = xrandrHandleCrtc(data, outputInfo->crtc); + bool res = xrandrHandleCrtc(data, outputInfo->crtc, primary); data->ffXRRFreeOutputInfo(outputInfo); @@ -208,7 +210,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) for(int i = 0; i < monitorInfo->noutput; i++) { - if(xrandrHandleOutput(data, monitorInfo->outputs[i])) + if(xrandrHandleOutput(data, monitorInfo->outputs[i], monitorInfo->primary)) foundOutput = true; } @@ -221,7 +223,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) (uint32_t) monitorInfo->height, 0, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + !!monitorInfo->primary ); } @@ -278,7 +281,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) (uint32_t) HeightOfScreen(screen), 0, NULL, - FF_DISPLAY_TYPE_UNKNOWN + FF_DISPLAY_TYPE_UNKNOWN, + false ); } From 5483cb9143edbd7ec417ca2aca7a76868f0be2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 16:33:43 +0800 Subject: [PATCH 149/493] Chassis: refactor --- src/detection/chassis/chassis.h | 3 +-- src/detection/chassis/chassis_bsd.c | 7 ++----- src/detection/chassis/chassis_linux.c | 10 ++-------- src/detection/chassis/chassis_nosupport.c | 8 ++------ src/modules/chassis/chassis.c | 13 ++++++++----- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/detection/chassis/chassis.h b/src/detection/chassis/chassis.h index eb6ce4c6c..221b066ce 100644 --- a/src/detection/chassis/chassis.h +++ b/src/detection/chassis/chassis.h @@ -10,9 +10,8 @@ typedef struct FFChassisResult FFstrbuf chassisType; FFstrbuf chassisVendor; FFstrbuf chassisVersion; - FFstrbuf error; } FFChassisResult; -void ffDetectChassis(FFChassisResult* result); +const char* ffDetectChassis(FFChassisResult* result); #endif diff --git a/src/detection/chassis/chassis_bsd.c b/src/detection/chassis/chassis_bsd.c index e6475c2eb..9614cfd7a 100644 --- a/src/detection/chassis/chassis_bsd.c +++ b/src/detection/chassis/chassis_bsd.c @@ -1,13 +1,10 @@ #include "chassis.h" #include "common/settings.h" -void ffDetectChassis(FFChassisResult* result) +const char* ffDetectChassis(FFChassisResult* result) { - ffStrbufInit(&result->error); - ffStrbufInit(&result->chassisType); - ffStrbufInit(&result->chassisVendor); - ffStrbufInit(&result->chassisVersion); ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->chassisType); ffSettingsGetFreeBSDKenv("smbios.chassis.maker", &result->chassisVendor); ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->chassisVersion); + return NULL; } diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index 0898fa4b8..0e40b217e 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -40,16 +40,10 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu ffStrbufClear(buffer); } -void ffDetectChassis(FFChassisResult* result) +const char* ffDetectChassis(FFChassisResult* result) { - ffStrbufInit(&result->error); - - ffStrbufInit(&result->chassisType); getHostValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType); - - ffStrbufInit(&result->chassisVendor); getHostValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor); - - ffStrbufInit(&result->chassisVersion); getHostValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion); + return NULL; } diff --git a/src/detection/chassis/chassis_nosupport.c b/src/detection/chassis/chassis_nosupport.c index 42c182567..c2acd7579 100644 --- a/src/detection/chassis/chassis_nosupport.c +++ b/src/detection/chassis/chassis_nosupport.c @@ -1,10 +1,6 @@ #include "chassis.h" -void ffDetectChassis(FFChassisResult* result) +const char* ffDetectChassis(FF_MAYBE_UNUSED FFChassisResult* result) { - ffStrbufInitS(&result->error, "Not supported on this platform"); - - ffStrbufInit(&result->chassisType); - ffStrbufInit(&result->chassisVendor); - ffStrbufInit(&result->chassisVersion); + return "Not supported on this platform"; } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 7d8e771aa..ac6a41354 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -8,18 +8,22 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) { FFChassisResult result; - ffDetectChassis(&result); + ffStrbufInit(&result.chassisType); + ffStrbufInit(&result.chassisVendor); + ffStrbufInit(&result.chassisVersion); - if(result.error.length > 0) + const char* error = ffDetectChassis(&result); + + if(error) { - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } if(result.chassisType.length == 0) { ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); - return; + goto exit; } if(options->moduleArgs.outputFormat.length == 0) @@ -46,7 +50,6 @@ exit: ffStrbufDestroy(&result.chassisType); ffStrbufDestroy(&result.chassisVendor); ffStrbufDestroy(&result.chassisVersion); - ffStrbufDestroy(&result.error); } void ffInitChassisOptions(FFChassisOptions* options) From 05c41ffd89037abea069d5a0a5dfcc8f7ccd52d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 16:40:43 +0800 Subject: [PATCH 150/493] Bios: code refactor --- src/detection/bios/bios.h | 3 +-- src/detection/bios/bios_apple.c | 17 ++++++--------- src/detection/bios/bios_bsd.c | 9 ++------ src/detection/bios/bios_linux.c | 12 ++-------- src/detection/bios/bios_nosupport.c | 9 ++------ src/detection/bios/bios_windows.c | 20 +++++++---------- src/modules/bios/bios.c | 34 ++++++++++++++++------------- 7 files changed, 41 insertions(+), 63 deletions(-) diff --git a/src/detection/bios/bios.h b/src/detection/bios/bios.h index 6f664b4b2..039918a56 100644 --- a/src/detection/bios/bios.h +++ b/src/detection/bios/bios.h @@ -11,9 +11,8 @@ typedef struct FFBiosResult FFstrbuf biosRelease; FFstrbuf biosVendor; FFstrbuf biosVersion; - FFstrbuf error; } FFBiosResult; -void ffDetectBios(FFBiosResult* bios); +const char* ffDetectBios(FFBiosResult* bios); #endif diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index 9d7ff75cc..b8be5c15e 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -3,14 +3,8 @@ #include -void ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FFBiosResult* bios) { - ffStrbufInit(&bios->error); - ffStrbufInit(&bios->biosDate); - ffStrbufInit(&bios->biosRelease); - ffStrbufInit(&bios->biosVendor); - ffStrbufInit(&bios->biosVersion); - io_registry_entry_t registryEntry; #ifndef __aarch64__ @@ -23,8 +17,7 @@ void ffDetectBios(FFBiosResult* bios) if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { IOObjectRelease(registryEntry); - ffStrbufAppendS(&bios->error, "IORegistryEntryCreateCFProperties(registryEntry) failed"); - return; + return "IORegistryEntryCreateCFProperties(registryEntry) failed"; } ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor); @@ -36,7 +29,7 @@ void ffDetectBios(FFBiosResult* bios) CFRelease(properties); IOObjectRelease(registryEntry); - return; + return NULL; } #else @@ -51,6 +44,7 @@ void ffDetectBios(FFBiosResult* bios) CFRelease(properties); } IOObjectRelease(registryEntry); + return NULL; } if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"))) @@ -64,7 +58,10 @@ void ffDetectBios(FFBiosResult* bios) CFRelease(properties); } IOObjectRelease(registryEntry); + return NULL; } #endif + + return "Failed to query bios info"; } diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 5699b3372..df8c853b9 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -2,16 +2,11 @@ #include "common/settings.h" -void ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FFBiosResult* bios) { - ffStrbufInit(&bios->error); - ffStrbufInit(&bios->biosDate); - ffStrbufInit(&bios->biosRelease); - ffStrbufInit(&bios->biosVendor); - ffStrbufInit(&bios->biosVersion); - ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &bios->biosDate); ffSettingsGetFreeBSDKenv("smbios.bios.revision", &bios->biosRelease); ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &bios->biosVendor); ffSettingsGetFreeBSDKenv("smbios.bios.version", &bios->biosVersion); + return NULL; } diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index ce23edf89..820cff62c 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -40,19 +40,11 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu ffStrbufClear(buffer); } -void ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FFBiosResult* bios) { - ffStrbufInit(&bios->error); - - ffStrbufInit(&bios->biosDate); getHostValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate); - - ffStrbufInit(&bios->biosRelease); getHostValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease); - - ffStrbufInit(&bios->biosVendor); getHostValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor); - - ffStrbufInit(&bios->biosVersion); getHostValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion); + return NULL; } diff --git a/src/detection/bios/bios_nosupport.c b/src/detection/bios/bios_nosupport.c index f8d886182..ac544fd3e 100644 --- a/src/detection/bios/bios_nosupport.c +++ b/src/detection/bios/bios_nosupport.c @@ -1,11 +1,6 @@ #include "bios.h" -void ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FF_MAYBE_UNUSED FFBiosResult* bios) { - ffStrbufInitS(&bios->error, "Not supported on this platform"); - - ffStrbufInit(&bios->biosDate); - ffStrbufInit(&bios->biosRelease); - ffStrbufInit(&bios->biosVendor); - ffStrbufInit(&bios->biosVersion); + return "Not supported on this platform"; } diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 7facb2576..e23baa9c1 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -1,21 +1,15 @@ #include "bios.h" #include "util/windows/registry.h" -void ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FFBiosResult* bios) { - ffStrbufInit(&bios->error); - - ffStrbufInit(&bios->biosDate); - ffStrbufInit(&bios->biosRelease); - ffStrbufInit(&bios->biosVendor); - ffStrbufInit(&bios->biosVersion); - FF_HKEY_AUTO_DESTROY hKey = NULL; - if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &bios->error)) - return; + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; + + if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosRelease, NULL)) + return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion\" doesn't exist"; - if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosRelease, &bios->error)) - return; ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->biosVendor, NULL); ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->biosDate, NULL); @@ -25,4 +19,6 @@ void ffDetectBios(FFBiosResult* bios) ffRegReadUint(hKey, L"BiosMinorRelease", &minor, NULL) ) ffStrbufAppendF(&bios->biosVersion, "%u.%u", (unsigned)major, (unsigned)minor); + + return NULL; } diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 139cd2740..b898217b3 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -7,16 +7,21 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) { - FFBiosResult result; - ffDetectBios(&result); + FFBiosResult bios; + ffStrbufInit(&bios.biosDate); + ffStrbufInit(&bios.biosRelease); + ffStrbufInit(&bios.biosVendor); + ffStrbufInit(&bios.biosVersion); - if(result.error.length > 0) + const char* error = ffDetectBios(&bios); + + if(error) { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } - if(result.biosRelease.length == 0) + if(bios.biosRelease.length == 0) { ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_release is not set."); goto exit; @@ -25,24 +30,23 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key); - puts(result.biosRelease.chars); + puts(bios.biosRelease.chars); } else { ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosDate}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosRelease}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosDate}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosRelease}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosVendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosVersion}, }); } exit: - ffStrbufDestroy(&result.biosDate); - ffStrbufDestroy(&result.biosRelease); - ffStrbufDestroy(&result.biosVendor); - ffStrbufDestroy(&result.biosVersion); - ffStrbufDestroy(&result.error); + ffStrbufDestroy(&bios.biosDate); + ffStrbufDestroy(&bios.biosRelease); + ffStrbufDestroy(&bios.biosVendor); + ffStrbufDestroy(&bios.biosVersion); } void ffInitBiosOptions(FFBiosOptions* options) From 98a7ea5a10872cc0ff154fd899351135570c7040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jun 2023 20:40:50 +0800 Subject: [PATCH 151/493] CMake (Windows): silence compiler warnings --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2295395d..a0af3392e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,10 +106,10 @@ else() message(STATUS "Threads type: disabled") endif() -set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=uninitialized -Werror=return-type") +set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=uninitialized -Werror=return-type") set(CMAKE_C_STANDARD 11) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration") if(WIN32) set(CMAKE_CXX_STANDARD 11) From 30dd291d3d616cc139fc9c1bafc99e8dd3467183 Mon Sep 17 00:00:00 2001 From: CarterLi Date: Fri, 16 Jun 2023 23:35:30 +0800 Subject: [PATCH 152/493] Gamepad (FreeBSD): fix detection --- src/detection/gamepad/gamepad_bsd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index 95b5b1769..49f49bf58 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -28,7 +28,8 @@ const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* struct hid_item hItem; while (hid_get_item(hData, &hItem) > 0) { - switch (HID_PAGE(hItem.usage)) + if (HID_PAGE(hItem.usage) != 1) continue; + switch (HID_USAGE(hItem.usage)) { case 1: // FreeBSD returns 1 for my Pro Controller for some reason case 5: From 40ae2fb1daa0f4769b75a87701c0653d92d5ceb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 17 Jun 2023 15:08:45 +0800 Subject: [PATCH 153/493] Display (Windows): detect primary monitor --- .../displayserver/displayserver_windows.c | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 907438e9d..565c8fcce 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -4,9 +4,26 @@ #include #include +#include + +static CALLBACK BOOL MonitorEnumProc( + HMONITOR hMonitor, + FF_MAYBE_UNUSED HDC hdc, + FF_MAYBE_UNUSED LPRECT lpRect, + LPARAM lParam +) +{ + FFlist* monitors = (FFlist*) lParam; + MONITORINFOEXW* newMonitor = ffListAdd(monitors); + newMonitor->cbSize = sizeof(*newMonitor); + return GetMonitorInfoW(hMonitor, (MONITORINFO*) newMonitor); +} static void detectDisplays(FFDisplayServerResult* ds) { + FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(MONITORINFOEXW)); + EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) &monitors); + DISPLAYCONFIG_PATH_INFO paths[128]; uint32_t pathCount = sizeof(paths) / sizeof(paths[0]); DISPLAYCONFIG_MODE_INFO modes[256]; @@ -33,14 +50,19 @@ static void detectDisplays(FFDisplayServerResult* ds) }, }; - uint32_t scaledWidth = 0, scaledHeight = 0; + MONITORINFOEXW* monitorInfo = NULL; if (DisplayConfigGetDeviceInfo(&sourceName.header) == ERROR_SUCCESS) { - HDC hdc = CreateICW(sourceName.viewGdiDeviceName, NULL, NULL, NULL); - scaledWidth = (uint32_t) GetDeviceCaps(hdc, HORZRES); - scaledHeight = (uint32_t) GetDeviceCaps(hdc, VERTRES); - DeleteDC(hdc); + FF_LIST_FOR_EACH(MONITORINFOEXW, item, monitors) + { + if (wcsncmp(item->szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0) + { + monitorInfo = item; + break; + } + } } + if (!monitorInfo) continue; FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); @@ -95,14 +117,15 @@ static void detectDisplays(FFDisplayServerResult* ds) width, height, path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator, - scaledWidth, - scaledHeight, + (uint32_t) (monitorInfo->rcMonitor.right - monitorInfo->rcMonitor.left), + (uint32_t) (monitorInfo->rcMonitor.bottom - monitorInfo->rcMonitor.top), rotation, &name, path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED - ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL + ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL, + !!(monitorInfo->dwFlags & MONITORINFOF_PRIMARY) ); } } From 5678019204addafc98264e536531ed50b510093e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 17 Jun 2023 15:23:05 +0800 Subject: [PATCH 154/493] CPU (Windows): fix detection bug --- src/detection/cpu/cpu_windows.c | 3 ++- src/modules/cpu/cpu.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 4b814ca2f..8c9246d2f 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -7,7 +7,8 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF { { DWORD length = 0; - if (GetLogicalProcessorInformationEx(RelationAll, NULL, &length) != ERROR_INSUFFICIENT_BUFFER) + GetLogicalProcessorInformationEx(RelationAll, NULL, &length); + if (length == 0) return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed"; SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 6fc3104bb..c8cc7a452 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -14,9 +14,13 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) ffStrbufInit(&cpu.name); ffStrbufInit(&cpu.vendor); - ffDetectCPU(instance, options, &cpu); + const char* error = ffDetectCPU(instance, options, &cpu); - if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) + if(error) + { + ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + } + else if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) { ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); } From 64bdb5968307427918da14f754c541497f4f3dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 17 Jun 2023 15:38:50 +0800 Subject: [PATCH 155/493] Display: print `*` for primary monitors Also `FF_FORMAT_ARG_VALUE_BOOL` was removed, which makes usages of `FF_FORMAT_ARG_VALUE_*` inconsistant --- src/common/format.c | 2 +- src/common/format.h | 2 -- src/modules/disk/disk.c | 6 ++++-- src/modules/display/display.c | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/format.c b/src/common/format.c index 07f54f247..4ed096dc1 100644 --- a/src/common/format.c +++ b/src/common/format.c @@ -25,7 +25,7 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg) else if(formatarg->type == FF_FORMAT_ARG_TYPE_DOUBLE) ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value); else if(formatarg->type == FF_FORMAT_ARG_TYPE_BOOL) - ffStrbufAppendS(buffer, formatarg->value != NULL ? "true" : "false"); + ffStrbufAppendS(buffer, *(bool*)formatarg->value ? "true" : "false"); else if(formatarg->type == FF_FORMAT_ARG_TYPE_LIST) { const FFlist* list = formatarg->value; diff --git a/src/common/format.h b/src/common/format.h index cc7e29e6d..57c8c680f 100644 --- a/src/common/format.h +++ b/src/common/format.h @@ -27,6 +27,4 @@ typedef struct FFformatarg void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg); void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments); -#define FF_FORMAT_ARG_VALUE_BOOL(xpr) ((xpr) ? (const void*) 1 : NULL) - #endif diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 4ff74d129..ec2478e72 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -76,6 +76,8 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk { uint8_t filesPercentage = disk->filesTotal > 0 ? (uint8_t) (((double) disk->filesUsed / (double) disk->filesTotal) * 100.0) : 0; + bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); + bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, @@ -83,8 +85,8 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk {FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed}, {FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal}, {FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_HIDDEN_BIT)}, + {FF_FORMAT_ARG_TYPE_BOOL, &isExternal}, + {FF_FORMAT_ARG_TYPE_BOOL, &isHidden}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name} }); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 72e1fd9bd..354b0061d 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -89,6 +89,9 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) result->scaledHeight > 0 && result->scaledHeight != result->height) printf(" (as %ix%i)", result->scaledWidth, result->scaledHeight); + if(moduleIndex > 0 && result->primary) + printf(" *"); + putchar('\n'); } else @@ -102,6 +105,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRING, displayType}, {FF_FORMAT_ARG_TYPE_UINT, &result->rotation}, + {FF_FORMAT_ARG_TYPE_BOOL, &result->primary}, }); } } From d1dc04020a3c9f5ceb1493c4b5ffd476bb260715 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 20:39:08 +0800 Subject: [PATCH 156/493] Fastfetch: print error messages when failed to parse JSON config file --- src/fastfetch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index fb548178b..d4e7a1afd 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -526,7 +526,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con static bool parseJsoncFile(FFinstance* instance, const char* path) { - yyjson_doc* doc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL); + yyjson_read_err error; + yyjson_doc* doc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, &error); if (doc) { instance->state.configDoc = doc; @@ -544,6 +545,11 @@ static bool parseJsoncFile(FFinstance* instance, const char* path) } return true; } + else if (error.code != YYJSON_READ_ERROR_FILE_OPEN) + { + fprintf(stderr, "ERROR: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg); + exit(477); + } return false; } From 184a6de1e9845e9310fd1ee3101cd668b06457d6 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 21:08:50 +0800 Subject: [PATCH 157/493] JsonConfig: always use `ffStrbufSet*` to set config properties --- src/common/jsonconfig.c | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 0b41fd2da..1b1aeffcc 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -346,13 +346,13 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) else if (strcasecmp(key, "hideCursor") == 0) config->hideCursor = yyjson_get_bool(val); else if (strcasecmp(key, "separator") == 0) - ffStrbufAppendS(&config->keyValueSeparator, yyjson_get_str(val)); + ffStrbufSetS(&config->keyValueSeparator, yyjson_get_str(val)); else if (strcasecmp(key, "color") == 0) { if (yyjson_is_str(val)) { ffOptionParseColor(yyjson_get_str(val), &config->colorKeys); - ffStrbufAppend(&config->colorTitle, &config->colorKeys); + ffStrbufSet(&config->colorTitle, &config->colorKeys); } else if (yyjson_is_obj(val)) { @@ -410,53 +410,53 @@ const char* ffParseLibraryJsonConfig(FFinstance* instance) const char* key = yyjson_get_str(key_); if (strcasecmp(key, "pci") == 0) - ffStrbufAppendS(&config->libPCI, yyjson_get_str(val)); + ffStrbufSetS(&config->libPCI, yyjson_get_str(val)); else if (strcasecmp(key, "vulkan") == 0) - ffStrbufAppendS(&config->libVulkan, yyjson_get_str(val)); + ffStrbufSetS(&config->libVulkan, yyjson_get_str(val)); else if (strcasecmp(key, "freetype") == 0) - ffStrbufAppendS(&config->libfreetype, yyjson_get_str(val)); + ffStrbufSetS(&config->libfreetype, yyjson_get_str(val)); else if (strcasecmp(key, "wayland") == 0) - ffStrbufAppendS(&config->libWayland, yyjson_get_str(val)); + ffStrbufSetS(&config->libWayland, yyjson_get_str(val)); else if (strcasecmp(key, "xcbRandr") == 0) - ffStrbufAppendS(&config->libXcbRandr, yyjson_get_str(val)); + ffStrbufSetS(&config->libXcbRandr, yyjson_get_str(val)); else if (strcasecmp(key, "xcb") == 0) - ffStrbufAppendS(&config->libXcb, yyjson_get_str(val)); + ffStrbufSetS(&config->libXcb, yyjson_get_str(val)); else if (strcasecmp(key, "Xrandr") == 0) - ffStrbufAppendS(&config->libXrandr, yyjson_get_str(val)); + ffStrbufSetS(&config->libXrandr, yyjson_get_str(val)); else if (strcasecmp(key, "X11") == 0) - ffStrbufAppendS(&config->libX11, yyjson_get_str(val)); + ffStrbufSetS(&config->libX11, yyjson_get_str(val)); else if (strcasecmp(key, "gio") == 0) - ffStrbufAppendS(&config->libGIO, yyjson_get_str(val)); + ffStrbufSetS(&config->libGIO, yyjson_get_str(val)); else if (strcasecmp(key, "DConf") == 0) - ffStrbufAppendS(&config->libDConf, yyjson_get_str(val)); + ffStrbufSetS(&config->libDConf, yyjson_get_str(val)); else if (strcasecmp(key, "dbus") == 0) - ffStrbufAppendS(&config->libDBus, yyjson_get_str(val)); + ffStrbufSetS(&config->libDBus, yyjson_get_str(val)); else if (strcasecmp(key, "XFConf") == 0) - ffStrbufAppendS(&config->libXFConf, yyjson_get_str(val)); + ffStrbufSetS(&config->libXFConf, yyjson_get_str(val)); else if (strcasecmp(key, "sqlite") == 0 || strcasecmp(key, "sqlite3") == 0) - ffStrbufAppendS(&config->libSQLite3, yyjson_get_str(val)); + ffStrbufSetS(&config->libSQLite3, yyjson_get_str(val)); else if (strcasecmp(key, "rpm") == 0) - ffStrbufAppendS(&config->librpm, yyjson_get_str(val)); + ffStrbufSetS(&config->librpm, yyjson_get_str(val)); else if (strcasecmp(key, "imagemagick") == 0) - ffStrbufAppendS(&config->libImageMagick, yyjson_get_str(val)); + ffStrbufSetS(&config->libImageMagick, yyjson_get_str(val)); else if (strcasecmp(key, "z") == 0) - ffStrbufAppendS(&config->libZ, yyjson_get_str(val)); + ffStrbufSetS(&config->libZ, yyjson_get_str(val)); else if (strcasecmp(key, "chafa") == 0) - ffStrbufAppendS(&config->libChafa, yyjson_get_str(val)); + ffStrbufSetS(&config->libChafa, yyjson_get_str(val)); else if (strcasecmp(key, "egl") == 0) - ffStrbufAppendS(&config->libEGL, yyjson_get_str(val)); + ffStrbufSetS(&config->libEGL, yyjson_get_str(val)); else if (strcasecmp(key, "glx") == 0) - ffStrbufAppendS(&config->libGLX, yyjson_get_str(val)); + ffStrbufSetS(&config->libGLX, yyjson_get_str(val)); else if (strcasecmp(key, "osmesa") == 0) - ffStrbufAppendS(&config->libOSMesa, yyjson_get_str(val)); + ffStrbufSetS(&config->libOSMesa, yyjson_get_str(val)); else if (strcasecmp(key, "opencl") == 0) - ffStrbufAppendS(&config->libOpenCL, yyjson_get_str(val)); + ffStrbufSetS(&config->libOpenCL, yyjson_get_str(val)); else if (strcasecmp(key, "wlanapi") == 0) - ffStrbufAppendS(&config->libwlanapi, yyjson_get_str(val)); + ffStrbufSetS(&config->libwlanapi, yyjson_get_str(val)); else if (strcasecmp(key, "pulse") == 0) - ffStrbufAppendS(&config->libPulse, yyjson_get_str(val)); + ffStrbufSetS(&config->libPulse, yyjson_get_str(val)); else if (strcasecmp(key, "nm") == 0) - ffStrbufAppendS(&config->libnm, yyjson_get_str(val)); + ffStrbufSetS(&config->libnm, yyjson_get_str(val)); else return "Unknown library property"; } From 6bb5f9d1ab662e1bb67fda9d44869aaf0b33f919 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 21:43:41 +0800 Subject: [PATCH 158/493] Bluetooth: fix key name of `showDisconnected` --- src/modules/bluetooth/bluetooth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index cf78eef7d..744bc549b 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -111,7 +111,7 @@ void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "showConnected") == 0) + if (strcasecmp(key, "showDisconnected") == 0) { options.showDisconnected = yyjson_get_bool(val); continue; From a994d398d9cc7a91bfec8c7e17e99d3b497ea791 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 22:07:31 +0800 Subject: [PATCH 159/493] Disk: fix key name of `showUnknown` --- src/modules/disk/disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index ec2478e72..68b1e249d 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -294,7 +294,7 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "show-unknown") == 0) + if (strcasecmp(key, "showUnknown") == 0) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; From 4bde3afe8a7e168235307f231a4155afac900889 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 22:33:41 +0800 Subject: [PATCH 160/493] OpenGL: change option key `type` to `library` To avoid conflict with JSON config `type` --- src/data/config_user.txt | 2 +- src/data/help.txt | 11 +++++----- src/detection/opengl/opengl_linux.c | 6 +++--- src/modules/opengl/opengl.c | 31 ++++++++++++++++------------- src/modules/opengl/option.h | 14 ++++++------- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 2ccb2e8b9..91902dedd 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -216,7 +216,7 @@ # Sets with opengl context creation library to use # Must be either auto, egl, glx or osmesa # Default is auto. -#--opengl-type auto +#--opengl-library auto # GPU hide options # Sets weather to hide certain gpu types diff --git a/src/data/help.txt b/src/data/help.txt index 3008888b7..6d7bd3f45 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -115,14 +115,13 @@ Module specific options: --bluetooth-show-disconnected: : Set if disconnected bluetooth devices should be printed. Default is false --display-compact-type: : Set if all displays should be printed in one line. Default is none --display-detect-name: : Set if display name should be detected and printed (if supported). Default is false - --display-precise-refresh-rate: :Set if decimal refresh rates should not be rounded into integers when printing + --display-precise-refresh-rate: :Set if decimal refresh rates should not be rounded into integers when printing. Default is true --sound-type: : Set what type of sound devices should be printed. Should be either main, active or all. Default is main --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ --cpu-temp : Detect and display CPU temperature if supported. Default is false --gpu-temp : Detect and display GPU temperature if supported. Default is false --gpu-force-vulkan : Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false - --gpu-hide-integrated : Hide integrated GPU if supported. Default is false - --gpu-hide-discrete : Hide discrete GPU if supported. Default is false + --gpu-hide-type : Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none --battery-temp : Detect and display Battery temperature if supported. Default is false --localip-show-ipv4 : Show IPv4 addresses in local ip module. Default is true --localip-show-ipv6 : Show IPv6 addresses in local ip module. Default is false @@ -135,10 +134,10 @@ Module specific options: --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use - --opengl-type : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto + --opengl-library : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others - --command-key : Set the module key to display, can be specified mulitple times - --command-text : Set the command text to be executed, can be specified mulitple times + --command-key : Set the module key to display + --command-text : Set the command text to be executed Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index e1127700b..9a4f42bec 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -318,7 +318,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) { #if FF_HAVE_GL - if(instance->config.openGL.type == FF_OPENGL_TYPE_GLX) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_GLX) { #ifdef FF_HAVE_GLX return glxPrint(instance, result); @@ -327,7 +327,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.openGL.type == FF_OPENGL_TYPE_EGL) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_EGL) { #ifdef FF_HAVE_EGL return eglPrint(instance, result); @@ -336,7 +336,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.openGL.type == FF_OPENGL_TYPE_OSMESA) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_OSMESA) { #ifdef FF_HAVE_OSMESA return osMesaPrint(instance, result); diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 7272cd31d..46924ceaa 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -47,7 +47,7 @@ void ffInitOpenGLOptions(FFOpenGLOptions* options) ffOptionInitModuleArg(&options->moduleArgs); #if defined(__linux__) || defined(__FreeBSD__) - options->type = FF_OPENGL_TYPE_AUTO; + options->library = FF_OPENGL_LIBRARY_AUTO; #endif } @@ -59,13 +59,16 @@ bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, cons return true; #if defined(__linux__) || defined(__FreeBSD__) - options->type = (FFOpenGLType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { - { "auto", FF_OPENGL_TYPE_AUTO }, - { "egl", FF_OPENGL_TYPE_EGL }, - { "glx", FF_OPENGL_TYPE_GLX }, - { "osmesa", FF_OPENGL_TYPE_OSMESA }, - {} - }); + if (strcasecmp(key, "library") == 0) + { + options->library = (FFOpenGLLibrary) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "auto", FF_OPENGL_LIBRARY_AUTO }, + { "egl", FF_OPENGL_LIBRARY_EGL }, + { "glx", FF_OPENGL_LIBRARY_GLX }, + { "osmesa", FF_OPENGL_LIBRARY_OSMESA }, + {} + }); + } #endif return false; @@ -95,20 +98,20 @@ void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) continue; #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "type") == 0) + if (strcasecmp(key, "library") == 0) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { - { "auto", FF_OPENGL_TYPE_AUTO }, - { "egl", FF_OPENGL_TYPE_EGL }, - { "glx", FF_OPENGL_TYPE_GLX }, - { "osmesa", FF_OPENGL_TYPE_OSMESA }, + { "auto", FF_OPENGL_LIBRARY_AUTO }, + { "egl", FF_OPENGL_LIBRARY_EGL }, + { "glx", FF_OPENGL_LIBRARY_GLX }, + { "osmesa", FF_OPENGL_LIBRARY_OSMESA }, {}, }); if (error) ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else - options.type = (FFOpenGLType) value; + options.library = (FFOpenGLLibrary) value; continue; } #endif diff --git a/src/modules/opengl/option.h b/src/modules/opengl/option.h index 72e29c980..712374d93 100644 --- a/src/modules/opengl/option.h +++ b/src/modules/opengl/option.h @@ -5,13 +5,13 @@ #include "common/option.h" #if defined(__linux__) || defined(__FreeBSD__) -typedef enum FFOpenGLType +typedef enum FFOpenGLLibrary { - FF_OPENGL_TYPE_AUTO, - FF_OPENGL_TYPE_EGL, - FF_OPENGL_TYPE_GLX, - FF_OPENGL_TYPE_OSMESA -} FFOpenGLType; + FF_OPENGL_LIBRARY_AUTO, + FF_OPENGL_LIBRARY_EGL, + FF_OPENGL_LIBRARY_GLX, + FF_OPENGL_LIBRARY_OSMESA +} FFOpenGLLibrary; #endif typedef struct FFOpenGLOptions @@ -20,6 +20,6 @@ typedef struct FFOpenGLOptions FFModuleArgs moduleArgs; #if defined(__linux__) || defined(__FreeBSD__) - FFOpenGLType type; + FFOpenGLLibrary library; #endif } FFOpenGLOptions; From 594765658a1a82997afbd916a9e31af47196a6c7 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 22:37:33 +0800 Subject: [PATCH 161/493] JsonConfig: update json_schema --- src/data/json_schema.jsonc | 361 ++++++++++++++++++++++++++++++++++++- 1 file changed, 359 insertions(+), 2 deletions(-) diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index 33fbd3f9d..0279f38a6 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -365,10 +365,367 @@ "items": { "anyOf": [ { - "type": "string" + "type": "string", + "enum": [ + "Battery", + "Bios", + "Bluetooth", + "Board", + "Break", + "Brightness", + "Chassis", + "CPU", + "CPUUsage", + "Command", + "Colors", + "Cursor", + "Custom", + "DateTime", + "Display", + "Disk", + "DE", + "Font", + "Gamepad", + "GPU", + "Host", + "Icons", + "Kernel", + "Locale", + "LocalIp", + "Media", + "Memory", + "OpenCL", + "OpenGL", + "OS", + "Packages", + "Player", + "PowerAdapter", + "Processes", + "PublicIp", + "Separator", + "Shell", + "Sound", + "Swap", + "Terminal", + "TerminalFont", + "Title", + "Theme", + "Uptime", + "Users", + "Vulkan", + "Wallpaper", + "Weather", + "WM", + "Wifi", + "WMTheme" + ] }, { - "type": "object" + "type": "object", + "required": ["type"], + "anyOf": [ + { + "properties": { + "type": { + "enum": ["break", "Colors"], + "additionalProperties": false + } + } + }, + { + "properties": { + "type": { + "enum": [ + "Bios", + "Board", + "Brightness", + "Chassis", + "CPUUsage", + "Cursor", + "DateTime", + "DE", + "Font", + "Gamepad", + "Host", + "Icons", + "Kernel", + "Locale", + "Media", + "Memory", + "OpenCL", + "OS" + ] + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Battery"] + }, + "dir": { + "title": "The directory where the battery folders are. Standard: /sys/class/power_supply/. Linux only", + "type": "string" + }, + "temp": { + "title": "Detect and display Battery temperature if supported", + "type": "boolean", + "default": false + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Bluetooth"] + }, + "showDisconnected": { + "title": "Set if disconnected bluetooth devices should be printed", + "type": "boolean", + "default": false + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["CPU"] + }, + "temp": { + "title": "Detect and display CPU temperature if supported", + "type": "boolean", + "default": false + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Command"] + }, + "shell": { + "title": "Set the shell program to execute the command text", + "type": "string", + "default": "cmd for Windows, csh for FreeBSD, bash for others" + }, + "text": { + "title": "Set the command text to be executed", + "type": "string" + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "title": "Print a custom string, with or without key", + "properties": { + "type": { + "enum": ["Custom"] + }, + "key": { + "title": "Leave empty not to print the key", + "type": "string", + "default": "*empty*" + }, + "format": { + "title": "Text to print", + "type": "string" + } + }, + "required": ["format"], + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Display"] + }, + "compactType": { + "enum": ["none", "original", "scaled"], + "title": "Set if all displays should be printed in one line", + "default": "none" + }, + "detectName": { + "title": "Set if display name should be detected and printed (if supported)", + "type": "boolean", + "default": false + }, + "preciseRefreshRate": { + "title": "Set if decimal refresh rates should not be rounded into integers when printing", + "type": "boolean", + "default": true + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Disk"] + }, + "folders": { + "type": "string", + "title": "A colon (semicolon on Windows) separated list of folder paths for the disk output", + "default": "\"/:/home\" (\"C:\\\\;D:\\\\ ...\" on Windows)" + }, + "showExternal": { + "type": "boolean", + "title": "Set if external volume should be printed", + "default": true + }, + "showHidden": { + "type": "boolean", + "title": "Set if hidden volumes should be printed", + "default": false + }, + "showSubvolumes": { + "type": "boolean", + "title": "Set if subvolumes should be printed", + "default": false + }, + "showUnknown": { + "type": "boolean", + "title": "Set if unknown (unable to detect sizes) volumes should be printed", + "default": false + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + } + }, + { + "properties": { + "type": { + "enum": ["GPU"] + }, + "temp": { + "title": "Detect and display GPU temperature if supported", + "type": "boolean", + "default": false + }, + "forceVulkan": { + "title": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`", + "type": "boolean", + "default": false + }, + "hideType": { + "title": "Specify the type of GPUs should not be printed", + "enum": ["integrated", "discrete", "none"], + "default": "none" + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["LocalIp"] + }, + "showIpv4": { + "title": "Show IPv4 addresses", + "type": "boolean", + "default": true + }, + "showIpv6": { + "title": "Show IPv6 addresses", + "type": "boolean", + "default": false + }, + "showMac": { + "title": "Show MAC addresses", + "type": "boolean", + "default": false + }, + "showLoop": { + "title": "Show loop back addresses (127.0.0.1)", + "type": "boolean", + "default": false + }, + "compact": { + "title": "Show all IPs in one line", + "type": "boolean", + "default": false + }, + "namePrefix": { + "title": "Show IPs with given name prefix only", + "type": "string" + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["OpenGL"] + }, + "library": { + "title": "Set the OpenGL context creation library to use. Linux only", + "enum": ["auto", "egl", "glx", "osmesa"], + "default": "auto" + }, + "key": { + "type": "string" + }, + "format": { + "type": "string" + } + } + } + ] } ] } From d508dc69dc4d11d42c0cd7d60ba15dda708f6264 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 02:07:34 +0800 Subject: [PATCH 162/493] JsonConfig: update JSON schema --- src/data/json_schema.jsonc | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index 0279f38a6..61de25f6d 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -1,6 +1,13 @@ { "$schema": "http://json-schema.org/schema", + "$defs": { + "colors": { + "type": "string", + "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + } + }, "type": "object", + "title": "JSON config file for fastfetch", "properties": { "logo": { "title": "Fastfetch logo configurations", @@ -33,49 +40,40 @@ "title": "Overwrite a color in the logo", "properties": { "1": { - "type": "string", "title": "Color 1", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "2": { - "type": "string", "title": "Color 2", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "3": { - "type": "string", "title": "Color 3", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "4": { - "type": "string", "title": "Color 4", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "5": { - "type": "string", "title": "Color 5", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "6": { - "type": "string", "title": "Color 6", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "7": { - "type": "string", "title": "Color 7", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "8": { - "type": "string", "title": "Color 8", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "9": { - "type": "string", "title": "Color 9", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" } } }, @@ -235,21 +233,19 @@ "title": "Set the color of the keys and title", "anyOf": [ { - "type": "string", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "title": "Set the both color of the keys and title", + "$ref": "#/$defs/colors" }, { "type": "object", "properties": { "keys": { - "type": "string", "title": "Set the color of the keys", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" }, "title": { - "type": "string", "title": "Set the color of the title", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "$ref": "#/$defs/colors" } } } @@ -427,10 +423,10 @@ { "properties": { "type": { - "enum": ["break", "Colors"], - "additionalProperties": false + "enum": ["Break", "Colors"] } - } + }, + "additionalProperties": false }, { "properties": { @@ -457,9 +453,11 @@ ] }, "key": { + "title": "Key of the module", "type": "string" }, "format": { + "title": "Format of the module", "type": "string" } }, @@ -633,7 +631,8 @@ "format": { "type": "string" } - } + }, + "additionalProperties": false }, { "properties": { @@ -723,7 +722,8 @@ "format": { "type": "string" } - } + }, + "additionalProperties": false } ] } From b8d01755a0230e906a3ed5f40c7c0c666ee31659 Mon Sep 17 00:00:00 2001 From: Sophie L Date: Sun, 18 Jun 2023 02:57:35 +0100 Subject: [PATCH 163/493] chore: typo/grammar fixes (#478) --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7a60115c5..a1d654210 100644 --- a/README.md +++ b/README.md @@ -14,20 +14,20 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/ ## Customization -With customization and speed being two competing goals, this project actually builds two executables. +With customization and speed being two competing goals, this project actually builds two executables: -* The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `$XDG_CONFIG_HOME/fastfetch/config.conf`. To view the available options run `fastfetch --help`. -* The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). +* The main one is `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent by modifying `$XDG_CONFIG_HOME/fastfetch/config.conf`. To view the available options, run `fastfetch --help`. +* The second executable is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). -At the moment the performance difference is measurable, but too small to be human recognizable. But the leap will get bigger with more and more options coming, and on slow machines this might actually make a difference. +Currently, the performance difference is measurable, but too small to be recognizable by humans. But with more options planned, the leap will get bigger over time and on slow machines this might actually make a difference. There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config `. They may also serve as a good example for format arguments. -Logos can be heavily customized to. See the [logo documentation](doc/logo.md) for more information. +Logos can be heavily customized too; see the [logo documentation](doc/logo.md) for more information. ## Dependencies -Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions. +Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most Linux distributions. The following libraries are used if present at runtime: @@ -75,7 +75,7 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, as fastfetch for Windows targets [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library, [it must be installed manually](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) as UCRT is only pre-installed in Windows 10 and later. -For the image logo, only chafa is supported due to [the design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not built by default due to the massive dependencies of imagemagick. You must built it yourself. +For the image logo, only chafa is supported due to [a design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not included by default due to the massive dependencies of imagemagick. You must built it yourself. ### Android From ea1e1b245d61056c6091ed9570900105d7056022 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 10:50:09 +0800 Subject: [PATCH 164/493] Chore: update issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 44 ++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0fb775db3..6835a92b1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,26 +8,30 @@ assignees: '' --- # General description of bug: + +[ ] The issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/) -# Often helpful questions: -* Does the issue occur across multiple terminal emulators? [Y/N] -* Does the issue occur across multiple shells? (bash, zsh, fish, etc) [Y/N] +# Often helpful information: Output of `fastfetch --version`: ``` //paste here ``` -Output of `fastfetch --load-config devinfo`: +The content of the configuration file you use (if any) ``` //paste here ``` -Output of `fastfetch --load-config devinfo-verbose`: +Output of `fastfetch --load-config devinfo-verbose --show-errors --multithreading false --disable-linewrap false`: + ``` //paste here ``` @@ -37,7 +41,29 @@ Output of `fastfetch --list-features`: //paste here ``` - +## If fastfatch crashed + +Paste the stacktrace here. You may get it with: + +``` +$ gdb /path/to/fastfetch +$ run +$ bt +``` + +If you are able to identify which module crashed, the strace can be helpful too + +``` +$ strace /path/to/fastfetch --multithreading false --structure {MODULE} --pipe +``` + +If you cannot do the instructions above, please upload the core dump file: + +## If my image logo didn't show / work + + + +* The image protocol you used: +* The terminal you used: +* Upload the image file here, or paste the image URL: +* Does it work with `--logo-width {WIDTH} --logo-height {HEIGHT}`? From 2998b1f02ec3ee70a4e45451d030506228cc23bf Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 11:14:50 +0800 Subject: [PATCH 165/493] Chore: remove `--*-error-format` --- CHANGELOG.md | 1 + src/common/jsonconfig.c | 5 ----- src/common/option.c | 7 ------- src/common/option.h | 1 - src/common/printing.c | 35 ++++++++++++----------------------- src/common/printing.h | 2 +- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8835339..15907a3a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This release introduces a new configuration file format: JSON config Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. * Remove `--shell-version` and `--terminal-version`. They are always enabled +* Remove `--*-error-format` Features: * Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 1b1aeffcc..9defa2572 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -21,11 +21,6 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } - else if(strcasecmp(key, "error") == 0) - { - ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); - return true; - } return false; } diff --git a/src/common/option.c b/src/common/option.c index f9bdbcff6..cc58fc5de 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -38,11 +38,6 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const ffOptionParseString(argumentKey, value, &result->outputFormat); return true; } - else if(strcasecmp(subKey, "error") == 0) - { - ffOptionParseString(argumentKey, value, &result->errorFormat); - return true; - } return false; } @@ -138,12 +133,10 @@ void ffOptionInitModuleArg(FFModuleArgs* args) { ffStrbufInit(&args->key); ffStrbufInit(&args->outputFormat); - ffStrbufInit(&args->errorFormat); } void ffOptionDestroyModuleArg(FFModuleArgs* args) { ffStrbufDestroy(&args->key); ffStrbufDestroy(&args->outputFormat); - ffStrbufDestroy(&args->errorFormat); } diff --git a/src/common/option.h b/src/common/option.h index e0ca7feca..992417430 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -6,7 +6,6 @@ typedef struct FFModuleArgs { FFstrbuf key; FFstrbuf outputFormat; - FFstrbuf errorFormat; } FFModuleArgs; typedef struct FFKeyValuePair diff --git a/src/common/printing.c b/src/common/printing.c index 7ea0ecb03..896ca7a66 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -60,40 +60,29 @@ void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleI ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->outputFormat, numArgs, arguments); } -static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, va_list arguments) +static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, va_list arguments) { - bool hasCustomErrorFormat = customErrorFormat != NULL && customErrorFormat->length > 0; - if(!hasCustomErrorFormat && !instance->config.showErrors) + if(!instance->config.showErrors) return; - if(hasCustomErrorFormat) - { - FF_STRBUF_AUTO_DESTROY error = ffStrbufCreateVF(message, arguments); - ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, 1, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &error} - }); - } - else - { - ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat); + ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat); - if(!instance->config.pipe) - fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); + if(!instance->config.pipe) + fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); - vprintf(message, arguments); + vprintf(message, arguments); - if(!instance->config.pipe) - fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); + if(!instance->config.pipe) + fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); - putchar('\n'); - } + putchar('\n'); } -void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...) +void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, ...) { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, message, arguments); + printError(instance, moduleName, moduleIndex, customKeyFormat, message, arguments); va_end(arguments); } @@ -101,7 +90,7 @@ void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIn { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->errorFormat, message, arguments); + printError(instance, moduleName, moduleIndex, &moduleArgs->key, message, arguments); va_end(arguments); } diff --git a/src/common/printing.h b/src/common/printing.h index 9a734634b..ef189d197 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -9,7 +9,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat); void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments); -FF_C_PRINTF(6, 7) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...); +FF_C_PRINTF(5, 6) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, ...); FF_C_PRINTF(5, 6) void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); From 36a2fee9d5da84cef3fe9ad67bccc940b7e56116 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 12:32:47 +0800 Subject: [PATCH 166/493] Global: support `--*-key-color` --- CHANGELOG.md | 1 + src/common/jsonconfig.c | 5 ++ src/common/option.c | 12 ++++ src/common/option.h | 1 + src/common/printing.c | 23 ++++--- src/common/printing.h | 6 +- src/data/json_schema.jsonc | 88 ++++++++++++++++++------- src/modules/battery/battery.c | 2 +- src/modules/bios/bios.c | 2 +- src/modules/bluetooth/bluetooth.c | 2 +- src/modules/board/board.c | 2 +- src/modules/brightness/brightness.c | 4 +- src/modules/chassis/chassis.c | 2 +- src/modules/command/command.c | 2 +- src/modules/cpu/cpu.c | 2 +- src/modules/cpuusage/cpuusage.c | 2 +- src/modules/cursor/cursor.c | 2 +- src/modules/custom/custom.c | 2 +- src/modules/datetime/datetime.c | 2 +- src/modules/de/de.c | 2 +- src/modules/disk/disk.c | 4 +- src/modules/display/display.c | 6 +- src/modules/font/font.c | 2 +- src/modules/gamepad/gamepad.c | 2 +- src/modules/gpu/gpu.c | 2 +- src/modules/host/host.c | 2 +- src/modules/icons/icons.c | 2 +- src/modules/kernel/kernel.c | 2 +- src/modules/locale/locale.c | 2 +- src/modules/localip/localip.c | 6 +- src/modules/media/media.c | 2 +- src/modules/memory/memory.c | 2 +- src/modules/opencl/opencl.c | 2 +- src/modules/opengl/opengl.c | 2 +- src/modules/os/os.c | 2 +- src/modules/packages/packages.c | 2 +- src/modules/player/player.c | 2 +- src/modules/poweradapter/poweradapter.c | 2 +- src/modules/processes/processes.c | 2 +- src/modules/publicip/publicip.c | 2 +- src/modules/shell/shell.c | 2 +- src/modules/sound/sound.c | 2 +- src/modules/swap/swap.c | 2 +- src/modules/terminal/terminal.c | 2 +- src/modules/terminalfont/terminalfont.c | 2 +- src/modules/theme/theme.c | 2 +- src/modules/uptime/uptime.c | 2 +- src/modules/users/users.c | 2 +- src/modules/vulkan/vulkan.c | 2 +- src/modules/wallpaper/wallpaper.c | 2 +- src/modules/weather/weather.c | 2 +- src/modules/wifi/wifi.c | 2 +- src/modules/wm/wm.c | 2 +- src/modules/wmtheme/wmtheme.c | 2 +- 54 files changed, 154 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15907a3a3..5a843e906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Features: * Support QTerminal version & terminal font detection * Support MATE Terminal version & terminal font detection * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. +* Support `--*-key-color` option to change the key color of specified module # 1.11.3 diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 9defa2572..cd4dbdcf6 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -16,6 +16,11 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } + else if(strcasecmp(key, "keyColor") == 0) + { + ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor); + return true; + } else if(strcasecmp(key, "format") == 0) { ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); diff --git a/src/common/option.c b/src/common/option.c index cc58fc5de..6b8496e3d 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -33,6 +33,16 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const ffOptionParseString(argumentKey, value, &result->key); return true; } + else if(strcasecmp(subKey, "key-color") == 0) + { + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(477); + } + ffOptionParseColor(value, &result->keyColor); + return true; + } else if(strcasecmp(subKey, "format") == 0) { ffOptionParseString(argumentKey, value, &result->outputFormat); @@ -132,11 +142,13 @@ void ffOptionParseColor(const char* value, FFstrbuf* buffer) void ffOptionInitModuleArg(FFModuleArgs* args) { ffStrbufInit(&args->key); + ffStrbufInit(&args->keyColor); ffStrbufInit(&args->outputFormat); } void ffOptionDestroyModuleArg(FFModuleArgs* args) { ffStrbufDestroy(&args->key); + ffStrbufDestroy(&args->keyColor); ffStrbufDestroy(&args->outputFormat); } diff --git a/src/common/option.h b/src/common/option.h index 992417430..07aded18d 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -5,6 +5,7 @@ typedef struct FFModuleArgs { FFstrbuf key; + FFstrbuf keyColor; FFstrbuf outputFormat; } FFModuleArgs; diff --git a/src/common/printing.c b/src/common/printing.c index 896ca7a66..97aacb62b 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -2,7 +2,7 @@ #include "common/printing.h" #include "util/textModifier.h" -void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat) +void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor) { ffLogoPrintLine(instance); @@ -13,7 +13,10 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod if(!instance->config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance->config.colorKeys); + if(customKeyColor != NULL && customKeyColor->length > 0) + ffPrintColor(customKeyColor); + else + ffPrintColor(&instance->config.colorKeys); } //NULL check is required for modules with custom keys, e.g. disk with the folder path @@ -42,14 +45,14 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); } -void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) +void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(256); ffParseFormatString(&buffer, format, numArgs, arguments); if(buffer.length > 0) { - ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat); + ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor); ffPrintUserString(buffer.chars); putchar('\n'); } @@ -57,15 +60,15 @@ void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t m void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) { - ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->outputFormat, numArgs, arguments); + ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, &moduleArgs->outputFormat, numArgs, arguments); } -static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, va_list arguments) +static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, va_list arguments) { if(!instance->config.showErrors) return; - ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat); + ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor); if(!instance->config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); @@ -78,11 +81,11 @@ static void printError(FFinstance* instance, const char* moduleName, uint8_t mod putchar('\n'); } -void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, ...) +void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...) { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, customKeyFormat, message, arguments); + printError(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor, message, arguments); va_end(arguments); } @@ -90,7 +93,7 @@ void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIn { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, &moduleArgs->key, message, arguments); + printError(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, message, arguments); va_end(arguments); } diff --git a/src/common/printing.h b/src/common/printing.h index ef189d197..801ef7e8e 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -6,10 +6,10 @@ #include "fastfetch.h" #include "common/format.h" -void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat); -void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); +void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor); +void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments); -FF_C_PRINTF(5, 6) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const char* message, ...); +FF_C_PRINTF(6, 7) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...); FF_C_PRINTF(5, 6) void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index 61de25f6d..28463cf5c 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -4,6 +4,19 @@ "colors": { "type": "string", "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + }, + "key": { + "title": "Key of the module", + "type": "string" + }, + "keyColor": { + "title": "Color of the module key", + "$ref": "#/$defs/colors", + "default": "Use display.color.keys" + }, + "format": { + "title": "Format of the module", + "type": "string" } }, "type": "object", @@ -453,12 +466,13 @@ ] }, "key": { - "title": "Key of the module", - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "title": "Format of the module", - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -478,10 +492,13 @@ "default": false }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -497,10 +514,13 @@ "default": false }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -516,10 +536,13 @@ "default": false }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -539,10 +562,13 @@ "type": "string" }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -558,6 +584,9 @@ "type": "string", "default": "*empty*" }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, "format": { "title": "Text to print", "type": "string" @@ -587,10 +616,13 @@ "default": true }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -626,10 +658,13 @@ "default": false }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -655,10 +690,13 @@ "default": "none" }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -698,10 +736,13 @@ "type": "string" }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false @@ -717,10 +758,13 @@ "default": "auto" }, "key": { - "type": "string" + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" }, "format": { - "type": "string" + "$ref": "#/$defs/format" } }, "additionalProperties": false diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index ea82b64da..1c962f325 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -10,7 +10,7 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter { if(instance->config.battery.moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); bool showStatus = !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index b898217b3..1eac53bac 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -29,7 +29,7 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(bios.biosRelease.chars); } else diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 744bc549b..aabed5444 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -9,7 +9,7 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&device->name, stdout); if(device->battery > 0) diff --git a/src/modules/board/board.c b/src/modules/board/board.c index a984e9427..c8913c90d 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -24,7 +24,7 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(result.boardName.chars); } else diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 8dde00757..9dcd77971 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -40,12 +40,12 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); + ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); printf("%.0f%%\n", item->value); } else { - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &item->value}, {FF_FORMAT_ARG_TYPE_FLOAT, &item->name} }); diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index ac6a41354..65b3282fc 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -28,7 +28,7 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateCopy(&result.chassisType); diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 69d0729aa..8e986ad3e 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -29,7 +29,7 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) return; } - ffPrintLogoAndKey(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index c8cc7a452..71e016aa8 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -28,7 +28,7 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(cpu.name.length > 0) ffStrbufWriteTo(&cpu.name, stdout); diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index 9df218d8f..bef65706c 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -20,7 +20,7 @@ void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 095dc7dba..61be4a105 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -27,7 +27,7 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.theme, stdout); if(result.size.length > 0) diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index ce57e5c5e..e81615881 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -11,7 +11,7 @@ void ffPrintCustom(FFinstance* instance, FFCustomOptions* options) return; } - ffPrintLogoAndKey(instance, options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffPrintUserString(options->moduleArgs.outputFormat.chars); puts(FASTFETCH_TEXT_MODIFIER_RESET); } diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 03ac5b92d..508b0bdfa 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -42,7 +42,7 @@ void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options) } const FFDateTimeResult* datetime = ffDetectDateTime(instance); - ffPrintLogoAndKey(instance, FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); //yyyy-MM-dd HH:mm:ss printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); diff --git a/src/modules/de/de.c b/src/modules/de/de.c index b0f709a29..806b65f85 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -17,7 +17,7 @@ void ffPrintDE(FFinstance* instance, FFDEOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->dePrettyName, stdout); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 68b1e249d..2824f907d 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -33,7 +33,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); + ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); @@ -78,7 +78,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage}, diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 354b0061d..e59435dab 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -22,7 +22,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) if (options->compactType != FF_DISPLAY_COMPACT_TYPE_NONE) { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); int index = 0; FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays) @@ -67,11 +67,11 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_STRING, displayType}, }); } - ffPrintLogoAndKey(instance, key.chars, 0, NULL); + ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); } else { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); } printf("%ix%i", result->width, result->height); diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 59736afb8..cd3875c10 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -22,7 +22,7 @@ void ffPrintFont(FFinstance* instance, FFFontOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&font.display, stdout); } else diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 86edbb683..1a79a624d 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -9,7 +9,7 @@ static void printDevice(FFinstance* instance, FFGamepadOptions* options, const F { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&device->name, stdout); } else diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 41a8ff682..2fff072a6 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -14,7 +14,7 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(gpu->vendor.length + 1 + gpu->name.length); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index b6c7f5b73..f306bdf1a 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -24,7 +24,7 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index b917e6857..c4fb36c0b 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -18,7 +18,7 @@ void ffPrintIcons(FFinstance* instance, FFIconsOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&icons, stdout); } else diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 9cce738ea..cf824efac 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -8,7 +8,7 @@ void ffPrintKernel(FFinstance* instance, FFKernelOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout); #ifdef _WIN32 diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index d8d7abe72..a849fbd6f 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -18,7 +18,7 @@ void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&locale, stdout); } else diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 06dc74189..011020bf9 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -75,7 +75,7 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT) { - ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { @@ -93,13 +93,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) formatKey(options, ip, &key); if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL); + ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); printIp(ip); putchar('\n'); } else { - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, diff --git a/src/modules/media/media.c b/src/modules/media/media.c index ac5ce83b3..a841773fa 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -79,7 +79,7 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options) if(artistInSongTitle(&songPretty, &artistPretty)) ffStrbufClear(&artistPretty); - ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(artistPretty.length > 0) { diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 3e175eea6..9d4133694 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -30,7 +30,7 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if (storage.bytesTotal == 0) puts("Disabled"); else diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 469b59cb2..5b52cd230 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -20,7 +20,7 @@ void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&opencl.version, stdout); } else diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 46924ceaa..27f5f32a4 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -22,7 +22,7 @@ void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(result.version.chars); } else diff --git a/src/modules/os/os.c b/src/modules/os/os.c index f057aa762..0d4e67554 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -114,7 +114,7 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) else buildOutputDefault(instance, os, &result); - ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 6f369fa42..c6fd4c9dc 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -20,7 +20,7 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); #define FF_PRINT_PACKAGE_NAME(var, name) \ if(counts.var > 0) \ diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 6c0644a85..1b94c3f04 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -58,7 +58,7 @@ void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&playerPretty, stdout); } else diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 3c858942c..f176d13f1 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -31,7 +31,7 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(result->name.length > 0) puts(result->name.chars); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index c09792537..4aa09318e 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -18,7 +18,7 @@ void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); printf("%u\n", numProcesses); } diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index 464acb5c4..b873b7e71 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -54,7 +54,7 @@ void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options) if (options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index c6efb899c..343932ad9 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -17,7 +17,7 @@ void ffPrintShell(FFinstance* instance, FFShellOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->shellPrettyName, stdout); if(result->shellVersion.length > 0) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index c5deab69a..9756cdf86 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -9,7 +9,7 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&device->name, stdout); if(device->volume != FF_SOUND_VOLUME_UNKNOWN) diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index af788bbe8..92c7a2837 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -30,7 +30,7 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if (storage.bytesTotal == 0) puts("Disabled"); else diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 4d7db5b46..7dfbbe3c9 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -19,7 +19,7 @@ void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(result->terminalVersion.length) printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 8c56d71c2..1ac69048d 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -20,7 +20,7 @@ void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&terminalFont.font.pretty, stdout); } else diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 63d16ba56..9bd382e4e 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -18,7 +18,7 @@ void ffPrintTheme(FFinstance* instance, FFThemeOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&theme, stdout); } else diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index 5218c7a6a..1cd92b1ba 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -24,7 +24,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(days == 0 && hours == 0 && minutes == 0) { diff --git a/src/modules/users/users.c b/src/modules/users/users.c index b3ed8389a..492ecbb61 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -31,7 +31,7 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(result.chars); } else diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index c9786cf2a..276a3f70f 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -17,7 +17,7 @@ void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(vulkan->apiVersion.length > 0) { diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 936442c6c..ccc8c95e5 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -18,7 +18,7 @@ void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&wallpaper, stdout); } else diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index ae6c73f3b..3d7637a7f 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -38,7 +38,7 @@ void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 2511a8857..380457937 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -28,7 +28,7 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(item->conn.ssid.length) { ffStrbufWriteTo(&item->conn.ssid, stdout); diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 4e04b0c71..7aa1c534f 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -17,7 +17,7 @@ void ffPrintWM(FFinstance* instance, FFWMOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->wmPrettyName, stdout); diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index d0273975a..8f1ab4441 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -13,7 +13,7 @@ void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key); + ffPrintLogoAndKey(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(themeOrError.chars); } else From fbbd549db23f28e8e1b5176a9d5c3452a81d7ed1 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 12:49:53 +0800 Subject: [PATCH 167/493] Fastfetch: set `pipe=true` automatically if stdout is not a tty --- src/common/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index 281bbbdf4..29a2933c2 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -44,11 +44,11 @@ static void defaultConfig(FFinstance* instance) instance->config.showErrors = false; instance->config.recache = false; instance->config.allowSlowOperations = false; - instance->config.disableLinewrap = true; - instance->config.hideCursor = true; + instance->config.pipe = !isatty(STDOUT_FILENO); + instance->config.disableLinewrap = !instance->config.pipe; + instance->config.hideCursor = !instance->config.pipe; instance->config.escapeBedrock = true; instance->config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; - instance->config.pipe = false; instance->config.multithreading = true; instance->config.stat = false; instance->config.noBuffer = false; From afe8d009361092d145abde5d43e0e1ed640c44f1 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 12:51:58 +0800 Subject: [PATCH 168/493] Users: revert 9b9d03947d97dc4459f3581a15899047c5740557 --- src/detection/users/users_linux.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index e2fce1751..3b4963a14 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -11,8 +11,6 @@ #define getutxent getutent #endif -#pragma GCC diagnostic ignored "-Wstringop-overread" - void ffDetectUsers(FFlist* users, FFstrbuf* error) { struct utmpx* n = NULL; @@ -26,7 +24,7 @@ next: FF_LIST_FOR_EACH(FFstrbuf, user, *users) { - if(ffStrbufCompS(user, n->ut_user) == 0) + if(ffStrbufEqualS(user, n->ut_user)) goto next; } From 35e57741d3f8fcce409daf7a8cc1dc348c6ba72c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 12:58:27 +0800 Subject: [PATCH 169/493] Global: document `---key-color` --- completions/bash | 80 +++++++++++++++++------------------ src/data/config_user.txt | 91 +++++++++++++++++++--------------------- src/data/help.txt | 14 +++---- 3 files changed, 90 insertions(+), 95 deletions(-) diff --git a/completions/bash b/completions/bash index 3a30c9b30..67b2269bc 100644 --- a/completions/bash +++ b/completions/bash @@ -239,124 +239,124 @@ __fastfetch_completion() "--weather-timeout" "--os-key" "--os-format" - "--os-error" + "--os-key-color" "--host-key" "--host-format" - "--host-error" + "--host-key-color" "--kernel-key" "--kernel-format" - "--kernel-error" + "--kernel-key-color" "--uptime-key" "--uptime-format" - "--uptime-error" + "--uptime-key-color" "--processes-key" "--processes-format" - "--processes-error" + "--processes-key-color" "--packages-key" "--packages-format" - "--packages-error" + "--packages-key-color" "--shell-key" "--shell-format" - "--shell-error" + "--shell-key-color" "--display-key" "--display-format" - "--display-error" + "--display-key-color" "--de-key" "--de-format" - "--de-error" + "--de-key-color" "--wm-key" "--wm-format" - "--wm-error" + "--wm-key-color" "--wm-theme-key" "--wm-theme-format" - "--wm-theme-error" + "--wm-theme-key-color" "--theme-key" "--theme-format" - "--theme-error" + "--theme-key-color" "--icons-key" "--icons-format" - "--icons-error" + "--icons-key-color" "--font-key" "--font-format" - "--font-error" + "--font-key-color" "--cursor-key" "--cursor-format" - "--cursor-error" + "--cursor-key-color" "--terminal-key" "--terminal-format" - "--terminal-error" + "--terminal-key-color" "--terminal-font-key" "--terminal-font-format" - "--terminal-font-error" + "--terminal-font-key-color" "--cpu-key" "--cpu-format" - "--cpu-error" + "--cpu-key-color" "--cpu-useage-key" "--cpu-useage-format" - "--cpu-useage-error" + "--cpu-useage-key-color" "--gpu-key" "--gpu-format" - "--gpu-error" + "--gpu-key-color" "--memory-key" "--memory-format" - "--memory-error" + "--memory-key-color" "--swap-key" "--swap-format" - "--swap-error" + "--swap-key-color" "--disk-key" "--disk-format" - "--disk-error" + "--disk-key-color" "--battery-key" "--battery-format" - "--battery-error" + "--battery-key-color" "--poweradapter-key" "--poweradapter-format" - "--poweradapter-error" + "--poweradapter-key-color" "--locale-key" "--locale-format" - "--locale-error" + "--locale-key-color" "--localip-key" "--localip-format" - "--localip-error" + "--localip-key-color" "--publicip-key" "--publicip-format" - "--publicip-error" + "--publicip-key-color" "--wifi-key" "--wifi-format" - "--wifi-error" + "--wifi-key-color" "--weather-key" "--weather-format" - "--weather-error" + "--weather-key-color" "--player-key" "--player-format" - "--player-error" + "--player-key-color" "--media-key" "--media-format" - "--media-error" + "--media-key-color" "--datetime-key" "--datetime-format" - "--datetime-error" + "--datetime-key-color" "--date-key" "--date-format" - "--date-error" + "--date-key-color" "--time-key" "--time-format" - "--time-error" + "--time-key-color" "--vulkan-key" "--vulkan-format" - "--vulkan-error" + "--vulkan-key-color" "--opengl-key" "--opengl-format" - "--opengl-error" + "--opengl-key-color" "--opencl-key" "--opencl-format" - "--opencl-error" + "--opencl-key-color" "--users-key" "--users-format" - "--users-error" + "--users-key-color" "--bluetooth-key" "--bluetooth-format" - "--bluetooth-error" + "--bluetooth-key-color" ) local FF_OPTIONS_PATH=( diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 91902dedd..a05ca7ad8 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -379,53 +379,50 @@ #--gamepad-format #--wallpaper-format -# Error options: -# Sets the format string to use if an error occured -# For information on format strings, see "fastfetch --help format". -# Each of them take the error as first and only argument. -# If one of them is set, the module will appear, even if --show-errors is not given. -#--os-error -#--host-error -#--chassis-error -#--kernel-error -#--uptime-error -#--processes-error -#--packages-error -#--shell-error -#--display-error -#--brightness-error -#--de-error -#--wm-error -#--wm-theme-error -#--theme-error -#--icons-error -#--font-error -#--cursor-error -#--terminal-error -#--terminal-font-error -#--cpu-error -#--cpu-usage-error -#--gpu-error -#--memory-error -#--swap-error -#--disk-error -#--battery-error -#--poweradapter-error -#--locale-error -#--localip-error -#--publicip-error -#--weather-error -#--player-error -#--media-error -#--datetime-error -#--vulkan-error -#--opengl-error -#--opencl-error -#--users-error -#--bluetooth-error -#--sound-error -#--gamepad-error -#--wallpaper-error +# Key color options: +# Overrides the global `--color-keys` for one specified module +#--os-key-color +#--host-key-color +#--chassis-key-color +#--kernel-key-color +#--uptime-key-color +#--processes-key-color +#--packages-key-color +#--shell-key-color +#--display-key-color +#--brightness-key-color +#--de-key-color +#--wm-key-color +#--wm-theme-key-color +#--theme-key-color +#--icons-key-color +#--font-key-color +#--cursor-key-color +#--terminal-key-color +#--terminal-font-key-color +#--cpu-key-color +#--cpu-usage-key-color +#--gpu-key-color +#--memory-key-color +#--swap-key-color +#--disk-key-color +#--battery-key-color +#--poweradapter-key-color +#--locale-key-color +#--localip-key-color +#--publicip-key-color +#--weather-key-color +#--player-key-color +#--media-key-color +#--datetime-key-color +#--vulkan-key-color +#--opengl-key-color +#--opencl-key-color +#--users-key-color +#--bluetooth-key-color +#--sound-key-color +#--gamepad-key-color +#--wallpaper-key-color # Library options: # Sets an user specific path to a library to load. diff --git a/src/data/help.txt b/src/data/help.txt index 6d7bd3f45..bad9e1def 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -67,16 +67,14 @@ Display options: --no-buffer : Set if the stdout application buffer should be disabled. Default is false General module options: - ---format : Set the format string to use for each specific module. - To see how a format string works, use fastfetch --help format. - To see help about a specific format string, use fastfetch --help -format. + ---format : Set the format string to use for each specific module. + To see how a format string works, use fastfetch --help format. + To see help about a specific format string, use fastfetch --help -format. - ---key : Set the key to use for each specific module. - For modules which print multiple lines, the string is parsed as a format string with the index as first character. + ---key : Set the key to use for each specific module. + For modules which print multiple lines, the string is parsed as a format string with the index as first character. - ---error : Set the error format string to use for each specific module. - The error is given as the first and only argument. - Setting this for a module will cause it to appear, even if --show-errors is not given. + ---key-color : Override the global `--color-keys` option for each specific module. Library options: Set the path of a library to load --lib-PCI From ba45229db048775ee5c5c0a08f95cf7b57dbffed Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 14:00:24 +0800 Subject: [PATCH 170/493] Colors: support `--colors-symbol` --- CHANGELOG.md | 1 + src/common/init.c | 2 + src/data/help.txt | 1 + src/data/json_schema.jsonc | 22 ++++++- src/fastfetch.c | 2 +- src/fastfetch.h | 1 + src/flashfetch.c | 2 +- src/modules/colors/colors.c | 118 +++++++++++++++++++++++++++++----- src/modules/colors/colors.h | 4 +- src/modules/colors/option.h | 21 ++++++ src/modules/display/display.c | 1 + src/modules/options.h | 1 + 12 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 src/modules/colors/option.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a843e906..11d538134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Features: * Support MATE Terminal version & terminal font detection * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module +* Support `--colors-symbol` # 1.11.3 diff --git a/src/common/init.c b/src/common/init.c index 29a2933c2..2d18c828d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -102,6 +102,7 @@ static void defaultConfig(FFinstance* instance) ffInitSoundOptions(&instance->config.sound); ffInitSeparatorOptions(&instance->config.separator); ffInitGamepadOptions(&instance->config.gamepad); + ffInitColorsOptions(&instance->config.colors); ffStrbufInit(&instance->config.libPCI); ffStrbufInit(&instance->config.libVulkan); @@ -306,6 +307,7 @@ static void destroyConfig(FFinstance* instance) ffDestroySeparatorOptions(&instance->config.separator); ffDestroySoundOptions(&instance->config.sound); ffDestroyGamepadOptions(&instance->config.gamepad); + ffDestroyColorsOptions(&instance->config.colors); ffStrbufDestroy(&instance->config.libPCI); ffStrbufDestroy(&instance->config.libVulkan); diff --git a/src/data/help.txt b/src/data/help.txt index bad9e1def..5feb254b6 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -136,6 +136,7 @@ Module specific options: --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others --command-key : Set the module key to display --command-text : Set the command text to be executed + --colors-symbol : Set the symbol to be printed by Colors module. Default is block Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index 28463cf5c..19ec8ef4a 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -436,7 +436,7 @@ { "properties": { "type": { - "enum": ["Break", "Colors"] + "enum": ["Break"] } }, "additionalProperties": false @@ -547,6 +547,26 @@ }, "additionalProperties": false }, + { + "properties": { + "type": { + "enum": ["Colors"] + }, + "symbol": { + "title": "Set the symbol to use", + "type": "string", + "enum": [ + "block", + "circle", + "diamond", + "triangle", + "square", + "star" + ], + "default": "blocks" + } + } + }, { "properties": { "type": { diff --git a/src/fastfetch.c b/src/fastfetch.c index d4e7a1afd..758cee228 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1153,7 +1153,7 @@ static void parseStructureCommand(FFinstance* instance, const char* line) else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) ffPrintDateTime(instance, &instance->config.dateTime); else if(strcasecmp(line, FF_COLORS_MODULE_NAME) == 0) - ffPrintColors(instance); + ffPrintColors(instance, &instance->config.colors); else if(strcasecmp(line, FF_VULKAN_MODULE_NAME) == 0) ffPrintVulkan(instance, &instance->config.vulkan); else if(strcasecmp(line, FF_OPENGL_MODULE_NAME) == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 0ecbcd12a..f95d0fc36 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -104,6 +104,7 @@ typedef struct FFconfig FFSeparatorOptions separator; FFSoundOptions sound; FFGamepadOptions gamepad; + FFColorsOptions colors; FFstrbuf libPCI; FFstrbuf libVulkan; diff --git a/src/flashfetch.c b/src/flashfetch.c index d09a7c2f4..b7b18fc9f 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -69,7 +69,7 @@ int main(int argc, char** argv) //ffPrintSound(&instance, &instance.config.sound); //ffPrintGamepad(&instance); ffPrintBreak(&instance); - ffPrintColors(&instance); + ffPrintColors(&instance, &instance.config.colors); ffFinish(&instance); ffDestroyInstance(&instance); diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 54b7a0d1d..07bcf6728 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -3,34 +3,120 @@ #include "util/textModifier.h" #include "modules/colors/colors.h" -void ffPrintColors(FFinstance* instance) +void ffPrintColors(FFinstance* instance, FFColorsOptions* options) { if(instance->config.pipe) return; ffLogoPrintLine(instance); - // 4%d: Set the background color - // 3%d: Set the foreground color - for(uint8_t i = 0; i < 8; i++) - printf("\033[4%d;3%dm███", i, i); + if (options->symbol == FF_COLORS_SYMBOL_BLOCK) + { + // 4%d: Set the background color + // 3%d: Set the foreground color + for(uint8_t i = 0; i < 8; i++) + printf("\033[4%d;3%dm███", i, i); - puts(FASTFETCH_TEXT_MODIFIER_RESET); + puts(FASTFETCH_TEXT_MODIFIER_RESET); - ffLogoPrintLine(instance); + ffLogoPrintLine(instance); - // 1: Set everything to bolt. This causes normal colors on some systems to be bright. - // 4%d: Set the backgound to the not bright color - // 3%d: Set the foreground to the not bright color - // 10%d: Set the background to the bright color - // 9%d: Set the foreground to the bright color - for(uint8_t i = 0; i < 8; i++) - printf("\033[1;4%d;3%d;10%d;9%dm███", i, i, i, i); + // 1: Set everything to bolt. This causes normal colors on some systems to be bright. + // 4%d: Set the backgound to the not bright color + // 3%d: Set the foreground to the not bright color + // 10%d: Set the background to the bright color + // 9%d: Set the foreground to the bright color + for(uint8_t i = 0; i < 8; i++) + printf("\033[1;4%d;3%d;10%d;9%dm███", i, i, i, i); + } + else + { + const char* symbol; + switch (options->symbol) + { + case FF_COLORS_SYMBOL_CIRCLE: symbol = "●"; break; + case FF_COLORS_SYMBOL_DIAMOND: symbol = "◆"; break; + case FF_COLORS_SYMBOL_TRIANGLE: symbol = "▲"; break; + case FF_COLORS_SYMBOL_SQUARE: symbol = "■"; break; + case FF_COLORS_SYMBOL_STAR: symbol = "★"; break; + default: symbol = "███"; break; + } + for (int i = 8; i >= 1; --i) + printf("\e[3%dm%s ", i, symbol); + } puts(FASTFETCH_TEXT_MODIFIER_RESET); } -void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module) +void ffInitColorsOptions(FFColorsOptions* options) { - return ffPrintColors(instance); + options->moduleName = FF_COLORS_MODULE_NAME; + options->symbol = FF_COLORS_SYMBOL_BLOCK; +} + +bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_COLORS_MODULE_NAME); + if (!subKey) return false; + + if (strcasecmp(subKey, "symbol") == 0) + { + options->symbol = (FFColorssymbol) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "block", FF_COLORS_SYMBOL_BLOCK }, + { "circle", FF_COLORS_SYMBOL_CIRCLE }, + { "diamond", FF_COLORS_SYMBOL_DIAMOND }, + { "triangle", FF_COLORS_SYMBOL_TRIANGLE }, + { "square", FF_COLORS_SYMBOL_SQUARE }, + { "star", FF_COLORS_SYMBOL_STAR }, + {}, + }); + return true; + } + + return false; +} + +void ffDestroyColorsOptions(FF_MAYBE_UNUSED FFColorsOptions* options) +{ +} + +void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) +{ + FFColorsOptions __attribute__((__cleanup__(ffDestroyColorsOptions))) options; + ffInitColorsOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(strcasecmp(key, "type") == 0) + continue; + + if (strcasecmp(key, "symbol") == 0) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "block", FF_COLORS_SYMBOL_BLOCK }, + { "circle", FF_COLORS_SYMBOL_CIRCLE }, + { "diamond", FF_COLORS_SYMBOL_DIAMOND }, + { "triangle", FF_COLORS_SYMBOL_TRIANGLE }, + { "square", FF_COLORS_SYMBOL_SQUARE }, + { "star", FF_COLORS_SYMBOL_STAR }, + {}, + }); + if (error) + ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error); + else + options.symbol = (FFColorssymbol) value; + continue; + } + + ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + } + } + + ffPrintColors(instance, &options); } diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index 990ae4348..7ab1a5efd 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -4,5 +4,7 @@ #define FF_COLORS_MODULE_NAME "Colors" -void ffPrintColors(FFinstance* instance); +void ffPrintColors(FFinstance* instance, FFColorsOptions* options); +void ffInitColorsOptions(FFColorsOptions* options); +void ffDestroyColorsOptions(FFColorsOptions* options); void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/colors/option.h b/src/modules/colors/option.h new file mode 100644 index 000000000..4e2e0b2d9 --- /dev/null +++ b/src/modules/colors/option.h @@ -0,0 +1,21 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef enum FFColorssymbol +{ + FF_COLORS_SYMBOL_BLOCK, + FF_COLORS_SYMBOL_CIRCLE, + FF_COLORS_SYMBOL_DIAMOND, + FF_COLORS_SYMBOL_SQUARE, + FF_COLORS_SYMBOL_TRIANGLE, + FF_COLORS_SYMBOL_STAR, +} FFColorssymbol; + +typedef struct FFColorsOptions +{ + const char* moduleName; + FFColorssymbol symbol; +} FFColorsOptions; diff --git a/src/modules/display/display.c b/src/modules/display/display.c index e59435dab..c3bf888d7 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -157,6 +157,7 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); } + void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) { FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; diff --git a/src/modules/options.h b/src/modules/options.h index f9ae625b9..12aa53998 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -10,6 +10,7 @@ #include "modules/chassis/option.h" #include "modules/cpu/option.h" #include "modules/cpuusage/option.h" +#include "modules/colors/option.h" #include "modules/cursor/option.h" #include "modules/custom/option.h" #include "modules/command/option.h" From 3670238f04a14242c91379c7649a3736dee90bef Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 14:04:04 +0800 Subject: [PATCH 171/493] Doc: update changelog for FreeBSD support --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d538134..ab3384e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Changes: * Remove `--*-error-format` Features: +* FreeBSD support is improved greatly, and actually tested in a phycial machine * Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux) * Support QTerminal version & terminal font detection * Support MATE Terminal version & terminal font detection From 6a44242795cffdd024bf60baac5699c92e203c06 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 14:16:06 +0800 Subject: [PATCH 172/493] Host (macOS): update newest product name data --- src/detection/host/host_apple.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index 8755795d4..e906b67b8 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -112,6 +112,10 @@ static const char* getProductName(const FFstrbuf* hwModel) else if(ffStrbufStartsWithS(hwModel, "Mac")) { const char* version = hwModel->chars + strlen("Mac"); + if(strEqual(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; + if(strEqual(version, "14,14")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; + if(strEqual(version, "14,13")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; + if(strEqual(version, "14,8")) return "Mac Pro (2023)"; if(strEqual(version, "14,6") || strEqual(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; if(strEqual(version, "14,5") || From 463838a19835dd808a7f7409ea40b72840c58fac Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 14:38:39 +0800 Subject: [PATCH 173/493] JsonConfig: update JSON schema --- src/data/json_schema.jsonc | 129 ++++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index 19ec8ef4a..c8b156700 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -462,7 +462,23 @@ "Media", "Memory", "OpenCL", - "OS" + "OS", + "Packages", + "Player", + "PowerAdapter", + "Processes", + "Shell", + "Swap", + "Terminal", + "TerminalFont", + "Theme", + "Uptime", + "Users", + "Vulkan", + "Wallpaper", + "WM", + "Wifi", + "WMTheme" ] }, "key": { @@ -788,6 +804,117 @@ } }, "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["PublicIp"] + }, + "url": { + "title": "The URL of public IP detection server to be used. Only HTTP protocol is supported", + "type": "string", + "format": "url", + "default": "http://ipinfo.io/ip" + }, + "timeout": { + "title": "Time in milliseconds to wait for the public ip server to respond", + "type": "integer", + "minimum": 0, + "default": "disabled (0)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "format": { + "$ref": "#/$defs/format" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Separator"] + }, + "string": { + "title": "Set the string printed by the separator module", + "type": "string", + "format": "url", + "default": "http://ipinfo.io/ip" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Sound"] + }, + "soundType": { + "title": "Set what type of sound devices should be printed", + "type": "string", + "enum": [ + "main", + "active", + "all" + ], + "default": "main" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "format": { + "$ref": "#/$defs/format" + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Title"] + }, + "fqdn": { + "type": "boolean", + "title": "Set if the title should use fully qualified domain name", + "default": false + } + }, + "additionalProperties": false + }, + { + "properties": { + "type": { + "enum": ["Weather"] + }, + "timeout": { + "title": "Time in milliseconds to wait for the weather server to respond", + "type": "integer", + "minimum": 0, + "default": "disabled (0)" + }, + "outputFormat": { + "title": "The output weather format to be used (must be URI encoded)", + "type": "string", + "default": "%t+-+%C+(%l)" + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "format": { + "$ref": "#/$defs/format" + } + }, + "additionalProperties": false } ] } From 805fb13b135f67ba5eee4936b0e7a66257b979e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 15:21:49 +0800 Subject: [PATCH 174/493] Global: refactor `strcasecmp() == 0` to `ffStrEqualsIgnCase()` to prevent me from forgetting to write `== 0` --- src/common/jsonconfig.c | 89 +++---- src/common/option.c | 16 +- src/fastfetch.c | 325 ++++++++++++------------ src/logo/option.c | 6 +- src/modules/battery/battery.c | 11 +- src/modules/bios/bios.c | 3 +- src/modules/bluetooth/bluetooth.c | 7 +- src/modules/board/board.c | 3 +- src/modules/brightness/brightness.c | 3 +- src/modules/chassis/chassis.c | 3 +- src/modules/colors/colors.c | 7 +- src/modules/command/command.c | 11 +- src/modules/cpu/cpu.c | 7 +- src/modules/cpuusage/cpuusage.c | 3 +- src/modules/cursor/cursor.c | 3 +- src/modules/custom/custom.c | 3 +- src/modules/datetime/datetime.c | 3 +- src/modules/de/de.c | 3 +- src/modules/disk/disk.c | 25 +- src/modules/display/display.c | 15 +- src/modules/font/font.c | 3 +- src/modules/gamepad/gamepad.c | 3 +- src/modules/gpu/gpu.c | 15 +- src/modules/host/host.c | 3 +- src/modules/icons/icons.c | 3 +- src/modules/kernel/kernel.c | 3 +- src/modules/locale/locale.c | 3 +- src/modules/localip/localip.c | 27 +- src/modules/media/media.c | 3 +- src/modules/memory/memory.c | 3 +- src/modules/opencl/opencl.c | 3 +- src/modules/opengl/opengl.c | 7 +- src/modules/os/os.c | 3 +- src/modules/packages/packages.c | 3 +- src/modules/player/player.c | 3 +- src/modules/poweradapter/poweradapter.c | 3 +- src/modules/processes/processes.c | 3 +- src/modules/publicip/publicip.c | 11 +- src/modules/separator/separator.c | 7 +- src/modules/shell/shell.c | 3 +- src/modules/sound/sound.c | 7 +- src/modules/swap/swap.c | 3 +- src/modules/terminal/terminal.c | 3 +- src/modules/terminalfont/terminalfont.c | 3 +- src/modules/theme/theme.c | 3 +- src/modules/title/title.c | 9 +- src/modules/uptime/uptime.c | 4 + src/modules/users/users.c | 3 +- src/modules/vulkan/vulkan.c | 3 +- src/modules/wallpaper/wallpaper.c | 3 +- src/modules/weather/weather.c | 11 +- src/modules/wifi/wifi.c | 3 +- src/modules/wm/wm.c | 3 +- src/modules/wmtheme/wmtheme.c | 3 +- src/util/stringUtils.c | 1 - src/util/stringUtils.h | 21 ++ 56 files changed, 405 insertions(+), 336 deletions(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index cd4dbdcf6..e3748b104 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -4,6 +4,7 @@ #include "common/io/io.h" #include "common/time.h" #include "modules/modules.h" +#include "util/stringUtils.h" #include #include @@ -11,17 +12,17 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs) { - if(strcasecmp(key, "key") == 0) + if(ffStrEqualsIgnCase(key, "key")) { ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } - else if(strcasecmp(key, "keyColor") == 0) + else if(ffStrEqualsIgnCase(key, "keyColor")) { ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor); return true; } - else if(strcasecmp(key, "format") == 0) + else if(ffStrEqualsIgnCase(key, "format")) { ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; @@ -51,7 +52,7 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p const char* strVal = yyjson_get_str(val); for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { - if (strcasecmp(strVal, pPair->key) == 0) + if (ffStrEqualsIgnCase(strVal, pPair->key)) { *result = pPair->value; return NULL; @@ -66,7 +67,7 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module)) { - if (strcasecmp(type, moduleName) == 0) + if (ffStrEqualsIgnCase(type, moduleName)) { f(instance, module); return true; @@ -294,21 +295,21 @@ const char* ffParseGeneralJsonConfig(FFinstance* instance) { const char* key = yyjson_get_str(key_); - if (strcasecmp(key, "allowSlowOperations") == 0) + if (ffStrEqualsIgnCase(key, "allowSlowOperations")) config->allowSlowOperations = yyjson_get_bool(val); - else if (strcasecmp(key, "thread") == 0 || strcasecmp(key, "multithreading") == 0) + else if (ffStrEqualsIgnCase(key, "thread") || ffStrEqualsIgnCase(key, "multithreading")) config->multithreading = yyjson_get_bool(val); - else if (strcasecmp(key, "stat") == 0) + else if (ffStrEqualsIgnCase(key, "stat")) config->stat = yyjson_get_bool(val); - else if (strcasecmp(key, "escapeBedrock") == 0) + else if (ffStrEqualsIgnCase(key, "escapeBedrock")) config->escapeBedrock = yyjson_get_bool(val); - else if (strcasecmp(key, "pipe") == 0) + else if (ffStrEqualsIgnCase(key, "pipe")) config->pipe = yyjson_get_bool(val); #if defined(__linux__) || defined(__FreeBSD__) - else if (strcasecmp(key, "playerName") == 0) + else if (ffStrEqualsIgnCase(key, "playerName")) ffStrbufSetS(&config->playerName, yyjson_get_str(val)); - else if (strcasecmp(key, "osFile") == 0) + else if (ffStrEqualsIgnCase(key, "osFile")) ffStrbufSetS(&config->osFile, yyjson_get_str(val)); #endif @@ -339,15 +340,15 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) { const char* key = yyjson_get_str(key_); - if (strcasecmp(key, "showErrors") == 0) + if (ffStrEqualsIgnCase(key, "showErrors")) config->showErrors = yyjson_get_bool(val); - else if (strcasecmp(key, "disableLinewrap") == 0) + else if (ffStrEqualsIgnCase(key, "disableLinewrap")) config->disableLinewrap = yyjson_get_bool(val); - else if (strcasecmp(key, "hideCursor") == 0) + else if (ffStrEqualsIgnCase(key, "hideCursor")) config->hideCursor = yyjson_get_bool(val); - else if (strcasecmp(key, "separator") == 0) + else if (ffStrEqualsIgnCase(key, "separator")) ffStrbufSetS(&config->keyValueSeparator, yyjson_get_str(val)); - else if (strcasecmp(key, "color") == 0) + else if (ffStrEqualsIgnCase(key, "color")) { if (yyjson_is_str(val)) { @@ -366,7 +367,7 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) else return "display.color must be either a string or an object"; } - else if (strcasecmp(key, "binaryPrefix") == 0) + else if (ffStrEqualsIgnCase(key, "binaryPrefix")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { @@ -378,9 +379,9 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) if (error) return error; config->binaryPrefixType = (FFBinaryPrefixType) value; } - else if (strcasecmp(key, "percentType") == 0) + else if (ffStrEqualsIgnCase(key, "percentType")) config->percentType = (uint32_t) yyjson_get_uint(val); - else if (strcasecmp(key, "noBuffer") == 0) + else if (ffStrEqualsIgnCase(key, "noBuffer")) config->noBuffer = yyjson_get_bool(val); else return "Unknown display property"; @@ -409,53 +410,53 @@ const char* ffParseLibraryJsonConfig(FFinstance* instance) { const char* key = yyjson_get_str(key_); - if (strcasecmp(key, "pci") == 0) + if (ffStrEqualsIgnCase(key, "pci")) ffStrbufSetS(&config->libPCI, yyjson_get_str(val)); - else if (strcasecmp(key, "vulkan") == 0) + else if (ffStrEqualsIgnCase(key, "vulkan")) ffStrbufSetS(&config->libVulkan, yyjson_get_str(val)); - else if (strcasecmp(key, "freetype") == 0) + else if (ffStrEqualsIgnCase(key, "freetype")) ffStrbufSetS(&config->libfreetype, yyjson_get_str(val)); - else if (strcasecmp(key, "wayland") == 0) + else if (ffStrEqualsIgnCase(key, "wayland")) ffStrbufSetS(&config->libWayland, yyjson_get_str(val)); - else if (strcasecmp(key, "xcbRandr") == 0) + else if (ffStrEqualsIgnCase(key, "xcbRandr")) ffStrbufSetS(&config->libXcbRandr, yyjson_get_str(val)); - else if (strcasecmp(key, "xcb") == 0) + else if (ffStrEqualsIgnCase(key, "xcb")) ffStrbufSetS(&config->libXcb, yyjson_get_str(val)); - else if (strcasecmp(key, "Xrandr") == 0) + else if (ffStrEqualsIgnCase(key, "Xrandr")) ffStrbufSetS(&config->libXrandr, yyjson_get_str(val)); - else if (strcasecmp(key, "X11") == 0) + else if (ffStrEqualsIgnCase(key, "X11")) ffStrbufSetS(&config->libX11, yyjson_get_str(val)); - else if (strcasecmp(key, "gio") == 0) + else if (ffStrEqualsIgnCase(key, "gio")) ffStrbufSetS(&config->libGIO, yyjson_get_str(val)); - else if (strcasecmp(key, "DConf") == 0) + else if (ffStrEqualsIgnCase(key, "DConf")) ffStrbufSetS(&config->libDConf, yyjson_get_str(val)); - else if (strcasecmp(key, "dbus") == 0) + else if (ffStrEqualsIgnCase(key, "dbus")) ffStrbufSetS(&config->libDBus, yyjson_get_str(val)); - else if (strcasecmp(key, "XFConf") == 0) + else if (ffStrEqualsIgnCase(key, "XFConf")) ffStrbufSetS(&config->libXFConf, yyjson_get_str(val)); - else if (strcasecmp(key, "sqlite") == 0 || strcasecmp(key, "sqlite3") == 0) + else if (ffStrEqualsIgnCase(key, "sqlite") || ffStrEqualsIgnCase(key, "sqlite3")) ffStrbufSetS(&config->libSQLite3, yyjson_get_str(val)); - else if (strcasecmp(key, "rpm") == 0) + else if (ffStrEqualsIgnCase(key, "rpm")) ffStrbufSetS(&config->librpm, yyjson_get_str(val)); - else if (strcasecmp(key, "imagemagick") == 0) + else if (ffStrEqualsIgnCase(key, "imagemagick")) ffStrbufSetS(&config->libImageMagick, yyjson_get_str(val)); - else if (strcasecmp(key, "z") == 0) + else if (ffStrEqualsIgnCase(key, "z")) ffStrbufSetS(&config->libZ, yyjson_get_str(val)); - else if (strcasecmp(key, "chafa") == 0) + else if (ffStrEqualsIgnCase(key, "chafa")) ffStrbufSetS(&config->libChafa, yyjson_get_str(val)); - else if (strcasecmp(key, "egl") == 0) + else if (ffStrEqualsIgnCase(key, "egl")) ffStrbufSetS(&config->libEGL, yyjson_get_str(val)); - else if (strcasecmp(key, "glx") == 0) + else if (ffStrEqualsIgnCase(key, "glx")) ffStrbufSetS(&config->libGLX, yyjson_get_str(val)); - else if (strcasecmp(key, "osmesa") == 0) + else if (ffStrEqualsIgnCase(key, "osmesa")) ffStrbufSetS(&config->libOSMesa, yyjson_get_str(val)); - else if (strcasecmp(key, "opencl") == 0) + else if (ffStrEqualsIgnCase(key, "opencl")) ffStrbufSetS(&config->libOpenCL, yyjson_get_str(val)); - else if (strcasecmp(key, "wlanapi") == 0) + else if (ffStrEqualsIgnCase(key, "wlanapi")) ffStrbufSetS(&config->libwlanapi, yyjson_get_str(val)); - else if (strcasecmp(key, "pulse") == 0) + else if (ffStrEqualsIgnCase(key, "pulse")) ffStrbufSetS(&config->libPulse, yyjson_get_str(val)); - else if (strcasecmp(key, "nm") == 0) + else if (ffStrEqualsIgnCase(key, "nm")) ffStrbufSetS(&config->libnm, yyjson_get_str(val)); else return "Unknown library property"; diff --git a/src/common/option.c b/src/common/option.c index 6b8496e3d..95c44e3e4 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -28,12 +28,12 @@ const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName) bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const char* value, FFModuleArgs* result) { - if(strcasecmp(subKey, "key") == 0) + if(ffStrEqualsIgnCase(subKey, "key")) { ffOptionParseString(argumentKey, value, &result->key); return true; } - else if(strcasecmp(subKey, "key-color") == 0) + else if(ffStrEqualsIgnCase(subKey, "key-color")) { if(value == NULL) { @@ -43,7 +43,7 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const ffOptionParseColor(value, &result->keyColor); return true; } - else if(strcasecmp(subKey, "format") == 0) + else if(ffStrEqualsIgnCase(subKey, "format")) { ffOptionParseString(argumentKey, value, &result->outputFormat); return true; @@ -91,7 +91,7 @@ int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyVa for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair) { - if(strcasecmp(requestedKey, pPair->key) == 0) + if(ffStrEqualsIgnCase(requestedKey, pPair->key)) return pPair->value; } @@ -103,10 +103,10 @@ bool ffOptionParseBoolean(const char* str) { return ( !ffStrSet(str) || - strcasecmp(str, "true") == 0 || - strcasecmp(str, "yes") == 0 || - strcasecmp(str, "on") == 0 || - strcasecmp(str, "1") == 0 + ffStrEqualsIgnCase(str, "true") || + ffStrEqualsIgnCase(str, "yes") || + ffStrEqualsIgnCase(str, "on") || + ffStrEqualsIgnCase(str, "1") ); } diff --git a/src/fastfetch.c b/src/fastfetch.c index 758cee228..2efa6fcf3 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -53,13 +53,13 @@ static inline void printCommandHelp(const char* command) { if(command == NULL) puts(FASTFETCH_DATATEXT_HELP); - else if(strcasecmp(command, "c") == 0 || strcasecmp(command, "color") == 0) + else if(ffStrEqualsIgnCase(command, "c") || ffStrEqualsIgnCase(command, "color")) puts(FASTFETCH_DATATEXT_HELP_COLOR); - else if(strcasecmp(command, "format") == 0) + else if(ffStrEqualsIgnCase(command, "format")) puts(FASTFETCH_DATATEXT_HELP_FORMAT); - else if(strcasecmp(command, "load-config") == 0 || strcasecmp(command, "loadconfig") == 0 || strcasecmp(command, "config") == 0) + else if(ffStrEqualsIgnCase(command, "load-config") || ffStrEqualsIgnCase(command, "loadconfig") || ffStrEqualsIgnCase(command, "config")) puts(FASTFETCH_DATATEXT_HELP_CONFIG); - else if(strcasecmp(command, "os-format") == 0) + else if(ffStrEqualsIgnCase(command, "os-format")) { constructAndPrintCommandHelpFormat("os", "{3} {12}", 12, "System name (typically just Linux)", @@ -76,7 +76,7 @@ static inline void printCommandHelp(const char* command) "Architecture of the OS" ); } - else if(strcasecmp(command, "host-format") == 0) + else if(ffStrEqualsIgnCase(command, "host-format")) { constructAndPrintCommandHelpFormat("host", "{2} {3}", 8, "product family", @@ -89,7 +89,7 @@ static inline void printCommandHelp(const char* command) "sys vendor" ); } - else if(strcasecmp(command, "bios-format") == 0) + else if(ffStrEqualsIgnCase(command, "bios-format")) { constructAndPrintCommandHelpFormat("bios", "{2} {3}", 4, "bios date", @@ -98,7 +98,7 @@ static inline void printCommandHelp(const char* command) "bios version" ); } - else if(strcasecmp(command, "board-format") == 0) + else if(ffStrEqualsIgnCase(command, "board-format")) { constructAndPrintCommandHelpFormat("board", "{2} {3}", 3, "board name", @@ -106,7 +106,7 @@ static inline void printCommandHelp(const char* command) "board version" ); } - else if(strcasecmp(command, "chassis-format") == 0) + else if(ffStrEqualsIgnCase(command, "chassis-format")) { constructAndPrintCommandHelpFormat("chassis", "{2} {3}", 4, "chassis type", @@ -114,7 +114,7 @@ static inline void printCommandHelp(const char* command) "chassis version" ); } - else if(strcasecmp(command, "kernel-format") == 0) + else if(ffStrEqualsIgnCase(command, "kernel-format")) { constructAndPrintCommandHelpFormat("kernel", "{2}", 3, "Kernel sysname", @@ -122,7 +122,7 @@ static inline void printCommandHelp(const char* command) "Kernel version" ); } - else if(strcasecmp(command, "uptime-format") == 0) + else if(ffStrEqualsIgnCase(command, "uptime-format")) { constructAndPrintCommandHelpFormat("uptime", "{} days {} hours {} mins", 4, "Days", @@ -131,13 +131,13 @@ static inline void printCommandHelp(const char* command) "Seconds" ); } - else if(strcasecmp(command, "processes-format") == 0) + else if(ffStrEqualsIgnCase(command, "processes-format")) { constructAndPrintCommandHelpFormat("processes", "{}", 1, "Count" ); } - else if(strcasecmp(command, "packages-format") == 0) + else if(ffStrEqualsIgnCase(command, "packages-format")) { constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco)", 21, "Number of all packages", @@ -163,7 +163,7 @@ static inline void printCommandHelp(const char* command) "Number of choco packages" ); } - else if(strcasecmp(command, "shell-format") == 0) + else if(ffStrEqualsIgnCase(command, "shell-format")) { constructAndPrintCommandHelpFormat("shell", "{3} {4}", 7, "Shell process name", @@ -175,7 +175,7 @@ static inline void printCommandHelp(const char* command) "User shell version" ); } - else if(strcasecmp(command, "display-format") == 0) + else if(ffStrEqualsIgnCase(command, "display-format")) { constructAndPrintCommandHelpFormat("display", "{}x{} @ {}Hz", 7, "Screen width", @@ -188,7 +188,7 @@ static inline void printCommandHelp(const char* command) "Screen rotation" ); } - else if(strcasecmp(command, "de-format") == 0) + else if(ffStrEqualsIgnCase(command, "de-format")) { constructAndPrintCommandHelpFormat("de", "{2} {3}", 3, "DE process name", @@ -196,7 +196,7 @@ static inline void printCommandHelp(const char* command) "DE version" ); } - else if(strcasecmp(command, "wm-format") == 0) + else if(ffStrEqualsIgnCase(command, "wm-format")) { constructAndPrintCommandHelpFormat("wm", "{2} ({3})", 3, "WM process name", @@ -204,31 +204,31 @@ static inline void printCommandHelp(const char* command) "WM protocol name" ); } - else if(strcasecmp(command, "wm-theme-format") == 0) + else if(ffStrEqualsIgnCase(command, "wm-theme-format")) { constructAndPrintCommandHelpFormat("wm-theme", "{}", 1, "WM theme name" ); } - else if(strcasecmp(command, "theme-format") == 0) + else if(ffStrEqualsIgnCase(command, "theme-format")) { constructAndPrintCommandHelpFormat("theme", "{}", 1, "Combined themes" ); } - else if(strcasecmp(command, "icons-format") == 0) + else if(ffStrEqualsIgnCase(command, "icons-format")) { constructAndPrintCommandHelpFormat("icons", "{}", 1, "Combined icons" ); } - else if(strcasecmp(command, "wallpaper-format") == 0) + else if(ffStrEqualsIgnCase(command, "wallpaper-format")) { constructAndPrintCommandHelpFormat("wallpaper", "{}", 1, "Wallpaper image file" ); } - else if(strcasecmp(command, "font-format") == 0) + else if(ffStrEqualsIgnCase(command, "font-format")) { constructAndPrintCommandHelpFormat("font", "{} [QT], {} [GTK2], {} [GTK3], {} [GTK4]", 4, "Font 1", @@ -237,14 +237,14 @@ static inline void printCommandHelp(const char* command) "Font 4" ); } - else if(strcasecmp(command, "cursor-format") == 0) + else if(ffStrEqualsIgnCase(command, "cursor-format")) { constructAndPrintCommandHelpFormat("cursor", "{} ({}pt)", 2, "Cursor theme", "Cursor size" ); } - else if(strcasecmp(command, "terminal-format") == 0) + else if(ffStrEqualsIgnCase(command, "terminal-format")) { constructAndPrintCommandHelpFormat("terminal", "{3}", 10, "Terminal process name", @@ -259,7 +259,7 @@ static inline void printCommandHelp(const char* command) "User shell version" ); } - else if(strcasecmp(command, "terminal-font-format") == 0) + else if(ffStrEqualsIgnCase(command, "terminal-font-format")) { constructAndPrintCommandHelpFormat("terminal-font", "{}", 4, "Terminal font", @@ -268,7 +268,7 @@ static inline void printCommandHelp(const char* command) "Terminal font styles" ); } - else if(strcasecmp(command, "cpu-format") == 0) + else if(ffStrEqualsIgnCase(command, "cpu-format")) { constructAndPrintCommandHelpFormat("cpu", "{1} ({5}) @ {7}GHz", 8, "Name", @@ -281,13 +281,13 @@ static inline void printCommandHelp(const char* command) "Temperature" ); } - else if(strcasecmp(command, "cpu-usage-format") == 0) + else if(ffStrEqualsIgnCase(command, "cpu-usage-format")) { constructAndPrintCommandHelpFormat("cpu-usage", "{0}%", 1, "CPU usage without percent mark" ); } - else if(strcasecmp(command, "gpu-format") == 0) + else if(ffStrEqualsIgnCase(command, "gpu-format")) { constructAndPrintCommandHelpFormat("gpu", "{} {}", 6, "GPU vendor", @@ -298,7 +298,7 @@ static inline void printCommandHelp(const char* command) "GPU type" ); } - else if(strcasecmp(command, "memory-format") == 0) + else if(ffStrEqualsIgnCase(command, "memory-format")) { constructAndPrintCommandHelpFormat("memory", "{} / {} ({}%)", 3, "Used size", @@ -306,7 +306,7 @@ static inline void printCommandHelp(const char* command) "Percentage used" ); } - else if(strcasecmp(command, "swap-format") == 0) + else if(ffStrEqualsIgnCase(command, "swap-format")) { constructAndPrintCommandHelpFormat("swap", "{} / {} ({}%)", 3, "Used size", @@ -314,7 +314,7 @@ static inline void printCommandHelp(const char* command) "Percentage used" ); } - else if(strcasecmp(command, "disk-format") == 0) + else if(ffStrEqualsIgnCase(command, "disk-format")) { constructAndPrintCommandHelpFormat("disk", "{1} / {2} ({3}%)", 9, "Size used", @@ -328,7 +328,7 @@ static inline void printCommandHelp(const char* command) "Filesystem" ); } - else if(strcasecmp(command, "battery-format") == 0) + else if(ffStrEqualsIgnCase(command, "battery-format")) { constructAndPrintCommandHelpFormat("battery", "{}%, {}", 5, "Battery manufactor", @@ -338,7 +338,7 @@ static inline void printCommandHelp(const char* command) "Battery status" ); } - else if(strcasecmp(command, "poweradapter-format") == 0) + else if(ffStrEqualsIgnCase(command, "poweradapter-format")) { constructAndPrintCommandHelpFormat("poweradapter", "{}%, {}", 5, "PowerAdapter watts", @@ -348,25 +348,25 @@ static inline void printCommandHelp(const char* command) "PowerAdapter description" ); } - else if(strcasecmp(command, "locale-format") == 0) + else if(ffStrEqualsIgnCase(command, "locale-format")) { constructAndPrintCommandHelpFormat("locale", "{}", 1, "Locale code" ); } - else if(strcasecmp(command, "local-ip-format") == 0) + else if(ffStrEqualsIgnCase(command, "local-ip-format")) { constructAndPrintCommandHelpFormat("local-ip", "{}", 1, "Local IP address" ); } - else if(strcasecmp(command, "public-ip-format") == 0) + else if(ffStrEqualsIgnCase(command, "public-ip-format")) { constructAndPrintCommandHelpFormat("public-ip", "{}", 1, "Public IP address" ); } - else if(strcasecmp(command, "wifi-format") == 0) + else if(ffStrEqualsIgnCase(command, "wifi-format")) { constructAndPrintCommandHelpFormat("wifi", "{4} - {6}", 3, "Interface description", @@ -381,7 +381,7 @@ static inline void printCommandHelp(const char* command) "Connection Security algorithm" ); } - else if(strcasecmp(command, "player-format") == 0) + else if(ffStrEqualsIgnCase(command, "player-format")) { constructAndPrintCommandHelpFormat("player", "{}", 4, "Pretty player name", @@ -390,7 +390,7 @@ static inline void printCommandHelp(const char* command) "URL name" ); } - else if(strcasecmp(command, "media-format") == 0) + else if(ffStrEqualsIgnCase(command, "media-format")) { constructAndPrintCommandHelpFormat("media", "{3} - {1}", 4, "Pretty media name", @@ -399,7 +399,7 @@ static inline void printCommandHelp(const char* command) "Album name" ); } - else if(strcasecmp(command, "datetime-format") == 0 || strcasecmp(command, "date-format") == 0 || strcasecmp(command, "time-format") == 0) + else if(ffStrEqualsIgnCase(command, "datetime-format") == 0 || ffStrEqualsIgnCase(command, "date-format") || ffStrEqualsIgnCase(command, "time-format")) { constructAndPrintCommandHelpFormat("[date][time]", "{1}-{4}-{11} {14}:{18}:{20}", 20, "year", @@ -424,7 +424,7 @@ static inline void printCommandHelp(const char* command) "second with leading zero" ); } - else if(strcasecmp(command, "vulkan-format") == 0) + else if(ffStrEqualsIgnCase(command, "vulkan-format")) { constructAndPrintCommandHelpFormat("vulkan", "{} (driver), {} (api version)", 3, "Driver name", @@ -432,7 +432,7 @@ static inline void printCommandHelp(const char* command) "Conformance version" ); } - else if(strcasecmp(command, "opengl-format") == 0) + else if(ffStrEqualsIgnCase(command, "opengl-format")) { constructAndPrintCommandHelpFormat("opengl", "{}", 3, "version", @@ -441,7 +441,7 @@ static inline void printCommandHelp(const char* command) "shading language version" ); } - else if(strcasecmp(command, "opencl-format") == 0) + else if(ffStrEqualsIgnCase(command, "opencl-format")) { constructAndPrintCommandHelpFormat("opencl", "{}", 3, "version", @@ -449,7 +449,7 @@ static inline void printCommandHelp(const char* command) "vendor" ); } - else if(strcasecmp(command, "bluetooth-format") == 0) + else if(ffStrEqualsIgnCase(command, "bluetooth-format")) { constructAndPrintCommandHelpFormat("bluetooth", "{1} (4%)", 4, "Name", @@ -458,7 +458,7 @@ static inline void printCommandHelp(const char* command) "Battery percentage" ); } - else if(strcasecmp(command, "sound-format") == 0) + else if(ffStrEqualsIgnCase(command, "sound-format")) { constructAndPrintCommandHelpFormat("sound", "{2} (3%)", 4, "Main", @@ -467,7 +467,7 @@ static inline void printCommandHelp(const char* command) "Identifier" ); } - else if(strcasecmp(command, "gamepad-format") == 0) + else if(ffStrEqualsIgnCase(command, "gamepad-format")) { constructAndPrintCommandHelpFormat("gamepad", "{1}", 1, "Name", @@ -681,23 +681,18 @@ static inline void optionCheckString(const char* key, const char* value, FFstrbu ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance } -static inline bool startsWith(const char* str, const char* compareTo) -{ - return strncasecmp(str, compareTo, strlen(compareTo)) == 0; -} - static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value) { /////////////////////// //Informative options// /////////////////////// - if(strcasecmp(key, "-h") == 0 || strcasecmp(key, "--help") == 0) + if(ffStrEqualsIgnCase(key, "-h") || ffStrEqualsIgnCase(key, "--help")) { printCommandHelp(value); exit(0); } - else if(strcasecmp(key, "-v") == 0 || strcasecmp(key, "--version") == 0) + else if(ffStrEqualsIgnCase(key, "-v") || ffStrEqualsIgnCase(key, "--version")) { #ifndef NDEBUG #define FF_BUILD_TYPE "-debug" @@ -732,30 +727,30 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con exit(0); } - else if(strcasecmp(key, "--version-raw") == 0) + else if(ffStrEqualsIgnCase(key, "--version-raw")) { puts(FASTFETCH_PROJECT_VERSION); exit(0); } - else if(startsWith(key, "--print")) + else if(ffStrStartsWithIgnCase(key, "--print")) { const char* subkey = key + strlen("--print"); - if(strcasecmp(subkey, "-config-system") == 0) + if(ffStrEqualsIgnCase(subkey, "-config-system")) { puts(FASTFETCH_DATATEXT_CONFIG_SYSTEM); exit(0); } - else if(strcasecmp(subkey, "-config-user") == 0) + else if(ffStrEqualsIgnCase(subkey, "-config-user")) { puts(FASTFETCH_DATATEXT_CONFIG_USER); exit(0); } - else if(strcasecmp(subkey, "-structure") == 0) + else if(ffStrEqualsIgnCase(subkey, "-structure")) { puts(FASTFETCH_DATATEXT_STRUCTURE); exit(0); } - else if(strcasecmp(subkey, "-logos") == 0) + else if(ffStrEqualsIgnCase(subkey, "-logos")) { ffLogoBuiltinPrint(instance); exit(0); @@ -763,35 +758,35 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else goto error; } - else if(startsWith(key, "--list")) + else if(ffStrStartsWithIgnCase(key, "--list")) { const char* subkey = key + strlen("--list"); - if(strcasecmp(subkey, "-modules") == 0) + if(ffStrEqualsIgnCase(subkey, "-modules")) { puts(FASTFETCH_DATATEXT_MODULES); exit(0); } - else if(strcasecmp(subkey, "-presets") == 0) + else if(ffStrEqualsIgnCase(subkey, "-presets")) { listAvailablePresets(instance); exit(0); } - else if(strcasecmp(subkey, "-config-paths") == 0) + else if(ffStrEqualsIgnCase(subkey, "-config-paths")) { listConfigPaths(instance); exit(0); } - else if(strcasecmp(subkey, "-data-paths") == 0) + else if(ffStrEqualsIgnCase(subkey, "-data-paths")) { listDataPaths(instance); exit(0); } - else if(strcasecmp(subkey, "-features") == 0) + else if(ffStrEqualsIgnCase(subkey, "-features")) { ffListFeatures(); exit(0); } - else if(strcasecmp(subkey, "-logos") == 0) + else if(ffStrEqualsIgnCase(subkey, "-logos")) { puts("Builtin logos:"); ffLogoBuiltinList(); @@ -799,7 +794,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con listAvailableLogos(instance); exit(0); } - else if(strcasecmp(subkey, "-logos-autocompletion") == 0) + else if(ffStrEqualsIgnCase(subkey, "-logos-autocompletion")) { ffLogoBuiltinListAutocompletion(); exit(0); @@ -812,34 +807,34 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //General options// /////////////////// - else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0) + else if(ffStrEqualsIgnCase(key, "-r") || ffStrEqualsIgnCase(key, "--recache")) instance->config.recache = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--load-config") == 0) + else if(ffStrEqualsIgnCase(key, "--load-config")) optionParseConfigFile(instance, data, key, value); - else if(strcasecmp(key, "--gen-config") == 0) + else if(ffStrEqualsIgnCase(key, "--gen-config")) generateConfigFile(instance, false); - else if(strcasecmp(key, "--gen-config-force") == 0) + else if(ffStrEqualsIgnCase(key, "--gen-config-force")) generateConfigFile(instance, true); - else if(strcasecmp(key, "--thread") == 0 || strcasecmp(key, "--multithreading") == 0) + else if(ffStrEqualsIgnCase(key, "--thread") || ffStrEqualsIgnCase(key, "--multithreading")) instance->config.multithreading = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--stat") == 0) + else if(ffStrEqualsIgnCase(key, "--stat")) { if((instance->config.stat = ffOptionParseBoolean(value))) instance->config.showErrors = true; } - else if(strcasecmp(key, "--allow-slow-operations") == 0) + else if(ffStrEqualsIgnCase(key, "--allow-slow-operations")) instance->config.allowSlowOperations = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--escape-bedrock") == 0) + else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) instance->config.escapeBedrock = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--pipe") == 0) + else if(ffStrEqualsIgnCase(key, "--pipe")) instance->config.pipe = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--load-user-config") == 0) + else if(ffStrEqualsIgnCase(key, "--load-user-config")) data->loadUserConfig = ffOptionParseBoolean(value); #if defined(__linux__) || defined(__FreeBSD__) - else if(strcasecmp(key, "--player-name") == 0) + else if(ffStrEqualsIgnCase(key, "--player-name")) ffOptionParseString(key, value, &instance->config.playerName); - else if (strcasecmp(key, "--os-file") == 0) + else if (ffStrEqualsIgnCase(key, "--os-file")) ffOptionParseString(key, value, &instance->config.osFile); #endif @@ -853,33 +848,33 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Display options// /////////////////// - else if(strcasecmp(key, "--show-errors") == 0) + else if(ffStrEqualsIgnCase(key, "--show-errors")) instance->config.showErrors = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--disable-linewrap") == 0) + else if(ffStrEqualsIgnCase(key, "--disable-linewrap")) instance->config.disableLinewrap = ffOptionParseBoolean(value); - else if(strcasecmp(key, "--hide-cursor") == 0) + else if(ffStrEqualsIgnCase(key, "--hide-cursor")) instance->config.hideCursor = ffOptionParseBoolean(value); - else if(strcasecmp(key, "-s") == 0 || strcasecmp(key, "--structure") == 0) + else if(ffStrEqualsIgnCase(key, "-s") || ffStrEqualsIgnCase(key, "--structure")) ffOptionParseString(key, value, &data->structure); - else if(strcasecmp(key, "--separator") == 0) + else if(ffStrEqualsIgnCase(key, "--separator")) ffOptionParseString(key, value, &instance->config.keyValueSeparator); - else if(strcasecmp(key, "--color-keys") == 0) + else if(ffStrEqualsIgnCase(key, "--color-keys")) { optionCheckString(key, value, &instance->config.colorKeys); ffOptionParseColor(value, &instance->config.colorKeys); } - else if(strcasecmp(key, "--color-title") == 0) + else if(ffStrEqualsIgnCase(key, "--color-title")) { optionCheckString(key, value, &instance->config.colorTitle); ffOptionParseColor(value, &instance->config.colorTitle); } - else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0) + else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color")) { optionCheckString(key, value, &instance->config.colorKeys); ffOptionParseColor(value, &instance->config.colorKeys); ffStrbufSet(&instance->config.colorTitle, &instance->config.colorKeys); } - else if(strcasecmp(key, "--binary-prefix") == 0) + else if(ffStrEqualsIgnCase(key, "--binary-prefix")) { instance->config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "iec", FF_BINARY_PREFIX_TYPE_IEC }, @@ -888,9 +883,9 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con {} }); } - else if(strcasecmp(key, "--percent-type") == 0) + else if(ffStrEqualsIgnCase(key, "--percent-type")) instance->config.percentType = ffOptionParseUInt32(key, value); - else if(strcasecmp(key, "--no-buffer") == 0) + else if(ffStrEqualsIgnCase(key, "--no-buffer")) instance->config.noBuffer = ffOptionParseBoolean(value); /////////////////////// @@ -951,56 +946,56 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con //Library options// /////////////////// - else if(startsWith(key, "--lib")) + else if(ffStrStartsWithIgnCase(key, "--lib")) { const char* subkey = key + strlen("--lib"); - if(strcasecmp(subkey, "-PCI") == 0) + if(ffStrEqualsIgnCase(subkey, "-PCI")) ffOptionParseString(key, value, &instance->config.libPCI); - else if(strcasecmp(subkey, "-vulkan") == 0) + else if(ffStrEqualsIgnCase(subkey, "-vulkan")) ffOptionParseString(key, value, &instance->config.libVulkan); - else if(strcasecmp(subkey, "-freetype") == 0) + else if(ffStrEqualsIgnCase(subkey, "-freetype")) ffOptionParseString(key, value, &instance->config.libfreetype); - else if(strcasecmp(subkey, "-wayland") == 0) + else if(ffStrEqualsIgnCase(subkey, "-wayland")) ffOptionParseString(key, value, &instance->config.libWayland); - else if(strcasecmp(subkey, "-xcb-randr") == 0) + else if(ffStrEqualsIgnCase(subkey, "-xcb-randr")) ffOptionParseString(key, value, &instance->config.libXcbRandr); - else if(strcasecmp(subkey, "-xcb") == 0) + else if(ffStrEqualsIgnCase(subkey, "-xcb")) ffOptionParseString(key, value, &instance->config.libXcb); - else if(strcasecmp(subkey, "-Xrandr") == 0) + else if(ffStrEqualsIgnCase(subkey, "-Xrandr")) ffOptionParseString(key, value, &instance->config.libXrandr); - else if(strcasecmp(subkey, "-X11") == 0) + else if(ffStrEqualsIgnCase(subkey, "-X11")) ffOptionParseString(key, value, &instance->config.libX11); - else if(strcasecmp(subkey, "-gio") == 0) + else if(ffStrEqualsIgnCase(subkey, "-gio")) ffOptionParseString(key, value, &instance->config.libGIO); - else if(strcasecmp(subkey, "-DConf") == 0) + else if(ffStrEqualsIgnCase(subkey, "-DConf")) ffOptionParseString(key, value, &instance->config.libDConf); - else if(strcasecmp(subkey, "-dbus") == 0) + else if(ffStrEqualsIgnCase(subkey, "-dbus")) ffOptionParseString(key, value, &instance->config.libDBus); - else if(strcasecmp(subkey, "-XFConf") == 0) + else if(ffStrEqualsIgnCase(subkey, "-XFConf")) ffOptionParseString(key, value, &instance->config.libXFConf); - else if(strcasecmp(subkey, "-sqlite") == 0 || strcasecmp(subkey, "-sqlite3") == 0) + else if(ffStrEqualsIgnCase(subkey, "-sqlite") || ffStrEqualsIgnCase(subkey, "-sqlite3")) ffOptionParseString(key, value, &instance->config.libSQLite3); - else if(strcasecmp(subkey, "-rpm") == 0) + else if(ffStrEqualsIgnCase(subkey, "-rpm")) ffOptionParseString(key, value, &instance->config.librpm); - else if(strcasecmp(subkey, "-imagemagick") == 0) + else if(ffStrEqualsIgnCase(subkey, "-imagemagick")) ffOptionParseString(key, value, &instance->config.libImageMagick); - else if(strcasecmp(subkey, "-z") == 0) + else if(ffStrEqualsIgnCase(subkey, "-z")) ffOptionParseString(key, value, &instance->config.libZ); - else if(strcasecmp(subkey, "-chafa") == 0) + else if(ffStrEqualsIgnCase(subkey, "-chafa")) ffOptionParseString(key, value, &instance->config.libChafa); - else if(strcasecmp(subkey, "-egl") == 0) + else if(ffStrEqualsIgnCase(subkey, "-egl")) ffOptionParseString(key, value, &instance->config.libEGL); - else if(strcasecmp(subkey, "-glx") == 0) + else if(ffStrEqualsIgnCase(subkey, "-glx")) ffOptionParseString(key, value, &instance->config.libGLX); - else if(strcasecmp(subkey, "-osmesa") == 0) + else if(ffStrEqualsIgnCase(subkey, "-osmesa")) ffOptionParseString(key, value, &instance->config.libOSMesa); - else if(strcasecmp(subkey, "-opencl") == 0) + else if(ffStrEqualsIgnCase(subkey, "-opencl")) ffOptionParseString(key, value, &instance->config.libOpenCL); - else if(strcasecmp(subkey, "-wlanapi") == 0) + else if(ffStrEqualsIgnCase(subkey, "-wlanapi")) ffOptionParseString(key, value, &instance->config.libwlanapi); - else if(strcasecmp(key, "-pulse") == 0) + else if(ffStrEqualsIgnCase(key, "-pulse")) ffOptionParseString(key, value, &instance->config.libPulse); - else if(strcasecmp(subkey, "-nm") == 0) + else if(ffStrEqualsIgnCase(subkey, "-nm")) ffOptionParseString(key, value, &instance->config.libnm); else goto error; @@ -1068,107 +1063,107 @@ static void parseArguments(FFinstance* instance, FFdata* data, int argc, const c static void parseStructureCommand(FFinstance* instance, const char* line) { - if(strcasecmp(line, FF_BREAK_MODULE_NAME) == 0) + if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME)) ffPrintBreak(instance); - else if(strcasecmp(line, FF_TITLE_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME)) ffPrintTitle(instance, &instance->config.title); - else if(strcasecmp(line, FF_SEPARATOR_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME)) ffPrintSeparator(instance, &instance->config.separator); - else if(strcasecmp(line, FF_OS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME)) ffPrintOS(instance, &instance->config.os); - else if(strcasecmp(line, FF_HOST_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME)) ffPrintHost(instance, &instance->config.host); - else if(strcasecmp(line, FF_BIOS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_BIOS_MODULE_NAME)) ffPrintBios(instance, &instance->config.bios); - else if(strcasecmp(line, FF_BOARD_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_BOARD_MODULE_NAME)) ffPrintBoard(instance, &instance->config.board); - else if(strcasecmp(line, FF_BRIGHTNESS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME)) ffPrintBrightness(instance, &instance->config.brightness); - else if(strcasecmp(line, FF_CHASSIS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME)) ffPrintChassis(instance, &instance->config.chassis); - else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME)) ffPrintKernel(instance, &instance->config.kernel); - else if(strcasecmp(line, FF_PROCESSES_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_PROCESSES_MODULE_NAME)) ffPrintProcesses(instance, &instance->config.processes); - else if(strcasecmp(line, FF_UPTIME_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME)) ffPrintUptime(instance, &instance->config.uptime); - else if(strcasecmp(line, FF_PACKAGES_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME)) ffPrintPackages(instance, &instance->config.packages); - else if(strcasecmp(line, FF_SHELL_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_SHELL_MODULE_NAME)) ffPrintShell(instance, &instance->config.shell); - else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_DISPLAY_MODULE_NAME)) ffPrintDisplay(instance, &instance->config.display); - else if(strcasecmp(line, FF_DE_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_DE_MODULE_NAME)) ffPrintDE(instance, &instance->config.de); - else if(strcasecmp(line, FF_WM_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_WM_MODULE_NAME)) ffPrintWM(instance, &instance->config.wm); - else if(strcasecmp(line, FF_THEME_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME)) ffPrintTheme(instance, &instance->config.theme); - else if(strcasecmp(line, FF_WMTHEME_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME)) ffPrintWMTheme(instance, &instance->config.wmTheme); - else if(strcasecmp(line, FF_ICONS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME)) ffPrintIcons(instance, &instance->config.icons); - else if(strcasecmp(line, FF_WALLPAPER_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME)) ffPrintWallpaper(instance, &instance->config.wallpaper); - else if(strcasecmp(line, FF_FONT_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME)) ffPrintFont(instance, &instance->config.font); - else if(strcasecmp(line, FF_CURSOR_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_CURSOR_MODULE_NAME)) ffPrintCursor(instance, &instance->config.cursor); - else if(strcasecmp(line, FF_TERMINAL_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME)) ffPrintTerminal(instance, &instance->config.terminal); - else if(strcasecmp(line, FF_TERMINALFONT_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME)) ffPrintTerminalFont(instance, &instance->config.terminalFont); - else if(strcasecmp(line, FF_CPU_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME)) ffPrintCPU(instance, &instance->config.cpu); - else if(strcasecmp(line, FF_CPUUSAGE_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME)) ffPrintCPUUsage(instance, &instance->config.cpuUsage); - else if(strcasecmp(line, FF_CUSTOM_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME)) ffPrintCustom(instance, &instance->config.custom); - else if(strcasecmp(line, FF_GPU_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME)) ffPrintGPU(instance, &instance->config.gpu); - else if(strcasecmp(line, FF_MEMORY_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_MEMORY_MODULE_NAME)) ffPrintMemory(instance, &instance->config.memory); - else if(strcasecmp(line, FF_SWAP_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME)) ffPrintSwap(instance, &instance->config.swap); - else if(strcasecmp(line, FF_DISK_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME)) ffPrintDisk(instance, &instance->config.disk); - else if(strcasecmp(line, FF_BATTERY_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_BATTERY_MODULE_NAME)) ffPrintBattery(instance, &instance->config.battery); - else if(strcasecmp(line, FF_POWERADAPTER_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME)) ffPrintPowerAdapter(instance, &instance->config.powerAdapter); - else if(strcasecmp(line, FF_LOCALE_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME)) ffPrintLocale(instance, &instance->config.locale); - else if(strcasecmp(line, FF_LOCALIP_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) ffPrintLocalIp(instance, &instance->config.localIP); - else if(strcasecmp(line, FF_PUBLICIP_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME)) ffPrintPublicIp(instance, &instance->config.publicIP); - else if(strcasecmp(line, FF_WIFI_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_WIFI_MODULE_NAME)) ffPrintWifi(instance, &instance->config.wifi); - else if(strcasecmp(line, FF_WEATHER_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_WEATHER_MODULE_NAME)) ffPrintWeather(instance, &instance->config.weather); - else if(strcasecmp(line, FF_PLAYER_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_PLAYER_MODULE_NAME)) ffPrintPlayer(instance, &instance->config.player); - else if(strcasecmp(line, FF_MEDIA_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) ffPrintMedia(instance, &instance->config.media); - else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) ffPrintDateTime(instance, &instance->config.dateTime); - else if(strcasecmp(line, FF_COLORS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) ffPrintColors(instance, &instance->config.colors); - else if(strcasecmp(line, FF_VULKAN_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME)) ffPrintVulkan(instance, &instance->config.vulkan); - else if(strcasecmp(line, FF_OPENGL_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_OPENGL_MODULE_NAME)) ffPrintOpenGL(instance, &instance->config.openGL); - else if(strcasecmp(line, FF_OPENCL_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME)) ffPrintOpenCL(instance, &instance->config.openCL); - else if(strcasecmp(line, FF_USERS_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME)) ffPrintUsers(instance, &instance->config.users); - else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_COMMAND_MODULE_NAME)) ffPrintCommand(instance, &instance->config.command); - else if(strcasecmp(line, FF_BLUETOOTH_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_BLUETOOTH_MODULE_NAME)) ffPrintBluetooth(instance, &instance->config.bluetooth); - else if(strcasecmp(line, FF_SOUND_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_SOUND_MODULE_NAME)) ffPrintSound(instance, &instance->config.sound); - else if(strcasecmp(line, FF_GAMEPAD_MODULE_NAME) == 0) + else if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME)) ffPrintGamepad(instance, &instance->config.gamepad); else ffPrintErrorString(instance, line, 0, NULL, NULL, ""); diff --git a/src/logo/option.c b/src/logo/option.c index 86574b680..51da4c332 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -289,17 +289,17 @@ const char* ffParseLogoJsonConfig(FFinstance* instance) #undef FF_PARSE_PADDING_POSITON continue; } - else if (strcasecmp(key, "printRemaining")) + else if (strcasecmp(key, "printRemaining") == 0) { options->printRemaining = yyjson_get_bool(val); continue; } - else if (strcasecmp(key, "preserveAspectRadio")) + else if (strcasecmp(key, "preserveAspectRadio") == 0) { options->preserveAspectRadio = yyjson_get_bool(val); continue; } - else if (strcasecmp(key, "chafa")) + else if (strcasecmp(key, "chafa") == 0) { if (!yyjson_is_obj(val)) return "Chafa config must be an object"; diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 1c962f325..d326a1584 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -3,6 +3,7 @@ #include "common/bar.h" #include "detection/battery/battery.h" #include "modules/battery/battery.h" +#include "util/stringUtils.h" #define FF_BATTERY_NUM_FORMAT_ARGS 5 @@ -119,14 +120,14 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "temp") == 0) + if (ffStrEqualsIgnCase(subKey, "temp")) { options->temp = ffOptionParseBoolean(value); return true; } #ifdef __linux__ - if (strcasecmp(subKey, "dir") == 0) + if (ffStrEqualsIgnCase(subKey, "dir")) { ffOptionParseString(key, value, &options->dir); return true; @@ -157,21 +158,21 @@ void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; #ifdef __linux__ - if (strcasecmp(key, "dir") == 0) + if (ffStrEqualsIgnCase(key, "dir")) { ffStrbufSetS(&options.dir, yyjson_get_str(val)); continue; } #endif - if (strcasecmp(key, "temp") == 0) + if (ffStrEqualsIgnCase(key, "temp")) { options.temp = yyjson_get_bool(val); continue; diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 1eac53bac..70850a714 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/bios/bios.h" #include "modules/bios/bios.h" +#include "util/stringUtils.h" #define FF_BIOS_NUM_FORMAT_ARGS 4 @@ -82,7 +83,7 @@ void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index aabed5444..9b386f5ab 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/bluetooth/bluetooth.h" #include "modules/bluetooth/bluetooth.h" +#include "util/stringUtils.h" #define FF_BLUETOOTH_NUM_FORMAT_ARGS 4 @@ -83,7 +84,7 @@ bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "show-disconnected") == 0) + if (ffStrEqualsIgnCase(subKey, "show-disconnected")) options->showDisconnected = ffOptionParseBoolean(value); return false; } @@ -105,13 +106,13 @@ void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "showDisconnected") == 0) + if (ffStrEqualsIgnCase(key, "showDisconnected")) { options.showDisconnected = yyjson_get_bool(val); continue; diff --git a/src/modules/board/board.c b/src/modules/board/board.c index c8913c90d..bb0027d9d 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/board/board.h" #include "modules/board/board.h" +#include "util/stringUtils.h" #define FF_BOARD_NUM_FORMAT_ARGS 3 @@ -76,7 +77,7 @@ void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 9dcd77971..0a5be81b3 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/brightness/brightness.h" #include "modules/brightness/brightness.h" +#include "util/stringUtils.h" #define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2 @@ -89,7 +90,7 @@ void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 65b3282fc..da6b6cf94 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/chassis/chassis.h" #include "modules/chassis/chassis.h" +#include "util/stringUtils.h" #define FF_CHASSIS_NUM_FORMAT_ARGS 3 @@ -85,7 +86,7 @@ void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 07bcf6728..5e16578c6 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "util/textModifier.h" #include "modules/colors/colors.h" +#include "util/stringUtils.h" void ffPrintColors(FFinstance* instance, FFColorsOptions* options) { @@ -59,7 +60,7 @@ bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, cons const char* subKey = ffOptionTestPrefix(key, FF_COLORS_MODULE_NAME); if (!subKey) return false; - if (strcasecmp(subKey, "symbol") == 0) + if (ffStrEqualsIgnCase(subKey, "symbol")) { options->symbol = (FFColorssymbol) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "block", FF_COLORS_SYMBOL_BLOCK }, @@ -92,10 +93,10 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; - if (strcasecmp(key, "symbol") == 0) + if (ffStrEqualsIgnCase(key, "symbol")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 8e986ad3e..d1fe505b4 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "common/processing.h" #include "modules/command/command.h" +#include "util/stringUtils.h" void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) { @@ -58,13 +59,13 @@ bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if(strcasecmp(subKey, "shell") == 0) + if(ffStrEqualsIgnCase(subKey, "shell")) { ffOptionParseString(key, value, &options->shell); return true; } - if(strcasecmp(subKey, "text") == 0) + if(ffStrEqualsIgnCase(subKey, "text")) { ffOptionParseString(key, value, &options->text); return true; @@ -92,19 +93,19 @@ void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "shell") == 0) + if (ffStrEqualsIgnCase(key, "shell")) { ffStrbufSetS(&options.shell, yyjson_get_str(val)); continue; } - if (strcasecmp(key, "text") == 0) + if (ffStrEqualsIgnCase(key, "text")) { ffStrbufSetS(&options.text, yyjson_get_str(val)); continue; diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 71e016aa8..8c9496fee 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/cpu/cpu.h" #include "modules/cpu/cpu.h" +#include "util/stringUtils.h" #define FF_CPU_NUM_FORMAT_ARGS 8 @@ -84,7 +85,7 @@ bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "temp") == 0) + if (ffStrEqualsIgnCase(subKey, "temp")) { options->temp = ffOptionParseBoolean(value); return true; @@ -110,13 +111,13 @@ void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "temp") == 0) + if (ffStrEqualsIgnCase(key, "temp")) { options.temp = yyjson_get_bool(val); continue; diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index bef65706c..0e2e04608 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -3,6 +3,7 @@ #include "common/bar.h" #include "detection/cpuusage/cpuusage.h" #include "modules/cpuusage/cpuusage.h" +#include "util/stringUtils.h" #define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage" #define FF_CPUUSAGE_NUM_FORMAT_ARGS 1 @@ -74,7 +75,7 @@ void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 61be4a105..b55934273 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/cursor/cursor.h" #include "modules/cursor/cursor.h" +#include "util/stringUtils.h" #define FF_CURSOR_NUM_FORMAT_ARGS 2 @@ -82,7 +83,7 @@ void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index e81615881..c461a5530 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "modules/custom/custom.h" #include "util/textModifier.h" +#include "util/stringUtils.h" void ffPrintCustom(FFinstance* instance, FFCustomOptions* options) { @@ -49,7 +50,7 @@ void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 508b0bdfa..049102f70 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/datetime/datetime.h" #include "modules/datetime/datetime.h" +#include "util/stringUtils.h" #define FF_DATETIME_DISPLAY_NAME "Date & Time" #define FF_DATETIME_NUM_FORMAT_ARGS 20 @@ -81,7 +82,7 @@ void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 806b65f85..3ae6105fd 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/de/de.h" +#include "util/stringUtils.h" #define FF_DE_NUM_FORMAT_ARGS 3 @@ -72,7 +73,7 @@ void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 2824f907d..dda9cb87f 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -4,6 +4,7 @@ #include "common/bar.h" #include "detection/disk/disk.h" #include "modules/disk/disk.h" +#include "util/stringUtils.h" #define FF_DISK_NUM_FORMAT_ARGS 10 #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -184,13 +185,13 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "folders") == 0) + if (ffStrEqualsIgnCase(subKey, "folders")) { ffOptionParseString(key, value, &options->folders); return true; } - if (strcasecmp(subKey, "show-regular") == 0) + if (ffStrEqualsIgnCase(subKey, "show-regular")) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_REGULAR_BIT; @@ -199,7 +200,7 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } - if (strcasecmp(subKey, "show-external") == 0) + if (ffStrEqualsIgnCase(subKey, "show-external")) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; @@ -208,7 +209,7 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } - if (strcasecmp(subKey, "show-hidden") == 0) + if (ffStrEqualsIgnCase(subKey, "show-hidden")) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT; @@ -217,7 +218,7 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } - if (strcasecmp(subKey, "show-subvolumes") == 0) + if (ffStrEqualsIgnCase(subKey, "show-subvolumes")) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; @@ -226,7 +227,7 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } - if (strcasecmp(subKey, "show-unknown") == 0) + if (ffStrEqualsIgnCase(subKey, "show-unknown")) { if (ffOptionParseBoolean(value)) options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; @@ -255,19 +256,19 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "folders") == 0) + if (ffStrEqualsIgnCase(key, "folders")) { ffStrbufSetS(&options.folders, yyjson_get_str(val)); continue; } - if (strcasecmp(key, "showExternal") == 0) + if (ffStrEqualsIgnCase(key, "showExternal")) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; @@ -276,7 +277,7 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showHidden") == 0) + if (ffStrEqualsIgnCase(key, "showHidden")) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_HIDDEN_BIT; @@ -285,7 +286,7 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showSubvolumes") == 0) + if (ffStrEqualsIgnCase(key, "showSubvolumes")) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; @@ -294,7 +295,7 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showUnknown") == 0) + if (ffStrEqualsIgnCase(key, "showUnknown")) { if (yyjson_get_bool(val)) options.showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; diff --git a/src/modules/display/display.c b/src/modules/display/display.c index c3bf888d7..0034805a8 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/display/display.h" +#include "util/stringUtils.h" #define FF_DISPLAY_NUM_FORMAT_ARGS 8 @@ -127,7 +128,7 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "compact-type") == 0) + if (ffStrEqualsIgnCase(subKey, "compact-type")) { options->compactType = (FFDisplayCompactType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "none", FF_DISPLAY_COMPACT_TYPE_NONE }, @@ -138,13 +139,13 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co return true; } - if (strcasecmp(subKey, "detect-name") == 0) + if (ffStrEqualsIgnCase(subKey, "detect-name")) { options->detectName = ffOptionParseBoolean(value); return true; } - if (strcasecmp(subKey, "precise-refresh-rate") == 0) + if (ffStrEqualsIgnCase(subKey, "precise-refresh-rate")) { options->preciseRefreshRate = ffOptionParseBoolean(value); return true; @@ -170,13 +171,13 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "compactType") == 0) + if (ffStrEqualsIgnCase(key, "compactType")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { @@ -192,13 +193,13 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "detectName") == 0) + if (ffStrEqualsIgnCase(key, "detectName")) { options.detectName = yyjson_get_bool(val); continue; } - if (strcasecmp(key, "preciseRefreshRate") == 0) + if (ffStrEqualsIgnCase(key, "preciseRefreshRate")) { options.preciseRefreshRate = yyjson_get_bool(val); continue; diff --git a/src/modules/font/font.c b/src/modules/font/font.c index cd3875c10..0d58be3cc 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/font/font.h" #include "modules/font/font.h" +#include "util/stringUtils.h" #define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1) @@ -75,7 +76,7 @@ void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 1a79a624d..9c228b29b 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/gamepad/gamepad.h" #include "modules/gamepad/gamepad.h" +#include "util/stringUtils.h" #define FF_GAMEPAD_NUM_FORMAT_ARGS 2 @@ -81,7 +82,7 @@ void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 2fff072a6..0fa1170ff 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -5,6 +5,7 @@ #include "detection/host/host.h" #include "detection/gpu/gpu.h" #include "modules/gpu/gpu.h" +#include "util/stringUtils.h" #include @@ -128,19 +129,19 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "force-vulkan") == 0) + if (ffStrEqualsIgnCase(subKey, "force-vulkan")) { options->forceVulkan = ffOptionParseBoolean(value); return true; } - if (strcasecmp(subKey, "temp") == 0) + if (ffStrEqualsIgnCase(subKey, "temp")) { options->temp = ffOptionParseBoolean(value); return true; } - if (strcasecmp(subKey, "hide-type") == 0) + if (ffStrEqualsIgnCase(subKey, "hide-type")) { options->hideType = (FFGPUType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "none", FF_GPU_TYPE_UNKNOWN }, @@ -170,25 +171,25 @@ void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "temp") == 0) + if (ffStrEqualsIgnCase(key, "temp")) { options.temp = yyjson_get_bool(val); continue; } - if (strcasecmp(key, "forceVulkan") == 0) + if (ffStrEqualsIgnCase(key, "forceVulkan")) { options.forceVulkan = yyjson_get_bool(val); continue; } - if (strcasecmp(key, "hideType") == 0) + if (ffStrEqualsIgnCase(key, "hideType")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { diff --git a/src/modules/host/host.c b/src/modules/host/host.c index f306bdf1a..e5dcaa8e9 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/host/host.h" #include "modules/host/host.h" +#include "util/stringUtils.h" #define FF_HOST_NUM_FORMAT_ARGS 5 @@ -92,7 +93,7 @@ void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index c4fb36c0b..cd331e89a 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/icons/icons.h" #include "modules/icons/icons.h" +#include "util/stringUtils.h" #define FF_ICONS_NUM_FORMAT_ARGS 1 @@ -62,7 +63,7 @@ void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index cf824efac..e62430fe4 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -1,6 +1,7 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "modules/kernel/kernel.h" +#include "util/stringUtils.h" #define FF_KERNEL_NUM_FORMAT_ARGS 4 @@ -62,7 +63,7 @@ void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index a849fbd6f..563fdd5f9 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/locale/locale.h" #include "modules/locale/locale.h" +#include "util/stringUtils.h" #define FF_LOCALE_NUM_FORMAT_ARGS 1 @@ -62,7 +63,7 @@ void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 011020bf9..e4c95b7e0 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/localip/localip.h" #include "modules/localip/localip.h" +#include "util/stringUtils.h" #define FF_LOCALIP_DISPLAY_NAME "Local IP" #define FF_LOCALIP_NUM_FORMAT_ARGS 2 @@ -134,7 +135,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "show-ipv4") == 0) + if (ffStrEqualsIgnCase(subKey, "show-ipv4")) { if (ffOptionParseBoolean(value)) options->showType |= FF_LOCALIP_TYPE_IPV4_BIT; @@ -143,7 +144,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } - if (strcasecmp(subKey, "show-ipv6") == 0) + if (ffStrEqualsIgnCase(subKey, "show-ipv6")) { if (ffOptionParseBoolean(value)) options->showType |= FF_LOCALIP_TYPE_IPV6_BIT; @@ -152,7 +153,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } - if (strcasecmp(subKey, "show-mac") == 0) + if (ffStrEqualsIgnCase(subKey, "show-mac")) { if (ffOptionParseBoolean(value)) options->showType |= FF_LOCALIP_TYPE_MAC_BIT; @@ -161,7 +162,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } - if (strcasecmp(subKey, "show-loop") == 0) + if (ffStrEqualsIgnCase(subKey, "show-loop")) { if (ffOptionParseBoolean(value)) options->showType |= FF_LOCALIP_TYPE_LOOP_BIT; @@ -170,7 +171,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } - if(strcasecmp(subKey, "compact") == 0) + if(ffStrEqualsIgnCase(subKey, "compact")) { if (ffOptionParseBoolean(value)) options->showType |= FF_LOCALIP_TYPE_COMPACT_BIT; @@ -179,7 +180,7 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } - if (strcasecmp(subKey, "name-prefix") == 0) + if (ffStrEqualsIgnCase(subKey, "name-prefix")) { ffOptionParseString(key, value, &options->namePrefix); return true; @@ -206,13 +207,13 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "showIpv4") == 0) + if (ffStrEqualsIgnCase(key, "showIpv4")) { if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_IPV4_BIT; @@ -221,7 +222,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showIpv6") == 0) + if (ffStrEqualsIgnCase(key, "showIpv6")) { if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_IPV6_BIT; @@ -230,7 +231,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showMac") == 0) + if (ffStrEqualsIgnCase(key, "showMac")) { if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_MAC_BIT; @@ -239,7 +240,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "showLoop") == 0) + if (ffStrEqualsIgnCase(key, "showLoop")) { if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_LOOP_BIT; @@ -248,7 +249,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "compact") == 0) + if (ffStrEqualsIgnCase(key, "compact")) { if (yyjson_get_bool(val)) options.showType |= FF_LOCALIP_TYPE_COMPACT_BIT; @@ -257,7 +258,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (strcasecmp(key, "namePrefix") == 0) + if (ffStrEqualsIgnCase(key, "namePrefix")) { ffStrbufSetS(&options.namePrefix, yyjson_get_str(val)); continue; diff --git a/src/modules/media/media.c b/src/modules/media/media.c index a841773fa..ccb9772db 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/media/media.h" #include "modules/media/media.h" +#include "util/stringUtils.h" #include @@ -137,7 +138,7 @@ void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 9d4133694..127987741 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -4,6 +4,7 @@ #include "common/bar.h" #include "detection/memory/memory.h" #include "modules/memory/memory.h" +#include "util/stringUtils.h" #define FF_MEMORY_NUM_FORMAT_ARGS 3 @@ -96,7 +97,7 @@ void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 5b52cd230..bf69739fa 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/opencl/opencl.h" #include "modules/opencl/opencl.h" +#include "util/stringUtils.h" #define FF_OPENCL_NUM_FORMAT_ARGS 3 @@ -71,7 +72,7 @@ void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 27f5f32a4..730f1f72d 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/opengl/opengl.h" #include "modules/opengl/opengl.h" +#include "util/stringUtils.h" #define FF_OPENGL_NUM_FORMAT_ARGS 4 @@ -59,7 +60,7 @@ bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, cons return true; #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "library") == 0) + if (ffStrEqualsIgnCase(key, "library")) { options->library = (FFOpenGLLibrary) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "auto", FF_OPENGL_LIBRARY_AUTO }, @@ -91,14 +92,14 @@ void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "library") == 0) + if (ffStrEqualsIgnCase(key, "library")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 0d4e67554..6964bed4e 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -3,6 +3,7 @@ #include "common/option.h" #include "detection/os/os.h" #include "modules/os/os.h" +#include "util/stringUtils.h" #include @@ -169,7 +170,7 @@ void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index c6fd4c9dc..a0269d504 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/packages/packages.h" #include "modules/packages/packages.h" +#include "util/stringUtils.h" #define FF_PACKAGES_NUM_FORMAT_ARGS 21 @@ -126,7 +127,7 @@ void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 1b94c3f04..56dfb0820 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/media/media.h" #include "modules/player/player.h" +#include "util/stringUtils.h" #include @@ -105,7 +106,7 @@ void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index f176d13f1..6fd67d8b6 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/poweradapter/poweradapter.h" #include "modules/poweradapter/poweradapter.h" +#include "util/stringUtils.h" #define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter" #define FF_POWERADAPTER_MODULE_ARGS 5 @@ -95,7 +96,7 @@ void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 4aa09318e..772994887 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/processes/processes.h" #include "modules/processes/processes.h" +#include "util/stringUtils.h" #define FF_PROCESSES_NUM_FORMAT_ARGS 1 @@ -63,7 +64,7 @@ void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index b873b7e71..920c7c944 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "common/networking.h" #include "modules/publicip/publicip.h" +#include "util/stringUtils.h" #define FF_PUBLICIP_DISPLAY_NAME "Public IP" #define FF_PUBLICIP_NUM_FORMAT_ARGS 1 @@ -81,13 +82,13 @@ bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "url") == 0) + if (ffStrEqualsIgnCase(subKey, "url")) { ffOptionParseString(key, value, &options->url); return true; } - if (strcasecmp(subKey, "timeout") == 0) + if (ffStrEqualsIgnCase(subKey, "timeout")) { options->timeout = ffOptionParseUInt32(key, value); return true; @@ -115,19 +116,19 @@ void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "url") == 0) + if (ffStrEqualsIgnCase(key, "url")) { ffStrbufSetS(&options.url, yyjson_get_str(val)); continue; } - if (strcasecmp(key, "timeout") == 0) + if (ffStrEqualsIgnCase(key, "timeout")) { options.timeout = (uint32_t) yyjson_get_uint(val); continue; diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 71e80835d..1ae369f70 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -1,6 +1,7 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "modules/separator/separator.h" +#include "util/stringUtils.h" void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) { @@ -44,7 +45,7 @@ bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key const char* subKey = ffOptionTestPrefix(key, FF_SEPARATOR_MODULE_NAME); if (!subKey) return false; - if (strcasecmp(subKey, "string") == 0) + if (ffStrEqualsIgnCase(subKey, "string")) { ffOptionParseString(key, value, &options->string); return true; @@ -70,10 +71,10 @@ void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; - if (strcasecmp(key, "string") == 0) + if (ffStrEqualsIgnCase(key, "string")) { ffStrbufSetS(&options.string, yyjson_get_str(val)); continue; diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index 343932ad9..ac76f14a5 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/terminalshell/terminalshell.h" #include "modules/shell/shell.h" +#include "util/stringUtils.h" #define FF_SHELL_NUM_FORMAT_ARGS 7 @@ -75,7 +76,7 @@ void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 9756cdf86..786d4ab78 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/sound/sound.h" #include "modules/sound/sound.h" +#include "util/stringUtils.h" #define FF_SOUND_NUM_FORMAT_ARGS 4 @@ -97,7 +98,7 @@ bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "sound-type") == 0) + if (ffStrEqualsIgnCase(subKey, "sound-type")) { options->soundType = (FFSoundType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "main", FF_SOUND_TYPE_MAIN }, @@ -128,13 +129,13 @@ void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "soundType") == 0) + if (ffStrEqualsIgnCase(key, "soundType")) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 92c7a2837..bf7ebb1fa 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -4,6 +4,7 @@ #include "common/bar.h" #include "detection/swap/swap.h" #include "modules/swap/swap.h" +#include "util/stringUtils.h" #define FF_SWAP_NUM_FORMAT_ARGS 3 @@ -96,7 +97,7 @@ void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 7dfbbe3c9..63de55909 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/terminalshell/terminalshell.h" #include "modules/terminal/terminal.h" +#include "util/stringUtils.h" #include @@ -76,7 +77,7 @@ void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 1ac69048d..db2177487 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/terminalfont/terminalfont.h" #include "modules/terminalfont/terminalfont.h" +#include "util/stringUtils.h" #define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font" #define FF_TERMINALFONT_NUM_FORMAT_ARGS 4 @@ -71,7 +72,7 @@ void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 9bd382e4e..67edd69ba 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/theme/theme.h" #include "modules/theme/theme.h" +#include "util/stringUtils.h" #define FF_THEME_NUM_FORMAT_ARGS 1 @@ -62,7 +63,7 @@ void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 58d398d3a..205d526ef 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -1,7 +1,8 @@ #include "common/printing.h" #include "common/jsonconfig.h" -#include "util/textModifier.h" #include "modules/title/title.h" +#include "util/textModifier.h" +#include "util/stringUtils.h" static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) { @@ -44,7 +45,7 @@ bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const const char* subKey = ffOptionTestPrefix(key, FF_TITLE_MODULE_NAME); if (!subKey) return false; - if (strcasecmp(subKey, "fdqn") == 0) + if (ffStrEqualsIgnCase(subKey, "fdqn")) { options->fdqn = ffOptionParseBoolean(value); return true; @@ -70,10 +71,10 @@ void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; - if (strcasecmp(key, "fdqn") == 0) + if (ffStrEqualsIgnCase(key, "fdqn")) { options.fdqn = yyjson_get_bool(val); continue; diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index 1cd92b1ba..6c7aaf892 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/uptime/uptime.h" #include "modules/uptime/uptime.h" +#include "util/stringUtils.h" #define FF_UPTIME_NUM_FORMAT_ARGS 4 @@ -111,6 +112,9 @@ void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 492ecbb61..6f81469d3 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/users/users.h" #include "modules/users/users.h" +#include "util/stringUtils.h" #define FF_USERS_NUM_FORMAT_ARGS 1 @@ -75,7 +76,7 @@ void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index 276a3f70f..da8897918 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/vulkan/vulkan.h" #include "modules/vulkan/vulkan.h" +#include "util/stringUtils.h" #define FF_VULKAN_NUM_FORMAT_ARGS 3 @@ -75,7 +76,7 @@ void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index ccc8c95e5..7f1623931 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/wallpaper/wallpaper.h" #include "modules/wallpaper/wallpaper.h" +#include "util/stringUtils.h" #define FF_WALLPAPER_NUM_FORMAT_ARGS 1 @@ -62,7 +63,7 @@ void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 3d7637a7f..d32095904 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "common/networking.h" #include "modules/weather/weather.h" +#include "util/stringUtils.h" #define FF_WEATHER_NUM_FORMAT_ARGS 1 @@ -65,13 +66,13 @@ bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (strcasecmp(subKey, "output-format") == 0) + if (ffStrEqualsIgnCase(subKey, "output-format")) { ffOptionParseString(key, value, &options->outputFormat); return true; } - if (strcasecmp(subKey, "timeout") == 0) + if (ffStrEqualsIgnCase(subKey, "timeout")) { options->timeout = ffOptionParseUInt32(key, value); return true; @@ -99,19 +100,19 @@ void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - if (strcasecmp(key, "outputFormat") == 0) + if (ffStrEqualsIgnCase(key, "outputFormat")) { ffStrbufSetS(&options.outputFormat, yyjson_get_str(val)); continue; } - if (strcasecmp(key, "timeout") == 0) + if (ffStrEqualsIgnCase(key, "timeout")) { options.timeout = (uint32_t) yyjson_get_uint(val); continue; diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 380457937..79e56db11 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/wifi/wifi.h" #include "modules/wifi/wifi.h" +#include "util/stringUtils.h" #define FF_WIFI_NUM_FORMAT_ARGS 10 @@ -102,7 +103,7 @@ void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 7aa1c534f..72a8536df 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" #include "modules/wm/wm.h" +#include "util/stringUtils.h" #define FF_WM_NUM_FORMAT_ARGS 3 @@ -73,7 +74,7 @@ void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 8f1ab4441..45d7ead7f 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -2,6 +2,7 @@ #include "common/jsonconfig.h" #include "detection/wmtheme/wmtheme.h" #include "modules/wmtheme/wmtheme.h" +#include "util/stringUtils.h" #define FF_WMTHEME_DISPLAY_NAME "WM Theme" #define FF_WMTHEME_NUM_FORMAT_ARGS 1 @@ -62,7 +63,7 @@ void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module) yyjson_obj_foreach(module, idx, max, key_, val) { const char* key = yyjson_get_str(key_); - if(strcasecmp(key, "type") == 0) + if(ffStrEqualsIgnCase(key, "type")) continue; if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) diff --git a/src/util/stringUtils.c b/src/util/stringUtils.c index 703c81a45..07a3bd101 100644 --- a/src/util/stringUtils.c +++ b/src/util/stringUtils.c @@ -1,6 +1,5 @@ #include "stringUtils.h" -#include #include bool ffStrSet(const char* str) diff --git a/src/util/stringUtils.h b/src/util/stringUtils.h index 7c2475353..2283b0aec 100644 --- a/src/util/stringUtils.h +++ b/src/util/stringUtils.h @@ -5,8 +5,29 @@ #include #include +#include bool ffStrSet(const char* str); bool ffStrHasNChars(const char* str, char c, uint32_t n); +static inline bool ffStrStartsWithIgnCase(const char* str, const char* compareTo) +{ + return strncasecmp(str, compareTo, strlen(compareTo)) == 0; +} + +static inline bool ffStrEqualsIgnCase(const char* str, const char* compareTo) +{ + return strcasecmp(str, compareTo) == 0; +} + +static inline bool ffStrStartsWith(const char* str, const char* compareTo) +{ + return strncmp(str, compareTo, strlen(compareTo)) == 0; +} + +static inline bool ffStrEquals(const char* str, const char* compareTo) +{ + return strcmp(str, compareTo) == 0; +} + #endif From da76c6efbe544fd0a65c233152d53bc723c0b779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 15:38:37 +0800 Subject: [PATCH 175/493] Global: refactor strncmp to ffStrStartsWith --- src/detection/displayserver/linux/wayland.c | 5 +++-- src/detection/gamepad/gamepad_linux.c | 3 ++- src/detection/media/media_linux.c | 2 +- src/detection/opencl/opencl.c | 5 ++--- src/detection/os/os_apple.m | 5 ++--- src/detection/packages/packages_linux.c | 3 ++- src/detection/wifi/wifi_bsd.c | 3 ++- src/detection/wifi/wifi_linux.c | 5 +++-- src/logo/option.c | 5 +++-- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index b5df76656..e58815c69 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -1,4 +1,5 @@ #include "displayserver_linux.h" +#include "util/stringUtils.h" #include #include @@ -105,9 +106,9 @@ static void waylandOutputGeometryListener(void *data, static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name) { WaylandDisplay* display = data; - if(strncmp(name, "eDP-", strlen("eDP-")) == 0) + if(ffStrStartsWith(name, "eDP-")) display->type = FF_DISPLAY_TYPE_BUILTIN; - else if(strncmp(name, "HDMI-", strlen("HDMI-")) == 0 || strncmp(name, "DP-", strlen("DP-")) == 0) + else if(ffStrStartsWith(name, "HDMI-") || ffStrStartsWith(name, "DP-")) display->type = FF_DISPLAY_TYPE_EXTERNAL; } #endif diff --git a/src/detection/gamepad/gamepad_linux.c b/src/detection/gamepad/gamepad_linux.c index 3da034044..8bbd53939 100644 --- a/src/detection/gamepad/gamepad_linux.c +++ b/src/detection/gamepad/gamepad_linux.c @@ -1,5 +1,6 @@ #include "gamepad.h" #include "common/io/io.h" +#include "util/stringUtils.h" #include #include @@ -16,7 +17,7 @@ const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(strncmp(entry->d_name, "js", 2) != 0) + if(!ffStrStartsWith(entry->d_name, "js")) continue; if(!isdigit(entry->d_name[2])) continue; diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 9615ee1a1..7ca21d30a 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -139,7 +139,7 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) const char* busName; data->lib->ffdbus_message_iter_get_basic(&arrayIterator, &busName); - if(strncmp(busName, FF_DBUS_MPRIS_PREFIX, sizeof(FF_DBUS_MPRIS_PREFIX) - 1) != 0) + if(!ffStrStartsWith(busName, FF_DBUS_MPRIS_PREFIX)) FF_DBUS_ITER_CONTINUE(data, &arrayIterator) if(getBusProperties(data, busName, result)) diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 6eb2791d8..2e5949af9 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -46,9 +46,8 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) return "clGetDeviceInfo returned NULL or empty string"; const char* versionPretty = version; - const char* prefix = "OpenCL "; - if(strncasecmp(version, prefix, sizeof(prefix) - 1) == 0) - versionPretty = version + sizeof(prefix) - 1; + if(ffStrStartsWithIgnCase(version, "OpenCL ")) + versionPretty = version + strlen("OpenCL "); ffStrbufSetS(&result->version, versionPretty); ffStrbufEnsureFree(&result->device, 128); diff --git a/src/detection/os/os_apple.m b/src/detection/os/os_apple.m index 0b537d718..190c1482b 100644 --- a/src/detection/os/os_apple.m +++ b/src/detection/os/os_apple.m @@ -78,12 +78,11 @@ static void parseOSXSoftwareLicense(FFOSResult* os) char* line = NULL; size_t len = 0; const char* searchStr = "\\f0\\b SOFTWARE LICENSE AGREEMENT FOR macOS "; - const size_t searchLen = strlen(searchStr); while(getline(&line, &len, rtf) != EOF) { - if (strncmp(line, searchStr, searchLen) == 0) + if (ffStrStartsWith(line, searchStr)) { - ffStrbufAppendS(&os->codename, line + searchLen); + ffStrbufAppendS(&os->codename, line + strlen(searchStr)); ffStrbufTrimRight(&os->codename, '\n'); ffStrbufTrimRight(&os->codename, '\\'); break; diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 81c1be565..b20c9177f 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -5,6 +5,7 @@ #include "common/properties.h" #include "common/settings.h" #include "detection/os/os.h" +#include "util/stringUtils.h" #include @@ -170,7 +171,7 @@ static uint32_t getXBPSImpl(FFstrbuf* baseDir) struct dirent *entry; while((entry = readdir(dir)) != NULL) { - if(entry->d_type != DT_REG || strncasecmp(entry->d_name, "pkgdb-", 6) != 0) + if(entry->d_type != DT_REG || !ffStrStartsWithIgnCase(entry->d_name, "pkgdb-")) continue; ffStrbufAppendC(baseDir, '/'); diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c index 85c5bb166..31ba488a2 100644 --- a/src/detection/wifi/wifi_bsd.c +++ b/src/detection/wifi/wifi_bsd.c @@ -1,6 +1,7 @@ #include "wifi.h" #include "common/processing.h" #include "common/properties.h" +#include "util/stringUtils.h" #include #include @@ -14,7 +15,7 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* res for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { - if (strncmp(i->if_name, "wlan", strlen("wlan")) != 0) continue; + if (!ffStrStartsWith(i->if_name, "wlan")) continue; FF_STRBUF_AUTO_DESTROY ifconfig = ffStrbufCreate(); if (ffProcessAppendStdOut(&ifconfig, (char* const[]) { "ifconfig", diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 191e4ad6b..871b9be50 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -1,4 +1,5 @@ #include "wifi.h" +#include "util/stringUtils.h" #include #include @@ -257,8 +258,8 @@ static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instan if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0) { - if(strncasecmp(iwr.u.name, "IEEE ", 5) == 0) - ffStrbufSetS(&item->conn.protocol, iwr.u.name + 5); + if(ffStrStartsWithIgnCase(iwr.u.name, "IEEE ")) + ffStrbufSetS(&item->conn.protocol, iwr.u.name + strlen("IEEE ")); else ffStrbufSetS(&item->conn.protocol, iwr.u.name); } diff --git a/src/logo/option.c b/src/logo/option.c index 51da4c332..7882ad669 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -1,6 +1,7 @@ #include "logo/logo.h" #include "common/jsonconfig.h" +#include "util/stringUtils.h" void ffInitLogoOptions(FFLogoOptions* options) { @@ -63,10 +64,10 @@ logoType: {}, }); } - else if(strncasecmp(subKey, "color-", strlen("color-")) && key[13] != '\0' && key[14] == '\0') // matches "--logo-color-*" + else if(ffStrStartsWithIgnCase(subKey, "color-") && subKey[6] != '\0' && subKey[7] == '\0') // matches "--logo-color-*" { //Map the number to an array index, so that '1' -> 0, '2' -> 1, etc. - int index = (int)key[13] - 49; + int index = (int)subKey[6] - '0' - 1; //Match only --logo-color-[1-9] if(index < 0 || index >= FASTFETCH_LOGO_MAX_COLORS) From baa8992322f7350a13af4edebe131e08d022f185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 16:07:23 +0800 Subject: [PATCH 176/493] Global: refactor `strcmp() == 0` to `ffStrEquals()` --- src/common/io/io_unix.c | 3 +- src/common/io/io_windows.c | 3 +- src/detection/battery/battery_linux.c | 3 +- src/detection/bluetooth/bluetooth_linux.c | 11 +- src/detection/brightness/brightness_linux.c | 3 +- .../displayserver/linux/displayserver_linux.c | 3 +- src/detection/displayserver/linux/wayland.c | 6 +- src/detection/displayserver/linux/wmde.c | 2 +- src/detection/host/host_apple.c | 232 +++++++++--------- src/detection/media/media_linux.c | 9 +- src/detection/os/os_apple.m | 1 + src/detection/packages/packages_linux.c | 2 +- src/detection/temps/temps_apple.c | 55 +++-- .../terminalfont/terminalfont_linux.c | 4 +- src/detection/terminalshell/terminalshell.c | 5 +- 15 files changed, 174 insertions(+), 168 deletions(-) diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 8d506b05e..54e561190 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -1,4 +1,5 @@ #include "io.h" +#include "util/stringUtils.h" #include #include @@ -194,7 +195,7 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol { if(entry->d_type == DT_DIR) { - if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) continue; ffStrbufAppendS(folder, entry->d_name); diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index 9a25a159a..f1f40a2b0 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -1,4 +1,5 @@ #include "io.h" +#include "util/stringUtils.h" static void createSubfolders(const char* fileName) { @@ -118,7 +119,7 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol { if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if(strcmp(entry.cFileName, ".") == 0 || strcmp(entry.cFileName, "..") == 0) + if(ffStrEquals(entry.cFileName, ".") || ffStrEquals(entry.cFileName, "..")) continue; ffStrbufSubstrBefore(folder, folderLength); diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 93f09faf1..bca7fbfdc 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -1,6 +1,7 @@ #include "fastfetch.h" #include "common/io/io.h" #include "battery.h" +#include "util/stringUtils.h" #include @@ -90,7 +91,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptio struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) continue; ffStrbufAppendS(&baseDir, entry->d_name); diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index 229a82a42..f429387e1 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -1,4 +1,5 @@ #include "bluetooth.h" +#include "util/stringUtils.h" #ifdef FF_HAVE_DBUS #include "common/dbus.h" @@ -59,15 +60,15 @@ static void detectBluetoothValue(FFDBusData* dbus, DBusMessageIter* iter, FFBlue dbus->lib->ffdbus_message_iter_next(&dictIter); - if(strcmp(deviceProperty, "Address") == 0) + if(ffStrEquals(deviceProperty, "Address")) ffDBusGetValue(dbus, &dictIter, &device->address); - else if(strcmp(deviceProperty, "Name") == 0) + else if(ffStrEquals(deviceProperty, "Name")) ffDBusGetValue(dbus, &dictIter, &device->name); - else if(strcmp(deviceProperty, "Icon") == 0) + else if(ffStrEquals(deviceProperty, "Icon")) ffDBusGetValue(dbus, &dictIter, &device->type); - else if(strcmp(deviceProperty, "Percentage") == 0) + else if(ffStrEquals(deviceProperty, "Percentage")) ffDBusGetByte(dbus, &dictIter, &device->battery); - else if(strcmp(deviceProperty, "Connected") == 0) + else if(ffStrEquals(deviceProperty, "Connected")) ffDBusGetBool(dbus, &dictIter, &device->connected); } diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index ee78bcea8..fc4afd556 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -1,5 +1,6 @@ #include "brightness.h" #include "common/io/io.h" +#include "util/stringUtils.h" #include #include @@ -24,7 +25,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) continue; ffStrbufAppendS(&backlightDir, entry->d_name); diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 4d50184f4..5c2ca46ef 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -1,4 +1,5 @@ #include "displayserver_linux.h" +#include "util/stringUtils.h" #include @@ -18,7 +19,7 @@ static void parseDRM(FFDisplayServerResult* result) struct dirent* entry; while((entry = readdir(dirp)) != NULL) { - if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) continue; ffStrbufAppendS(&drmDir, entry->d_name); diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index e58815c69..bb06661f1 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -92,9 +92,9 @@ static void waylandOutputGeometryListener(void *data, WaylandDisplay* display = data; display->transform = (enum wl_output_transform) transform; - if(make && strcmp(make, "unknown") != 0) + if(make && !ffStrEquals(make, "unknown")) ffStrbufAppendS(&display->name, make); - if(model && strcmp(model, "unknown") != 0) + if(model && !ffStrEquals(model, "unknown")) { if(display->name.length > 0) ffStrbufAppendC(&display->name, '-'); @@ -214,7 +214,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u { WaylandData* wldata = data; - if(strcmp(interface, wldata->ffwl_output_interface->name) == 0) + if(ffStrEquals(interface, wldata->ffwl_output_interface->name)) waylandOutputHandler(wldata, registry, name, version); } diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 67d8a5c27..1c404f4c5 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -144,7 +144,7 @@ static void getGnome(const FFinstance* instance, FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "gnome-shell"); const char* sessionMode = getenv("GNOME_SHELL_SESSION_MODE"); - if (sessionMode && strcmp(sessionMode, "classic") == 0) + if (sessionMode && ffStrEquals(sessionMode, "classic")) ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC); else ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME); diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index e906b67b8..d47ea8c44 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -1,10 +1,6 @@ #include "host.h" #include "common/sysctl.h" - -static inline bool strEqual(const char* a, const char* b) -{ - return strcmp(a, b) == 0; -} +#include "util/stringUtils.h" static const char* getProductName(const FFstrbuf* hwModel) { @@ -18,143 +14,143 @@ static const char* getProductName(const FFstrbuf* hwModel) if(ffStrbufStartsWithS(hwModel, "MacBookPro")) { const char* version = hwModel->chars + strlen("MacBookPro"); - if(strEqual(version, "18,3") || - strEqual(version, "18,4")) return "MacBook Pro (14-inch, 2021)"; - if(strEqual(version, "18,1") || - strEqual(version, "18,2")) return "MacBook Pro (16-inch, 2021)"; - if(strEqual(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)"; - if(strEqual(version, "16,4")) return "MacBook Pro (16-inch, 2019)"; - if(strEqual(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)"; - if(strEqual(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)"; - if(strEqual(version, "16,1")) return "MacBook Pro (16-inch, 2019)"; - if(strEqual(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)"; - if(strEqual(version, "15,3")) return "MacBook Pro (15-inch, 2019)"; - if(strEqual(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)"; - if(strEqual(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)"; - if(strEqual(version, "14,3")) return "MacBook Pro (15-inch, 2017)"; - if(strEqual(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)"; - if(strEqual(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)"; - if(strEqual(version, "13,3")) return "MacBook Pro (15-inch, 2016)"; - if(strEqual(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)"; - if(strEqual(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)"; - if(strEqual(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)"; - if(strEqual(version, "11,4") || - strEqual(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)"; - if(strEqual(version, "11,2") || - strEqual(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)"; - if(strEqual(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)"; - if(strEqual(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)"; - if(strEqual(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)"; - if(strEqual(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)"; - if(strEqual(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)"; - if(strEqual(version, "8,3")) return "MacBook Pro (17-inch, 2011)"; - if(strEqual(version, "8,2")) return "MacBook Pro (15-inch, 2011)"; - if(strEqual(version, "8,1")) return "MacBook Pro (13-inch, 2011)"; - if(strEqual(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)"; - if(strEqual(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)"; - if(strEqual(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)"; - if(strEqual(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)"; - if(strEqual(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)"; - if(strEqual(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)"; - if(strEqual(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)"; - if(strEqual(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)"; + if(ffStrEquals(version, "18,3") || + ffStrEquals(version, "18,4")) return "MacBook Pro (14-inch, 2021)"; + if(ffStrEquals(version, "18,1") || + ffStrEquals(version, "18,2")) return "MacBook Pro (16-inch, 2021)"; + if(ffStrEquals(version, "17,1")) return "MacBook Pro (13-inch, M1, 2020)"; + if(ffStrEquals(version, "16,4")) return "MacBook Pro (16-inch, 2019)"; + if(ffStrEquals(version, "16,3")) return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "16,2")) return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "16,1")) return "MacBook Pro (16-inch, 2019)"; + if(ffStrEquals(version, "15,4")) return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "15,3")) return "MacBook Pro (15-inch, 2019)"; + if(ffStrEquals(version, "15,2")) return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "15,1")) return "MacBook Pro (15-inch, 2018/2019)"; + if(ffStrEquals(version, "14,3")) return "MacBook Pro (15-inch, 2017)"; + if(ffStrEquals(version, "14,2")) return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "14,1")) return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "13,3")) return "MacBook Pro (15-inch, 2016)"; + if(ffStrEquals(version, "13,2")) return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)"; + if(ffStrEquals(version, "13,1")) return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)"; + if(ffStrEquals(version, "12,1")) return "MacBook Pro (Retina, 13-inch, Early 2015)"; + if(ffStrEquals(version, "11,4") || + ffStrEquals(version, "11,5")) return "MacBook Pro (Retina, 15-inch, Mid 2015)"; + if(ffStrEquals(version, "11,2") || + ffStrEquals(version, "11,3")) return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)"; + if(ffStrEquals(version, "11,1")) return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)"; + if(ffStrEquals(version, "10,2")) return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)"; + if(ffStrEquals(version, "10,1")) return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)"; + if(ffStrEquals(version, "9,2")) return "MacBook Pro (13-inch, Mid 2012)"; + if(ffStrEquals(version, "9,1")) return "MacBook Pro (15-inch, Mid 2012)"; + if(ffStrEquals(version, "8,3")) return "MacBook Pro (17-inch, 2011)"; + if(ffStrEquals(version, "8,2")) return "MacBook Pro (15-inch, 2011)"; + if(ffStrEquals(version, "8,1")) return "MacBook Pro (13-inch, 2011)"; + if(ffStrEquals(version, "7,1")) return "MacBook Pro (13-inch, Mid 2010)"; + if(ffStrEquals(version, "6,2")) return "MacBook Pro (15-inch, Mid 2010)"; + if(ffStrEquals(version, "6,1")) return "MacBook Pro (17-inch, Mid 2010)"; + if(ffStrEquals(version, "5,5")) return "MacBook Pro (13-inch, Mid 2009)"; + if(ffStrEquals(version, "5,3")) return "MacBook Pro (15-inch, Mid 2009)"; + if(ffStrEquals(version, "5,2")) return "MacBook Pro (17-inch, Mid/Early 2009)"; + if(ffStrEquals(version, "5,1")) return "MacBook Pro (15-inch, Late 2008)"; + if(ffStrEquals(version, "4,1")) return "MacBook Pro (17/15-inch, Early 2008)"; } else if(ffStrbufStartsWithS(hwModel, "MacBookAir")) { const char* version = hwModel->chars + strlen("MacBookAir"); - if(strEqual(version, "10,1")) return "MacBook Air (M1, 2020)"; - if(strEqual(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)"; - if(strEqual(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)"; - if(strEqual(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)"; - if(strEqual(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)"; - if(strEqual(version, "7,1")) return "MacBook Air (11-inch, Early 2015)"; - if(strEqual(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)"; - if(strEqual(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)"; - if(strEqual(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)"; - if(strEqual(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)"; - if(strEqual(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)"; - if(strEqual(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)"; - if(strEqual(version, "3,2")) return "MacBook Air (13-inch, Late 2010)"; - if(strEqual(version, "3,1")) return "MacBook Air (11-inch, Late 2010)"; - if(strEqual(version, "2,1")) return "MacBook Air (Mid 2009)"; + if(ffStrEquals(version, "10,1")) return "MacBook Air (M1, 2020)"; + if(ffStrEquals(version, "9,1")) return "MacBook Air (Retina, 13-inch, 2020)"; + if(ffStrEquals(version, "8,2")) return "MacBook Air (Retina, 13-inch, 2019)"; + if(ffStrEquals(version, "8,1")) return "MacBook Air (Retina, 13-inch, 2018)"; + if(ffStrEquals(version, "7,2")) return "MacBook Air (13-inch, Early 2015/2017)"; + if(ffStrEquals(version, "7,1")) return "MacBook Air (11-inch, Early 2015)"; + if(ffStrEquals(version, "6,2")) return "MacBook Air (13-inch, Mid 2013/Early 2014)"; + if(ffStrEquals(version, "6,1")) return "MacBook Air (11-inch, Mid 2013/Early 2014)"; + if(ffStrEquals(version, "5,2")) return "MacBook Air (13-inch, Mid 2012)"; + if(ffStrEquals(version, "5,1")) return "MacBook Air (11-inch, Mid 2012)"; + if(ffStrEquals(version, "4,2")) return "MacBook Air (13-inch, Mid 2011)"; + if(ffStrEquals(version, "4,1")) return "MacBook Air (11-inch, Mid 2011)"; + if(ffStrEquals(version, "3,2")) return "MacBook Air (13-inch, Late 2010)"; + if(ffStrEquals(version, "3,1")) return "MacBook Air (11-inch, Late 2010)"; + if(ffStrEquals(version, "2,1")) return "MacBook Air (Mid 2009)"; } else if(ffStrbufStartsWithS(hwModel, "Macmini")) { const char* version = hwModel->chars + strlen("Macmini"); - if(strEqual(version, "9,1")) return "Mac mini (M1, 2020)"; - if(strEqual(version, "8,1")) return "Mac mini (2018)"; - if(strEqual(version, "7,1")) return "Mac mini (Mid 2014)"; - if(strEqual(version, "6,1") || - strEqual(version, "6,2")) return "Mac mini (Late 2012)"; - if(strEqual(version, "5,1") || - strEqual(version, "5,2")) return "Mac mini (Mid 2011)"; - if(strEqual(version, "4,1")) return "Mac mini (Mid 2010)"; - if(strEqual(version, "3,1")) return "Mac mini (Early/Late 2009)"; + if(ffStrEquals(version, "9,1")) return "Mac mini (M1, 2020)"; + if(ffStrEquals(version, "8,1")) return "Mac mini (2018)"; + if(ffStrEquals(version, "7,1")) return "Mac mini (Mid 2014)"; + if(ffStrEquals(version, "6,1") || + ffStrEquals(version, "6,2")) return "Mac mini (Late 2012)"; + if(ffStrEquals(version, "5,1") || + ffStrEquals(version, "5,2")) return "Mac mini (Mid 2011)"; + if(ffStrEquals(version, "4,1")) return "Mac mini (Mid 2010)"; + if(ffStrEquals(version, "3,1")) return "Mac mini (Early/Late 2009)"; } else if(ffStrbufStartsWithS(hwModel, "MacBook")) { const char* version = hwModel->chars + strlen("MacBook"); - if(strEqual(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)"; - if(strEqual(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)"; - if(strEqual(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)"; - if(strEqual(version, "7,1")) return "MacBook (13-inch, Mid 2010)"; - if(strEqual(version, "6,1")) return "MacBook (13-inch, Late 2009)"; - if(strEqual(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)"; + if(ffStrEquals(version, "10,1")) return "MacBook (Retina, 12-inch, 2017)"; + if(ffStrEquals(version, "9,1")) return "MacBook (Retina, 12-inch, Early 2016)"; + if(ffStrEquals(version, "8,1")) return "MacBook (Retina, 12-inch, Early 2015)"; + if(ffStrEquals(version, "7,1")) return "MacBook (13-inch, Mid 2010)"; + if(ffStrEquals(version, "6,1")) return "MacBook (13-inch, Late 2009)"; + if(ffStrEquals(version, "5,2")) return "MacBook (13-inch, Early/Mid 2009)"; } else if(ffStrbufStartsWithS(hwModel, "MacPro")) { const char* version = hwModel->chars + strlen("MacPro"); - if(strEqual(version, "7,1")) return "Mac Pro (2019)"; - if(strEqual(version, "6,1")) return "Mac Pro (Late 2013)"; - if(strEqual(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)"; - if(strEqual(version, "4,1")) return "Mac Pro (Early 2009)"; + if(ffStrEquals(version, "7,1")) return "Mac Pro (2019)"; + if(ffStrEquals(version, "6,1")) return "Mac Pro (Late 2013)"; + if(ffStrEquals(version, "5,1")) return "Mac Pro (Mid 2010 - Mid 2012)"; + if(ffStrEquals(version, "4,1")) return "Mac Pro (Early 2009)"; } else if(ffStrbufStartsWithS(hwModel, "Mac")) { const char* version = hwModel->chars + strlen("Mac"); - if(strEqual(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; - if(strEqual(version, "14,14")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; - if(strEqual(version, "14,13")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; - if(strEqual(version, "14,8")) return "Mac Pro (2023)"; - if(strEqual(version, "14,6") || - strEqual(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; - if(strEqual(version, "14,5") || - strEqual(version, "14,9")) return "MacBook Pro (14-inch, 2023)"; - if(strEqual(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)"; - if(strEqual(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)"; - if(strEqual(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)"; - if(strEqual(version, "14,2")) return "MacBook Air (M2, 2022)"; - if(strEqual(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)"; - if(strEqual(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)"; + if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; + if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; + if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; + if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)"; + if(ffStrEquals(version, "14,6") || + ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; + if(ffStrEquals(version, "14,5") || + ffStrEquals(version, "14,9")) return "MacBook Pro (14-inch, 2023)"; + if(ffStrEquals(version, "14,3")) return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)"; + if(ffStrEquals(version, "14,12")) return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)"; + if(ffStrEquals(version, "14,7")) return "MacBook Pro (13-inch, M2, 2022)"; + if(ffStrEquals(version, "14,2")) return "MacBook Air (M2, 2022)"; + if(ffStrEquals(version, "13,1")) return "Mac Studio (M1 Max, 2022, Two USB-C front ports)"; + if(ffStrEquals(version, "13,2")) return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)"; } else if(ffStrbufStartsWithS(hwModel, "iMac")) { const char* version = hwModel->chars + strlen("iMac"); - if(strEqual(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; - if(strEqual(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)"; - if(strEqual(version, "20,1") || - strEqual(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)"; - if(strEqual(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)"; - if(strEqual(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)"; - if(strEqual(version, "Pro1,1")) return "iMac Pro (2017)"; - if(strEqual(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)"; - if(strEqual(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)"; - if(strEqual(version, "18,1")) return "iMac (21.5-inch, 2017)"; - if(strEqual(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)"; - if(strEqual(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)"; - if(strEqual(version, "16,1")) return "iMac (21.5-inch, Late 2015)"; - if(strEqual(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)"; - if(strEqual(version, "14,4")) return "iMac (21.5-inch, Mid 2014)"; - if(strEqual(version, "14,2")) return "iMac (27-inch, Late 2013)"; - if(strEqual(version, "14,1")) return "iMac (21.5-inch, Late 2013)"; - if(strEqual(version, "13,2")) return "iMac (27-inch, Late 2012)"; - if(strEqual(version, "13,1")) return "iMac (21.5-inch, Late 2012)"; - if(strEqual(version, "12,2")) return "iMac (27-inch, Mid 2011)"; - if(strEqual(version, "12,1")) return "iMac (21.5-inch, Mid 2011)"; - if(strEqual(version, "11,3")) return "iMac (27-inch, Mid 2010)"; - if(strEqual(version, "11,2")) return "iMac (21.5-inch, Mid 2010)"; - if(strEqual(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)"; - if(strEqual(version, "9,1")) return "iMac (24/20-inch, Early 2009)"; + if(ffStrEquals(version, "21,1")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; + if(ffStrEquals(version, "21,2")) return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)"; + if(ffStrEquals(version, "20,1") || + ffStrEquals(version, "20,2")) return "iMac (Retina 5K, 27-inch, 2020)"; + if(ffStrEquals(version, "19,1")) return "iMac (Retina 5K, 27-inch, 2019)"; + if(ffStrEquals(version, "19,2")) return "iMac (Retina 4K, 21.5-inch, 2019)"; + if(ffStrEquals(version, "Pro1,1")) return "iMac Pro (2017)"; + if(ffStrEquals(version, "18,3")) return "iMac (Retina 5K, 27-inch, 2017)"; + if(ffStrEquals(version, "18,2")) return "iMac (Retina 4K, 21.5-inch, 2017)"; + if(ffStrEquals(version, "18,1")) return "iMac (21.5-inch, 2017)"; + if(ffStrEquals(version, "17,1")) return "iMac (Retina 5K, 27-inch, Late 2015)"; + if(ffStrEquals(version, "16,2")) return "iMac (Retina 4K, 21.5-inch, Late 2015)"; + if(ffStrEquals(version, "16,1")) return "iMac (21.5-inch, Late 2015)"; + if(ffStrEquals(version, "15,1")) return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)"; + if(ffStrEquals(version, "14,4")) return "iMac (21.5-inch, Mid 2014)"; + if(ffStrEquals(version, "14,2")) return "iMac (27-inch, Late 2013)"; + if(ffStrEquals(version, "14,1")) return "iMac (21.5-inch, Late 2013)"; + if(ffStrEquals(version, "13,2")) return "iMac (27-inch, Late 2012)"; + if(ffStrEquals(version, "13,1")) return "iMac (21.5-inch, Late 2012)"; + if(ffStrEquals(version, "12,2")) return "iMac (27-inch, Mid 2011)"; + if(ffStrEquals(version, "12,1")) return "iMac (21.5-inch, Mid 2011)"; + if(ffStrEquals(version, "11,3")) return "iMac (27-inch, Mid 2010)"; + if(ffStrEquals(version, "11,2")) return "iMac (21.5-inch, Mid 2010)"; + if(ffStrEquals(version, "10,1")) return "iMac (27/21.5-inch, Late 2009)"; + if(ffStrEquals(version, "9,1")) return "iMac (24/20-inch, Early 2009)"; } return hwModel->chars; } diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 7ca21d30a..9eb92bf73 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -1,6 +1,7 @@ #include "fastfetch.h" #include "detection/media/media.h" #include "common/thread.h" +#include "util/stringUtils.h" #include @@ -61,13 +62,13 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul data->lib->ffdbus_message_iter_next(&dictIterator); - if(strcmp(key, "xesam:title") == 0) + if(ffStrEquals(key, "xesam:title")) ffDBusGetValue(data, &dictIterator, &result->song); - else if(strcmp(key, "xesam:album") == 0) + else if(ffStrEquals(key, "xesam:album")) ffDBusGetValue(data, &dictIterator, &result->album); - else if(strcmp(key, "xesam:artist") == 0) + else if(ffStrEquals(key, "xesam:artist")) ffDBusGetValue(data, &dictIterator, &result->artist); - else if(strcmp(key, "xesam:url") == 0) + else if(ffStrEquals(key, "xesam:url")) ffDBusGetValue(data, &dictIterator, &result->url); if(result->song.length > 0 && result->artist.length > 0 && result->album.length > 0 && result->url.length > 0) diff --git a/src/detection/os/os_apple.m b/src/detection/os/os_apple.m index 190c1482b..dac09ddcd 100644 --- a/src/detection/os/os_apple.m +++ b/src/detection/os/os_apple.m @@ -1,5 +1,6 @@ #include "os.h" #include "common/sysctl.h" +#include "util/stringUtils.h" #include #include diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index b20c9177f..3fc5c9816 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -309,7 +309,7 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi { if(entry->d_type != DT_DIR) continue; - if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) continue; ffStrbufAppendS(baseDir, entry->d_name); diff --git a/src/detection/temps/temps_apple.c b/src/detection/temps/temps_apple.c index 041e1418e..02ed59d7e 100644 --- a/src/detection/temps/temps_apple.c +++ b/src/detection/temps/temps_apple.c @@ -1,5 +1,6 @@ #include "fastfetch.h" #include "temps_apple.h" +#include "util/stringUtils.h" #include #include @@ -198,108 +199,108 @@ static const char *smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl if (val.dataSize == 0) return "Empty SMC result"; - if (strcmp(val.dataType, kDataTypeUi8) == 0 || - strcmp(val.dataType, kDataTypeUi16) == 0 || - strcmp(val.dataType, kDataTypeUi32) == 0 || - strcmp(val.dataType, kDataTypeUi64) == 0) + if (ffStrEquals(val.dataType, kDataTypeUi8) || + ffStrEquals(val.dataType, kDataTypeUi16) || + ffStrEquals(val.dataType, kDataTypeUi32) || + ffStrEquals(val.dataType, kDataTypeUi64)) { uint64_t tmp = 0; for (uint32_t i = 0; i < val.dataSize; i++) tmp += (uint64_t)((uint8_t)(val.bytes[i]) * pow(256, val.dataSize - 1 - i)); *value = (double)tmp; } - else if (strcmp(val.dataType, kDataTypeFlt) == 0) + else if (ffStrEquals(val.dataType, kDataTypeFlt)) { *value = *(float *)(val.bytes); } - else if (strcmp(val.dataType, kDataTypeFp1f) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp1f) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 32768.0; } - else if (strcmp(val.dataType, kDataTypeFp4c) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp4c) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4096.0; } - else if (strcmp(val.dataType, kDataTypeFp5b) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp5b) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 2048.0; } - else if (strcmp(val.dataType, kDataTypeFp6a) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp6a) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1024.0; } - else if (strcmp(val.dataType, kDataTypeFp79) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp79) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 512.0; } - else if (strcmp(val.dataType, kDataTypeFp88) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFp88) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 256.0; } - else if (strcmp(val.dataType, kDataTypeFpa6) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFpa6) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 64.0; } - else if (strcmp(val.dataType, kDataTypeFpc4) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFpc4) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16.0; } - else if (strcmp(val.dataType, kDataTypeFpe2) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeFpe2) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4.0; } - else if (strcmp(val.dataType, kDataTypeSp1e) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp1e) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16384.0; } - else if (strcmp(val.dataType, kDataTypeSp3c) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp3c) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4096.0; } - else if (strcmp(val.dataType, kDataTypeSp4b) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp4b) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 2048.0; } - else if (strcmp(val.dataType, kDataTypeSp5a) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp5a) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1024.0; } - else if (strcmp(val.dataType, kDataTypeSp69) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp69) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 512.0; } - else if (strcmp(val.dataType, kDataTypeSp78) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp78) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 256.0; } - else if (strcmp(val.dataType, kDataTypeSp87) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp87) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 128.0; } - else if (strcmp(val.dataType, kDataTypeSp96) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSp96) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 64.0; } - else if (strcmp(val.dataType, kDataTypeSpb4) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSpb4) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16.0; } - else if (strcmp(val.dataType, kDataTypeSpf0) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSpf0) && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1.0; } - else if (strcmp(val.dataType, kDataTypeSi8) == 0 && val.dataSize == 1) + else if (ffStrEquals(val.dataType, kDataTypeSi8) && val.dataSize == 1) { signed char *bytes = (signed char *)val.bytes; int16_t temp = 0; temp += (int8_t)(bytes[0]); *value = temp; } - else if (strcmp(val.dataType, kDataTypeSi16) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypeSi16) && val.dataSize == 2) { *value = ntohs(*(int16_t *)(val.bytes)); } - else if (strcmp(val.dataType, kDataTypePwm) == 0 && val.dataSize == 2) + else if (ffStrEquals(val.dataType, kDataTypePwm) && val.dataSize == 2) { *value = (double)ntohs(*(uint16_t *)(val.bytes)) * 100 / 65536.0; } diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 1a32692cb..869add82d 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -138,13 +138,13 @@ static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResul for(int count = 0; getline(&line, &len, file) != -1 && count < 2;) { - if(strcmp(line, "[basic.interface.font]\n") == 0) + if(ffStrEquals(line, "[basic.interface.font]\n")) { if(getline(&line, &len, file) != -1) ffParsePropLine(line, "value=", &fontName); ++count; } - else if(strcmp(line, "[basic.interface.font_size]\n") == 0) + else if(ffStrEquals(line, "[basic.interface.font_size]\n")) { if(getline(&line, &len, file) != -1) ffParsePropLine(line, "value=", &fontSize); diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index b7497b775..8651ac893 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -2,6 +2,7 @@ #include "common/io/io.h" #include "common/processing.h" #include "common/properties.h" +#include "util/stringUtils.h" #ifdef _WIN32 @@ -305,8 +306,8 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(termProgram) { if(ffStrbufStartsWithIgnCaseS(processName, termProgram) || // processName ends with `.exe` on Windows - (strcmp(termProgram, "vscode") == 0 && ffStrbufStartsWithIgnCaseS(processName, "code")) || - (strcmp(termProgram, "iTerm.app") == 0 && ffStrbufStartsWithIgnCaseS(processName, "iTermServer-")) + (ffStrEquals(termProgram, "vscode") && ffStrbufStartsWithIgnCaseS(processName, "code")) || + (ffStrEquals(termProgram, "iTerm.app") && ffStrbufStartsWithIgnCaseS(processName, "iTermServer-")) ) { ffStrbufSetS(version, termProgramVersion); return true; From 16d2fd7f9b40f09ebfd761620b9b43690fe669bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 16:17:31 +0800 Subject: [PATCH 177/493] Disk: don't display file system if it's not set --- src/modules/disk/disk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index dda9cb87f..f94555b81 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -60,7 +60,8 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { - ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); + if(disk->filesystem.length) + ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT) ffStrbufAppendS(&str, "[External]"); From bc7d84fea2053883f734c5cc40a50b176cd67fa1 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 19 Jun 2023 14:40:34 +0200 Subject: [PATCH 178/493] WM/DE: Linux: Use strcasestr to catch more processes --- src/detection/displayserver/displayserver.h | 6 ++ src/detection/displayserver/linux/wmde.c | 100 ++++++++------------ 2 files changed, 46 insertions(+), 60 deletions(-) diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index 5ffd5a30d..ba874dc25 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -30,6 +30,12 @@ #define FF_WM_PRETTY_WESTON "Weston" #define FF_WM_PRETTY_XMONAD "XMonad" #define FF_WM_PRETTY_WSLG "WSLg" +#define FF_WM_PRETTY_TINYWM "TinyWM" +#define FF_WM_PRETTY_QTILE "Qtile" +#define FF_WM_PRETTY_HERBSTLUFTWM "herbstluftwm" +#define FF_WM_PRETTY_ICEWM "IceWM" +#define FF_WM_PRETTY_SPECTRWM "spectrwm" + #define FF_WM_PROTOCOL_TTY "TTY" #define FF_WM_PROTOCOL_X11 "X11" diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 1c404f4c5..e76130b5d 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -67,11 +67,13 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) strcasecmp(name, "gnome shell") == 0 || strcasecmp(name, "gnome-session-binary") == 0 || strcasestr(name, "mutter") != NULL - ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUTTER); + ) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUTTER); else if( strcasecmp(name, "cinnamon-session") == 0 || strcasestr(name, "muffin") != NULL - ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUFFIN); + ) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUFFIN); else if(strcasestr(name, "sway") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_SWAY); else if(strcasestr(name, "weston") != NULL) @@ -88,14 +90,25 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XMONAD); else if(strcasestr(name, "wslg") != NULL) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WSLG); - else if( // WMs where the pretty name matches the process name - strcasestr(name, "dwm") != NULL || - strcasestr(name, "bspwm") != NULL || - strcasestr(name, "tinywm") != NULL - ) ffStrbufSetS(&result->wmPrettyName, name); + else if(strcasestr(name, "dwm") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_DWM); + else if(strcasestr(name, "bspwm") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_BSPWM); + else if(strcasestr(name, "tinywm") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_TINYWM); + else if(strcasestr(name, "qtile") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_QTILE); + else if(strcasestr(name, "herbstluftwm") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_HERBSTLUFTWM); + else if(strcasestr(name, "icewm") != NULL) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_ICEWM); +} - if(result->wmPrettyName.length > 0 && result->wmProcessName.length == 0) - ffStrbufSetS(&result->wmProcessName, name); +static void applyNameIfWM(FFDisplayServerResult* result, const char* processName) +{ + applyPrettyNameIfWM(result, processName); + if(result->wmPrettyName.length > 0) + ffStrbufSetS(&result->wmProcessName, processName); } static void applyBetterWM(FFDisplayServerResult* result, const char* processName) @@ -103,12 +116,11 @@ static void applyBetterWM(FFDisplayServerResult* result, const char* processName if(!ffStrSet(processName)) return; + ffStrbufSetS(&result->wmProcessName, processName); + //If it is a known wm, this will set the pretty name applyPrettyNameIfWM(result, processName); - //If it isn't a known wm, we have to set the process name our self - ffStrbufSetS(&result->wmProcessName, processName); - //If it isn't a known wm, set the pretty name to the process name if(result->wmPrettyName.length == 0) ffStrbufAppend(&result->wmPrettyName, &result->wmProcessName); @@ -261,52 +273,20 @@ static void applyPrettyNameIfDE(const FFinstance* instance, FFDisplayServerResul { if(!ffStrSet(name)) return; - - else if( - strcasecmp(name, "KDE") == 0 || - strcasecmp(name, "plasma") == 0 || - strcasecmp(name, "plasmashell") == 0 || - strcasecmp(name, "plasmawayland") == 0 - ) getKDE(instance, result); - - else if( - strcasecmp(name, "Gnome") == 0 || - strcasecmp(name, "ubuntu:GNOME") == 0 || - strcasecmp(name, "ubuntu") == 0 || - strcasecmp(name, "gnome-shell") == 0 - ) getGnome(instance, result); - - else if( - strcasecmp(name, "X-Cinnamon") == 0 || - strcasecmp(name, "Cinnamon") == 0 - ) getCinnamon(instance, result); - - else if( - strcasecmp(name, "XFCE") == 0 || - strcasecmp(name, "X-XFCE") == 0 || - strcasecmp(name, "XFCE4") == 0 || - strcasecmp(name, "X-XFCE4") == 0 || - strcasecmp(name, "xfce4-session") == 0 - ) getXFCE4(instance, result); - - else if( - strcasecmp(name, "MATE") == 0 || - strcasecmp(name, "X-MATE") == 0 || - strcasecmp(name, "mate-session") == 0 - ) getMate(instance, result); - - else if( - strcasecmp(name, "LXQt") == 0 || - strcasecmp(name, "X-LXQT") == 0 || - strcasecmp(name, "lxqt-session") == 0 - ) getLXQt(instance, result); - - else if( - strcasecmp(name, "Budgie") == 0 || - strcasecmp(name, "X-Budgie") == 0 || - strcasecmp(name, "budgie-desktop") == 0 || - strcasecmp(name, "Budgie:GNOME") == 0 - ) getBudgie(instance, result); + else if(strcasestr(name, "plasma") != NULL || strcasestr(name, "kde") != NULL) + getKDE(instance, result); + else if(strcasestr(name, "gnome") != NULL) + getGnome(instance, result); + else if(strcasestr(name, "cinnamon") != NULL) + getCinnamon(instance, result); + else if(strcasestr(name, "xfce") != NULL) + getXFCE4(instance, result); + else if(strcasestr(name, "mate") != NULL) + getMate(instance, result); + else if(strcasestr(name, "lxqt") != NULL) + getLXQt(instance, result); + else if(strcasestr(name, "budgie") != NULL) + getBudgie(instance, result); } static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) @@ -390,7 +370,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re applyPrettyNameIfDE(instance, result, processName.chars); if(result->wmPrettyName.length == 0) - applyPrettyNameIfWM(result, processName.chars); + applyNameIfWM(result, processName.chars); if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0) break; @@ -423,7 +403,7 @@ void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result) else { //if env is a known WM, use it - applyPrettyNameIfWM(result, env); + applyNameIfWM(result, env); } //Connecting to a display server only gives WM results, not DE results. From 9f5dc24bf6d24a28024a0de7fe22725c30a959e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 21:16:54 +0800 Subject: [PATCH 179/493] Bios: print version; don't print N/A --- src/detection/bios/bios_linux.c | 3 ++- src/modules/bios/bios.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index 820cff62c..ae46e7c99 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -23,7 +23,8 @@ static bool hostValueSet(FFstrbuf* value) ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && ffStrbufIgnCaseCompS(value, "INVALID") != 0 && ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 + ffStrbufIgnCaseCompS(value, "All Series") != 0 && + ffStrbufIgnCaseCompS(value, "N/A") != 0 ; } diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 70850a714..8c387f372 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -31,7 +31,10 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - puts(bios.biosRelease.chars); + ffStrbufWriteTo(&bios.biosRelease, stdout); + if (bios.biosVersion.length) + printf(" (%s)", bios.biosVersion.chars); + putchar('\n'); } else { From eef3afabb766a545dfb162067fc8a746e3c07555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 21:17:07 +0800 Subject: [PATCH 180/493] Board: print version; don't print N/A --- src/detection/board/board_linux.c | 3 ++- src/modules/board/board.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index 8f5bcd2ff..c376b0fe6 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -23,7 +23,8 @@ static bool hostValueSet(FFstrbuf* value) ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && ffStrbufIgnCaseCompS(value, "INVALID") != 0 && ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 + ffStrbufIgnCaseCompS(value, "All Series") != 0 && + ffStrbufIgnCaseCompS(value, "N/A") != 0 ; } diff --git a/src/modules/board/board.c b/src/modules/board/board.c index bb0027d9d..b590d96b0 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -26,7 +26,10 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - puts(result.boardName.chars); + ffStrbufWriteTo(&result.boardName, stdout); + if (result.boardVersion.length) + printf(" (%s)", result.boardVersion.chars); + putchar('\n'); } else { From 9bd8a788c8f236243e9abd2a8b975c738ba7572b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 21:19:09 +0800 Subject: [PATCH 181/493] Chassis: print version; don't print N/A --- src/detection/chassis/chassis_linux.c | 3 ++- src/modules/chassis/chassis.c | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index 0e40b217e..66e30e447 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -23,7 +23,8 @@ static bool hostValueSet(FFstrbuf* value) ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && ffStrbufIgnCaseCompS(value, "INVALID") != 0 && ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 + ffStrbufIgnCaseCompS(value, "All Series") != 0 && + ffStrbufIgnCaseCompS(value, "N/A") != 0 ; } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index da6b6cf94..66ae7f2d7 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -30,13 +30,10 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - - FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateCopy(&result.chassisType); - - if(result.chassisVersion.length > 0) - ffStrbufAppendF(&output, " (%s)", result.chassisVersion.chars); - - ffStrbufPutTo(&output, stdout); + ffStrbufWriteTo(&result.chassisType, stdout); + if (result.chassisVersion.length) + printf(" (%s)", result.chassisVersion.chars); + putchar('\n'); } else { From 2ff4daef205387c906acc99d236d445aed535860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 21:27:47 +0800 Subject: [PATCH 182/493] Board: simplify code --- src/detection/board/board.h | 3 +-- src/detection/board/board_bsd.c | 6 ++---- src/detection/board/board_linux.c | 10 ++-------- src/detection/board/board_nosupport.c | 8 ++------ src/detection/board/board_windows.c | 19 ++++++++----------- src/modules/board/board.c | 10 ++++++---- 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/detection/board/board.h b/src/detection/board/board.h index 15044469e..f4065d103 100644 --- a/src/detection/board/board.h +++ b/src/detection/board/board.h @@ -10,9 +10,8 @@ typedef struct FFBoardResult FFstrbuf boardName; FFstrbuf boardVendor; FFstrbuf boardVersion; - FFstrbuf error; } FFBoardResult; -void ffDetectBoard(FFBoardResult* result); +const char* ffDetectBoard(FFBoardResult* result); #endif diff --git a/src/detection/board/board_bsd.c b/src/detection/board/board_bsd.c index a10821ac6..f05811bec 100644 --- a/src/detection/board/board_bsd.c +++ b/src/detection/board/board_bsd.c @@ -1,12 +1,10 @@ #include "board.h" #include "common/settings.h" -void ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FFBoardResult* board) { - ffStrbufInit(&board->boardName); - ffStrbufInit(&board->boardVendor); - ffStrbufInit(&board->boardVersion); ffSettingsGetFreeBSDKenv("smbios.planar.product", &board->boardName); ffSettingsGetFreeBSDKenv("smbios.planar.maker", &board->boardVendor); ffSettingsGetFreeBSDKenv("smbios.planar.version", &board->boardVersion); + return NULL; } diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index c376b0fe6..435087798 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -41,16 +41,10 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu ffStrbufClear(buffer); } -void ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FFBoardResult* board) { - ffStrbufInit(&board->error); - - ffStrbufInit(&board->boardName); getHostValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->boardName); - - ffStrbufInit(&board->boardVendor); getHostValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->boardVendor); - - ffStrbufInit(&board->boardVersion); getHostValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->boardVersion); + return NULL; } diff --git a/src/detection/board/board_nosupport.c b/src/detection/board/board_nosupport.c index 0b182ba3e..7dc258c97 100644 --- a/src/detection/board/board_nosupport.c +++ b/src/detection/board/board_nosupport.c @@ -1,10 +1,6 @@ #include "board.h" -void ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FFBoardResult* board) { - ffStrbufInitS(&board->error, "Not supported on this platform"); - - ffStrbufInit(&board->boardName); - ffStrbufInit(&board->boardVendor); - ffStrbufInit(&board->boardVersion); + return "Not supported on this platform"; } diff --git a/src/detection/board/board_windows.c b/src/detection/board/board_windows.c index 4d02b679b..a027fb883 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -1,21 +1,18 @@ #include "board.h" #include "util/windows/registry.h" -void ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FFBoardResult* board) { - ffStrbufInit(&board->error); - - ffStrbufInit(&board->boardName); - ffStrbufInit(&board->boardVendor); - ffStrbufInit(&board->boardVersion); - FF_HKEY_AUTO_DESTROY hKey = NULL; - if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &board->error)) - return; + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\") failed"; + + if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->boardName, NULL)) + return "ffRegReadStrbuf(hKey, L\"BaseBoardProduct\") failed"; - if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->boardName, &board->error)) - return; ffRegReadStrbuf(hKey, L"BaseBoardManufacturer", &board->boardVendor, NULL); ffRegReadStrbuf(hKey, L"BaseBoardVersion", &board->boardVersion, NULL); + + return NULL; } diff --git a/src/modules/board/board.c b/src/modules/board/board.c index b590d96b0..fe72f5b7d 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -9,11 +9,14 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) { FFBoardResult result; - ffDetectBoard(&result); + ffStrbufInit(&result.boardName); + ffStrbufInit(&result.boardVendor); + ffStrbufInit(&result.boardVersion); + const char* error = ffDetectBoard(&result); - if(result.error.length > 0) + if(error) { - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%*s", result.error.length, result.error.chars); + ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } @@ -44,7 +47,6 @@ exit: ffStrbufDestroy(&result.boardName); ffStrbufDestroy(&result.boardVendor); ffStrbufDestroy(&result.boardVersion); - ffStrbufDestroy(&result.error); } void ffInitBoardOptions(FFBoardOptions* options) From 054093025e9b9773853151665ee1cd635f0e7953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 19 Jun 2023 19:59:21 +0800 Subject: [PATCH 183/493] Disk (Android): actually detect something --- src/detection/disk/disk_linux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 446e93b15..2859fa374 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -17,6 +17,8 @@ static bool isPhysicalDevice(FFstrbuf* device) { + #ifndef __ANDROID__ //On Android, `/dev` is not accessable, so that the following checks always fail + //DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem. if(ffStrbufEqualS(device, "drvfs")) return true; @@ -37,6 +39,8 @@ static bool isPhysicalDevice(FFstrbuf* device) if(!ffStrbufStartsWithS(device, "/dev/")) return false; + #endif // __ANDROID__ + if( ffStrbufStartsWithS(device, "/dev/loop") || //Ignore loop devices ffStrbufStartsWithS(device, "/dev/ram") || //Ignore ram devices From ce864b88dfbfc085c220287457688ff235bdd5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 09:29:58 +0800 Subject: [PATCH 184/493] Fastfetch: don't print modules in `config.jsonc` if `--structure` is specified Good for testing --- src/fastfetch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 2efa6fcf3..bdb84bdfb 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1183,7 +1183,7 @@ int main(int argc, const char** argv) parseConfigFiles(&instance, &data); parseArguments(&instance, &data, argc, argv); - if(!instance.state.configDoc) + if(data.structure.length > 0 || !instance.state.configDoc) { //If we don't have a custom structure, use the default one if(data.structure.length == 0) @@ -1208,7 +1208,7 @@ int main(int argc, const char** argv) if (!instance.config.noBuffer) fflush(stdout); #endif - if (instance.state.configDoc) + if (data.structure.length == 0 && instance.state.configDoc) { ffPrintJsonConfig(&instance); } From 4905d5adede3a288f1a48b45d02ae2fa6db397fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 14:14:11 +0800 Subject: [PATCH 185/493] Wifi (Windows): remove `--lib-wlanapi` It's not used --- src/common/init.c | 2 -- src/common/jsonconfig.c | 2 -- src/fastfetch.c | 2 -- src/fastfetch.h | 1 - 4 files changed, 7 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index 2d18c828d..94883b468 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -126,7 +126,6 @@ static void defaultConfig(FFinstance* instance) ffStrbufInit(&instance->config.libOpenCL); ffStrbufInit(&instance->config.libfreetype); ffStrbufInit(&instance->config.libPulse); - ffStrbufInit(&instance->config.libwlanapi); ffStrbufInit(&instance->config.libnm); instance->config.percentType = 1; @@ -331,7 +330,6 @@ static void destroyConfig(FFinstance* instance) ffStrbufDestroy(&instance->config.libOpenCL); ffStrbufDestroy(&instance->config.libfreetype); ffStrbufDestroy(&instance->config.libPulse); - ffStrbufDestroy(&instance->config.libwlanapi); ffStrbufDestroy(&instance->config.libnm); } diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index e3748b104..377aa3da7 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -452,8 +452,6 @@ const char* ffParseLibraryJsonConfig(FFinstance* instance) ffStrbufSetS(&config->libOSMesa, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "opencl")) ffStrbufSetS(&config->libOpenCL, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "wlanapi")) - ffStrbufSetS(&config->libwlanapi, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "pulse")) ffStrbufSetS(&config->libPulse, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "nm")) diff --git a/src/fastfetch.c b/src/fastfetch.c index bdb84bdfb..f7587004a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -991,8 +991,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con ffOptionParseString(key, value, &instance->config.libOSMesa); else if(ffStrEqualsIgnCase(subkey, "-opencl")) ffOptionParseString(key, value, &instance->config.libOpenCL); - else if(ffStrEqualsIgnCase(subkey, "-wlanapi")) - ffOptionParseString(key, value, &instance->config.libwlanapi); else if(ffStrEqualsIgnCase(key, "-pulse")) ffOptionParseString(key, value, &instance->config.libPulse); else if(ffStrEqualsIgnCase(subkey, "-nm")) diff --git a/src/fastfetch.h b/src/fastfetch.h index f95d0fc36..7f2991db2 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -128,7 +128,6 @@ typedef struct FFconfig FFstrbuf libOpenCL; FFstrbuf libfreetype; FFstrbuf libPulse; - FFstrbuf libwlanapi; FFstrbuf libnm; uint32_t percentType; From 31dbd4b941e7f9732d64d82c43188ddb19b6e655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 14:41:01 +0800 Subject: [PATCH 186/493] JsonConfig: update json_schema.jsonc Turn all module types to lower case --- src/data/json_schema.jsonc | 574 ++++++++++++++++++++++--------------- 1 file changed, 348 insertions(+), 226 deletions(-) diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index c8b156700..b579fb7a1 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -6,28 +6,34 @@ "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] }, "key": { - "title": "Key of the module", + "title": "modules.*.key", + "description": "Key of the module", "type": "string" }, "keyColor": { - "title": "Color of the module key", + "title": "modules.*.keyColor", + "description": "Color of the module key", "$ref": "#/$defs/colors", "default": "Use display.color.keys" }, "format": { - "title": "Format of the module", + "title": "modules.*.format", + "description": "Format of the module", "type": "string" } }, "type": "object", - "title": "JSON config file for fastfetch", + "title": "Fastfetch config", + "description": "JSON config file for fastfetch. Usually be `~/.config/fastfetch.jsonc`", "properties": { "logo": { - "title": "Fastfetch logo configurations", + "title": "logo", + "description": "Fastfetch logo configurations", "type": "object", "properties": { "type": { - "title": "Set the type of the logo given", + "title": "logo.type", + "description": "Set the type of the logo given", "enum": [ "auto", "builtin", @@ -45,108 +51,131 @@ "default": "auto" }, "source": { + "title": "logo.source", "type": "string", - "title": "Set the source file of the logo" + "description": "Set the source file of the logo" }, "color": { + "title": "logo.color", "type": "object", - "title": "Overwrite a color in the logo", + "description": "Overwrite a color in the logo", "properties": { "1": { - "title": "Color 1", + "title": "logo.color.1", + "description": "Color 1", "$ref": "#/$defs/colors" }, "2": { - "title": "Color 2", + "title": "logo.color.2", + "description": "Color 2", "$ref": "#/$defs/colors" }, "3": { - "title": "Color 3", + "title": "logo.color.3", + "description": "Color 3", "$ref": "#/$defs/colors" }, "4": { - "title": "Color 4", + "title": "logo.color.4", + "description": "Color 4", "$ref": "#/$defs/colors" }, "5": { - "title": "Color 5", + "title": "logo.color.5", + "description": "Color 5", "$ref": "#/$defs/colors" }, "6": { - "title": "Color 6", + "title": "logo.color.6", + "description": "Color 6", "$ref": "#/$defs/colors" }, "7": { - "title": "Color 7", + "title": "logo.color.7", + "description": "Color 7", "$ref": "#/$defs/colors" }, "8": { - "title": "Color 8", + "title": "logo.color.8", + "description": "Color 8", "$ref": "#/$defs/colors" }, "9": { - "title": "Color 9", + "title": "logo.color.9", + "description": "Color 9", "$ref": "#/$defs/colors" } } }, "width": { + "title": "logo.width", "type": "integer", - "title": "Set the width of the logo (in characters). Required for iTerm image protocol", + "description": "Set the width of the logo (in characters). Required for iTerm image protocol", "minimum": 1 }, "height": { + "title": "logo.height", "type": "integer", - "title": "Set the height of the logo (in characters). Required for iTerm image protocol", + "description": "Set the height of the logo (in characters). Required for iTerm image protocol", "minimum": 1 }, "padding": { + "title": "logo.padding", "type": "object", - "title": "Set the padding of the logo", + "description": "Set the padding of the logo", "properties": { "top": { + "title": "logo.padding.top", "type": "integer", - "title": "Set the top padding of the logo", + "description": "Set the top padding of the logo", "minimum": 0 }, "left": { + "title": "logo.padding.left", "type": "integer", - "title": "Set the left padding of the logo", + "description": "Set the left padding of the logo", "minimum": 0 }, "right": { + "title": "logo.padding.right", "type": "integer", - "title": "Set the right padding of the logo", + "description": "Set the right padding of the logo", "minimum": 0 } } }, "printRemaining": { + "title": "logo.printRemaining", "type": "boolean", - "title": "Whether to print the remaining logo, if it has more lines than modules to display", + "description": "Whether to print the remaining logo, if it has more lines than modules to display", "default": false }, "preserveAspectRadio": { + "title": "logo.preserveAspectRadio", "type": "boolean", - "title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", + "description": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", "default": false }, "chafa": { + "title": "logo.chafa", "type": "object", - "title": "Chafa configuration. See chafa document for details", + "description": "Chafa configuration. See chafa document for details", "properties": { "fgOnly": { + "title": "logo.chafa.fgOnly", "type": "boolean", - "title": "Produce character-cell output using foreground colors only", + "description": "Produce character-cell output using foreground colors only", "default": false }, "symbols": { + "title": "logo.chafa.symbols", "type": "string", - "title": "Specify character symbols to employ in final output" + "description": "Specify character symbols to employ in final output" }, "canvasMode": { + "title": "logo.chafa.canvasMode", "type": "string", - "title": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", + "description": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", "enum": [ "TRUECOLOR", "INDEXED_256", @@ -159,16 +188,18 @@ ] }, "colorSpace": { + "title": "logo.chafa.colorSpace", "type": "string", - "title": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", + "description": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", "enum": [ "RGB", "DIN99D" ] }, "ditherMode": { + "title": "logo.chafa.ditherMode", "type": "string", - "title": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", + "description": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", "enum": [ "NONE", "ORDERED", @@ -180,84 +211,100 @@ } }, "general": { - "title": "Fastfetch general configurations", + "title": "general", + "description": "Fastfetch general configurations", "type": "object", "properties": { "allowSlowOperations": { + "title": "general.allowSlowOperations", "type": "boolean", - "title": "Allow operations that can be very slow for more detailed output", + "description": "Allow operations that can be very slow for more detailed output", "default": false }, "multithreading": { + "title": "general.multithreading", "type": "boolean", - "title": "Use multiple threads to detect values", + "description": "Use multiple threads to detect values", "default": true }, "stat": { + "title": "general.stat", "type": "boolean", - "title": "Show time usage (in ms) for individual modules", + "description": "Show time usage (in ms) for individual modules", "default": false }, "escapeBedrock": { + "title": "general.escapeBedrock", "type": "boolean", - "title": "On Bedrock Linux, whether to escape the bedrock jail", + "description": "On Bedrock Linux, whether to escape the bedrock jail", "default": true }, "pipe": { + "title": "general.pipe", "type": "boolean", - "title": "Whether to enable pipe mode (disable logo and all escape sequences)", + "description": "Whether to enable pipe mode (disable logo and all escape sequences)", "default": false }, "playerName": { + "title": "general.playerName", "type": "string", - "title": "The name of the player to use for module Media and Player. Linux only" + "description": "The name of the player to use for module Media and Player. Linux only" }, "osFile": { + "title": "general.osFile", "type": "string", - "title": "Set the path to the file containing OS information. Linux only" + "description": "Set the path to the file containing OS information. Linux only" } } }, "display": { - "title": "Fastfetch general configurations", + "title": "display", + "description": "Configure how things to be displayed", "type": "object", "properties": { "showErrors": { + "title": "display.showErrors", "type": "boolean", - "title": "Print occurring errors to the console. False to ignore errored modules", + "description": "Print occurring errors to the console. False to ignore errored modules", "default": false }, "disableLinewrap": { + "title": "display.disableLinewrap", "type": "boolean", - "title": "Whether to disable line wrap during the run", + "description": "Whether to disable line wrap during the run", "default": true }, "hideCursor": { + "title": "display.hideCursor", "type": "boolean", - "title": "Whether to hide the cursor during the run", + "description": "Whether to hide the cursor during the run", "default": true }, "separator": { + "title": "display.separator", "type": "string", - "title": "Set the separator between key and value", + "description": "Set the separator between key and value", "default": ": " }, "color": { - "title": "Set the color of the keys and title", + "title": "display.color", + "description": "Set the color of the keys and title", "anyOf": [ { - "title": "Set the both color of the keys and title", + "description": "Set the both color of the keys and title", "$ref": "#/$defs/colors" }, { "type": "object", "properties": { "keys": { - "title": "Set the color of the keys", + "title": "display.color.keys", + "description": "Set the color of the keys", "$ref": "#/$defs/colors" }, "title": { - "title": "Set the color of the title", + "title": "display.color.title", + "description": "Set the color of the title", "$ref": "#/$defs/colors" } } @@ -266,7 +313,8 @@ }, "binaryPrefix": { "type": "string", - "title": "Set the binary prefix to used when printing bytes", + "title": "display.binaryPrefix", + "description": "Set the binary prefix to used when printing bytes", "enum": [ "iec", "si", @@ -275,158 +323,203 @@ }, "percentType": { "type": "number", - "title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", + "title": "display.percentType", + "description": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", "minimum": 0, "maximum": 9, "default": 1 }, "noBuffer": { "type": "boolean", - "title": "Whether to disable the stdout application buffer", + "title": "display.noBuffer", + "description": "Whether to disable the stdout application buffer", "default": false } } }, "library": { - "title": "Set the path of a library to load", + "title": "library", + "description": "Set the path of a library to load", "type": "object", "properties": { "pci": { - "type": "string" + "title": "library.pci", + "type": "string", + "description": "GPU output (Linux and FreeBSD)" }, "vulkan": { - "type": "string" + "title": "library.vulkan", + "type": "string", + "description": "Vulkan module & fallback for GPU output" }, "freetype": { - "type": "string" + "title": "library.freetype", + "type": "string", + "description": "Used for Termux font detection (Android)" }, "wayland": { - "type": "string" + "title": "library.wayland", + "type": "string", + "description": "Better display performance and output in wayland sessions.\nSupports different refresh rates per monitor.\n(Linux)" }, "xcbRandr": { - "type": "string" + "title": "library.xcbRandr", + "type": "string", + "description": "" }, "xcb": { - "type": "string" + "title": "library.xcb", + "type": "string", + "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, - "Xrandr": { - "type": "string" + "xrandr": { + "title": "library.xrandr", + "type": "string", + "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, - "X11": { - "type": "string" + "x11": { + "title": "library.x11", + "type": "string", + "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, "gio": { - "type": "string" + "title": "library.gio", + "type": "string", + "description": "Needed for values that are only stored GSettings (Linux, FreeBSD)" }, - "DConf": { - "type": "string" + "dconf": { + "title": "library.dconf", + "type": "string", + "description": "Needed for values that are only stored in DConf + Fallback for GSettings (Linux, FreeBSD)" }, "dbus": { - "type": "string" + "title": "library.dbus", + "type": "string", + "description": "Bluetooth, Player & Media detection (Linux, FreeBSD)" }, - "XFConf": { - "type": "string" + "xfconf": { + "title": "library.xfconf", + "type": "string", + "description": "Needed for XFWM theme and XFCE Terminal font (Linux, FreeBSD)" }, "sqlite3": { - "type": "string" + "title": "library.sqlite3", + "type": "string", + "description": "Needed for pkg & rpm package count (Linux, FreeBSD)" }, "rpm": { - "type": "string" + "title": "library.rpm", + "type": "string", + "description": "Slower fallback for rpm package count. Needed on openSUSE & old CentOS / Redhat. (Linux)" }, "imagemagick": { - "type": "string" + "title": "library.imagemagick", + "type": "string", + "description": "Images in terminal using sixel or kitty graphics protocol (Linux, FreeBSD, macOS)" }, "z": { - "title": "zlib", + "title": "library.z", + "description": "Libz. Faster image output when using kitty graphics protocol (Linux, FreeBSD, macOS)", "type": "string" }, "chafa": { - "type": "string" + "title": "library.chafa", + "type": "string", + "description": "Image output as ascii art (Linux, FreeBSD, macOS)" }, "egl": { - "type": "string" + "title": "library.egl", + "type": "string", + "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "glx": { - "type": "string" + "title": "library.glx", + "type": "string", + "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "osmesa": { - "type": "string" + "title": "library.osmesa", + "type": "string", + "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "opencl": { - "type": "string" - }, - "wlanapi": { - "type": "string" + "title": "library.opencl", + "type": "string", + "description": "OpenCL module (Linux, FreeBSD, Windows)" }, "pulse": { - "title": "pulseaudio", + "title": "library.pulse", + "description": "Pulseaudio. Used for Sound detection (Linux, FreeBSD)", "type": "string" }, "nm": { - "title": "NetworkManager", + "title": "library.nm", + "description": "NetworkManager. Used for Wifi detection (Linux)", "type": "string" } } }, "modules": { - "title": "Fastfetch modules to run", + "title": "modules", + "description": "Fastfetch modules to run", "type": "array", "items": { "anyOf": [ { "type": "string", + "description": "Run module with default configurations", "enum": [ - "Battery", - "Bios", - "Bluetooth", - "Board", - "Break", - "Brightness", - "Chassis", - "CPU", - "CPUUsage", - "Command", - "Colors", - "Cursor", - "Custom", - "DateTime", - "Display", - "Disk", - "DE", - "Font", - "Gamepad", - "GPU", - "Host", - "Icons", - "Kernel", - "Locale", - "LocalIp", - "Media", - "Memory", - "OpenCL", - "OpenGL", - "OS", - "Packages", - "Player", - "PowerAdapter", - "Processes", - "PublicIp", - "Separator", - "Shell", - "Sound", - "Swap", - "Terminal", - "TerminalFont", - "Title", - "Theme", - "Uptime", - "Users", - "Vulkan", - "Wallpaper", - "Weather", - "WM", - "Wifi", - "WMTheme" + "battery", + "bios", + "bluetooth", + "board", + "break", + "brightness", + "chassis", + "cpu", + "cpuusage", + "command", + "colors", + "cursor", + "custom", + "datetime", + "display", + "disk", + "de", + "font", + "gamepad", + "gpu", + "host", + "icons", + "kernel", + "locale", + "localip", + "media", + "memory", + "opencl", + "opengl", + "os", + "packages", + "player", + "poweradapter", + "processes", + "publicip", + "separator", + "shell", + "sound", + "swap", + "terminal", + "terminalfont", + "title", + "theme", + "uptime", + "users", + "vulkan", + "wallpaper", + "weather", + "wm", + "wifi", + "wmtheme" ] }, { @@ -436,7 +529,7 @@ { "properties": { "type": { - "enum": ["Break"] + "const": "Break" } }, "additionalProperties": false @@ -445,40 +538,40 @@ "properties": { "type": { "enum": [ - "Bios", - "Board", - "Brightness", - "Chassis", - "CPUUsage", - "Cursor", - "DateTime", - "DE", - "Font", - "Gamepad", - "Host", - "Icons", - "Kernel", - "Locale", - "Media", - "Memory", - "OpenCL", - "OS", - "Packages", - "Player", - "PowerAdapter", - "Processes", - "Shell", - "Swap", - "Terminal", - "TerminalFont", - "Theme", - "Uptime", - "Users", - "Vulkan", - "Wallpaper", - "WM", - "Wifi", - "WMTheme" + "bios", + "board", + "brightness", + "chassis", + "cpuusage", + "cursor", + "datetime", + "de", + "font", + "gamepad", + "host", + "icons", + "kernel", + "locale", + "media", + "memory", + "opencl", + "os", + "packages", + "player", + "poweradapter", + "processes", + "shell", + "swap", + "terminal", + "terminalfont", + "theme", + "uptime", + "users", + "vulkan", + "wallpaper", + "wm", + "wifi", + "wmtheme" ] }, "key": { @@ -496,14 +589,16 @@ { "properties": { "type": { - "enum": ["Battery"] + "const": "battery" }, "dir": { - "title": "The directory where the battery folders are. Standard: /sys/class/power_supply/. Linux only", + "title": "modules.battery.dir", + "description": "The directory where the battery folders are. Standard: /sys/class/power_supply/. Linux only", "type": "string" }, "temp": { - "title": "Detect and display Battery temperature if supported", + "title": "modules.battery.temp", + "description": "Detect and display Battery temperature if supported", "type": "boolean", "default": false }, @@ -522,10 +617,11 @@ { "properties": { "type": { - "enum": ["Bluetooth"] + "const": "bluetooth" }, "showDisconnected": { - "title": "Set if disconnected bluetooth devices should be printed", + "title": "modules.bluetooth.showDisconnected", + "description": "Set if disconnected bluetooth devices should be printed", "type": "boolean", "default": false }, @@ -544,10 +640,11 @@ { "properties": { "type": { - "enum": ["CPU"] + "const": "cpu" }, "temp": { - "title": "Detect and display CPU temperature if supported", + "title": "modules.cpu.temp", + "description": "Detect and display CPU temperature if supported", "type": "boolean", "default": false }, @@ -566,10 +663,11 @@ { "properties": { "type": { - "enum": ["Colors"] + "const": "colors" }, "symbol": { - "title": "Set the symbol to use", + "title": "modules.colors.symbol", + "description": "Set the symbol to use", "type": "string", "enum": [ "block", @@ -579,22 +677,23 @@ "square", "star" ], - "default": "blocks" + "default": "block" } } }, { "properties": { "type": { - "enum": ["Command"] + "const": "command" }, "shell": { - "title": "Set the shell program to execute the command text", - "type": "string", - "default": "cmd for Windows, csh for FreeBSD, bash for others" + "title": "modules.command.shell", + "description": "Set the shell program to execute the command text\nDefault: cmd for Windows, csh for FreeBSD, bash for others", + "type": "string" }, "text": { - "title": "Set the command text to be executed", + "title": "modules.command.text", + "description": "Set the command text to be executed", "type": "string" }, "key": { @@ -610,21 +709,20 @@ "additionalProperties": false }, { - "title": "Print a custom string, with or without key", + "description": "Print a custom string, with or without key", "properties": { "type": { - "enum": ["Custom"] + "const": "custom" }, "key": { - "title": "Leave empty not to print the key", - "type": "string", - "default": "*empty*" + "description": "Leave empty not to print the key", + "type": "string" }, "keyColor": { "$ref": "#/$defs/keyColor" }, "format": { - "title": "Text to print", + "description": "Text to print", "type": "string" } }, @@ -634,20 +732,23 @@ { "properties": { "type": { - "enum": ["Display"] + "const": "display" }, "compactType": { + "title": "modules.display.compactType", "enum": ["none", "original", "scaled"], - "title": "Set if all displays should be printed in one line", + "description": "Set if all displays should be printed in one line", "default": "none" }, "detectName": { - "title": "Set if display name should be detected and printed (if supported)", + "title": "modules.display.detectName", + "description": "Set if display name should be detected and printed (if supported)", "type": "boolean", "default": false }, "preciseRefreshRate": { - "title": "Set if decimal refresh rates should not be rounded into integers when printing", + "title": "modules.display.preciseRefreshRate", + "description": "Set if decimal refresh rates should not be rounded into integers when printing", "type": "boolean", "default": true }, @@ -666,31 +767,35 @@ { "properties": { "type": { - "enum": ["Disk"] + "const": "disk" }, "folders": { + "title": "modules.disk.folders", "type": "string", - "title": "A colon (semicolon on Windows) separated list of folder paths for the disk output", - "default": "\"/:/home\" (\"C:\\\\;D:\\\\ ...\" on Windows)" + "description": "A colon (semicolon on Windows) separated list of folder paths for the disk output\nDefault: \"/:/home\" (\"C:\\\\;D:\\\\ ...\" on Windows)" }, "showExternal": { + "title": "modules.disk.showExternal", "type": "boolean", - "title": "Set if external volume should be printed", + "description": "Set if external volume should be printed", "default": true }, "showHidden": { + "title": "modules.disk.showHidden", "type": "boolean", - "title": "Set if hidden volumes should be printed", + "description": "Set if hidden volumes should be printed", "default": false }, "showSubvolumes": { + "title": "modules.disk.showSubvolumes", "type": "boolean", - "title": "Set if subvolumes should be printed", + "description": "Set if subvolumes should be printed", "default": false }, "showUnknown": { + "title": "modules.disk.showUnknown", "type": "boolean", - "title": "Set if unknown (unable to detect sizes) volumes should be printed", + "description": "Set if unknown (unable to detect sizes) volumes should be printed", "default": false }, "key": { @@ -708,20 +813,23 @@ { "properties": { "type": { - "enum": ["GPU"] + "const": "gpu" }, "temp": { - "title": "Detect and display GPU temperature if supported", + "title": "modules.gpu.temp", + "description": "Detect and display GPU temperature if supported", "type": "boolean", "default": false }, "forceVulkan": { - "title": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`", + "title": "modules.gpu.forceVulkan", + "description": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`", "type": "boolean", "default": false }, "hideType": { - "title": "Specify the type of GPUs should not be printed", + "title": "modules.gpu.hideType", + "description": "Specify the type of GPUs should not be printed", "enum": ["integrated", "discrete", "none"], "default": "none" }, @@ -740,35 +848,41 @@ { "properties": { "type": { - "enum": ["LocalIp"] + "const": "localip" }, "showIpv4": { - "title": "Show IPv4 addresses", + "title": "modules.localip.showIpv4", + "description": "Show IPv4 addresses", "type": "boolean", "default": true }, "showIpv6": { - "title": "Show IPv6 addresses", + "title": "modules.localip.showIpv6", + "description": "Show IPv6 addresses", "type": "boolean", "default": false }, "showMac": { - "title": "Show MAC addresses", + "title": "modules.localip.showMac", + "description": "Show MAC addresses", "type": "boolean", "default": false }, "showLoop": { - "title": "Show loop back addresses (127.0.0.1)", + "title": "modules.localip.showLoop", + "description": "Show loop back addresses (127.0.0.1)", "type": "boolean", "default": false }, "compact": { - "title": "Show all IPs in one line", + "title": "modules.localip.compact", + "description": "Show all IPs in one line", "type": "boolean", "default": false }, "namePrefix": { - "title": "Show IPs with given name prefix only", + "title": "modules.localip.namePrefix", + "description": "Show IPs with given name prefix only", "type": "string" }, "key": { @@ -786,10 +900,11 @@ { "properties": { "type": { - "enum": ["OpenGL"] + "const": "opengl" }, "library": { - "title": "Set the OpenGL context creation library to use. Linux only", + "title": "modules.opengl.library", + "description": "Set the OpenGL context creation library to use. Linux only", "enum": ["auto", "egl", "glx", "osmesa"], "default": "auto" }, @@ -808,16 +923,18 @@ { "properties": { "type": { - "enum": ["PublicIp"] + "const": "publicip" }, "url": { - "title": "The URL of public IP detection server to be used. Only HTTP protocol is supported", + "title": "modules.publicip.url", + "description": "The URL of public IP detection server to be used. Only HTTP protocol is supported", "type": "string", "format": "url", "default": "http://ipinfo.io/ip" }, "timeout": { - "title": "Time in milliseconds to wait for the public ip server to respond", + "title": "modules.publicip.timeout", + "description": "Time in milliseconds to wait for the public ip server to respond", "type": "integer", "minimum": 0, "default": "disabled (0)" @@ -837,10 +954,11 @@ { "properties": { "type": { - "enum": ["Separator"] + "const": "separator" }, "string": { - "title": "Set the string printed by the separator module", + "title": "modules.separator.string", + "description": "Set the string to be printed", "type": "string", "format": "url", "default": "http://ipinfo.io/ip" @@ -851,10 +969,11 @@ { "properties": { "type": { - "enum": ["Sound"] + "const": "sound" }, "soundType": { - "title": "Set what type of sound devices should be printed", + "title": "modules.sound.soundType", + "description": "Set what type of sound devices should be printed", "type": "string", "enum": [ "main", @@ -878,11 +997,12 @@ { "properties": { "type": { - "enum": ["Title"] + "const": "title" }, "fqdn": { + "title": "modules.title.fqdn", "type": "boolean", - "title": "Set if the title should use fully qualified domain name", + "description": "Set if the title should use fully qualified domain name", "default": false } }, @@ -891,16 +1011,18 @@ { "properties": { "type": { - "enum": ["Weather"] + "const": "weather" }, "timeout": { - "title": "Time in milliseconds to wait for the weather server to respond", + "title": "modules.weather.timeout", + "description": "Time in milliseconds to wait for the weather server to respond", "type": "integer", "minimum": 0, "default": "disabled (0)" }, "outputFormat": { - "title": "The output weather format to be used (must be URI encoded)", + "title": "modules.weather.outputFormat", + "description": "The output weather format to be used (must be URI encoded)", "type": "string", "default": "%t+-+%C+(%l)" }, From 9369122017f59dadb600d77099dc8d91358a893b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 14:46:15 +0800 Subject: [PATCH 187/493] Board: silense compiler warnings --- src/detection/board/board_nosupport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/board/board_nosupport.c b/src/detection/board/board_nosupport.c index 7dc258c97..bcf451d5b 100644 --- a/src/detection/board/board_nosupport.c +++ b/src/detection/board/board_nosupport.c @@ -1,6 +1,6 @@ #include "board.h" -const char* ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FF_MAYBE_UNUSED FFBoardResult* board) { return "Not supported on this platform"; } From bd71bfd9f3a1c17b3c6671c36b9edcbe15b286c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 15:13:43 +0800 Subject: [PATCH 188/493] Colors: add `--colors-padding-left` --- CHANGELOG.md | 2 +- src/data/help.txt | 1 + src/data/json_schema.jsonc | 7 +++++++ src/fastfetch.c | 1 + src/modules/colors/colors.c | 19 +++++++++++++++++++ src/modules/colors/colors.h | 1 + src/modules/colors/option.h | 1 + 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab3384e8d..711ce403a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Features: * Support MATE Terminal version & terminal font detection * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module -* Support `--colors-symbol` +* Support `--colors-symbol` and `--colors-padding-left` # 1.11.3 diff --git a/src/data/help.txt b/src/data/help.txt index 5feb254b6..137a09597 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -137,6 +137,7 @@ Module specific options: --command-key : Set the module key to display --command-text : Set the command text to be executed --colors-symbol : Set the symbol to be printed by Colors module. Default is block + --colors-padding-left : Set the number of white spaces to print before the symbol. Default is 0 Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index b579fb7a1..b5edf812f 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -678,6 +678,13 @@ "star" ], "default": "block" + }, + "paddingLeft": { + "title": "modules.colors.paddingLeft", + "description": "Set the number of white spaces to print before the symbol", + "type": "integer", + "minimum": 0, + "default": 0 } } }, diff --git a/src/fastfetch.c b/src/fastfetch.c index f7587004a..c601ed647 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -941,6 +941,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(ffParseSoundCommandOptions(&instance->config.sound, key, value)) {} else if(ffParseGamepadCommandOptions(&instance->config.gamepad, key, value)) {} + else if(ffParseColorsCommandOptions(&instance->config.colors, key, value)) {} /////////////////// //Library options// diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 5e16578c6..646205bd0 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -11,6 +11,9 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options) ffLogoPrintLine(instance); + if(options->paddingLeft > 0) + ffPrintCharTimes(' ', options->paddingLeft); + if (options->symbol == FF_COLORS_SYMBOL_BLOCK) { // 4%d: Set the background color @@ -22,6 +25,9 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options) ffLogoPrintLine(instance); + if(options->paddingLeft > 0) + ffPrintCharTimes(' ', options->paddingLeft); + // 1: Set everything to bolt. This causes normal colors on some systems to be bright. // 4%d: Set the backgound to the not bright color // 3%d: Set the foreground to the not bright color @@ -53,6 +59,7 @@ void ffInitColorsOptions(FFColorsOptions* options) { options->moduleName = FF_COLORS_MODULE_NAME; options->symbol = FF_COLORS_SYMBOL_BLOCK; + options->paddingLeft = 0; } bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value) @@ -74,6 +81,12 @@ bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, cons return true; } + if (ffStrEqualsIgnCase(subKey, "padding-left")) + { + options->paddingLeft = ffOptionParseUInt32(key, value); + return true; + } + return false; } @@ -115,6 +128,12 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "paddingLeft")) + { + options.paddingLeft = (uint32_t) yyjson_get_uint(val); + continue; + } + ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index 7ab1a5efd..bcf2c2315 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -7,4 +7,5 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options); void ffInitColorsOptions(FFColorsOptions* options); void ffDestroyColorsOptions(FFColorsOptions* options); +bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value); void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/colors/option.h b/src/modules/colors/option.h index 4e2e0b2d9..6a4061ae2 100644 --- a/src/modules/colors/option.h +++ b/src/modules/colors/option.h @@ -18,4 +18,5 @@ typedef struct FFColorsOptions { const char* moduleName; FFColorssymbol symbol; + uint32_t paddingLeft; } FFColorsOptions; From a53d74e4834ab627c65ef27904c6987575cecc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 15:23:38 +0800 Subject: [PATCH 189/493] Colors: FFColorssymbol -> FFColorsSymbol --- src/modules/colors/colors.c | 4 ++-- src/modules/colors/option.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 646205bd0..1064f3283 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -69,7 +69,7 @@ bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, cons if (ffStrEqualsIgnCase(subKey, "symbol")) { - options->symbol = (FFColorssymbol) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + options->symbol = (FFColorsSymbol) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "block", FF_COLORS_SYMBOL_BLOCK }, { "circle", FF_COLORS_SYMBOL_CIRCLE }, { "diamond", FF_COLORS_SYMBOL_DIAMOND }, @@ -124,7 +124,7 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) if (error) ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error); else - options.symbol = (FFColorssymbol) value; + options.symbol = (FFColorsSymbol) value; continue; } diff --git a/src/modules/colors/option.h b/src/modules/colors/option.h index 6a4061ae2..afcb23fb6 100644 --- a/src/modules/colors/option.h +++ b/src/modules/colors/option.h @@ -4,7 +4,7 @@ #include "common/option.h" -typedef enum FFColorssymbol +typedef enum FFColorsSymbol { FF_COLORS_SYMBOL_BLOCK, FF_COLORS_SYMBOL_CIRCLE, @@ -12,11 +12,11 @@ typedef enum FFColorssymbol FF_COLORS_SYMBOL_SQUARE, FF_COLORS_SYMBOL_TRIANGLE, FF_COLORS_SYMBOL_STAR, -} FFColorssymbol; +} FFColorsSymbol; typedef struct FFColorsOptions { const char* moduleName; - FFColorssymbol symbol; + FFColorsSymbol symbol; uint32_t paddingLeft; } FFColorsOptions; From 54f6b6a9c9f98dcc0d0fd6836bf081363e90efd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 15:54:57 +0800 Subject: [PATCH 190/493] Display: remove `--detect-name` --- CHANGELOG.md | 1 + src/data/json_schema.jsonc | 6 ------ src/modules/brightness/brightness.c | 26 ++++++++++++++++++++++++-- src/modules/display/display.c | 15 +-------------- src/modules/display/option.h | 1 - 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 711ce403a..8429c1ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. * Remove `--shell-version` and `--terminal-version`. They are always enabled * Remove `--*-error-format` +* Remove `--display-detect-name`. Display name is always detected, and will be printed if multiple displays are detected Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index b5edf812f..e3c335810 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -747,12 +747,6 @@ "description": "Set if all displays should be printed in one line", "default": "none" }, - "detectName": { - "title": "modules.display.detectName", - "description": "Set if display name should be detected and printed (if supported)", - "type": "boolean", - "default": false - }, "preciseRefreshRate": { "title": "modules.display.preciseRefreshRate", "description": "Set if decimal refresh rates should not be rounded into integers when printing", diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 0a5be81b3..8f53caf77 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -1,6 +1,8 @@ +#include "common/bar.h" #include "common/printing.h" #include "common/jsonconfig.h" #include "detection/brightness/brightness.h" +#include "detection/displayserver/displayserver.h" #include "modules/brightness/brightness.h" #include "util/stringUtils.h" @@ -10,6 +12,8 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); + const FFDisplayServerResult* ds = ffConnectDisplayServer(instance); + const char* error = ffDetectBrightness(&result); if(error) @@ -30,7 +34,9 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) { if(options->moduleArgs.key.length == 0) { - ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars); + ffStrbufAppendS(&key, FF_BRIGHTNESS_MODULE_NAME); + if (ds->displays.length > 1) + ffStrbufAppendF(&key, " (%s)", item->name.chars); } else { @@ -39,10 +45,26 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) }); } + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); - printf("%.0f%%\n", item->value); + + if (instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + { + ffAppendPercentBar(instance, &str, (uint8_t) (item->value + 0.5), 0, 10, 10); + } + + if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + { + if(str.length > 0) + ffStrbufAppendC(&str, ' '); + + ffAppendPercentNum(instance, &str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0); + } + + ffStrbufPutTo(&str, stdout); } else { diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 0034805a8..ddbe7536c 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -53,7 +53,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - if((options->detectName && result->name.length) || (moduleIndex > 0 && displayType)) + if(moduleIndex > 0) { ffStrbufClear(&key); if(options->moduleArgs.key.length == 0) @@ -117,7 +117,6 @@ void ffInitDisplayOptions(FFDisplayOptions* options) options->moduleName = FF_DISPLAY_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE; - options->detectName = false; options->preciseRefreshRate = false; } @@ -139,12 +138,6 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co return true; } - if (ffStrEqualsIgnCase(subKey, "detect-name")) - { - options->detectName = ffOptionParseBoolean(value); - return true; - } - if (ffStrEqualsIgnCase(subKey, "precise-refresh-rate")) { options->preciseRefreshRate = ffOptionParseBoolean(value); @@ -193,12 +186,6 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) continue; } - if (ffStrEqualsIgnCase(key, "detectName")) - { - options.detectName = yyjson_get_bool(val); - continue; - } - if (ffStrEqualsIgnCase(key, "preciseRefreshRate")) { options.preciseRefreshRate = yyjson_get_bool(val); diff --git a/src/modules/display/option.h b/src/modules/display/option.h index 4e47b1bee..20def688c 100644 --- a/src/modules/display/option.h +++ b/src/modules/display/option.h @@ -17,6 +17,5 @@ typedef struct FFDisplayOptions FFModuleArgs moduleArgs; FFDisplayCompactType compactType; - bool detectName; bool preciseRefreshRate; } FFDisplayOptions; From baebbb61eb5adf2faa741fd846fb6e5d7766d1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 17:27:43 +0800 Subject: [PATCH 191/493] DisplayServer (Wayland): detect name using `wl_output_listener::name` Which matches X11 and module Brightness --- src/detection/displayserver/linux/wayland.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index bb06661f1..a6864c397 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -85,21 +85,12 @@ static void waylandOutputGeometryListener(void *data, FF_MAYBE_UNUSED int32_t physical_width, FF_MAYBE_UNUSED int32_t physical_height, FF_MAYBE_UNUSED int32_t subpixel, - const char *make, - const char *model, + FF_MAYBE_UNUSED const char *make, + FF_MAYBE_UNUSED const char *model, int32_t transform) { WaylandDisplay* display = data; display->transform = (enum wl_output_transform) transform; - - if(make && !ffStrEquals(make, "unknown")) - ffStrbufAppendS(&display->name, make); - if(model && !ffStrEquals(model, "unknown")) - { - if(display->name.length > 0) - ffStrbufAppendC(&display->name, '-'); - ffStrbufAppendS(&display->name, model); - } } #ifdef WL_OUTPUT_NAME_SINCE_VERSION @@ -110,6 +101,7 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp display->type = FF_DISPLAY_TYPE_BUILTIN; else if(ffStrStartsWith(name, "HDMI-") || ffStrStartsWith(name, "DP-")) display->type = FF_DISPLAY_TYPE_EXTERNAL; + ffStrbufAppendS(&display->name, name); } #endif From 1716489396b7cef918dc3a57f513ef2c4720fcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 17:28:10 +0800 Subject: [PATCH 192/493] Display: always show display name --- src/modules/brightness/brightness.c | 7 +------ src/modules/display/display.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 8f53caf77..32c0ca408 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -2,7 +2,6 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "detection/brightness/brightness.h" -#include "detection/displayserver/displayserver.h" #include "modules/brightness/brightness.h" #include "util/stringUtils.h" @@ -12,8 +11,6 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); - const FFDisplayServerResult* ds = ffConnectDisplayServer(instance); - const char* error = ffDetectBrightness(&result); if(error) @@ -34,9 +31,7 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) { if(options->moduleArgs.key.length == 0) { - ffStrbufAppendS(&key, FF_BRIGHTNESS_MODULE_NAME); - if (ds->displays.length > 1) - ffStrbufAppendF(&key, " (%s)", item->name.chars); + ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars); } else { diff --git a/src/modules/display/display.c b/src/modules/display/display.c index ddbe7536c..d33bfefea 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -53,27 +53,20 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - if(moduleIndex > 0) + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) { - ffStrbufClear(&key); - if(options->moduleArgs.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); - } - else - { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &i}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, - {FF_FORMAT_ARG_TYPE_STRING, displayType}, - }); - } - ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); } else { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &i}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, + }); } + ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); printf("%ix%i", result->width, result->height); From 9d6e1eb47d677636ae19f6b43a0026271e5c545c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 18:12:12 +0800 Subject: [PATCH 193/493] Display (DRM): detect display name Also fix crashes... --- .../displayserver/linux/displayserver_linux.c | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 5c2ca46ef..f2101e010 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -32,16 +32,30 @@ static void parseDRM(FFDisplayServerResult* result) continue; } - FFDisplayResult* display = ffListAdd(&result->displays); - display->width = 0; - display->height = 0; - display->refreshRate = 0; - display->scaledWidth = 0; - display->scaledHeight = 0; + uint32_t width = 0, height = 0; - int scanned = fscanf(modeFile, "%ux%u", &display->width, &display->height); - if(scanned < 2 || display->width == 0 || display->height == 0) - --result->displays.length; + int scanned = fscanf(modeFile, "%ux%u", &width, &height); + if(scanned == 2 && width > 0 && height > 0) + { + const char* plainName = entry->d_name; + if (ffStrStartsWith(plainName, "card")) + { + const char* tmp = strchr(plainName + strlen("card"), '-'); + if (tmp) plainName = tmp + 1; + } + + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(plainName); + ffdsAppendDisplay( + result, + width, height, + 0, + 0, 0, + 0, + &name, + FF_DISPLAY_TYPE_UNKNOWN, + false + ); + } fclose(modeFile); ffStrbufSubstrBefore(&drmDir, drmDirLength); From 113848c57841844d031f3e86a491c632b2802f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 18:15:30 +0800 Subject: [PATCH 194/493] DisplayServer (Linux): mark `plasmashell --version` as slow operation It costs more than 1 sec some time --- src/detection/displayserver/linux/wmde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index e76130b5d..61abf753d 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -138,7 +138,7 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) ffParsePropFileData(instance, "wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) ffParsePropFileData(instance, "wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - if(result->deVersion.length == 0) + if(result->deVersion.length == 0 && instance->config.allowSlowOperations) { if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ "plasmashell", From a88f603e6d483cb815fe26c3d8ab8007510e558b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 18:31:44 +0800 Subject: [PATCH 195/493] DisplayServer (Linux): add fast path of kde version detection for Fedora --- src/detection/displayserver/linux/wmde.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 61abf753d..d95ef83cc 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -131,13 +131,24 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) ffStrbufSetS(&result->deProcessName, "plasmashell"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_PLASMA); - ffParsePropFileData(instance, "xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + ffParsePropFileValues("/usr/share/xsessions/plasmax11.desktop", 1, (FFpropquery[]) { + {"X-KDE-PluginInfo-Version =", &result->deVersion} + }); + if(result->deVersion.length == 0) + ffParsePropFileData(instance, "xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) ffParsePropFileData(instance, "xsessions/plasma5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + if(result->deVersion.length == 0) + { + ffParsePropFileValues("/usr/share/wayland-sessions/plasma.desktop", 1, (FFpropquery[]) { + {"X-KDE-PluginInfo-Version =", &result->deVersion} + }); + } if(result->deVersion.length == 0) ffParsePropFileData(instance, "wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) ffParsePropFileData(instance, "wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + if(result->deVersion.length == 0 && instance->config.allowSlowOperations) { if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ From 68feaa2800e3aa953186f55db07e4892f4e19e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 23:01:18 +0800 Subject: [PATCH 196/493] LM: new module --- CHANGELOG.md | 1 + CMakeLists.txt | 6 +++ README.md | 2 +- presets/all | 2 +- src/common/init.c | 2 + src/common/jsonconfig.c | 1 + src/data/config_user.txt | 3 ++ src/data/json_schema.jsonc | 2 + src/detection/lm/lm.h | 18 +++++++ src/detection/lm/lm_linux.c | 23 +++++++++ src/detection/lm/lm_nosupport.c | 6 +++ src/fastfetch.c | 9 ++++ src/fastfetch.h | 1 + src/modules/lm/lm.c | 87 +++++++++++++++++++++++++++++++++ src/modules/lm/lm.h | 11 +++++ src/modules/lm/option.h | 11 +++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + 18 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 src/detection/lm/lm.h create mode 100644 src/detection/lm/lm_linux.c create mode 100644 src/detection/lm/lm_nosupport.c create mode 100644 src/modules/lm/lm.c create mode 100644 src/modules/lm/lm.h create mode 100644 src/modules/lm/option.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 8429c1ac1..47476d0f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Features: * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module * Support `--colors-symbol` and `--colors-padding-left` +* Add LM (Login Manager) module # 1.11.3 diff --git a/CMakeLists.txt b/CMakeLists.txt index a0af3392e..36d44d31a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,6 +293,7 @@ set(LIBFASTFETCH_SRC src/modules/icons/icons.c src/modules/gamepad/gamepad.c src/modules/kernel/kernel.c + src/modules/lm/lm.c src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c @@ -354,6 +355,7 @@ if(LINUX) src/detection/gtk_qt/gtk.c src/detection/host/host_linux.c src/detection/icons/icons_linux.c + src/detection/lm/lm_linux.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c @@ -397,6 +399,7 @@ elseif(ANDROID) src/detection/gpu/gpu_nosupport.c src/detection/host/host_android.c src/detection/icons/icons_nosupport.c + src/detection/lm/lm_nosupport.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_nosupport.c @@ -445,6 +448,7 @@ elseif(BSD) src/detection/gpu/gpu_linux.c src/detection/gtk_qt/gtk.c src/detection/host/host_bsd.c + src/detection/lm/lm_linux.c src/detection/icons/icons_linux.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_bsd.c @@ -490,6 +494,7 @@ elseif(APPLE) src/detection/font/font_apple.m src/detection/gpu/gpu_apple.c src/detection/host/host_apple.c + src/detection/lm/lm_nosupport.c src/detection/icons/icons_nosupport.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_apple.c @@ -535,6 +540,7 @@ elseif(WIN32) src/detection/gpu/gpu_windows.c src/detection/host/host_windows.c src/detection/icons/icons_windows.c + src/detection/lm/lm_nosupport.c src/detection/localip/localip_windows.c src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c diff --git a/README.md b/README.md index a1d654210..48377ed83 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ All categories not listed here should work without needing a specific implementa ##### Available Modules ``` -Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme +Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme ``` ##### Builtin logos diff --git a/presets/all b/presets/all index 7079c84af..b669e6643 100644 --- a/presets/all +++ b/presets/all @@ -1 +1 @@ ---structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors +--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors diff --git a/src/common/init.c b/src/common/init.c index 94883b468..ed522d8ff 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -85,6 +85,7 @@ static void defaultConfig(FFinstance* instance) ffInitDiskOptions(&instance->config.disk); ffInitBatteryOptions(&instance->config.battery); ffInitPowerAdapterOptions(&instance->config.powerAdapter); + ffInitLMOptions(&instance->config.lm); ffInitLocaleOptions(&instance->config.locale); ffInitLocalIpOptions(&instance->config.localIP); ffInitPublicIpOptions(&instance->config.publicIP); @@ -289,6 +290,7 @@ static void destroyConfig(FFinstance* instance) ffDestroyDiskOptions(&instance->config.disk); ffDestroyBatteryOptions(&instance->config.battery); ffDestroyPowerAdapterOptions(&instance->config.powerAdapter); + ffDestroyLMOptions(&instance->config.lm); ffDestroyLocaleOptions(&instance->config.locale); ffDestroyLocalIpOptions(&instance->config.localIP); ffDestroyPublicIpOptions(&instance->config.publicIP); diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 377aa3da7..c2ee05cf9 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -144,6 +144,7 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson case 'L': { return + tryModule(instance, type, module, FF_LM_MODULE_NAME, ffParseLMJsonObject) || tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || tryModule(instance, type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || false; diff --git a/src/data/config_user.txt b/src/data/config_user.txt index a05ca7ad8..c2842ad67 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -314,6 +314,7 @@ #--disk-key Disk ({1}) #--battery-key Battery {1} #--poweradapter-key Power Adapter {1} +#--lm-key LM #--locale-key Locale #--localip-key Local IP ({1}) #--publicip-key Public IP @@ -363,6 +364,7 @@ #--disk-format #--battery-format #--poweradapter-format +#--lm-format #--locale-format #--localip-format #--publicip-format @@ -408,6 +410,7 @@ #--disk-key-color #--battery-key-color #--poweradapter-key-color +#--lm-key-color #--locale-key-color #--localip-key-color #--publicip-key-color diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index e3c335810..37def9a95 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -492,6 +492,7 @@ "host", "icons", "kernel", + "lm", "locale", "localip", "media", @@ -551,6 +552,7 @@ "host", "icons", "kernel", + "lm", "locale", "media", "memory", diff --git a/src/detection/lm/lm.h b/src/detection/lm/lm.h new file mode 100644 index 000000000..5fd1919d5 --- /dev/null +++ b/src/detection/lm/lm.h @@ -0,0 +1,18 @@ +#pragma once + +#ifndef FF_INCLUDED_detection_lm_lm +#define FF_INCLUDED_detection_lm_lm + +#include "fastfetch.h" + +typedef struct FFLMResult +{ + FFstrbuf service; + FFstrbuf type; + // bool isDisplay; + // bool remote; +} FFLMResult; + +const char* ffDetectLM(FFLMResult* result); + +#endif diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c new file mode 100644 index 000000000..b5893c497 --- /dev/null +++ b/src/detection/lm/lm_linux.c @@ -0,0 +1,23 @@ +#include "lm.h" +#include "common/properties.h" + +#define FF_SYSTEMD_SESSIONS_PATH "/var/run/systemd/sessions/" + +const char* ffDetectLM(FFLMResult* result) +{ + const char* sessionId = getenv("XDG_SESSION_ID"); + if (!sessionId) return "$XDG_SESSION_ID is not set"; + + char path[64] = FF_SYSTEMD_SESSIONS_PATH; + strncpy(path + strlen(FF_SYSTEMD_SESSIONS_PATH), sessionId, sizeof(path) - strlen(FF_SYSTEMD_SESSIONS_PATH) - 1); + + // The file reads `This is private data. Do not parse`. + // What does it mean? But let's ignore it for now. + if (!ffParsePropFileValues(path, 2, (FFpropquery[]) { + {"SERVICE=", &result->service}, + {"TYPE=", &result->type}, + })) + return "Failed to parse /run/systemd/sessions/$XDG_SESSION_ID"; + + return NULL; +} diff --git a/src/detection/lm/lm_nosupport.c b/src/detection/lm/lm_nosupport.c new file mode 100644 index 000000000..9a0a816a1 --- /dev/null +++ b/src/detection/lm/lm_nosupport.c @@ -0,0 +1,6 @@ +#include "lm.h" + +const char* ffDetectLM(FFLMResult* result) +{ + return "Not supported on this platform"; +} diff --git a/src/fastfetch.c b/src/fastfetch.c index c601ed647..8de3e4f14 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -348,6 +348,13 @@ static inline void printCommandHelp(const char* command) "PowerAdapter description" ); } + else if(ffStrEqualsIgnCase(command, "lm-format")) + { + constructAndPrintCommandHelpFormat("lm", "{} ({})", 2, + "LM service", + "LM type" + ); + } else if(ffStrEqualsIgnCase(command, "locale-format")) { constructAndPrintCommandHelpFormat("locale", "{}", 1, @@ -1130,6 +1137,8 @@ static void parseStructureCommand(FFinstance* instance, const char* line) ffPrintBattery(instance, &instance->config.battery); else if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME)) ffPrintPowerAdapter(instance, &instance->config.powerAdapter); + else if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME)) + ffPrintLM(instance, &instance->config.lm); else if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME)) ffPrintLocale(instance, &instance->config.locale); else if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index 7f2991db2..48d7dfa37 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -89,6 +89,7 @@ typedef struct FFconfig FFDiskOptions disk; FFBatteryOptions battery; FFPowerAdapterOptions powerAdapter; + FFLMOptions lm; FFLocaleOptions locale; FFLocalIpOptions localIP; FFPublicIpOptions publicIP; diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c new file mode 100644 index 000000000..cfb1ac72b --- /dev/null +++ b/src/modules/lm/lm.c @@ -0,0 +1,87 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/lm/lm.h" +#include "modules/lm/lm.h" +#include "util/stringUtils.h" + +#define FF_LM_NUM_FORMAT_ARGS 2 + +void ffPrintLM(FFinstance* instance, FFLMOptions* options) +{ + FFLMResult result; + const char* error = ffDetectLM(&result); + + if(error) + { + ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(result.service.length == 0) + { + ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found"); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffStrbufWriteTo(&result.service, stdout); + if(result.type.length) + printf(" (%s)", result.type.chars); + putchar('\n'); + } + else + { + ffPrintFormat(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &result.service}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, + }); + } +} + +void ffInitLMOptions(FFLMOptions* options) +{ + options->moduleName = FF_LM_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseLMCommandOptions(FFLMOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_LM_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyLMOptions(FFLMOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module) +{ + FFLMOptions __attribute__((__cleanup__(ffDestroyLMOptions))) options; + ffInitLMOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintLM(instance, &options); +} diff --git a/src/modules/lm/lm.h b/src/modules/lm/lm.h new file mode 100644 index 000000000..862f474e0 --- /dev/null +++ b/src/modules/lm/lm.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_LM_MODULE_NAME "LM" + +void ffPrintLM(FFinstance* instance, FFLMOptions* options); +void ffInitLMOptions(FFLMOptions* options); +bool ffParseLMCommandOptions(FFLMOptions* options, const char* key, const char* value); +void ffDestroyLMOptions(FFLMOptions* options); +void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/lm/option.h b/src/modules/lm/option.h new file mode 100644 index 000000000..2a788186c --- /dev/null +++ b/src/modules/lm/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFLMOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFLMOptions; diff --git a/src/modules/modules.h b/src/modules/modules.h index 3966b9500..6959ab815 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -25,6 +25,7 @@ #include "modules/host/host.h" #include "modules/icons/icons.h" #include "modules/kernel/kernel.h" +#include "modules/lm/lm.h" #include "modules/locale/locale.h" #include "modules/localip/localip.h" #include "modules/media/media.h" diff --git a/src/modules/options.h b/src/modules/options.h index 12aa53998..2fdc65c3e 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -25,6 +25,7 @@ #include "modules/icons/option.h" #include "modules/kernel/option.h" #include "modules/locale/option.h" +#include "modules/lm/option.h" #include "modules/localip/option.h" #include "modules/media/option.h" #include "modules/memory/option.h" From 1c65c75dbab0f3efe0cf752162e82e54a6a4b6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 20 Jun 2023 23:43:56 +0800 Subject: [PATCH 197/493] LM: init variables Don't know why it didn't crash before --- src/modules/lm/lm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index cfb1ac72b..5f52baf9d 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -9,6 +9,8 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options) { FFLMResult result; + ffStrbufInit(&result.service); + ffStrbufInit(&result.type); const char* error = ffDetectLM(&result); if(error) @@ -38,6 +40,8 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, }); } + ffStrbufDestroy(&result.service); + ffStrbufDestroy(&result.type); } void ffInitLMOptions(FFLMOptions* options) From 151753cb2fa3aefe6484fb1176ff24cf9e91be81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 21 Jun 2023 16:07:35 +0800 Subject: [PATCH 198/493] LM: support systems without $XDG_SESSION_ID being set --- src/detection/lm/lm_linux.c | 41 ++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index b5893c497..dcc65c7c2 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -1,23 +1,50 @@ #include "lm.h" #include "common/properties.h" +#include "common/dbus.h" +#include "detection/displayserver/displayserver.h" + +#include #define FF_SYSTEMD_SESSIONS_PATH "/var/run/systemd/sessions/" +#define FF_SYSTEMD_USERS_PATH "/run/systemd/users/" const char* ffDetectLM(FFLMResult* result) { - const char* sessionId = getenv("XDG_SESSION_ID"); - if (!sessionId) return "$XDG_SESSION_ID is not set"; + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); - char path[64] = FF_SYSTEMD_SESSIONS_PATH; - strncpy(path + strlen(FF_SYSTEMD_SESSIONS_PATH), sessionId, sizeof(path) - strlen(FF_SYSTEMD_SESSIONS_PATH) - 1); + FF_STRBUF_AUTO_DESTROY sessionId = ffStrbufCreateS(getenv("XDG_SESSION_ID")); + if (sessionId.length == 0) + { + // On some incorrectly configured systems, $XDG_SESSION_ID is not set. Try finding it ourself + // WARNING: This is private data. Do not parse + ffStrbufAppendF(&path, "/run/systemd/users/%d", getuid()); - // The file reads `This is private data. Do not parse`. - // What does it mean? But let's ignore it for now. - if (!ffParsePropFileValues(path, 2, (FFpropquery[]) { + // This is actually buggy, and assumes current user is using DE + // `sd_pid_get_session` can be a better option, but we need to find a pid to use + if (!ffParsePropFileValues(path.chars, 1, (FFpropquery[]) { + {"DISPLAY=", &sessionId}, + })) + return "Failed to get $XDG_SESSION_ID"; + ffStrbufClear(&path); + } + + ffStrbufAppendS(&path, "/var/run/systemd/sessions/"); + ffStrbufAppend(&path, &sessionId); + + // WARNING: This is private data. Do not parse + if (!ffParsePropFileValues(path.chars, 2, (FFpropquery[]) { {"SERVICE=", &result->service}, {"TYPE=", &result->type}, })) return "Failed to parse /run/systemd/sessions/$XDG_SESSION_ID"; + // Correct char cases + if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND)) + ffStrbufSetS(&result->type, FF_WM_PROTOCOL_WAYLAND); + else if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_X11)) + ffStrbufSetS(&result->type, FF_WM_PROTOCOL_X11); + else if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_TTY)) + ffStrbufSetS(&result->type, FF_WM_PROTOCOL_TTY); + return NULL; } From 5b5527f4c9aed9182e552b2f2ae5a5fcf21e2774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 21 Jun 2023 16:21:14 +0800 Subject: [PATCH 199/493] JsonConfig: allow JSON files without `"modules"` key --- src/common/jsonconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index c2ee05cf9..98ae8a2d3 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -230,7 +230,7 @@ static const char* printJsonConfig(FFinstance* instance) return "Invalid JSON config format. Root value must be an object"; yyjson_val* modules = yyjson_obj_get(root, "modules"); - if (!modules) return "Property 'modules' is not found"; + if (!modules) return NULL; if (!yyjson_is_arr(modules)) return "Property 'modules' must be an array of strings or objects"; yyjson_val* item; From 9ddec1d9aa549b992a45abb5b8c5f67128ca06ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 21 Jun 2023 16:33:46 +0800 Subject: [PATCH 200/493] JsonConfig: update json_schema, and move it to `doc`. Move logo.md to Github wiki --- CHANGELOG.md | 1 + .../json_schema.jsonc => doc/json_schema.json | 411 ++++++++---------- doc/logo.md | 116 ----- 3 files changed, 178 insertions(+), 350 deletions(-) rename src/data/json_schema.jsonc => doc/json_schema.json (65%) delete mode 100644 doc/logo.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 47476d0f3..f7b57b7a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Changes: * Remove `--shell-version` and `--terminal-version`. They are always enabled * Remove `--*-error-format` * Remove `--display-detect-name`. Display name is always detected, and will be printed if multiple displays are detected +* Remove `--set` and `--set-keyless`. Use JSON config with Custom module instead Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine diff --git a/src/data/json_schema.jsonc b/doc/json_schema.json similarity index 65% rename from src/data/json_schema.jsonc rename to doc/json_schema.json index 37def9a95..919c86de6 100644 --- a/src/data/json_schema.jsonc +++ b/doc/json_schema.json @@ -6,34 +6,32 @@ "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] }, "key": { - "title": "modules.*.key", - "description": "Key of the module", + "title": "Key of the module", "type": "string" }, "keyColor": { - "title": "modules.*.keyColor", - "description": "Color of the module key", - "$ref": "#/$defs/colors", - "default": "Use display.color.keys" + "title": "Color of the module key. Left empty to use `display.color.keys`", + "$ref": "#/$defs/colors" }, "format": { - "title": "modules.*.format", - "description": "Format of the module", + "title": "Output format of the module", "type": "string" } }, "type": "object", - "title": "Fastfetch config", - "description": "JSON config file for fastfetch. Usually be `~/.config/fastfetch.jsonc`", + "title": "JSON config file for fastfetch. Usually be `~/.config/fastfetch.jsonc`", "properties": { + "$schema": { + "type": "string", + "title": "JSON schema URL", + "format": "uri" + }, "logo": { - "title": "logo", - "description": "Fastfetch logo configurations", + "title": "Fastfetch logo configurations", "type": "object", "properties": { "type": { - "title": "logo.type", - "description": "Set the type of the logo given", + "title": "Set the type of the logo given", "enum": [ "auto", "builtin", @@ -51,131 +49,108 @@ "default": "auto" }, "source": { - "title": "logo.source", "type": "string", - "description": "Set the source file of the logo" + "title": "Set the source file of the logo" }, "color": { - "title": "logo.color", "type": "object", - "description": "Overwrite a color in the logo", + "title": "Overwrite a color in the logo", "properties": { "1": { - "title": "logo.color.1", - "description": "Color 1", + "title": "Color 1", "$ref": "#/$defs/colors" }, "2": { - "title": "logo.color.2", - "description": "Color 2", + "title": "Color 2", "$ref": "#/$defs/colors" }, "3": { - "title": "logo.color.3", - "description": "Color 3", + "title": "Color 3", "$ref": "#/$defs/colors" }, "4": { - "title": "logo.color.4", - "description": "Color 4", + "title": "Color 4", "$ref": "#/$defs/colors" }, "5": { - "title": "logo.color.5", - "description": "Color 5", + "title": "Color 5", "$ref": "#/$defs/colors" }, "6": { - "title": "logo.color.6", - "description": "Color 6", + "title": "Color 6", "$ref": "#/$defs/colors" }, "7": { - "title": "logo.color.7", - "description": "Color 7", + "title": "Color 7", "$ref": "#/$defs/colors" }, "8": { - "title": "logo.color.8", - "description": "Color 8", + "title": "Color 8", "$ref": "#/$defs/colors" }, "9": { - "title": "logo.color.9", - "description": "Color 9", + "title": "Color 9", "$ref": "#/$defs/colors" } } }, "width": { - "title": "logo.width", "type": "integer", - "description": "Set the width of the logo (in characters). Required for iTerm image protocol", + "title": "Set the width of the logo (in characters). Required for iTerm image protocol", "minimum": 1 }, "height": { - "title": "logo.height", "type": "integer", - "description": "Set the height of the logo (in characters). Required for iTerm image protocol", + "title": "Set the height of the logo (in characters). Required for iTerm image protocol", "minimum": 1 }, "padding": { - "title": "logo.padding", "type": "object", - "description": "Set the padding of the logo", + "title": "Set the padding of the logo", "properties": { "top": { - "title": "logo.padding.top", "type": "integer", - "description": "Set the top padding of the logo", + "title": "Set the top padding of the logo", "minimum": 0 }, "left": { - "title": "logo.padding.left", "type": "integer", - "description": "Set the left padding of the logo", + "title": "Set the left padding of the logo", "minimum": 0 }, "right": { - "title": "logo.padding.right", "type": "integer", - "description": "Set the right padding of the logo", + "title": "Set the right padding of the logo", "minimum": 0 } } }, "printRemaining": { - "title": "logo.printRemaining", "type": "boolean", - "description": "Whether to print the remaining logo, if it has more lines than modules to display", + "title": "Whether to print the remaining logo, if it has more lines than modules to display", "default": false }, "preserveAspectRadio": { - "title": "logo.preserveAspectRadio", "type": "boolean", - "description": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", + "title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", "default": false }, "chafa": { - "title": "logo.chafa", "type": "object", - "description": "Chafa configuration. See chafa document for details", + "title": "Chafa configuration. See chafa document for details", "properties": { "fgOnly": { - "title": "logo.chafa.fgOnly", "type": "boolean", - "description": "Produce character-cell output using foreground colors only", + "title": "Produce character-cell output using foreground colors only", "default": false }, "symbols": { - "title": "logo.chafa.symbols", "type": "string", - "description": "Specify character symbols to employ in final output" + "title": "Specify character symbols to employ in final output" }, "canvasMode": { - "title": "logo.chafa.canvasMode", "type": "string", - "description": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", + "title": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", "enum": [ "TRUECOLOR", "INDEXED_256", @@ -188,18 +163,16 @@ ] }, "colorSpace": { - "title": "logo.chafa.colorSpace", "type": "string", - "description": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", + "title": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", "enum": [ "RGB", "DIN99D" ] }, "ditherMode": { - "title": "logo.chafa.ditherMode", "type": "string", - "description": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", + "title": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", "enum": [ "NONE", "ORDERED", @@ -208,103 +181,89 @@ } } } - } + }, + "additionalProperties": false }, "general": { - "title": "general", - "description": "Fastfetch general configurations", + "title": "Fastfetch general configurations", "type": "object", "properties": { "allowSlowOperations": { - "title": "general.allowSlowOperations", "type": "boolean", - "description": "Allow operations that can be very slow for more detailed output", + "title": "Allow operations that can be very slow for more detailed output", "default": false }, "multithreading": { - "title": "general.multithreading", "type": "boolean", - "description": "Use multiple threads to detect values", + "title": "Use multiple threads to detect values", "default": true }, "stat": { - "title": "general.stat", "type": "boolean", - "description": "Show time usage (in ms) for individual modules", + "title": "Show time usage (in ms) for individual modules", "default": false }, "escapeBedrock": { - "title": "general.escapeBedrock", "type": "boolean", - "description": "On Bedrock Linux, whether to escape the bedrock jail", + "title": "On Bedrock Linux, whether to escape the bedrock jail", "default": true }, "pipe": { - "title": "general.pipe", "type": "boolean", - "description": "Whether to enable pipe mode (disable logo and all escape sequences)", + "title": "Whether to enable pipe mode (disable logo and all escape sequences)", "default": false }, "playerName": { - "title": "general.playerName", "type": "string", - "description": "The name of the player to use for module Media and Player. Linux only" + "title": "The name of the player to use for module Media and Player. Linux only" }, "osFile": { - "title": "general.osFile", "type": "string", - "description": "Set the path to the file containing OS information. Linux only" + "title": "Set the path to the file containing OS information. Linux only" } - } + }, + "additionalProperties": false }, "display": { - "title": "display", - "description": "Configure how things to be displayed", + "title": "Configure how things to be displayed", "type": "object", "properties": { "showErrors": { - "title": "display.showErrors", "type": "boolean", - "description": "Print occurring errors to the console. False to ignore errored modules", + "title": "Print occurring errors to the console. False to ignore errored modules", "default": false }, "disableLinewrap": { - "title": "display.disableLinewrap", "type": "boolean", - "description": "Whether to disable line wrap during the run", + "title": "Whether to disable line wrap during the run", "default": true }, "hideCursor": { - "title": "display.hideCursor", "type": "boolean", - "description": "Whether to hide the cursor during the run", + "title": "Whether to hide the cursor during the run", "default": true }, "separator": { - "title": "display.separator", "type": "string", - "description": "Set the separator between key and value", + "title": "Set the separator between key and value", "default": ": " }, "color": { - "title": "display.color", - "description": "Set the color of the keys and title", - "anyOf": [ + "title": "Set the color of the keys and title", + "oneOf": [ { - "description": "Set the both color of the keys and title", + "title": "Set the both color of the keys and title", "$ref": "#/$defs/colors" }, { "type": "object", "properties": { "keys": { - "title": "display.color.keys", - "description": "Set the color of the keys", + "title": "Set the color of the keys", "$ref": "#/$defs/colors" }, "title": { - "title": "display.color.title", - "description": "Set the color of the title", + "title": "Set the color of the title", "$ref": "#/$defs/colors" } } @@ -313,8 +272,7 @@ }, "binaryPrefix": { "type": "string", - "title": "display.binaryPrefix", - "description": "Set the binary prefix to used when printing bytes", + "title": "Set the binary prefix to used when printing bytes", "enum": [ "iec", "si", @@ -323,151 +281,126 @@ }, "percentType": { "type": "number", - "title": "display.percentType", - "description": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", + "title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", "minimum": 0, "maximum": 9, "default": 1 }, "noBuffer": { "type": "boolean", - "title": "display.noBuffer", - "description": "Whether to disable the stdout application buffer", + "title": "Whether to disable the stdout application buffer", "default": false } - } + }, + "additionalProperties": false }, "library": { - "title": "library", - "description": "Set the path of a library to load", + "title": "Set the path of a library to load", "type": "object", "properties": { "pci": { - "title": "library.pci", "type": "string", - "description": "GPU output (Linux and FreeBSD)" + "title": "GPU output (Linux and FreeBSD)" }, "vulkan": { - "title": "library.vulkan", "type": "string", - "description": "Vulkan module & fallback for GPU output" + "title": "Vulkan module & fallback for GPU output" }, "freetype": { - "title": "library.freetype", "type": "string", - "description": "Used for Termux font detection (Android)" + "title": "Used for Termux font detection (Android)" }, "wayland": { - "title": "library.wayland", "type": "string", - "description": "Better display performance and output in wayland sessions.\nSupports different refresh rates per monitor.\n(Linux)" + "title": "Better display performance and output in wayland sessions.\nSupports different refresh rates per monitor.\n(Linux)" }, "xcbRandr": { - "title": "library.xcbRandr", "type": "string", - "description": "" + "title": "" }, "xcb": { - "title": "library.xcb", "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" + "title": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, "xrandr": { - "title": "library.xrandr", "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" + "title": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, "x11": { - "title": "library.x11", "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" + "title": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD)" }, "gio": { - "title": "library.gio", "type": "string", - "description": "Needed for values that are only stored GSettings (Linux, FreeBSD)" + "title": "Needed for values that are only stored GSettings (Linux, FreeBSD)" }, "dconf": { - "title": "library.dconf", "type": "string", - "description": "Needed for values that are only stored in DConf + Fallback for GSettings (Linux, FreeBSD)" + "title": "Needed for values that are only stored in DConf + Fallback for GSettings (Linux, FreeBSD)" }, "dbus": { - "title": "library.dbus", "type": "string", - "description": "Bluetooth, Player & Media detection (Linux, FreeBSD)" + "title": "Bluetooth, Player & Media detection (Linux, FreeBSD)" }, "xfconf": { - "title": "library.xfconf", "type": "string", - "description": "Needed for XFWM theme and XFCE Terminal font (Linux, FreeBSD)" + "title": "Needed for XFWM theme and XFCE Terminal font (Linux, FreeBSD)" }, "sqlite3": { - "title": "library.sqlite3", "type": "string", - "description": "Needed for pkg & rpm package count (Linux, FreeBSD)" + "title": "Needed for pkg & rpm package count (Linux, FreeBSD)" }, "rpm": { - "title": "library.rpm", "type": "string", - "description": "Slower fallback for rpm package count. Needed on openSUSE & old CentOS / Redhat. (Linux)" + "title": "Slower fallback for rpm package count. Needed on openSUSE & old CentOS / Redhat. (Linux)" }, "imagemagick": { - "title": "library.imagemagick", "type": "string", - "description": "Images in terminal using sixel or kitty graphics protocol (Linux, FreeBSD, macOS)" + "title": "Images in terminal using sixel or kitty graphics protocol (Linux, FreeBSD, macOS)" }, "z": { - "title": "library.z", - "description": "Libz. Faster image output when using kitty graphics protocol (Linux, FreeBSD, macOS)", + "title": "Libz. Faster image output when using kitty graphics protocol (Linux, FreeBSD, macOS)", "type": "string" }, "chafa": { - "title": "library.chafa", "type": "string", - "description": "Image output as ascii art (Linux, FreeBSD, macOS)" + "title": "Image output as ascii art (Linux, FreeBSD, macOS)" }, "egl": { - "title": "library.egl", "type": "string", - "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" + "title": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "glx": { - "title": "library.glx", "type": "string", - "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" + "title": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "osmesa": { - "title": "library.osmesa", "type": "string", - "description": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" + "title": "Needed by the OpenGL module for gl context creation (Linux, FreeBSD)" }, "opencl": { - "title": "library.opencl", "type": "string", - "description": "OpenCL module (Linux, FreeBSD, Windows)" + "title": "OpenCL module (Linux, FreeBSD, Windows)" }, "pulse": { - "title": "library.pulse", - "description": "Pulseaudio. Used for Sound detection (Linux, FreeBSD)", + "title": "Pulseaudio. Used for Sound detection (Linux, FreeBSD)", "type": "string" }, "nm": { - "title": "library.nm", - "description": "NetworkManager. Used for Wifi detection (Linux)", + "title": "NetworkManager. Used for Wifi detection (Linux)", "type": "string" } - } + }, + "additionalProperties": false }, "modules": { - "title": "modules", - "description": "Fastfetch modules to run", + "title": "Fastfetch modules to run", "type": "array", "items": { "anyOf": [ { "type": "string", - "description": "Run module with default configurations", + "title": "Run module with default configurations", "enum": [ "battery", "bios", @@ -481,7 +414,6 @@ "command", "colors", "cursor", - "custom", "datetime", "display", "disk", @@ -525,12 +457,23 @@ }, { "type": "object", - "required": ["type"], - "anyOf": [ + "title": "Run module with custom configurations", + "required": [ + "type" + ], + "properties": { + "type": { + "title": "Module type", + "type": "string" + } + }, + "oneOf": [ { + "title": "Break", + "description": "Print a empty line", "properties": { "type": { - "const": "Break" + "const": "break" } }, "additionalProperties": false @@ -589,18 +532,17 @@ "additionalProperties": false }, { + "title": "Battery", "properties": { "type": { "const": "battery" }, "dir": { - "title": "modules.battery.dir", - "description": "The directory where the battery folders are. Standard: /sys/class/power_supply/. Linux only", + "title": "The directory where the battery folders are. Standard: `/sys/class/power_supply/`. Linux only", "type": "string" }, "temp": { - "title": "modules.battery.temp", - "description": "Detect and display Battery temperature if supported", + "title": "Detect and display Battery temperature if supported", "type": "boolean", "default": false }, @@ -617,13 +559,13 @@ "additionalProperties": false }, { + "title": "Bluetooth", "properties": { "type": { "const": "bluetooth" }, "showDisconnected": { - "title": "modules.bluetooth.showDisconnected", - "description": "Set if disconnected bluetooth devices should be printed", + "title": "Set if disconnected bluetooth devices should be printed", "type": "boolean", "default": false }, @@ -640,13 +582,13 @@ "additionalProperties": false }, { + "title": "CPU", "properties": { "type": { "const": "cpu" }, "temp": { - "title": "modules.cpu.temp", - "description": "Detect and display CPU temperature if supported", + "title": "Detect and display CPU temperature if supported", "type": "boolean", "default": false }, @@ -663,13 +605,13 @@ "additionalProperties": false }, { + "title": "Colors", "properties": { "type": { "const": "colors" }, "symbol": { - "title": "modules.colors.symbol", - "description": "Set the symbol to use", + "title": "Set the symbol to use", "type": "string", "enum": [ "block", @@ -682,8 +624,7 @@ "default": "block" }, "paddingLeft": { - "title": "modules.colors.paddingLeft", - "description": "Set the number of white spaces to print before the symbol", + "title": "Set the number of white spaces to print before the symbol", "type": "integer", "minimum": 0, "default": 0 @@ -691,18 +632,17 @@ } }, { + "title": "Command", "properties": { "type": { "const": "command" }, "shell": { - "title": "modules.command.shell", - "description": "Set the shell program to execute the command text\nDefault: cmd for Windows, csh for FreeBSD, bash for others", + "title": "Set the shell program to execute the command text\nDefault: cmd for Windows, csh for FreeBSD, bash for others", "type": "string" }, "text": { - "title": "modules.command.text", - "description": "Set the command text to be executed", + "title": "Set the command text to be executed", "type": "string" }, "key": { @@ -718,40 +658,46 @@ "additionalProperties": false }, { + "title": "Custom", "description": "Print a custom string, with or without key", "properties": { "type": { "const": "custom" }, "key": { - "description": "Leave empty not to print the key", + "title": "Leave empty not to print the key", "type": "string" }, "keyColor": { "$ref": "#/$defs/keyColor" }, "format": { - "description": "Text to print", + "title": "Text to print", "type": "string" } }, - "required": ["format"], + "required": [ + "format" + ], "additionalProperties": false }, { + "title": "Display", "properties": { "type": { "const": "display" }, "compactType": { - "title": "modules.display.compactType", - "enum": ["none", "original", "scaled"], - "description": "Set if all displays should be printed in one line", + "enum": [ + "none", + "original", + "scaled" + ], + "title": "Set if all displays should be printed in one line", "default": "none" }, "preciseRefreshRate": { - "title": "modules.display.preciseRefreshRate", - "description": "Set if decimal refresh rates should not be rounded into integers when printing", + "title": "Set if decimal refresh rates should not be rounded into integers when printing", "type": "boolean", "default": true }, @@ -768,37 +714,33 @@ "additionalProperties": false }, { + "title": "Disk", "properties": { "type": { "const": "disk" }, "folders": { - "title": "modules.disk.folders", "type": "string", - "description": "A colon (semicolon on Windows) separated list of folder paths for the disk output\nDefault: \"/:/home\" (\"C:\\\\;D:\\\\ ...\" on Windows)" + "title": "A colon (semicolon on Windows) separated list of folder paths for the disk output\nDefault: \"/:/home\" (\"C:\\\\;D:\\\\ ...\" on Windows)" }, "showExternal": { - "title": "modules.disk.showExternal", "type": "boolean", - "description": "Set if external volume should be printed", + "title": "Set if external volume should be printed", "default": true }, "showHidden": { - "title": "modules.disk.showHidden", "type": "boolean", - "description": "Set if hidden volumes should be printed", + "title": "Set if hidden volumes should be printed", "default": false }, "showSubvolumes": { - "title": "modules.disk.showSubvolumes", "type": "boolean", - "description": "Set if subvolumes should be printed", + "title": "Set if subvolumes should be printed", "default": false }, "showUnknown": { - "title": "modules.disk.showUnknown", "type": "boolean", - "description": "Set if unknown (unable to detect sizes) volumes should be printed", + "title": "Set if unknown (unable to detect sizes) volumes should be printed", "default": false }, "key": { @@ -814,26 +756,28 @@ "additionalProperties": false }, { + "title": "GPU", "properties": { "type": { "const": "gpu" }, "temp": { - "title": "modules.gpu.temp", - "description": "Detect and display GPU temperature if supported", + "title": "Detect and display GPU temperature if supported", "type": "boolean", "default": false }, "forceVulkan": { - "title": "modules.gpu.forceVulkan", - "description": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`", + "title": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`", "type": "boolean", "default": false }, "hideType": { - "title": "modules.gpu.hideType", - "description": "Specify the type of GPUs should not be printed", - "enum": ["integrated", "discrete", "none"], + "title": "Specify the type of GPUs should not be printed", + "enum": [ + "integrated", + "discrete", + "none" + ], "default": "none" }, "key": { @@ -849,43 +793,38 @@ "additionalProperties": false }, { + "title": "Local IP", "properties": { "type": { "const": "localip" }, "showIpv4": { - "title": "modules.localip.showIpv4", - "description": "Show IPv4 addresses", + "title": "Show IPv4 addresses", "type": "boolean", "default": true }, "showIpv6": { - "title": "modules.localip.showIpv6", - "description": "Show IPv6 addresses", + "title": "Show IPv6 addresses", "type": "boolean", "default": false }, "showMac": { - "title": "modules.localip.showMac", - "description": "Show MAC addresses", + "title": "Show MAC addresses", "type": "boolean", "default": false }, "showLoop": { - "title": "modules.localip.showLoop", - "description": "Show loop back addresses (127.0.0.1)", + "title": "Show loop back addresses (127.0.0.1)", "type": "boolean", "default": false }, "compact": { - "title": "modules.localip.compact", - "description": "Show all IPs in one line", + "title": "Show all IPs in one line", "type": "boolean", "default": false }, "namePrefix": { - "title": "modules.localip.namePrefix", - "description": "Show IPs with given name prefix only", + "title": "Show IPs with given name prefix only", "type": "string" }, "key": { @@ -901,14 +840,19 @@ "additionalProperties": false }, { + "title": "OpenGL", "properties": { "type": { "const": "opengl" }, "library": { - "title": "modules.opengl.library", - "description": "Set the OpenGL context creation library to use. Linux only", - "enum": ["auto", "egl", "glx", "osmesa"], + "title": "Set the OpenGL context creation library to use. Linux only", + "enum": [ + "auto", + "egl", + "glx", + "osmesa" + ], "default": "auto" }, "key": { @@ -924,20 +868,19 @@ "additionalProperties": false }, { + "title": "Public IP", "properties": { "type": { "const": "publicip" }, "url": { - "title": "modules.publicip.url", - "description": "The URL of public IP detection server to be used. Only HTTP protocol is supported", + "title": "The URL of public IP detection server to be used. Only HTTP protocol is supported", "type": "string", "format": "url", "default": "http://ipinfo.io/ip" }, "timeout": { - "title": "modules.publicip.timeout", - "description": "Time in milliseconds to wait for the public ip server to respond", + "title": "Time in milliseconds to wait for the public ip server to respond", "type": "integer", "minimum": 0, "default": "disabled (0)" @@ -955,13 +898,13 @@ "additionalProperties": false }, { + "title": "Separator", "properties": { "type": { "const": "separator" }, "string": { - "title": "modules.separator.string", - "description": "Set the string to be printed", + "title": "Set the string to be printed", "type": "string", "format": "url", "default": "http://ipinfo.io/ip" @@ -970,13 +913,13 @@ "additionalProperties": false }, { + "title": "Sound", "properties": { "type": { "const": "sound" }, "soundType": { - "title": "modules.sound.soundType", - "description": "Set what type of sound devices should be printed", + "title": "Set what type of sound devices should be printed", "type": "string", "enum": [ "main", @@ -998,34 +941,33 @@ "additionalProperties": false }, { + "title": "Title", "properties": { "type": { "const": "title" }, "fqdn": { - "title": "modules.title.fqdn", "type": "boolean", - "description": "Set if the title should use fully qualified domain name", + "title": "Set if the title should use fully qualified domain name", "default": false } }, "additionalProperties": false }, { + "title": "Weather", "properties": { "type": { "const": "weather" }, "timeout": { - "title": "modules.weather.timeout", - "description": "Time in milliseconds to wait for the weather server to respond", + "title": "Time in milliseconds to wait for the weather server to respond", "type": "integer", "minimum": 0, "default": "disabled (0)" }, "outputFormat": { - "title": "modules.weather.outputFormat", - "description": "The output weather format to be used (must be URI encoded)", + "title": "The output weather format to be used (must be URI encoded)", "type": "string", "default": "%t+-+%C+(%l)" }, @@ -1046,5 +988,6 @@ ] } } - } + }, + "additionalProperties": false } diff --git a/doc/logo.md b/doc/logo.md deleted file mode 100644 index 69d13e8ef..000000000 --- a/doc/logo.md +++ /dev/null @@ -1,116 +0,0 @@ -# Logo options - -## General - -| Option | Default | Description | -|--------|---------|-------------| -| `--logo`, `-l` | `""` | The logo source, interpreted depending on type | -| `--logo-type` | `auto` | The logo type. See the following categories for possible values | -| `--` | `""` | Short for `--logo-type --logo ` | -| `--logo-padding` | `""` | Sets the padding left and right of the logo | -| `--logo-padding-left` | `0` | Sets the padding left of the logo | -| `--logo-padding-right` | `4` | Sets the padding right of the logo | -| `--logo-padding-top` | `0` | Sets the padding top of the logo | - -All filesytem paths can be: -* Absolute -* Relative to the current working directory -* Relative to any of the directories listed by `fastfetch --list-data-paths` + `/logos` - For example, the file `~/.local/share/fastfetch/logos/shrek` can simply be referenced as `shrek`. - -## Text - -| Option | Default | Description | -|--------|---------|-------------| -| `--logo-color-[1-9]` | `""` | Overrides a color for logos that support it | -| `--logo-print-remaining` | `true` | Print the remaining logo, if it is higher than the keys | - -* Color placeholders are in the form `$[1-9]`. To print a `$`, use `$$`. -* If a color placeholder value is not set, the placeholder is simply discarded. - -## Image - -| Option | Default | Description | -|--------|---------|-------------| -| `--logo-width` | `""` | Sets the width of the logo for logos that support it | -| `--logo-height` | `""` | Sets the height of the logo for logos that support it | - -* If one of the height / width options is set, but the other not, the aspect ratio is preserved. -* If neither height nor width is set, the original size is used. - -# Logo types - -## auto - -Trys to detect the logo type depending on the value of `--logo`, in the following order: -* If the value is empty / not set, an autodected builtin logo is displayed. -* If the value is the name of a builtin logo, it is displayed. -* If the value is the path to an image file, and the terminal emulator is known to support an image protocol, the image is displayed. -* If the value is the path to a text file, the content is displayed. -* The autodetected builtin logo is displayed. - -## builtin - -The value of `--logo` is interpreted as the name of a builtin logo. -* If the value is empty / not set, it is autodetected. -* Use `--list-logos` to get a list of all available logos. -* Use `--print-logos` to see all available logos. -* All builtin logos set default values for `--logo-color-[1-9]`. -* Use `none` to disable the logo, but keep key colors from the detected logo. - -## file - -The value of `--logo` is interpreted as the path to a file. The content of the file is displayed. -* If the file can't be read, the autodetected builtin logo is displayed. - -## file-raw - -The value of `--logo` is interpreted as the path to a file. The content of the file is displayed. -* No color placeholder replacement is done. -* If the file can't be read, the autodetected builtin logo is displayed. - -## data - -The value of `--logo` is interpreted as the logo and directly displayed. -* If the value is empty / not set, the autodetected builtin logo is displayed. - -## data-raw - -The value of `--logo` is interpreted as the logo and directly displayed. -* No color placeholder replacement is done. -* If the value is empty / not set, the autodetected builtin logo is displayed. - -## sixel - -The value of `--logo` is interpreted as the path to an image file. It is displayed using the sixel graphics protocol. -* `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature. - -## kitty - -The value of `--logo` is interpreted as the path to an image file. It is displayed using the kitty graphics protocol. -* If the file is a png file, and both `--logo-width` and `--logo-height` are specified, the image is directly send to the terminal emulator. -* Otherwise `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature. - -## iterm - -The value of `--logo` is interpreted as the path to an image file. It is displayed using the iTerm graphics protocol. -* Both `--logo-width` and `--logo-height` must be specified. - -## chafa - -The value of `--logo` is interpreted as the path to an image file. It is converted to an ascii logo using `libchafa`. -* `fastfetch` must be compiled with the `chafa` feature. -* `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature. -* Use `--chafa-fg-only` to set weather to render foreground only. -* Use `--chafa-symbols` to set the symbols. -* Use `--chafa-canvas-mode` to set the canvas mode. -* Use `--chafa-color-space` to set the color space. -* Use `--chafa-dither-mode` to set the dither mode. -* See the [chafa documentation](https://hpjansson.org/chafa/man/) for more information. - -## raw - -The value of `--logo` is interpreted as the path to a binary file. It is printed as-is. -* Both `--logo-width` and `--logo-height` must be specified. -* Use this to display a pre converted image file. -* If the file can't be read, the autodetected builtin logo is displayed. From 66126d8e7c26ee4da10d84d9214210e110fe772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 00:00:08 +0800 Subject: [PATCH 201/493] LM: silense warnings --- src/detection/lm/lm_nosupport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/lm/lm_nosupport.c b/src/detection/lm/lm_nosupport.c index 9a0a816a1..cd1f5f7f7 100644 --- a/src/detection/lm/lm_nosupport.c +++ b/src/detection/lm/lm_nosupport.c @@ -1,6 +1,6 @@ #include "lm.h" -const char* ffDetectLM(FFLMResult* result) +const char* ffDetectLM(FF_MAYBE_UNUSED FFLMResult* result) { return "Not supported on this platform"; } From be8782231bbc8c91bed4577a6e008d06d7bea484 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 01:38:25 +0000 Subject: [PATCH 202/493] Terminal (FreeBSD): fix Gnome Terminal version detetion on FreeBSD --- src/detection/terminalshell/terminalshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 8651ac893..841ca8142 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -253,7 +253,7 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #if defined(__linux__) || defined(__FreeBSD__) - if(ffStrbufIgnCaseEqualS(processName, "gnome-terminal-")) + if(ffStrbufStartsWithIgnCaseS(processName, "gnome-terminal-")) return getTerminalVersionGnome(version); if(ffStrbufIgnCaseEqualS(processName, "konsole")) From d6879219e70ec4a24d001a1494f4adef0c7f9b23 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 01:42:02 +0000 Subject: [PATCH 203/493] Disk (FreeBSD): hide `/compat/linux/*` --- src/detection/disk/disk_bsd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index e6be77659..e9911eb72 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -11,7 +11,8 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) ffStrbufStartsWithS(&disk->mountpoint, "/var") || ffStrbufStartsWithS(&disk->mountpoint, "/tmp") || ffStrbufStartsWithS(&disk->mountpoint, "/proc") || - ffStrbufStartsWithS(&disk->mountpoint, "/zroot") + ffStrbufStartsWithS(&disk->mountpoint, "/zroot") || + ffStrbufStartsWithS(&disk->mountpoint, "/compat/linux/") ) disk->type = FF_DISK_TYPE_HIDDEN_BIT; else if((fs->f_flags & MNT_NOSUID) || !(fs->f_flags & MNT_LOCAL)) From 26978b7d4802f2cb530d0e91972121f62f18ff7c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 02:01:33 +0000 Subject: [PATCH 204/493] Terminal (Linux): print `gnome-terminal-server` as `gnome-terminal` --- src/detection/terminalshell/terminalshell_linux.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 1c6188601..300af0a31 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -372,12 +372,22 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitS(&result.shellPrettyName, result.shellExeName); } - if(ffStrbufEqualS(&result.terminalProcessName, "iTerm.app") || ffStrbufStartsWithS(&result.terminalProcessName, "iTermServer-")) + #if defined(__linux__) || defined(__FreeBSD__) + + if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-")) + ffStrbufInitS(&result.terminalPrettyName, "gnome-terminal"); + + #elif defined(__APPLE__) + + else if(ffStrbufEqualS(&result.terminalProcessName, "iTerm.app") || ffStrbufStartsWithS(&result.terminalProcessName, "iTermServer-")) ffStrbufInitS(&result.terminalPrettyName, "iTerm"); else if(ffStrbufEqualS(&result.terminalProcessName, "Apple_Terminal")) ffStrbufInitS(&result.terminalPrettyName, "Apple Terminal"); else if(ffStrbufEqualS(&result.terminalProcessName, "WarpTerminal")) ffStrbufInitS(&result.terminalPrettyName, "Warp"); + + #endif + else if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) ffStrbufInitS(&result.terminalPrettyName, "WezTerm"); else if(strncmp(result.terminalExeName, result.terminalProcessName.chars, result.terminalProcessName.length) == 0) // if exeName starts with processName, print it. Otherwise print processName From d50d77f5282e2302efcc984f83e768d206e3c0fc Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 02:12:59 +0000 Subject: [PATCH 205/493] TerminalFont (FreeBSD): fix gnome-terminal font detection --- src/detection/terminalfont/terminalfont_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 869add82d..32cb3b847 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -218,7 +218,7 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh detectFromConfigFile(instance, "lxterminal/lxterminal.conf", "fontname =", terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "tilix")) detectFromGSettings(instance, "/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", "default", terminalFont); - else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "gnome-terminal-")) + else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "gnome-terminal-")) detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", "default", terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "mate-terminal")) detectFromGSettings(instance, "/org/mate/terminal/profiles/", "org.mate.terminal.global", "org.mate.terminal.profile", "default-profile", terminalFont); From f7059783dc7c38d08c7b7435c689c4754909b95e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 03:07:18 +0000 Subject: [PATCH 206/493] Logo: more BSD logos --- src/logo/builtin.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 656babf3e..ab670e6a8 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -328,6 +328,43 @@ static const FFlogo* getLogoArcoLinux() FF_LOGO_RETURN } +static const FFlogo* getLogoBSD() +{ + FF_LOGO_INIT + FF_LOGO_NAMES("bsd") + FF_LOGO_LINES( +"$1 , ,\n" +" /( )`\n" +" \\ \\___ / |\n" +" /- _ `-/ '\n" +" ($2/\\/ \\ $1\\ /\\\n" +" $2/ / | ` $1\\\n" +" $3O O $2) $1/ |\n" +" $2`-^--'$1`< '\n" +" (_.) _ ) /\n" +" `.___/` /\n" +" `-----' /\n" +"$4<----. __ / __ \\\n" +"$4<----|====$1O)))$4==$1) \\) /$4====|\n" +"<----' $1`--' `.__,' \\\n" +" | |\n" +" \\ / /\\\n" +" $5______$1( (_ / \\______/\n" +" $5,' ,-----' |\n" +" `--{__________)\n" + ) + FF_LOGO_COLORS( + "31", + "37", + "34", + "33", + "36" + ) + FF_LOGO_COLOR_KEYS("31"); + FF_LOGO_COLOR_TITLE("37"); + FF_LOGO_RETURN +} + static const FFlogo* getLogoBedrock() { FF_LOGO_INIT @@ -899,6 +936,26 @@ static const FFlogo* getLogoFreeBSD() FF_LOGO_RETURN } +static const FFlogo* getLogoFreeBSDSmall() +{ + FF_LOGO_INIT + FF_LOGO_NAMES("freebsd_small") + FF_LOGO_LINES( + "$1/\\,-'''''-,/\\\n" + "\\_) (_/\n" + "| |\n" + "| |\n" + " ; ;\n" + " '-_____-'" + ) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("31") //red + FF_LOGO_COLOR_TITLE("31") //red + FF_LOGO_RETURN +} + static const FFlogo* getLogoGaruda() { FF_LOGO_INIT @@ -1005,6 +1062,35 @@ static const FFlogo* getLogoGentooSmall() FF_LOGO_RETURN } +#define FF_RAW_STRING(x) #x + +static const FFlogo* getLogoGhostBSD() +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ghostbsd") + FF_LOGO_LINES( + "$1 ,gggggg.\n" + " ,agg9* .g)\n" + " .agg* ._.,gg*\n" + " ,gga* (ggg*'\n" + " ,ga* ,ga*\n" + " ,ga' .ag*\n" + " ,ga' .agga'\n" + " 9g' .agg'g*,a\n" + " 'gggg*',gga'\n" + " .gg*'\n" + " .gga*\n" + " .gga*\n" + " (ga*" + ) + FF_LOGO_COLORS( + "34" //blue + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + static const FFlogo* getLogoKDENeon() { FF_LOGO_INIT @@ -2525,6 +2611,7 @@ GetLogoMethod* ffLogoBuiltinGetAll() getLogoArtix, getLogoArtixSmall, getLogoBedrock, + getLogoBSD, getLogoCachyOS, getLogoCachyOSSmall, getLogoCelOS, @@ -2543,10 +2630,12 @@ GetLogoMethod* ffLogoBuiltinGetAll() getLogoFedoraSmall, getLogoFedoraOld, getLogoFreeBSD, + getLogoFreeBSDSmall, getLogoGaruda, getLogoGarudaSmall, getLogoGentoo, getLogoGentooSmall, + getLogoGhostBSD, getLogoKDENeon, getLogoKISSLinux, getLogoKubuntu, From 85597e4d46878ce2205fee3ef4fdea5985d9e111 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 04:06:08 +0000 Subject: [PATCH 207/493] CPU (FreeBSD): actually support temp detection --- CMakeLists.txt | 2 +- src/detection/cpu/cpu_bsd.c | 12 +++--------- src/detection/gpu/gpu_linux.c | 7 +++++-- src/detection/temps/temps_bsd.c | 13 +++++++++++++ src/detection/temps/temps_bsd.h | 8 ++++++++ 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src/detection/temps/temps_bsd.c create mode 100644 src/detection/temps/temps_bsd.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d44d31a..96cb3784e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -462,7 +462,7 @@ elseif(BSD) src/detection/gtk_qt/qt.c src/detection/sound/sound_linux.c src/detection/swap/swap_bsd.c - src/detection/temps/temps_linux.c + src/detection/temps/temps_bsd.c src/detection/terminalfont/terminalfont_linux.c src/detection/terminalshell/terminalshell_linux.c src/detection/theme/theme_linux.c diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 8f6ca0956..fe3315e61 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -1,5 +1,6 @@ #include "cpu.h" #include "common/sysctl.h" +#include "detection/temps/temps_bsd.h" const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) { @@ -12,17 +13,10 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0; cpu->frequencyMax = cpu->frequencyMin; + cpu->temperature = FF_CPU_TEMP_UNSET; if (options->temp) - { - FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate(); - if(ffSysctlGetString("hw.acpi.thermal.tz0.temperature", &cpuTemp)) - cpu->temperature = FF_CPU_TEMP_UNSET; - else - cpu->temperature = ffStrbufToDouble(&cpuTemp); - } - else - cpu->temperature = FF_CPU_TEMP_UNSET; + ffDetectThermalTemp(&cpu->temperature); return NULL; } diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index f7f9a5a34..8b9478e1b 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -122,7 +122,7 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* } } -static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device) +FF_MAYBE_UNUSED static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device) { const FFTempsResult* tempsResult = ffDetectTemps(); @@ -171,7 +171,7 @@ static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* dev gpu->type = FF_GPU_TYPE_INTEGRATED; } -static void pciHandleDevice(const FFinstance* instance, const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) +static void pciHandleDevice(const FFinstance* instance, FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) { pci->ffpci_fill_info(device, PCI_FILL_CLASS); @@ -206,8 +206,11 @@ static void pciHandleDevice(const FFinstance* instance, const FFGPUOptions* opti gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; + + #ifdef __linux__ if(options->temp) pciDetectTemperatur(gpu, device); + #endif } jmp_buf pciInitJmpBuf; diff --git a/src/detection/temps/temps_bsd.c b/src/detection/temps/temps_bsd.c new file mode 100644 index 000000000..39693d65d --- /dev/null +++ b/src/detection/temps/temps_bsd.c @@ -0,0 +1,13 @@ +#include "temps_bsd.h" +#include "common/sysctl.h" + +const char* ffDetectThermalTemp(double* current) +{ + int temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999); + if (temp == -999999) + return "ffSysctlGetInt(\"hw.acpi.thermal.tz0.temperature\") failed"; + + // In tenth of degrees Kelvin + *current = (double) temp / 10 - 273.15; + return NULL; +} diff --git a/src/detection/temps/temps_bsd.h b/src/detection/temps/temps_bsd.h new file mode 100644 index 000000000..a41aba6bc --- /dev/null +++ b/src/detection/temps/temps_bsd.h @@ -0,0 +1,8 @@ +#pragma once + +#ifndef FF_INCLUDED_detection_temps_windows +#define FF_INCLUDED_detection_temps_windows + +const char* ffDetectThermalTemp(double* current); + +#endif From dbda2f84bc4e98a78bff35214440ad848c9bee6c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 04:19:27 +0000 Subject: [PATCH 208/493] Wallpaper: print filename only --- src/modules/wallpaper/wallpaper.c | 166 ++++++++++++++++-------------- 1 file changed, 89 insertions(+), 77 deletions(-) diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 7f1623931..3325fd6a5 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -1,77 +1,89 @@ -#include "common/printing.h" -#include "common/jsonconfig.h" -#include "detection/wallpaper/wallpaper.h" -#include "modules/wallpaper/wallpaper.h" -#include "util/stringUtils.h" - -#define FF_WALLPAPER_NUM_FORMAT_ARGS 1 - -void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) -{ - FF_STRBUF_AUTO_DESTROY wallpaper = ffStrbufCreate(); - const char* error = ffDetectWallpaper(instance, &wallpaper); - - if(error) - { - ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); - return; - } - - if(options->moduleArgs.outputFormat.length == 0) - { - ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufPutTo(&wallpaper, stdout); - } - else - { - ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &wallpaper} - }); - } -} - -void ffInitWallpaperOptions(FFWallpaperOptions* options) -{ - options->moduleName = FF_WALLPAPER_MODULE_NAME; - ffOptionInitModuleArg(&options->moduleArgs); -} - -bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value) -{ - const char* subKey = ffOptionTestPrefix(key, FF_WALLPAPER_MODULE_NAME); - if (!subKey) return false; - if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) - return true; - - return false; -} - -void ffDestroyWallpaperOptions(FFWallpaperOptions* options) -{ - ffOptionDestroyModuleArg(&options->moduleArgs); -} - -void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) -{ - FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options; - ffInitWallpaperOptions(&options); - - if (module) - { - yyjson_val *key_, *val; - size_t idx, max; - yyjson_obj_foreach(module, idx, max, key_, val) - { - const char* key = yyjson_get_str(key_); - if(ffStrEqualsIgnCase(key, "type")) - continue; - - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) - continue; - - ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } - } - - ffPrintWallpaper(instance, &options); -} +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/wallpaper/wallpaper.h" +#include "modules/wallpaper/wallpaper.h" +#include "util/stringUtils.h" + +#define FF_WALLPAPER_NUM_FORMAT_ARGS 2 + +void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) +{ + FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate(); + const char* error = ffDetectWallpaper(instance, &fullpath); + + const uint32_t index = ffStrbufLastIndexC(&fullpath, + #ifndef _WIN32 + '/' + #else + '\\' + #endif + ) + 1; + const char* filename = index >= fullpath.length + ? fullpath.chars + : fullpath.chars + index; + + if(error) + { + ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + puts(filename); + } + else + { + ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRING, filename}, + {FF_FORMAT_ARG_TYPE_STRBUF, &fullpath}, + }); + } +} + +void ffInitWallpaperOptions(FFWallpaperOptions* options) +{ + options->moduleName = FF_WALLPAPER_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_WALLPAPER_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyWallpaperOptions(FFWallpaperOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) +{ + FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options; + ffInitWallpaperOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintWallpaper(instance, &options); +} From 9794c4b78f239eeb4a559661a95dc1dc504d578f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 13:14:38 +0800 Subject: [PATCH 209/493] CI: fix build --- src/detection/terminalshell/terminalshell_linux.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 300af0a31..9e60aacda 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -372,9 +372,13 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitS(&result.shellPrettyName, result.shellExeName); } + + if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) + ffStrbufInitS(&result.terminalPrettyName, "WezTerm"); + #if defined(__linux__) || defined(__FreeBSD__) - if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-")) + else if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-")) ffStrbufInitS(&result.terminalPrettyName, "gnome-terminal"); #elif defined(__APPLE__) @@ -388,8 +392,6 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) #endif - else if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) - ffStrbufInitS(&result.terminalPrettyName, "WezTerm"); else if(strncmp(result.terminalExeName, result.terminalProcessName.chars, result.terminalProcessName.length) == 0) // if exeName starts with processName, print it. Otherwise print processName ffStrbufInitS(&result.terminalPrettyName, result.terminalExeName); else From 1ad204e0a1659a53d07056d86a6196d62022299b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 14:53:15 +0800 Subject: [PATCH 210/493] Logo (Windows): make Windows logos colorable --- src/logo/builtin.c | 72 ++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index ab670e6a8..4962331e3 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1505,26 +1505,28 @@ static const FFlogo* getLogoWindows11() FF_LOGO_INIT FF_LOGO_NAMES("Windows 11", "Windows Server 2022") FF_LOGO_LINES( - "$1\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" + "$1///////////////// $2/////////////////\n" "\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////\n" - "///////////////// /////////////////" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////\n" + "$3///////////////// $4/////////////////" ) FF_LOGO_COLORS( + "34", //blue + "34", //blue + "34", //blue "34" //blue ) FF_LOGO_COLOR_KEYS("33"); //yellow @@ -1537,8 +1539,7 @@ static const FFlogo* getLogoWindows11Small() FF_LOGO_INIT FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") FF_LOGO_LINES( - "$1\n" - "lllllllll lllllllll\n" + "$1lllllllll lllllllll\n" "lllllllll lllllllll\n" "lllllllll lllllllll\n" "lllllllll lllllllll\n" @@ -1561,27 +1562,30 @@ static const FFlogo* getLogoWindows8() FF_LOGO_INIT FF_LOGO_NAMES("Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019") FF_LOGO_LINES( - "$1 ..,\n" + " $2..,\n" " ....,,:;+ccllll\n" - " ...,,+:; cllllllllllllllllll\n" - ",cclllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" + "$1 ...,,+:; $2cllllllllllllllllll\n" + "$1,cclllllllllll $2lllllllllllllllllll\n" + "$1llllllllllllll $2lllllllllllllllllll\n" + "$1llllllllllllll $2lllllllllllllllllll\n" + "$1llllllllllllll $2lllllllllllllllllll\n" + "$1llllllllllllll $2lllllllllllllllllll\n" + "$1llllllllllllll $2lllllllllllllllllll\n" "\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "llllllllllllll lllllllllllllllllll\n" - "`'ccllllllllll lllllllllllllllllll\n" - " `' \\*:: :ccllllllllllllllll\n" + "$3llllllllllllll $4lllllllllllllllllll\n" + "$3llllllllllllll $4lllllllllllllllllll\n" + "$3llllllllllllll $4lllllllllllllllllll\n" + "$3llllllllllllll $4lllllllllllllllllll\n" + "$3llllllllllllll $4lllllllllllllllllll\n" + "$3`'ccllllllllll $4lllllllllllllllllll\n" + "$3 `' \\*:: $4:ccllllllllllllllll\n" " ````''*::cll\n" " ``" ) FF_LOGO_COLORS( + "36", //cyan + "36", //cyan + "36", //cyan "36" //cyan ) FF_LOGO_COLOR_KEYS("33"); //yellow From e261bf8be00728d9c52c36c5c7197582cedd0015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 14:58:07 +0800 Subject: [PATCH 211/493] Host (WSL): make WSL version the product version --- src/detection/host/host_linux.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 57e8f6caf..ac9e17a94 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -86,6 +86,7 @@ const char* ffDetectHost(FFHostResult* host) if(getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) { ffStrbufAppendS(&host->productName, "Windows Subsystem for Linux"); + ffStrbufAppendS(&host->productFamily, "WSL"); FF_STRBUF_AUTO_DESTROY wslVer = ffStrbufCreate(); //Wide charactors if(!ffProcessAppendStdOut(&wslVer, (char* const[]){ @@ -96,12 +97,10 @@ const char* ffDetectHost(FFHostResult* host) { ffStrbufSubstrBeforeFirstC(&wslVer, '\r'); //CRLF ffStrbufSubstrAfterLastC(&wslVer, ' '); - ffStrbufAppendS(&host->productName, " ("); for(uint32_t i = 0; i < wslVer.length; ++i) { if(wslVer.chars[i]) //don't append \0 - ffStrbufAppendC(&host->productName, wslVer.chars[i]); + ffStrbufAppendC(&host->productVersion, wslVer.chars[i]); } - ffStrbufAppendC(&host->productName, ')'); } } } From 3c414abc8fc81a118e6aca51427613d31908abb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 15:12:49 +0800 Subject: [PATCH 212/493] Display: don't print `(null)` --- src/modules/display/display.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index d33bfefea..3688fa069 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -56,7 +56,13 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) ffStrbufClear(&key); if(options->moduleArgs.key.length == 0) { - ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); + const char* subkey = result->name.length ? result->name.chars : displayType; + if (subkey) + ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, subkey); + else if (moduleIndex > 0) + ffStrbufAppendF(&key, "%s (%d)", FF_DISPLAY_MODULE_NAME, moduleIndex); + else + ffStrbufAppendS(&key, FF_DISPLAY_MODULE_NAME); } else { From 291c43dd31b27d36d8330ff3921de4b12db26384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 16:55:11 +0800 Subject: [PATCH 213/493] Bios: print as `${version} (${release})` As biosRelease looks more like a version on my laptop --- src/detection/bios/bios_windows.c | 4 ++-- src/modules/bios/bios.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index e23baa9c1..8d385a1df 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -7,7 +7,7 @@ const char* ffDetectBios(FFBiosResult* bios) if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; - if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosRelease, NULL)) + if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosVersion, NULL)) return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion\" doesn't exist"; ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->biosVendor, NULL); @@ -18,7 +18,7 @@ const char* ffDetectBios(FFBiosResult* bios) ffRegReadUint(hKey, L"BiosMajorRelease", &major, NULL) && ffRegReadUint(hKey, L"BiosMinorRelease", &minor, NULL) ) - ffStrbufAppendF(&bios->biosVersion, "%u.%u", (unsigned)major, (unsigned)minor); + ffStrbufAppendF(&bios->biosRelease, "%u.%u", (unsigned)major, (unsigned)minor); return NULL; } diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 8c387f372..381f4e5b8 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -22,18 +22,18 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) goto exit; } - if(bios.biosRelease.length == 0) + if(bios.biosVersion.length == 0) { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_release is not set."); + ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set."); goto exit; } if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufWriteTo(&bios.biosRelease, stdout); - if (bios.biosVersion.length) - printf(" (%s)", bios.biosVersion.chars); + ffStrbufWriteTo(&bios.biosVersion, stdout); + if (bios.biosRelease.length) + printf(" (%s)", bios.biosRelease.chars); putchar('\n'); } else From 5394d6da8ae08290b31ea65f259762fd5576127b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 17:32:01 +0800 Subject: [PATCH 214/493] Chassis (Windows): add basic support --- CMakeLists.txt | 3 +- src/detection/chassis/chassis.c | 46 +++++++++++++++++++++++++ src/detection/chassis/chassis.h | 1 + src/detection/chassis/chassis_windows.c | 20 +++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/detection/chassis/chassis.c create mode 100644 src/detection/chassis/chassis_windows.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 96cb3784e..669233184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,7 @@ set(LIBFASTFETCH_SRC src/common/printing.c src/common/properties.c src/common/settings.c + src/detection/chassis/chassis.c src/detection/cpu/cpu.c src/detection/cpuusage/cpuusage.c src/detection/datetime/datetime.c @@ -530,7 +531,7 @@ elseif(WIN32) src/detection/bluetooth/bluetooth_windows.c src/detection/board/board_windows.c src/detection/brightness/brightness_windows.cpp - src/detection/chassis/chassis_nosupport.c + src/detection/chassis/chassis_windows.c src/detection/cpu/cpu_windows.c src/detection/cpuusage/cpuusage_windows.c src/detection/cursor/cursor_windows.c diff --git a/src/detection/chassis/chassis.c b/src/detection/chassis/chassis.c new file mode 100644 index 000000000..732df2074 --- /dev/null +++ b/src/detection/chassis/chassis.c @@ -0,0 +1,46 @@ +#include "chassis.h" + +const char* ffChassisTypeToString(uint32_t chassisType) +{ + // https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf + // 7.4.1 System Enclosure or Chassis Types + switch (chassisType) + { + case 0x01: return "Other"; + case 0x02: return "Unknown"; + case 0x03: return "Desktop"; + case 0x04: return "Low Profile Desktop"; + case 0x05: return "Pizza Box"; + case 0x06: return "Mini Tower"; + case 0x07: return "Tower"; + case 0x08: return "Portable"; + case 0x09: return "Laptop"; + case 0x0A: return "Notebook"; + case 0x0B: return "Hand Held"; + case 0x0C: return "Docking Station"; + case 0x0D: return "All in One"; + case 0x0E: return "Sub Notebook"; + case 0x0F: return "Space-saving"; + case 0x10: return "Lunch Box"; + case 0x11: return "Main Server Chassis"; + case 0x12: return "Expansion Chassis"; + case 0x13: return "SubChassis"; + case 0x14: return "Bus Expansion Chassis"; + case 0x15: return "Peripheral Chassis"; + case 0x16: return "RAID Chassis"; + case 0x17: return "Rack Mount Chassis"; + case 0x18: return "Sealed-case PC"; + case 0x19: return "Multi-system chassis"; + case 0x1A: return "Compact PCI"; + case 0x1B: return "Advanced TCA"; + case 0x1C: return "Blade"; + case 0x1E: return "Tablet"; + case 0x1F: return "Convertible"; + case 0x20: return "Detachable"; + case 0x21: return "IoT Gateway"; + case 0x22: return "Embedded PC"; + case 0x23: return "Mini PC"; + case 0x24: return "Stick PC"; + default: return NULL; + } +} diff --git a/src/detection/chassis/chassis.h b/src/detection/chassis/chassis.h index 221b066ce..b7551d38b 100644 --- a/src/detection/chassis/chassis.h +++ b/src/detection/chassis/chassis.h @@ -13,5 +13,6 @@ typedef struct FFChassisResult } FFChassisResult; const char* ffDetectChassis(FFChassisResult* result); +const char* ffChassisTypeToString(uint32_t chassisType); #endif diff --git a/src/detection/chassis/chassis_windows.c b/src/detection/chassis/chassis_windows.c new file mode 100644 index 000000000..f80d0ff28 --- /dev/null +++ b/src/detection/chassis/chassis_windows.c @@ -0,0 +1,20 @@ +#include "chassis.h" +#include "util/windows/registry.h" + +const char* ffDetectChassis(FFChassisResult* result) +{ + FF_HKEY_AUTO_DESTROY hKey = NULL; + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) // SMBIOS + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; + + uint32_t chassisType = 0; + if(!ffRegReadUint(hKey, L"EnclosureType", &chassisType, NULL)) + return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\EnclosureType\" doesn't exist"; + + const char* chassisTypeStr = ffChassisTypeToString(chassisType); + if(!chassisTypeStr) + return "Unknown chassis type"; + + ffStrbufAppendS(&result->chassisType, chassisTypeStr); + return NULL; +} From 0e4da16d9e8706df8cc971cd9b54b2d7cc2b2ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 17:44:20 +0800 Subject: [PATCH 215/493] Chassis (Linux): convert chassis type number to display string --- src/detection/chassis/chassis_linux.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index 66e30e447..c58bda3cd 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -46,5 +46,12 @@ const char* ffDetectChassis(FFChassisResult* result) getHostValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType); getHostValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor); getHostValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion); + + if(result->chassisType.length) + { + const char* chassisTypeStr = ffChassisTypeToString(ffStrbufToUInt16(&result->chassisType, 9999)); + if(chassisTypeStr) + ffStrbufSetS(&result->chassisType, chassisTypeStr); + } return NULL; } From 376cb4a1ebaae510b719afa3f58bf1dca578a6a9 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 22 Jun 2023 10:45:43 +0000 Subject: [PATCH 216/493] Global: SMBIOS related code cleanup --- CMakeLists.txt | 1 + src/detection/bios/bios_bsd.c | 15 +++++--- src/detection/bios/bios_linux.c | 40 ++++---------------- src/detection/board/board_bsd.c | 12 ++++-- src/detection/board/board_linux.c | 38 ++++--------------- src/detection/chassis/chassis_bsd.c | 5 +++ src/detection/chassis/chassis_linux.c | 38 ++++--------------- src/detection/host/host_android.c | 16 -------- src/detection/host/host_apple.c | 6 +-- src/detection/host/host_bsd.c | 11 +++--- src/detection/host/host_linux.c | 54 ++++++--------------------- src/detection/host/host_windows.c | 6 --- src/modules/host/host.c | 5 +++ src/util/smbiosHelper.c | 26 +++++++++++++ src/util/smbiosHelper.h | 15 ++++++++ 15 files changed, 110 insertions(+), 178 deletions(-) create mode 100644 src/util/smbiosHelper.c create mode 100644 src/util/smbiosHelper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 669233184..f2fb3fa78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,6 +328,7 @@ set(LIBFASTFETCH_SRC src/util/FFstrbuf.c src/util/platform/FFPlatform.c src/util/stringUtils.c + src/util/smbiosHelper.c ) if(LINUX) diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index df8c853b9..69413a5d5 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -1,12 +1,17 @@ #include "bios.h" #include "common/settings.h" +#include "util/smbiosHelper.h" -const char* ffDetectBios(FFBiosResult* bios) +const char* ffDetectBios(FFBiosResult* result) { - ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &bios->biosDate); - ffSettingsGetFreeBSDKenv("smbios.bios.revision", &bios->biosRelease); - ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &bios->biosVendor); - ffSettingsGetFreeBSDKenv("smbios.bios.version", &bios->biosVersion); + ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &result->biosDate); + ffCleanUpSmbiosValue(&result->biosDate); + ffSettingsGetFreeBSDKenv("smbios.bios.revision", &result->biosRelease); + ffCleanUpSmbiosValue(&result->biosRelease); + ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &result->biosVendor); + ffCleanUpSmbiosValue(&result->biosVendor); + ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->biosVersion); + ffCleanUpSmbiosValue(&result->biosVersion); return NULL; } diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index ae46e7c99..384cf3e2a 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -1,41 +1,17 @@ #include "bios.h" #include "common/io/io.h" +#include "util/smbiosHelper.h" #include -static bool hostValueSet(FFstrbuf* value) -{ - return - value->length > 0 && - ffStrbufStartsWithIgnCaseS(value, "To be filled") != true && - ffStrbufStartsWithIgnCaseS(value, "To be set") != true && - ffStrbufStartsWithIgnCaseS(value, "OEM") != true && - ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true && - ffStrbufIgnCaseCompS(value, "None") != 0 && - ffStrbufIgnCaseCompS(value, "System Product") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Version") != 0 && - ffStrbufIgnCaseCompS(value, "System Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Version") != 0 && - ffStrbufIgnCaseCompS(value, "Default string") != 0 && - ffStrbufIgnCaseCompS(value, "Undefined") != 0 && - ffStrbufIgnCaseCompS(value, "Not Specified") != 0 && - ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && - ffStrbufIgnCaseCompS(value, "INVALID") != 0 && - ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 && - ffStrbufIgnCaseCompS(value, "N/A") != 0 - ; -} - -static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) +static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) { ffReadFileBuffer(devicesPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffReadFileBuffer(classPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffStrbufClear(buffer); @@ -43,9 +19,9 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu const char* ffDetectBios(FFBiosResult* bios) { - getHostValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate); - getHostValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease); - getHostValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor); - getHostValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion); return NULL; } diff --git a/src/detection/board/board_bsd.c b/src/detection/board/board_bsd.c index f05811bec..6650c8b5b 100644 --- a/src/detection/board/board_bsd.c +++ b/src/detection/board/board_bsd.c @@ -1,10 +1,14 @@ #include "board.h" #include "common/settings.h" +#include "util/smbiosHelper.h" -const char* ffDetectBoard(FFBoardResult* board) +const char* ffDetectBoard(FFBoardResult* result) { - ffSettingsGetFreeBSDKenv("smbios.planar.product", &board->boardName); - ffSettingsGetFreeBSDKenv("smbios.planar.maker", &board->boardVendor); - ffSettingsGetFreeBSDKenv("smbios.planar.version", &board->boardVersion); + ffSettingsGetFreeBSDKenv("smbios.planar.product", &result->boardName); + ffCleanUpSmbiosValue(&result->boardName); + ffSettingsGetFreeBSDKenv("smbios.planar.maker", &result->boardVendor); + ffCleanUpSmbiosValue(&result->boardVendor); + ffSettingsGetFreeBSDKenv("smbios.planar.version", &result->boardVersion); + ffCleanUpSmbiosValue(&result->boardVersion); return NULL; } diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index 435087798..011a1e5a5 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -1,41 +1,17 @@ #include "board.h" #include "common/io/io.h" +#include "util/smbiosHelper.h" #include -static bool hostValueSet(FFstrbuf* value) -{ - return - value->length > 0 && - ffStrbufStartsWithIgnCaseS(value, "To be filled") != true && - ffStrbufStartsWithIgnCaseS(value, "To be set") != true && - ffStrbufStartsWithIgnCaseS(value, "OEM") != true && - ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true && - ffStrbufIgnCaseCompS(value, "None") != 0 && - ffStrbufIgnCaseCompS(value, "System Product") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Version") != 0 && - ffStrbufIgnCaseCompS(value, "System Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Version") != 0 && - ffStrbufIgnCaseCompS(value, "Default string") != 0 && - ffStrbufIgnCaseCompS(value, "Undefined") != 0 && - ffStrbufIgnCaseCompS(value, "Not Specified") != 0 && - ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && - ffStrbufIgnCaseCompS(value, "INVALID") != 0 && - ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 && - ffStrbufIgnCaseCompS(value, "N/A") != 0 - ; -} - -static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) +static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) { ffReadFileBuffer(devicesPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffReadFileBuffer(classPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffStrbufClear(buffer); @@ -43,8 +19,8 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu const char* ffDetectBoard(FFBoardResult* board) { - getHostValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->boardName); - getHostValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->boardVendor); - getHostValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->boardVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->boardName); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->boardVendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->boardVersion); return NULL; } diff --git a/src/detection/chassis/chassis_bsd.c b/src/detection/chassis/chassis_bsd.c index 9614cfd7a..91ca9f7e0 100644 --- a/src/detection/chassis/chassis_bsd.c +++ b/src/detection/chassis/chassis_bsd.c @@ -1,10 +1,15 @@ #include "chassis.h" #include "common/settings.h" +#include "util/smbiosHelper.h" const char* ffDetectChassis(FFChassisResult* result) { + // Unlike other platforms, `smbios.chassis.type` return display string directly on my machine ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->chassisType); + ffCleanUpSmbiosValue(&result->chassisType); ffSettingsGetFreeBSDKenv("smbios.chassis.maker", &result->chassisVendor); + ffCleanUpSmbiosValue(&result->chassisVendor); ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->chassisVersion); + ffCleanUpSmbiosValue(&result->chassisVersion); return NULL; } diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index c58bda3cd..82aff1189 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -1,41 +1,17 @@ #include "chassis.h" #include "common/io/io.h" +#include "util/smbiosHelper.h" #include -static bool hostValueSet(FFstrbuf* value) -{ - return - value->length > 0 && - ffStrbufStartsWithIgnCaseS(value, "To be filled") != true && - ffStrbufStartsWithIgnCaseS(value, "To be set") != true && - ffStrbufStartsWithIgnCaseS(value, "OEM") != true && - ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true && - ffStrbufIgnCaseCompS(value, "None") != 0 && - ffStrbufIgnCaseCompS(value, "System Product") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Version") != 0 && - ffStrbufIgnCaseCompS(value, "System Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Version") != 0 && - ffStrbufIgnCaseCompS(value, "Default string") != 0 && - ffStrbufIgnCaseCompS(value, "Undefined") != 0 && - ffStrbufIgnCaseCompS(value, "Not Specified") != 0 && - ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && - ffStrbufIgnCaseCompS(value, "INVALID") != 0 && - ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 && - ffStrbufIgnCaseCompS(value, "N/A") != 0 - ; -} - -static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) +static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) { ffReadFileBuffer(devicesPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffReadFileBuffer(classPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffStrbufClear(buffer); @@ -43,9 +19,9 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu const char* ffDetectChassis(FFChassisResult* result) { - getHostValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType); - getHostValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor); - getHostValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion); if(result->chassisType.length) { diff --git a/src/detection/host/host_android.c b/src/detection/host/host_android.c index 384faf736..53e18d1ea 100644 --- a/src/detection/host/host_android.c +++ b/src/detection/host/host_android.c @@ -4,15 +4,8 @@ const char* ffDetectHost(FFHostResult* host) { - //Family - - ffStrbufInit(&host->productFamily); ffSettingsGetAndroidProperty("ro.product.device", &host->productFamily); - //Name - - ffStrbufInit(&host->productName); - ffSettingsGetAndroidProperty("ro.product.brand", &host->productName); if(host->productName.length > 0) { @@ -21,18 +14,9 @@ const char* ffDetectHost(FFHostResult* host) } ffSettingsGetAndroidProperty("ro.product.model", &host->productName); - ffStrbufTrimRight(&host->productName, ' '); - //Sys vendor - - ffStrbufInit(&host->sysVendor); ffSettingsGetAndroidProperty("ro.product.manufacturer", &host->sysVendor); - //Not implemented - - ffStrbufInit(&host->productVersion); - ffStrbufInit(&host->productSku); - return NULL; } diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index d47ea8c44..a07c9d356 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -157,11 +157,7 @@ static const char* getProductName(const FFstrbuf* hwModel) const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->productName); - ffStrbufInit(&host->productFamily); - ffStrbufInit(&host->productVersion); - ffStrbufInit(&host->productSku); - ffStrbufInitS(&host->sysVendor, "Apple"); + ffStrbufAppendS(&host->sysVendor, "Apple"); const char* error = ffSysctlGetString("hw.model", &host->productFamily); if (error) return error; diff --git a/src/detection/host/host_bsd.c b/src/detection/host/host_bsd.c index dcbd5006b..9a7dcbd71 100644 --- a/src/detection/host/host_bsd.c +++ b/src/detection/host/host_bsd.c @@ -1,18 +1,19 @@ #include "host.h" #include "common/settings.h" +#include "util/smbiosHelper.h" const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->productName); - ffStrbufInit(&host->productFamily); - ffStrbufInit(&host->productVersion); - ffStrbufInit(&host->productSku); - ffStrbufInit(&host->sysVendor); ffSettingsGetFreeBSDKenv("smbios.system.product", &host->productName); + ffCleanUpSmbiosValue(&host->productName); ffSettingsGetFreeBSDKenv("smbios.system.family", &host->productFamily); + ffCleanUpSmbiosValue(&host->productFamily); ffSettingsGetFreeBSDKenv("smbios.system.version", &host->productVersion); + ffCleanUpSmbiosValue(&host->productVersion); ffSettingsGetFreeBSDKenv("smbios.system.sku", &host->productSku); + ffCleanUpSmbiosValue(&host->productSku); ffSettingsGetFreeBSDKenv("smbios.system.maker", &host->sysVendor); + ffCleanUpSmbiosValue(&host->sysVendor); return NULL; } diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index ac9e17a94..386affbcc 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -1,41 +1,18 @@ #include "host.h" #include "common/io/io.h" #include "common/processing.h" +#include "util/smbiosHelper.h" #include -static bool hostValueSet(FFstrbuf* value) -{ - return - value->length > 0 && - ffStrbufStartsWithIgnCaseS(value, "To be filled") != true && - ffStrbufStartsWithIgnCaseS(value, "To be set") != true && - ffStrbufStartsWithIgnCaseS(value, "OEM") != true && - ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true && - ffStrbufIgnCaseCompS(value, "None") != 0 && - ffStrbufIgnCaseCompS(value, "System Product") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Product Version") != 0 && - ffStrbufIgnCaseCompS(value, "System Name") != 0 && - ffStrbufIgnCaseCompS(value, "System Version") != 0 && - ffStrbufIgnCaseCompS(value, "Default string") != 0 && - ffStrbufIgnCaseCompS(value, "Undefined") != 0 && - ffStrbufIgnCaseCompS(value, "Not Specified") != 0 && - ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 && - ffStrbufIgnCaseCompS(value, "INVALID") != 0 && - ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 && - ffStrbufIgnCaseCompS(value, "All Series") != 0 - ; -} - -static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) +static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) { ffReadFileBuffer(devicesPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffReadFileBuffer(classPath, buffer); - if(hostValueSet(buffer)) + if(ffIsSmbiosValueSet(buffer)) return; ffStrbufClear(buffer); @@ -43,17 +20,17 @@ static void getHostValue(const char* devicesPath, const char* classPath, FFstrbu static void getHostProductName(FFstrbuf* name) { - getHostValue("/sys/devices/virtual/dmi/id/product_name", "/sys/class/dmi/id/product_name", name); + getSmbiosValue("/sys/devices/virtual/dmi/id/product_name", "/sys/class/dmi/id/product_name", name); if(name->length > 0) return; ffReadFileBuffer("/sys/firmware/devicetree/base/model", name); - if(hostValueSet(name)) + if(ffIsSmbiosValueSet(name)) return; //does a clear before the read ffReadFileBuffer("/tmp/sysinfo/model", name); - if(hostValueSet(name)) + if(ffIsSmbiosValueSet(name)) return; ffStrbufClear(name); @@ -61,20 +38,11 @@ static void getHostProductName(FFstrbuf* name) const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->productFamily); - getHostValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->productFamily); - - ffStrbufInit(&host->productName); + getSmbiosValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->productFamily); getHostProductName(&host->productName); - - ffStrbufInit(&host->productVersion); - getHostValue("/sys/devices/virtual/dmi/id/product_version", "/sys/class/dmi/id/product_version", &host->productVersion); - - ffStrbufInit(&host->productSku); - getHostValue("/sys/devices/virtual/dmi/id/product_sku", "/sys/class/dmi/id/product_sku", &host->productSku); - - ffStrbufInit(&host->sysVendor); - getHostValue("/sys/devices/virtual/dmi/id/sys_vendor", "/sys/class/dmi/id/sys_vendor", &host->sysVendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/product_version", "/sys/class/dmi/id/product_version", &host->productVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/product_sku", "/sys/class/dmi/id/product_sku", &host->productSku); + getSmbiosValue("/sys/devices/virtual/dmi/id/sys_vendor", "/sys/class/dmi/id/sys_vendor", &host->sysVendor); //KVM/Qemu virtual machine if(ffStrbufStartsWithS(&host->productName, "Standard PC")) diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index 1a940e1ac..9498fa5e6 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -3,12 +3,6 @@ const char* ffDetectHost(FFHostResult* host) { - ffStrbufInit(&host->productName); - ffStrbufInit(&host->productFamily); - ffStrbufInit(&host->productVersion); - ffStrbufInit(&host->productSku); - ffStrbufInit(&host->sysVendor); - FF_HKEY_AUTO_DESTROY hKey = NULL; if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) diff --git a/src/modules/host/host.c b/src/modules/host/host.c index e5dcaa8e9..a196c2cc7 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -9,6 +9,11 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) { FFHostResult host; + ffStrbufInit(&host.productFamily); + ffStrbufInit(&host.productName); + ffStrbufInit(&host.productVersion); + ffStrbufInit(&host.productSku); + ffStrbufInit(&host.sysVendor); const char* error = ffDetectHost(&host); if(error) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c new file mode 100644 index 000000000..1033ec880 --- /dev/null +++ b/src/util/smbiosHelper.c @@ -0,0 +1,26 @@ +#include "smbiosHelper.h" + +bool ffIsSmbiosValueSet(FFstrbuf* value) +{ + return + value->length > 0 && + !ffStrbufStartsWithIgnCaseS(value, "To be filled") && + !ffStrbufStartsWithIgnCaseS(value, "To be set") && + !ffStrbufStartsWithIgnCaseS(value, "OEM") && + !ffStrbufStartsWithIgnCaseS(value, "O.E.M.") && + !ffStrbufIgnCaseEqualS(value, "None") && + !ffStrbufIgnCaseEqualS(value, "System Product") && + !ffStrbufIgnCaseEqualS(value, "System Product Name") && + !ffStrbufIgnCaseEqualS(value, "System Product Version") && + !ffStrbufIgnCaseEqualS(value, "System Name") && + !ffStrbufIgnCaseEqualS(value, "System Version") && + !ffStrbufIgnCaseEqualS(value, "Default string") && + !ffStrbufIgnCaseEqualS(value, "Undefined") && + !ffStrbufIgnCaseEqualS(value, "Not Specified") && + !ffStrbufIgnCaseEqualS(value, "Not Applicable") && + !ffStrbufIgnCaseEqualS(value, "INVALID") && + !ffStrbufIgnCaseEqualS(value, "Type1ProductConfigId") && + !ffStrbufIgnCaseEqualS(value, "All Series") && + !ffStrbufIgnCaseEqualS(value, "N/A") + ; +} diff --git a/src/util/smbiosHelper.h b/src/util/smbiosHelper.h new file mode 100644 index 000000000..9be3e3120 --- /dev/null +++ b/src/util/smbiosHelper.h @@ -0,0 +1,15 @@ +#pragma once + +#ifndef FASTFETCH_INCLUDED_SMBIOSVALUEHELPER +#define FASTFETCH_INCLUDED_SMBIOSVALUEHELPER + +#include "util/FFstrbuf.h" + +bool ffIsSmbiosValueSet(FFstrbuf* value); +static inline void ffCleanUpSmbiosValue(FFstrbuf* value) +{ + if (!ffIsSmbiosValueSet(value)) + ffStrbufClear(value); +} + +#endif \ No newline at end of file From a35d1a32ea46664cc5938354d4bbfbc7b0b4226d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 19:05:13 +0800 Subject: [PATCH 217/493] Chassis: code refactor --- src/detection/chassis/chassis.c | 4 ++-- src/detection/chassis/chassis.h | 8 ++++---- src/detection/chassis/chassis_bsd.c | 12 ++++++------ src/detection/chassis/chassis_linux.c | 14 ++++++------- src/detection/chassis/chassis_windows.c | 10 +++++----- src/modules/chassis/chassis.c | 26 ++++++++++++------------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/detection/chassis/chassis.c b/src/detection/chassis/chassis.c index 732df2074..f2ebc2da1 100644 --- a/src/detection/chassis/chassis.c +++ b/src/detection/chassis/chassis.c @@ -1,10 +1,10 @@ #include "chassis.h" -const char* ffChassisTypeToString(uint32_t chassisType) +const char* ffChassisTypeToString(uint32_t type) { // https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf // 7.4.1 System Enclosure or Chassis Types - switch (chassisType) + switch (type) { case 0x01: return "Other"; case 0x02: return "Unknown"; diff --git a/src/detection/chassis/chassis.h b/src/detection/chassis/chassis.h index b7551d38b..876936c8d 100644 --- a/src/detection/chassis/chassis.h +++ b/src/detection/chassis/chassis.h @@ -7,12 +7,12 @@ typedef struct FFChassisResult { - FFstrbuf chassisType; - FFstrbuf chassisVendor; - FFstrbuf chassisVersion; + FFstrbuf type; + FFstrbuf vendor; + FFstrbuf version; } FFChassisResult; const char* ffDetectChassis(FFChassisResult* result); -const char* ffChassisTypeToString(uint32_t chassisType); +const char* ffChassisTypeToString(uint32_t type); #endif diff --git a/src/detection/chassis/chassis_bsd.c b/src/detection/chassis/chassis_bsd.c index 91ca9f7e0..c38b562c2 100644 --- a/src/detection/chassis/chassis_bsd.c +++ b/src/detection/chassis/chassis_bsd.c @@ -5,11 +5,11 @@ const char* ffDetectChassis(FFChassisResult* result) { // Unlike other platforms, `smbios.chassis.type` return display string directly on my machine - ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->chassisType); - ffCleanUpSmbiosValue(&result->chassisType); - ffSettingsGetFreeBSDKenv("smbios.chassis.maker", &result->chassisVendor); - ffCleanUpSmbiosValue(&result->chassisVendor); - ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->chassisVersion); - ffCleanUpSmbiosValue(&result->chassisVersion); + ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->type); + ffCleanUpSmbiosValue(&result->type); + ffSettingsGetFreeBSDKenv("smbios.chassis.maker", &result->vendor); + ffCleanUpSmbiosValue(&result->vendor); + ffSettingsGetFreeBSDKenv("smbios.chassis.version", &result->version); + ffCleanUpSmbiosValue(&result->version); return NULL; } diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index 82aff1189..deace35d9 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -19,15 +19,15 @@ static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstr const char* ffDetectChassis(FFChassisResult* result) { - getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType); - getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor); - getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->type); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->vendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->version); - if(result->chassisType.length) + if(result->type.length) { - const char* chassisTypeStr = ffChassisTypeToString(ffStrbufToUInt16(&result->chassisType, 9999)); - if(chassisTypeStr) - ffStrbufSetS(&result->chassisType, chassisTypeStr); + const char* typeStr = ffChassisTypeToString(ffStrbufToUInt16(&result->type, 9999)); + if(typeStr) + ffStrbufSetS(&result->type, typeStr); } return NULL; } diff --git a/src/detection/chassis/chassis_windows.c b/src/detection/chassis/chassis_windows.c index f80d0ff28..52d1337c1 100644 --- a/src/detection/chassis/chassis_windows.c +++ b/src/detection/chassis/chassis_windows.c @@ -7,14 +7,14 @@ const char* ffDetectChassis(FFChassisResult* result) if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) // SMBIOS return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; - uint32_t chassisType = 0; - if(!ffRegReadUint(hKey, L"EnclosureType", &chassisType, NULL)) + uint32_t type = 0; + if(!ffRegReadUint(hKey, L"EnclosureType", &type, NULL)) return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\EnclosureType\" doesn't exist"; - const char* chassisTypeStr = ffChassisTypeToString(chassisType); - if(!chassisTypeStr) + const char* typeStr = ffChassisTypeToString(type); + if(!typeStr) return "Unknown chassis type"; - ffStrbufAppendS(&result->chassisType, chassisTypeStr); + ffStrbufAppendS(&result->type, typeStr); return NULL; } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 66ae7f2d7..15d6ba959 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -9,9 +9,9 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) { FFChassisResult result; - ffStrbufInit(&result.chassisType); - ffStrbufInit(&result.chassisVendor); - ffStrbufInit(&result.chassisVersion); + ffStrbufInit(&result.type); + ffStrbufInit(&result.vendor); + ffStrbufInit(&result.version); const char* error = ffDetectChassis(&result); @@ -21,7 +21,7 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) goto exit; } - if(result.chassisType.length == 0) + if(result.type.length == 0) { ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); goto exit; @@ -30,24 +30,24 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufWriteTo(&result.chassisType, stdout); - if (result.chassisVersion.length) - printf(" (%s)", result.chassisVersion.chars); + ffStrbufWriteTo(&result.type, stdout); + if (result.version.length) + printf(" (%s)", result.version.chars); putchar('\n'); } else { ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisType}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, }); } exit: - ffStrbufDestroy(&result.chassisType); - ffStrbufDestroy(&result.chassisVendor); - ffStrbufDestroy(&result.chassisVersion); + ffStrbufDestroy(&result.type); + ffStrbufDestroy(&result.vendor); + ffStrbufDestroy(&result.version); } void ffInitChassisOptions(FFChassisOptions* options) From e4e5560b75b3e498ec8b585ce401845bb69c4da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 22:32:14 +0800 Subject: [PATCH 218/493] Board: code refactor --- src/detection/board/board.h | 6 +++--- src/detection/board/board_bsd.c | 12 ++++++------ src/detection/board/board_linux.c | 6 +++--- src/detection/board/board_windows.c | 6 +++--- src/modules/board/board.c | 26 +++++++++++++------------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/detection/board/board.h b/src/detection/board/board.h index f4065d103..bc232e244 100644 --- a/src/detection/board/board.h +++ b/src/detection/board/board.h @@ -7,9 +7,9 @@ typedef struct FFBoardResult { - FFstrbuf boardName; - FFstrbuf boardVendor; - FFstrbuf boardVersion; + FFstrbuf name; + FFstrbuf vendor; + FFstrbuf version; } FFBoardResult; const char* ffDetectBoard(FFBoardResult* result); diff --git a/src/detection/board/board_bsd.c b/src/detection/board/board_bsd.c index 6650c8b5b..871cf87aa 100644 --- a/src/detection/board/board_bsd.c +++ b/src/detection/board/board_bsd.c @@ -4,11 +4,11 @@ const char* ffDetectBoard(FFBoardResult* result) { - ffSettingsGetFreeBSDKenv("smbios.planar.product", &result->boardName); - ffCleanUpSmbiosValue(&result->boardName); - ffSettingsGetFreeBSDKenv("smbios.planar.maker", &result->boardVendor); - ffCleanUpSmbiosValue(&result->boardVendor); - ffSettingsGetFreeBSDKenv("smbios.planar.version", &result->boardVersion); - ffCleanUpSmbiosValue(&result->boardVersion); + ffSettingsGetFreeBSDKenv("smbios.planar.product", &result->name); + ffCleanUpSmbiosValue(&result->name); + ffSettingsGetFreeBSDKenv("smbios.planar.maker", &result->vendor); + ffCleanUpSmbiosValue(&result->vendor); + ffSettingsGetFreeBSDKenv("smbios.planar.version", &result->version); + ffCleanUpSmbiosValue(&result->version); return NULL; } diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index 011a1e5a5..a4d1225b7 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -19,8 +19,8 @@ static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstr const char* ffDetectBoard(FFBoardResult* board) { - getSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->boardName); - getSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->boardVendor); - getSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->boardVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->name); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->vendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->version); return NULL; } diff --git a/src/detection/board/board_windows.c b/src/detection/board/board_windows.c index a027fb883..16db05161 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -8,11 +8,11 @@ const char* ffDetectBoard(FFBoardResult* board) if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\") failed"; - if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->boardName, NULL)) + if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->name, NULL)) return "ffRegReadStrbuf(hKey, L\"BaseBoardProduct\") failed"; - ffRegReadStrbuf(hKey, L"BaseBoardManufacturer", &board->boardVendor, NULL); - ffRegReadStrbuf(hKey, L"BaseBoardVersion", &board->boardVersion, NULL); + ffRegReadStrbuf(hKey, L"BaseBoardManufacturer", &board->vendor, NULL); + ffRegReadStrbuf(hKey, L"BaseBoardVersion", &board->version, NULL); return NULL; } diff --git a/src/modules/board/board.c b/src/modules/board/board.c index fe72f5b7d..68802c28e 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -9,9 +9,9 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) { FFBoardResult result; - ffStrbufInit(&result.boardName); - ffStrbufInit(&result.boardVendor); - ffStrbufInit(&result.boardVersion); + ffStrbufInit(&result.name); + ffStrbufInit(&result.vendor); + ffStrbufInit(&result.version); const char* error = ffDetectBoard(&result); if(error) @@ -20,7 +20,7 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) goto exit; } - if(result.boardName.length == 0) + if(result.name.length == 0) { ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set."); goto exit; @@ -29,24 +29,24 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufWriteTo(&result.boardName, stdout); - if (result.boardVersion.length) - printf(" (%s)", result.boardVersion.chars); + ffStrbufWriteTo(&result.name, stdout); + if (result.version.length) + printf(" (%s)", result.version.chars); putchar('\n'); } else { ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, }); } exit: - ffStrbufDestroy(&result.boardName); - ffStrbufDestroy(&result.boardVendor); - ffStrbufDestroy(&result.boardVersion); + ffStrbufDestroy(&result.name); + ffStrbufDestroy(&result.vendor); + ffStrbufDestroy(&result.version); } void ffInitBoardOptions(FFBoardOptions* options) From 466477429d0d0a48823d311b49d0f118047f4a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 22 Jun 2023 22:35:09 +0800 Subject: [PATCH 219/493] Bios: code refactor --- src/detection/bios/bios.h | 6 +++--- src/detection/bios/bios_apple.c | 16 ++++++++-------- src/detection/bios/bios_bsd.c | 12 ++++++------ src/detection/bios/bios_linux.c | 6 +++--- src/detection/bios/bios_windows.c | 6 +++--- src/modules/bios/bios.c | 22 +++++++++++----------- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/detection/bios/bios.h b/src/detection/bios/bios.h index 039918a56..423ef3798 100644 --- a/src/detection/bios/bios.h +++ b/src/detection/bios/bios.h @@ -7,10 +7,10 @@ typedef struct FFBiosResult { - FFstrbuf biosDate; + FFstrbuf date; FFstrbuf biosRelease; - FFstrbuf biosVendor; - FFstrbuf biosVersion; + FFstrbuf vendor; + FFstrbuf version; } FFBiosResult; const char* ffDetectBios(FFBiosResult* bios); diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index b8be5c15e..5983a60d1 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -20,12 +20,12 @@ const char* ffDetectBios(FFBiosResult* bios) return "IORegistryEntryCreateCFProperties(registryEntry) failed"; } - ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor); - ffCfDictGetString(properties, CFSTR("version"), &bios->biosVersion); - ffCfDictGetString(properties, CFSTR("release-date"), &bios->biosDate); - if(!ffStrbufContainC(&bios->biosDate, '-')) + ffCfDictGetString(properties, CFSTR("vendor"), &bios->vendor); + ffCfDictGetString(properties, CFSTR("version"), &bios->version); + ffCfDictGetString(properties, CFSTR("release-date"), &bios->date); + if(!ffStrbufContainC(&bios->date, '-')) ffStrbufAppendS(&bios->biosRelease, "Efi-"); - ffStrbufAppend(&bios->biosRelease, &bios->biosVersion); + ffStrbufAppend(&bios->biosRelease, &bios->version); CFRelease(properties); IOObjectRelease(registryEntry); @@ -40,7 +40,7 @@ const char* ffDetectBios(FFBiosResult* bios) CFMutableDictionaryRef properties; if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess) { - ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->biosVendor); + ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->vendor); CFRelease(properties); } IOObjectRelease(registryEntry); @@ -53,8 +53,8 @@ const char* ffDetectBios(FFBiosResult* bios) if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess) { ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease); - ffStrbufAppend(&bios->biosVersion, &bios->biosRelease); - ffStrbufSubstrAfterFirstC(&bios->biosVersion, '-'); + ffStrbufAppend(&bios->version, &bios->biosRelease); + ffStrbufSubstrAfterFirstC(&bios->version, '-'); CFRelease(properties); } IOObjectRelease(registryEntry); diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 69413a5d5..4d8f61002 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -5,13 +5,13 @@ const char* ffDetectBios(FFBiosResult* result) { - ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &result->biosDate); - ffCleanUpSmbiosValue(&result->biosDate); + ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &result->date); + ffCleanUpSmbiosValue(&result->date); ffSettingsGetFreeBSDKenv("smbios.bios.revision", &result->biosRelease); ffCleanUpSmbiosValue(&result->biosRelease); - ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &result->biosVendor); - ffCleanUpSmbiosValue(&result->biosVendor); - ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->biosVersion); - ffCleanUpSmbiosValue(&result->biosVersion); + ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &result->vendor); + ffCleanUpSmbiosValue(&result->vendor); + ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->version); + ffCleanUpSmbiosValue(&result->version); return NULL; } diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index 384cf3e2a..bf8427bae 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -19,9 +19,9 @@ static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstr const char* ffDetectBios(FFBiosResult* bios) { - getSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->date); getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease); - getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor); - getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->vendor); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->version); return NULL; } diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 8d385a1df..b154b290d 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -7,11 +7,11 @@ const char* ffDetectBios(FFBiosResult* bios) if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; - if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosVersion, NULL)) + if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->version, NULL)) return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion\" doesn't exist"; - ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->biosVendor, NULL); - ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->biosDate, NULL); + ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->vendor, NULL); + ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->date, NULL); uint32_t major, minor; if( diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 381f4e5b8..f24b0ee98 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -9,10 +9,10 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) { FFBiosResult bios; - ffStrbufInit(&bios.biosDate); + ffStrbufInit(&bios.date); ffStrbufInit(&bios.biosRelease); - ffStrbufInit(&bios.biosVendor); - ffStrbufInit(&bios.biosVersion); + ffStrbufInit(&bios.vendor); + ffStrbufInit(&bios.version); const char* error = ffDetectBios(&bios); @@ -22,7 +22,7 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) goto exit; } - if(bios.biosVersion.length == 0) + if(bios.version.length == 0) { ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set."); goto exit; @@ -31,7 +31,7 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufWriteTo(&bios.biosVersion, stdout); + ffStrbufWriteTo(&bios.version, stdout); if (bios.biosRelease.length) printf(" (%s)", bios.biosRelease.chars); putchar('\n'); @@ -39,18 +39,18 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) else { ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosDate}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.date}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosRelease}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosVendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.version}, }); } exit: - ffStrbufDestroy(&bios.biosDate); + ffStrbufDestroy(&bios.date); ffStrbufDestroy(&bios.biosRelease); - ffStrbufDestroy(&bios.biosVendor); - ffStrbufDestroy(&bios.biosVersion); + ffStrbufDestroy(&bios.vendor); + ffStrbufDestroy(&bios.version); } void ffInitBiosOptions(FFBiosOptions* options) From fc587ecffa78e51a238f5d6ecda2ccafa6f510a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 23 Jun 2023 11:41:22 +0800 Subject: [PATCH 220/493] Chassis (Windows): add `detectWithWmi` to detect chassis version and chassis vendor --- CMakeLists.txt | 9 +- src/detection/chassis/chassis_windows.c | 20 ---- src/detection/chassis/chassis_windows.cpp | 56 +++++++++++ src/util/windows/wmi.cpp | 24 ++--- src/util/windows/wmi.hpp | 114 ++++++++++++++++++++++ 5 files changed, 183 insertions(+), 40 deletions(-) delete mode 100644 src/detection/chassis/chassis_windows.c create mode 100644 src/detection/chassis/chassis_windows.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f2fb3fa78..426a07cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,6 @@ elseif(NOT APPLE AND NOT WIN32) message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") endif() -if(WIN32) - enable_language(CXX) -endif() - ############################# # Compile time dependencies # ############################# @@ -112,7 +108,8 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration") if(WIN32) - set(CMAKE_CXX_STANDARD 11) + enable_language(CXX) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1") endif() @@ -532,7 +529,7 @@ elseif(WIN32) src/detection/bluetooth/bluetooth_windows.c src/detection/board/board_windows.c src/detection/brightness/brightness_windows.cpp - src/detection/chassis/chassis_windows.c + src/detection/chassis/chassis_windows.cpp src/detection/cpu/cpu_windows.c src/detection/cpuusage/cpuusage_windows.c src/detection/cursor/cursor_windows.c diff --git a/src/detection/chassis/chassis_windows.c b/src/detection/chassis/chassis_windows.c deleted file mode 100644 index 52d1337c1..000000000 --- a/src/detection/chassis/chassis_windows.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "chassis.h" -#include "util/windows/registry.h" - -const char* ffDetectChassis(FFChassisResult* result) -{ - FF_HKEY_AUTO_DESTROY hKey = NULL; - if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) // SMBIOS - return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; - - uint32_t type = 0; - if(!ffRegReadUint(hKey, L"EnclosureType", &type, NULL)) - return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\EnclosureType\" doesn't exist"; - - const char* typeStr = ffChassisTypeToString(type); - if(!typeStr) - return "Unknown chassis type"; - - ffStrbufAppendS(&result->type, typeStr); - return NULL; -} diff --git a/src/detection/chassis/chassis_windows.cpp b/src/detection/chassis/chassis_windows.cpp new file mode 100644 index 000000000..3264381c0 --- /dev/null +++ b/src/detection/chassis/chassis_windows.cpp @@ -0,0 +1,56 @@ +extern "C" { +#include "chassis.h" +#include "util/windows/registry.h" +} +#include "util/windows/wmi.hpp" + +static const char* detectWithRegistry(FFChassisResult* result) +{ + FF_HKEY_AUTO_DESTROY hKey = NULL; + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL)) // SMBIOS + return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; + + uint32_t type = 0; + if(!ffRegReadUint(hKey, L"EnclosureType", &type, NULL)) + return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\EnclosureType\" doesn't exist"; + + const char* typeStr = ffChassisTypeToString(type); + if(!typeStr) + return "Unknown chassis type"; + + ffStrbufAppendS(&result->type, typeStr); + return NULL; +} + +FF_MAYBE_UNUSED static const char* detectWithWmi(FFChassisResult* result) +{ + FFWmiQuery query(L"SELECT Version, ChassisTypes, Manufacturer FROM Win32_SystemEnclosure"); + if (!query) + return "Query WMI service failed"; + + if (FFWmiRecord record = query.next()) + { + FFWmiVariant vtProp; + if(FAILED(record.obj->Get(L"ChassisTypes", 0, &vtProp, nullptr, nullptr))) + return "Get ChassisTypes failed"; + + auto [arr, len] = (std::pair) vtProp; + + if(len == 0) + return "ChassisTypes contain no data failed"; + + ffStrbufAppendS(&result->type, ffChassisTypeToString((uint32_t) *arr)); + + record.getString(L"Version", &result->version); + record.getString(L"Manufacturer", &result->vendor); + return NULL; + } + return "No WMI result returned"; +} + +extern "C" +const char* ffDetectChassis(FFChassisResult* result) +{ + return detectWithRegistry(result); + // TODO: if (instance->config.allowSlowOperations) detectWithWmi(result); +} diff --git a/src/util/windows/wmi.cpp b/src/util/windows/wmi.cpp index b8e576fd5..f1e2e10a1 100644 --- a/src/util/windows/wmi.cpp +++ b/src/util/windows/wmi.cpp @@ -1,6 +1,10 @@ #include "wmi.hpp" #include "util/windows/com.hpp" +extern "C" { +#include "util/windows/unicode.h" +} + #include #include #include @@ -144,8 +148,7 @@ bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) { bool result = true; - VARIANT vtProp; - VariantInit(&vtProp); + FFWmiVariant vtProp; CIMTYPE type; if(FAILED(obj->Get(key, 0, &vtProp, &type, nullptr)) || vtProp.vt != VT_BSTR) @@ -180,13 +183,12 @@ bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) ffStrbufAppendS(strbuf, vtProp.pcVal); break; - case VT_LPWSTR: // TODO + case VT_LPWSTR: default: - result = false; + ffStrbufSetWS(strbuf, vtProp.bstrVal); break; } } - VariantClear(&vtProp); return result; } @@ -194,8 +196,7 @@ bool FFWmiRecord::getSigned(const wchar_t* key, int64_t* integer) { bool result = true; - VARIANT vtProp; - VariantInit(&vtProp); + FFWmiVariant vtProp; CIMTYPE type; if(FAILED(obj->Get(key, 0, &vtProp, &type, nullptr))) @@ -221,7 +222,6 @@ bool FFWmiRecord::getSigned(const wchar_t* key, int64_t* integer) default: *integer = 0; result = false; } } - VariantClear(&vtProp); return result; } @@ -229,8 +229,7 @@ bool FFWmiRecord::getUnsigned(const wchar_t* key, uint64_t* integer) { bool result = true; - VARIANT vtProp; - VariantInit(&vtProp); + FFWmiVariant vtProp; if(FAILED(obj->Get(key, 0, &vtProp, nullptr, nullptr))) { @@ -255,7 +254,6 @@ bool FFWmiRecord::getUnsigned(const wchar_t* key, uint64_t* integer) default: *integer = 0; result = false; } } - VariantClear(&vtProp); return result; } @@ -263,8 +261,7 @@ bool FFWmiRecord::getReal(const wchar_t* key, double* real) { bool result = true; - VARIANT vtProp; - VariantInit(&vtProp); + FFWmiVariant vtProp; if(FAILED(obj->Get(key, 0, &vtProp, nullptr, nullptr))) { @@ -291,6 +288,5 @@ bool FFWmiRecord::getReal(const wchar_t* key, double* real) default: *real = NAN; result = false; } } - VariantClear(&vtProp); return result; } diff --git a/src/util/windows/wmi.hpp b/src/util/windows/wmi.hpp index 32ce0bcb4..d5a08f62e 100644 --- a/src/util/windows/wmi.hpp +++ b/src/util/windows/wmi.hpp @@ -11,6 +11,9 @@ extern "C" { #include #include +#include +#include +#include enum class FFWmiNamespace { CIMV2, @@ -74,6 +77,117 @@ struct FFWmiQuery } }; +struct FFWmiVariant: VARIANT { + explicit FFWmiVariant() { VariantInit(this); } + ~FFWmiVariant() { VariantClear(this); } + + FFWmiVariant(const FFWmiVariant&) = delete; + + // boolean + explicit operator bool() { + assert(this->vt == VT_BOOL); + return this->boolVal != VARIANT_FALSE; + } + + // signed + explicit operator int8_t() { + assert(this->vt == VT_I1); + return this->cVal; + } + explicit operator int16_t() { + assert(vt == VT_I2); + return this->iVal; + } + explicit operator int32_t() { + assert(this->vt == VT_I4 || vt == VT_INT); + return this->intVal; + } + explicit operator int64_t() { + assert(this->vt == VT_I8); + return this->llVal; + } + + // unsigned + explicit operator uint8_t() { + assert(this->vt == VT_I1); + return this->bVal; + } + explicit operator uint16_t() { + assert(this->vt == VT_I2); + return this->uiVal; + } + explicit operator uint32_t() { + assert(this->vt == VT_UI4 || vt == VT_UINT); + return this->uintVal; + } + explicit operator uint64_t() { + assert(this->vt == VT_UI8); + return this->ullVal; + } + explicit operator float() { + assert(this->vt == VT_R4); + return this->fltVal; + } + explicit operator double() { + assert(this->vt == VT_R8); + return this->dblVal; + } + + // string + explicit operator const std::string_view() { + assert(this->vt == VT_LPSTR); + return this->pcVal; + } + explicit operator const std::wstring_view() { + assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR); + return this->bstrVal; + } + + // array signed + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I1); + return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I2); + return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I4); + return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I8); + return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims); + } + + // array unsigned + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI1); + return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI2); + return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI4); + return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims); + } + explicit operator std::pair() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI8); + return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims); + } +}; + #else // Win32 COM headers requires C++ compiler #error Must be included in C++ source file From 20f8b8558dd9f7f7e25b88089fef0f26d1881af5 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 23 Jun 2023 05:34:23 +0000 Subject: [PATCH 221/493] DisplayServer (Wayland): warn if some properties of wl_output_listener are not supported --- src/detection/displayserver/linux/wayland.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index a6864c397..019a84ae2 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -127,18 +127,26 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist #ifdef WL_OUTPUT_DONE_SINCE_VERSION .done = (void*) stubListener, + #else + #warning wl_output_listener::done is not supported #endif #ifdef WL_OUTPUT_SCALE_SINCE_VERSION .scale = waylandOutputScaleListener, + #else + #warning wl_output_listener::scale is not supported #endif #ifdef WL_OUTPUT_NAME_SINCE_VERSION .name = waylandOutputNameListener, + #else + #warning wl_output_listener::name is not supported #endif #ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION .description = (void*) stubListener, + #else + #warning wl_output_listener::description is not supported #endif }; From cff95e66be47563f34db1f482e02e91ec014119d Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 23 Jun 2023 06:07:22 +0000 Subject: [PATCH 222/493] DisplayServer: dirty hack for #477 --- src/detection/displayserver/linux/wayland.c | 45 +++++++-------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 019a84ae2..5ab460efd 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -10,6 +10,7 @@ #include "common/thread.h" #include #include +#include typedef struct WaylandData { @@ -70,13 +71,11 @@ static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_outp display->refreshRate = refreshRate; } -#ifdef WL_OUTPUT_SCALE_SINCE_VERSION static void waylandOutputScaleListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, int32_t scale) { WaylandDisplay* display = data; display->scale = scale; } -#endif static void waylandOutputGeometryListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, @@ -93,7 +92,6 @@ static void waylandOutputGeometryListener(void *data, display->transform = (enum wl_output_transform) transform; } -#ifdef WL_OUTPUT_NAME_SINCE_VERSION static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name) { WaylandDisplay* display = data; @@ -103,7 +101,6 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp display->type = FF_DISPLAY_TYPE_EXTERNAL; ffStrbufAppendS(&display->name, name); } -#endif static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { @@ -121,34 +118,20 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist }; ffStrbufInit(&display.name); - struct wl_output_listener outputListener = { - .mode = waylandOutputModeListener, - .geometry = waylandOutputGeometryListener, - - #ifdef WL_OUTPUT_DONE_SINCE_VERSION - .done = (void*) stubListener, - #else - #warning wl_output_listener::done is not supported - #endif - - #ifdef WL_OUTPUT_SCALE_SINCE_VERSION - .scale = waylandOutputScaleListener, - #else - #warning wl_output_listener::scale is not supported - #endif - - #ifdef WL_OUTPUT_NAME_SINCE_VERSION - .name = waylandOutputNameListener, - #else - #warning wl_output_listener::name is not supported - #endif - - #ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION - .description = (void*) stubListener, - #else - #warning wl_output_listener::description is not supported - #endif + // Dirty hack for #477 + // The order of these callbacks MUST follow `struct wl_output_listener` + void* outputListener[] = { + waylandOutputGeometryListener, // geometry + waylandOutputModeListener, // mode + stubListener, // done + waylandOutputScaleListener, // scale + waylandOutputNameListener, // name + stubListener, // description }; + static_assert( + sizeof(outputListener) >= sizeof(struct wl_output_listener), + "sizeof(outputListener) is too small. Please report it to fastfetch github issue" + ); wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &outputListener, &display); wldata->ffwl_display_roundtrip(wldata->display); From 6b96ad4b71dc07a6ee21d3c780c4c71d1b4237e1 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 23 Jun 2023 07:16:19 +0000 Subject: [PATCH 223/493] Doc: update issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6835a92b1..0c595ee2e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,9 +8,13 @@ assignees: '' --- # General description of bug: - -[ ] The issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/) +* What happened: +* What should happen: +* Did it work in an older version: +* Where did you get the binary: + +- [ ] The issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/) # Often helpful information: From 48b01c96652754125f6cb1d0a3f61244cd06ec91 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Sat, 24 Jun 2023 10:07:43 +0200 Subject: [PATCH 224/493] Don't catch polkit-gnome and gnome-keyring Fixes #480 --- src/detection/displayserver/linux/wmde.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index d95ef83cc..aa9c2c112 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -284,9 +284,13 @@ static void applyPrettyNameIfDE(const FFinstance* instance, FFDisplayServerResul { if(!ffStrSet(name)) return; - else if(strcasestr(name, "plasma") != NULL || strcasestr(name, "kde") != NULL) + else if(strcasestr(name, "plasma") != NULL) getKDE(instance, result); - else if(strcasestr(name, "gnome") != NULL) + else if( + strcasecmp(name, "polkit-gnome") != 0 && + strcasecmp(name, "gnome-keyring") != 0 && + strcasestr(name, "gnome") != NULL + ) getGnome(instance, result); else if(strcasestr(name, "cinnamon") != NULL) getCinnamon(instance, result); From d0f093c5670fed8a4d33b669b53e050910500a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 10:59:53 +0800 Subject: [PATCH 225/493] Global: make `FFinstance instance` a global variable As discussed in https://github.com/fastfetch-cli/fastfetch/discussions/473 --- src/common/bar.c | 18 +- src/common/bar.h | 4 +- src/common/dbus.c | 12 +- src/common/dbus.h | 2 +- src/common/init.c | 418 +++++++++--------- src/common/jsonconfig.c | 148 +++---- src/common/jsonconfig.h | 8 +- src/common/printing.c | 40 +- src/common/printing.h | 10 +- src/common/properties.c | 4 +- src/common/properties.h | 22 +- src/common/settings.c | 62 +-- src/common/settings.h | 12 +- src/common/thread.h | 2 + src/detection/battery/battery.h | 2 +- src/detection/battery/battery_android.c | 2 +- src/detection/battery/battery_apple.c | 4 +- src/detection/battery/battery_bsd.c | 2 +- src/detection/battery/battery_linux.c | 2 +- src/detection/battery/battery_nosupport.c | 4 +- src/detection/battery/battery_windows.c | 4 +- src/detection/bluetooth/bluetooth.h | 2 +- src/detection/bluetooth/bluetooth_apple.m | 2 +- src/detection/bluetooth/bluetooth_linux.c | 9 +- src/detection/bluetooth/bluetooth_nosupport.c | 2 +- src/detection/bluetooth/bluetooth_windows.c | 2 +- src/detection/chassis/chassis_windows.cpp | 2 +- src/detection/cpu/cpu.c | 6 +- src/detection/cpu/cpu.h | 2 +- src/detection/cpu/cpu_apple.c | 2 +- src/detection/cpu/cpu_bsd.c | 2 +- src/detection/cpu/cpu_linux.c | 2 +- src/detection/cpu/cpu_windows.c | 2 +- src/detection/cpuusage/cpuusage.c | 2 +- src/detection/cursor/cursor.h | 2 +- src/detection/cursor/cursor_apple.m | 4 +- src/detection/cursor/cursor_linux.c | 37 +- src/detection/cursor/cursor_nosupport.c | 3 +- src/detection/cursor/cursor_windows.c | 4 +- src/detection/datetime/datetime.c | 4 +- src/detection/datetime/datetime.h | 2 +- src/detection/displayserver/displayserver.c | 6 +- src/detection/displayserver/displayserver.h | 2 +- .../displayserver/displayserver_apple.c | 6 +- .../displayserver/displayserver_nosupport.c | 4 +- .../displayserver/displayserver_windows.c | 4 +- .../displayserver/linux/displayserver_linux.c | 14 +- .../displayserver/linux/displayserver_linux.h | 12 +- src/detection/displayserver/linux/wayland.c | 10 +- src/detection/displayserver/linux/wmde.c | 76 ++-- src/detection/displayserver/linux/xcb.c | 16 +- src/detection/displayserver/linux/xlib.c | 16 +- src/detection/font/font.c | 6 +- src/detection/font/font.h | 2 +- src/detection/font/font_apple.m | 2 +- src/detection/font/font_linux.c | 12 +- src/detection/font/font_nosupport.c | 4 +- src/detection/font/font_windows.c | 2 +- src/detection/gamepad/gamepad.h | 2 +- src/detection/gamepad/gamepad_apple.c | 2 +- src/detection/gamepad/gamepad_bsd.c | 2 +- src/detection/gamepad/gamepad_linux.c | 2 +- src/detection/gamepad/gamepad_nosupport.c | 2 +- src/detection/gamepad/gamepad_windows.c | 2 +- src/detection/gpu/gpu.c | 6 +- src/detection/gpu/gpu.h | 4 +- src/detection/gpu/gpu_apple.c | 2 +- src/detection/gpu/gpu_linux.c | 24 +- src/detection/gpu/gpu_nosupport.c | 4 +- src/detection/gpu/gpu_windows.c | 2 +- src/detection/gtk_qt/gtk.c | 68 +-- src/detection/gtk_qt/gtk_qt.h | 8 +- src/detection/gtk_qt/qt.c | 18 +- src/detection/icons/icons.h | 2 +- src/detection/icons/icons_linux.c | 12 +- src/detection/icons/icons_nosupport.c | 2 +- src/detection/icons/icons_windows.c | 2 +- src/detection/media/media.c | 6 +- src/detection/media/media.h | 2 +- src/detection/media/media_apple.m | 2 +- src/detection/media/media_linux.c | 13 +- src/detection/media/media_nosupport.c | 3 +- src/detection/opencl/opencl.c | 8 +- src/detection/opencl/opencl.h | 2 +- src/detection/opengl/opengl.h | 2 +- src/detection/opengl/opengl_apple.c | 4 +- src/detection/opengl/opengl_linux.c | 32 +- src/detection/opengl/opengl_windows.c | 4 +- src/detection/os/os.c | 6 +- src/detection/os/os.h | 2 +- src/detection/os/os_android.c | 4 +- src/detection/os/os_apple.m | 4 +- src/detection/os/os_linux.c | 12 +- src/detection/os/os_windows.cpp | 4 +- src/detection/packages/packages.c | 6 +- src/detection/packages/packages.h | 2 +- src/detection/packages/packages_apple.c | 3 +- src/detection/packages/packages_linux.c | 34 +- src/detection/packages/packages_windows.c | 16 +- src/detection/poweradapter/poweradapter.h | 2 +- .../poweradapter/poweradapter_apple.c | 4 +- .../poweradapter/poweradapter_nosupport.c | 4 +- src/detection/sound/sound.h | 2 +- src/detection/sound/sound_apple.c | 2 +- src/detection/sound/sound_linux.c | 10 +- src/detection/sound/sound_nosupport.c | 2 +- src/detection/sound/sound_windows.cpp | 2 +- src/detection/temps/temps_linux.c | 2 +- src/detection/terminalfont/terminalfont.c | 44 +- src/detection/terminalfont/terminalfont.h | 2 +- .../terminalfont/terminalfont_android.c | 8 +- .../terminalfont/terminalfont_apple.m | 14 +- .../terminalfont/terminalfont_linux.c | 68 +-- .../terminalfont/terminalfont_windows.c | 22 +- src/detection/terminalshell/terminalshell.h | 2 +- .../terminalshell/terminalshell_linux.c | 10 +- .../terminalshell/terminalshell_windows.c | 16 +- src/detection/theme/theme.h | 2 +- src/detection/theme/theme_linux.c | 12 +- src/detection/theme/theme_nosupport.c | 2 +- src/detection/vulkan/vulkan.c | 11 +- src/detection/vulkan/vulkan.h | 2 +- src/detection/wallpaper/wallpaper.h | 2 +- src/detection/wallpaper/wallpaper_apple.c | 6 +- src/detection/wallpaper/wallpaper_linux.c | 6 +- src/detection/wallpaper/wallpaper_nosupport.c | 2 +- src/detection/wallpaper/wallpaper_windows.c | 2 +- src/detection/wifi/wifi.h | 2 +- src/detection/wifi/wifi_android.c | 2 +- src/detection/wifi/wifi_apple.m | 4 +- src/detection/wifi/wifi_bsd.c | 2 +- src/detection/wifi/wifi_linux.c | 14 +- src/detection/wifi/wifi_windows.c | 2 +- src/detection/wmtheme/wmtheme.h | 2 +- src/detection/wmtheme/wmtheme_apple.m | 4 +- src/detection/wmtheme/wmtheme_linux.c | 54 +-- src/detection/wmtheme/wmtheme_nosupport.c | 3 +- src/detection/wmtheme/wmtheme_windows.c | 2 +- src/fastfetch.c | 407 +++++++++-------- src/fastfetch.h | 17 +- src/flashfetch.c | 114 +++-- src/logo/builtin.c | 176 ++++---- src/logo/image/im6.c | 6 +- src/logo/image/im7.c | 6 +- src/logo/image/image.c | 168 +++---- src/logo/image/image.h | 6 +- src/logo/logo.c | 192 ++++---- src/logo/logo.h | 6 +- src/logo/option.c | 6 +- src/modules/battery/battery.c | 38 +- src/modules/battery/battery.h | 4 +- src/modules/bios/bios.c | 16 +- src/modules/bios/bios.h | 4 +- src/modules/bluetooth/bluetooth.c | 22 +- src/modules/bluetooth/bluetooth.h | 4 +- src/modules/board/board.c | 16 +- src/modules/board/board.h | 4 +- src/modules/break/break.c | 8 +- src/modules/break/break.h | 4 +- src/modules/brightness/brightness.c | 24 +- src/modules/brightness/brightness.h | 4 +- src/modules/chassis/chassis.c | 16 +- src/modules/chassis/chassis.h | 4 +- src/modules/colors/colors.c | 16 +- src/modules/colors/colors.h | 4 +- src/modules/command/command.c | 14 +- src/modules/command/command.h | 4 +- src/modules/cpu/cpu.c | 18 +- src/modules/cpu/cpu.h | 4 +- src/modules/cpuusage/cpuusage.c | 22 +- src/modules/cpuusage/cpuusage.h | 4 +- src/modules/cursor/cursor.c | 16 +- src/modules/cursor/cursor.h | 4 +- src/modules/custom/custom.c | 12 +- src/modules/custom/custom.h | 4 +- src/modules/datetime/datetime.c | 20 +- src/modules/datetime/datetime.h | 4 +- src/modules/de/de.c | 16 +- src/modules/de/de.h | 4 +- src/modules/disk/disk.c | 50 +-- src/modules/disk/disk.h | 4 +- src/modules/display/display.c | 22 +- src/modules/display/display.h | 4 +- src/modules/font/font.c | 16 +- src/modules/font/font.h | 4 +- src/modules/gamepad/gamepad.c | 22 +- src/modules/gamepad/gamepad.h | 4 +- src/modules/gpu/gpu.c | 30 +- src/modules/gpu/gpu.h | 4 +- src/modules/host/host.c | 16 +- src/modules/host/host.h | 4 +- src/modules/icons/icons.c | 16 +- src/modules/icons/icons.h | 4 +- src/modules/kernel/kernel.c | 26 +- src/modules/kernel/kernel.h | 4 +- src/modules/lm/lm.c | 16 +- src/modules/lm/lm.h | 4 +- src/modules/locale/locale.c | 14 +- src/modules/locale/locale.h | 4 +- src/modules/localip/localip.c | 18 +- src/modules/localip/localip.h | 4 +- src/modules/media/media.c | 16 +- src/modules/media/media.h | 4 +- src/modules/memory/memory.c | 28 +- src/modules/memory/memory.h | 4 +- src/modules/opencl/opencl.c | 16 +- src/modules/opencl/opencl.h | 4 +- src/modules/opengl/opengl.c | 18 +- src/modules/opengl/opengl.h | 4 +- src/modules/os/os.c | 38 +- src/modules/os/os.h | 4 +- src/modules/packages/packages.c | 16 +- src/modules/packages/packages.h | 4 +- src/modules/player/player.c | 16 +- src/modules/player/player.h | 4 +- src/modules/poweradapter/poweradapter.c | 18 +- src/modules/poweradapter/poweradapter.h | 4 +- src/modules/processes/processes.c | 14 +- src/modules/processes/processes.h | 4 +- src/modules/publicip/publicip.c | 16 +- src/modules/publicip/publicip.h | 4 +- src/modules/separator/separator.c | 18 +- src/modules/separator/separator.h | 4 +- src/modules/shell/shell.c | 16 +- src/modules/shell/shell.h | 4 +- src/modules/sound/sound.c | 24 +- src/modules/sound/sound.h | 4 +- src/modules/swap/swap.c | 28 +- src/modules/swap/swap.h | 4 +- src/modules/terminal/terminal.c | 16 +- src/modules/terminal/terminal.h | 4 +- src/modules/terminalfont/terminalfont.c | 16 +- src/modules/terminalfont/terminalfont.h | 4 +- src/modules/theme/theme.c | 16 +- src/modules/theme/theme.h | 4 +- src/modules/title/title.c | 28 +- src/modules/title/title.h | 4 +- src/modules/uptime/uptime.c | 14 +- src/modules/uptime/uptime.h | 4 +- src/modules/users/users.c | 14 +- src/modules/users/users.h | 4 +- src/modules/vulkan/vulkan.c | 16 +- src/modules/vulkan/vulkan.h | 4 +- src/modules/wallpaper/wallpaper.c | 16 +- src/modules/wallpaper/wallpaper.h | 4 +- src/modules/weather/weather.c | 16 +- src/modules/weather/weather.h | 4 +- src/modules/wifi/wifi.c | 18 +- src/modules/wifi/wifi.h | 4 +- src/modules/wm/wm.c | 16 +- src/modules/wm/wm.h | 4 +- src/modules/wmtheme/wmtheme.c | 16 +- src/modules/wmtheme/wmtheme.h | 4 +- src/util/windows/com.cpp | 2 +- src/util/windows/wmi.cpp | 6 +- 255 files changed, 2020 insertions(+), 2064 deletions(-) diff --git a/src/common/bar.c b/src/common/bar.c index d4a8cf0f1..e42a07c2a 100644 --- a/src/common/bar.c +++ b/src/common/bar.c @@ -3,7 +3,7 @@ // green, yellow, red: print the color on nth (0~9) block // set its value == 10 means the color will not be printed -void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red) +void ffAppendPercentBar(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red) { assert(green <= 10 && yellow <= 10 && red <= 10); @@ -15,14 +15,14 @@ void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, percent = (uint8_t)(percent + 5) / 10; assert(percent <= 10); - if(!instance->config.pipe) + if(!instance.config.pipe) ffStrbufAppendS(buffer, "\033[97m[ "); else ffStrbufAppendS(buffer, "[ "); for (uint8_t i = 0; i < percent; ++i) { - if(!instance->config.pipe) + if(!instance.config.pipe) { if (i == green) ffStrbufAppendS(buffer, "\033[32m"); @@ -36,13 +36,13 @@ void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, if (percent < 10) { - if(!instance->config.pipe) + if(!instance.config.pipe) ffStrbufAppendS(buffer, "\033[97m"); for (uint8_t i = percent; i < 10; ++i) ffStrbufAppendS(buffer, "-"); } - if(!instance->config.pipe) + if(!instance.config.pipe) ffStrbufAppendS(buffer, "\033[97m ]" FASTFETCH_TEXT_MODIFIER_RESET); else ffStrbufAppendS(buffer, " ]"); @@ -57,16 +57,16 @@ void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, // [green, 100]: print green // [yellow, green): print yellow // [0, yellow): PRINT RED -void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses) +void ffAppendPercentNum(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses) { assert(green <= 100 && yellow <= 100); - bool colored = !!(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT); + bool colored = !!(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT); if (parentheses) ffStrbufAppendC(buffer, '('); - if (colored && !instance->config.pipe) + if (colored && !instance.config.pipe) { if(green < yellow) { @@ -89,7 +89,7 @@ void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, } ffStrbufAppendF(buffer, "%u%%", (unsigned) percent); - if (colored && !instance->config.pipe) + if (colored && !instance.config.pipe) { ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET); } diff --git a/src/common/bar.h b/src/common/bar.h index f28cbe777..d776454d4 100644 --- a/src/common/bar.h +++ b/src/common/bar.h @@ -13,7 +13,7 @@ enum FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3, }; -void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red); -void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses); +void ffAppendPercentBar(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red); +void ffAppendPercentNum(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses); #endif diff --git a/src/common/dbus.c b/src/common/dbus.c index b0f5c4ffe..968358a8d 100644 --- a/src/common/dbus.c +++ b/src/common/dbus.c @@ -5,9 +5,9 @@ #include "common/thread.h" #include "util/stringUtils.h" -static bool loadLibSymbols(const FFinstance* instance, FFDBusLibrary* lib) +static bool loadLibSymbols(FFDBusLibrary* lib) { - FF_LIBRARY_LOAD(dbus, &instance->config.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD(dbus, &instance.config.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init, false) @@ -28,7 +28,7 @@ static bool loadLibSymbols(const FFinstance* instance, FFDBusLibrary* lib) return true; } -static const FFDBusLibrary* loadLib(const FFinstance* instance) +static const FFDBusLibrary* loadLib(void) { static FFDBusLibrary lib; static bool loaded = false; @@ -40,16 +40,16 @@ static const FFDBusLibrary* loadLib(const FFinstance* instance) if(!loaded) { loaded = true; - loadSuccess = loadLibSymbols(instance, &lib); + loadSuccess = loadLibSymbols(&lib); } ffThreadMutexUnlock(&mutex); return loadSuccess ? &lib : NULL; } -const char* ffDBusLoadData(const FFinstance* instance, DBusBusType busType, FFDBusData* data) +const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data) { - data->lib = loadLib(instance); + data->lib = loadLib(); if(data->lib == NULL) return "Failed to load DBus library"; diff --git a/src/common/dbus.h b/src/common/dbus.h index 7f0fa2402..bf112e244 100644 --- a/src/common/dbus.h +++ b/src/common/dbus.h @@ -45,7 +45,7 @@ typedef struct FFDBusData DBusConnection* connection; } FFDBusData; -const char* ffDBusLoadData(const FFinstance* instance, DBusBusType busType, FFDBusData* data); //Returns an error message or NULL on success +const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data); //Returns an error message or NULL on success bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result); bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result); bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result); diff --git a/src/common/init.c b/src/common/init.c index ed522d8ff..423f0de58 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -17,6 +17,8 @@ #include "modules/modules.h" +FFinstance instance; // Global singleton + static void initState(FFstate* state) { state->logoWidth = 0; @@ -28,119 +30,119 @@ static void initState(FFstate* state) state->configDoc = NULL; } -static void defaultConfig(FFinstance* instance) +static void defaultConfig(void) { - ffInitLogoOptions(&instance->config.logo); + ffInitLogoOptions(&instance.config.logo); - ffStrbufInit(&instance->config.colorKeys); - ffStrbufInit(&instance->config.colorTitle); - ffStrbufInitS(&instance->config.keyValueSeparator, ": "); + ffStrbufInit(&instance.config.colorKeys); + ffStrbufInit(&instance.config.colorTitle); + ffStrbufInitS(&instance.config.keyValueSeparator, ": "); #if defined(__linux__) || defined(__FreeBSD__) - ffStrbufInit(&instance->config.playerName); - ffStrbufInit(&instance->config.osFile); + ffStrbufInit(&instance.config.playerName); + ffStrbufInit(&instance.config.osFile); #endif - instance->config.showErrors = false; - instance->config.recache = false; - instance->config.allowSlowOperations = false; - instance->config.pipe = !isatty(STDOUT_FILENO); - instance->config.disableLinewrap = !instance->config.pipe; - instance->config.hideCursor = !instance->config.pipe; - instance->config.escapeBedrock = true; - instance->config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; - instance->config.multithreading = true; - instance->config.stat = false; - instance->config.noBuffer = false; + instance.config.showErrors = false; + instance.config.recache = false; + instance.config.allowSlowOperations = false; + instance.config.pipe = !isatty(STDOUT_FILENO); + instance.config.disableLinewrap = !instance.config.pipe; + instance.config.hideCursor = !instance.config.pipe; + instance.config.escapeBedrock = true; + instance.config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; + instance.config.multithreading = true; + instance.config.stat = false; + instance.config.noBuffer = false; - ffInitTitleOptions(&instance->config.title); - ffInitOSOptions(&instance->config.os); - ffInitHostOptions(&instance->config.host); - ffInitBiosOptions(&instance->config.bios); - ffInitBoardOptions(&instance->config.board); - ffInitBrightnessOptions(&instance->config.brightness); - ffInitChassisOptions(&instance->config.chassis); - ffInitCommandOptions(&instance->config.command); - ffInitCustomOptions(&instance->config.custom); - ffInitKernelOptions(&instance->config.kernel); - ffInitUptimeOptions(&instance->config.uptime); - ffInitProcessesOptions(&instance->config.processes); - ffInitPackagesOptions(&instance->config.packages); - ffInitShellOptions(&instance->config.shell); - ffInitDisplayOptions(&instance->config.display); - ffInitDEOptions(&instance->config.de); - ffInitWMOptions(&instance->config.wm); - ffInitWMThemeOptions(&instance->config.wmTheme); - ffInitThemeOptions(&instance->config.theme); - ffInitIconsOptions(&instance->config.icons); - ffInitFontOptions(&instance->config.font); - ffInitCursorOptions(&instance->config.cursor); - ffInitTerminalOptions(&instance->config.terminal); - ffInitTerminalFontOptions(&instance->config.terminalFont); - ffInitCPUOptions(&instance->config.cpu); - ffInitCPUUsageOptions(&instance->config.cpuUsage); - ffInitGPUOptions(&instance->config.gpu); - ffInitMemoryOptions(&instance->config.memory); - ffInitSwapOptions(&instance->config.swap); - ffInitDiskOptions(&instance->config.disk); - ffInitBatteryOptions(&instance->config.battery); - ffInitPowerAdapterOptions(&instance->config.powerAdapter); - ffInitLMOptions(&instance->config.lm); - ffInitLocaleOptions(&instance->config.locale); - ffInitLocalIpOptions(&instance->config.localIP); - ffInitPublicIpOptions(&instance->config.publicIP); - ffInitWeatherOptions(&instance->config.weather); - ffInitWifiOptions(&instance->config.wifi); - ffInitPlayerOptions(&instance->config.player); - ffInitMediaOptions(&instance->config.media); - ffInitDateTimeOptions(&instance->config.dateTime); - ffInitVulkanOptions(&instance->config.vulkan); - ffInitWallpaperOptions(&instance->config.wallpaper); - ffInitOpenGLOptions(&instance->config.openGL); - ffInitOpenCLOptions(&instance->config.openCL); - ffInitUsersOptions(&instance->config.users); - ffInitBluetoothOptions(&instance->config.bluetooth); - ffInitSoundOptions(&instance->config.sound); - ffInitSeparatorOptions(&instance->config.separator); - ffInitGamepadOptions(&instance->config.gamepad); - ffInitColorsOptions(&instance->config.colors); + ffInitTitleOptions(&instance.config.title); + ffInitOSOptions(&instance.config.os); + ffInitHostOptions(&instance.config.host); + ffInitBiosOptions(&instance.config.bios); + ffInitBoardOptions(&instance.config.board); + ffInitBrightnessOptions(&instance.config.brightness); + ffInitChassisOptions(&instance.config.chassis); + ffInitCommandOptions(&instance.config.command); + ffInitCustomOptions(&instance.config.custom); + ffInitKernelOptions(&instance.config.kernel); + ffInitUptimeOptions(&instance.config.uptime); + ffInitProcessesOptions(&instance.config.processes); + ffInitPackagesOptions(&instance.config.packages); + ffInitShellOptions(&instance.config.shell); + ffInitDisplayOptions(&instance.config.display); + ffInitDEOptions(&instance.config.de); + ffInitWMOptions(&instance.config.wm); + ffInitWMThemeOptions(&instance.config.wmTheme); + ffInitThemeOptions(&instance.config.theme); + ffInitIconsOptions(&instance.config.icons); + ffInitFontOptions(&instance.config.font); + ffInitCursorOptions(&instance.config.cursor); + ffInitTerminalOptions(&instance.config.terminal); + ffInitTerminalFontOptions(&instance.config.terminalFont); + ffInitCPUOptions(&instance.config.cpu); + ffInitCPUUsageOptions(&instance.config.cpuUsage); + ffInitGPUOptions(&instance.config.gpu); + ffInitMemoryOptions(&instance.config.memory); + ffInitSwapOptions(&instance.config.swap); + ffInitDiskOptions(&instance.config.disk); + ffInitBatteryOptions(&instance.config.battery); + ffInitPowerAdapterOptions(&instance.config.powerAdapter); + ffInitLMOptions(&instance.config.lm); + ffInitLocaleOptions(&instance.config.locale); + ffInitLocalIpOptions(&instance.config.localIP); + ffInitPublicIpOptions(&instance.config.publicIP); + ffInitWeatherOptions(&instance.config.weather); + ffInitWifiOptions(&instance.config.wifi); + ffInitPlayerOptions(&instance.config.player); + ffInitMediaOptions(&instance.config.media); + ffInitDateTimeOptions(&instance.config.dateTime); + ffInitVulkanOptions(&instance.config.vulkan); + ffInitWallpaperOptions(&instance.config.wallpaper); + ffInitOpenGLOptions(&instance.config.openGL); + ffInitOpenCLOptions(&instance.config.openCL); + ffInitUsersOptions(&instance.config.users); + ffInitBluetoothOptions(&instance.config.bluetooth); + ffInitSoundOptions(&instance.config.sound); + ffInitSeparatorOptions(&instance.config.separator); + ffInitGamepadOptions(&instance.config.gamepad); + ffInitColorsOptions(&instance.config.colors); - ffStrbufInit(&instance->config.libPCI); - ffStrbufInit(&instance->config.libVulkan); - ffStrbufInit(&instance->config.libWayland); - ffStrbufInit(&instance->config.libXcbRandr); - ffStrbufInit(&instance->config.libXcb); - ffStrbufInit(&instance->config.libXrandr); - ffStrbufInit(&instance->config.libX11); - ffStrbufInit(&instance->config.libGIO); - ffStrbufInit(&instance->config.libDConf); - ffStrbufInit(&instance->config.libDBus); - ffStrbufInit(&instance->config.libXFConf); - ffStrbufInit(&instance->config.libSQLite3); - ffStrbufInit(&instance->config.librpm); - ffStrbufInit(&instance->config.libImageMagick); - ffStrbufInit(&instance->config.libZ); - ffStrbufInit(&instance->config.libChafa); - ffStrbufInit(&instance->config.libEGL); - ffStrbufInit(&instance->config.libGLX); - ffStrbufInit(&instance->config.libOSMesa); - ffStrbufInit(&instance->config.libOpenCL); - ffStrbufInit(&instance->config.libfreetype); - ffStrbufInit(&instance->config.libPulse); - ffStrbufInit(&instance->config.libnm); + ffStrbufInit(&instance.config.libPCI); + ffStrbufInit(&instance.config.libVulkan); + ffStrbufInit(&instance.config.libWayland); + ffStrbufInit(&instance.config.libXcbRandr); + ffStrbufInit(&instance.config.libXcb); + ffStrbufInit(&instance.config.libXrandr); + ffStrbufInit(&instance.config.libX11); + ffStrbufInit(&instance.config.libGIO); + ffStrbufInit(&instance.config.libDConf); + ffStrbufInit(&instance.config.libDBus); + ffStrbufInit(&instance.config.libXFConf); + ffStrbufInit(&instance.config.libSQLite3); + ffStrbufInit(&instance.config.librpm); + ffStrbufInit(&instance.config.libImageMagick); + ffStrbufInit(&instance.config.libZ); + ffStrbufInit(&instance.config.libChafa); + ffStrbufInit(&instance.config.libEGL); + ffStrbufInit(&instance.config.libGLX); + ffStrbufInit(&instance.config.libOSMesa); + ffStrbufInit(&instance.config.libOpenCL); + ffStrbufInit(&instance.config.libfreetype); + ffStrbufInit(&instance.config.libPulse); + ffStrbufInit(&instance.config.libnm); - instance->config.percentType = 1; + instance.config.percentType = 1; } -void ffInitInstance(FFinstance* instance) +void ffInitInstance(void) { #ifdef WIN32 //https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support setlocale(LC_ALL, ".UTF8"); #endif - initState(&instance->state); - defaultConfig(instance); + initState(&instance.state); + defaultConfig(); } #if defined(FF_HAVE_THREADS) && !(defined(__APPLE__) || defined(_WIN32) || defined(__ANDROID__)) @@ -149,19 +151,19 @@ void ffInitInstance(FFinstance* instance) #define FF_START_DETECTION_THREADS -FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*) -FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectQt, FFinstance*) -FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK2, FFinstance*) -FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK3, FFinstance*) -FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK4, FFinstance*) +FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffConnectDisplayServer) +FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectQt) +FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK2) +FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK3) +FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK4) -void startDetectionThreads(FFinstance* instance) +void startDetectionThreads(void) { - ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, instance)); - ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, instance)); - ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, instance)); - ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, instance)); - ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, instance)); + ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, NULL)); + ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, NULL)); + ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, NULL)); + ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, NULL)); + ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, NULL)); } #endif //FF_HAVE_THREADS @@ -169,7 +171,7 @@ void startDetectionThreads(FFinstance* instance) static volatile bool ffDisableLinewrap = true; static volatile bool ffHideCursor = true; -static void resetConsole() +static void resetConsole(void) { if(ffDisableLinewrap) fputs("\033[?7h", stdout); @@ -198,18 +200,18 @@ static void exitSignalHandler(int signal) } #endif -void ffStart(FFinstance* instance) +void ffStart(void) { #ifdef FF_START_DETECTION_THREADS - if(instance->config.multithreading) - startDetectionThreads(instance); + if(instance.config.multithreading) + startDetectionThreads(); #endif - ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe; - ffHideCursor = instance->config.hideCursor && !instance->config.pipe; + ffDisableLinewrap = instance.config.disableLinewrap && !instance.config.pipe; + ffHideCursor = instance.config.hideCursor && !instance.config.pipe; #ifdef _WIN32 - if (!instance->config.noBuffer) setvbuf(stdout, NULL, _IOFBF, 4096); + if (!instance.config.noBuffer) setvbuf(stdout, NULL, _IOFBF, 4096); SetConsoleCtrlHandler(consoleHandler, TRUE); HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); DWORD mode = 0; @@ -217,7 +219,7 @@ void ffStart(FFinstance* instance) SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING); SetConsoleOutputCP(CP_UTF8); #else - if (instance->config.noBuffer) setvbuf(stdout, NULL, _IONBF, 0); + if (instance.config.noBuffer) setvbuf(stdout, NULL, _IONBF, 0); struct sigaction action = { .sa_handler = exitSignalHandler }; sigaction(SIGINT, &action, NULL); sigaction(SIGTERM, &action, NULL); @@ -225,7 +227,7 @@ void ffStart(FFinstance* instance) #endif //reset everything to default before we start printing - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); if(ffHideCursor) @@ -234,121 +236,121 @@ void ffStart(FFinstance* instance) if(ffDisableLinewrap) fputs("\033[?7l", stdout); - ffLogoPrint(instance); + ffLogoPrint(); } -void ffFinish(FFinstance* instance) +void ffFinish(void) { - if(instance->config.logo.printRemaining) - ffLogoPrintRemaining(instance); + if(instance.config.logo.printRemaining) + ffLogoPrintRemaining(); resetConsole(); } -static void destroyConfig(FFinstance* instance) +static void destroyConfig(void) { - ffDestroyLogoOptions(&instance->config.logo); + ffDestroyLogoOptions(&instance.config.logo); - ffStrbufDestroy(&instance->config.colorKeys); - ffStrbufDestroy(&instance->config.colorTitle); - ffStrbufDestroy(&instance->config.keyValueSeparator); + ffStrbufDestroy(&instance.config.colorKeys); + ffStrbufDestroy(&instance.config.colorTitle); + ffStrbufDestroy(&instance.config.keyValueSeparator); #if defined(__linux__) || defined(__FreeBSD__) - ffStrbufDestroy(&instance->config.playerName); - ffStrbufDestroy(&instance->config.osFile); + ffStrbufDestroy(&instance.config.playerName); + ffStrbufDestroy(&instance.config.osFile); #endif - ffDestroyTitleOptions(&instance->config.title); - ffDestroyOSOptions(&instance->config.os); - ffDestroyHostOptions(&instance->config.host); - ffDestroyBiosOptions(&instance->config.bios); - ffDestroyBoardOptions(&instance->config.board); - ffDestroyBrightnessOptions(&instance->config.brightness); - ffDestroyChassisOptions(&instance->config.chassis); - ffDestroyCommandOptions(&instance->config.command); - ffDestroyCustomOptions(&instance->config.custom); - ffDestroyKernelOptions(&instance->config.kernel); - ffDestroyUptimeOptions(&instance->config.uptime); - ffDestroyProcessesOptions(&instance->config.processes); - ffDestroyPackagesOptions(&instance->config.packages); - ffDestroyShellOptions(&instance->config.shell); - ffDestroyDisplayOptions(&instance->config.display); - ffDestroyDEOptions(&instance->config.de); - ffDestroyWMOptions(&instance->config.wm); - ffDestroyWMThemeOptions(&instance->config.wmTheme); - ffDestroyThemeOptions(&instance->config.theme); - ffDestroyIconsOptions(&instance->config.icons); - ffDestroyFontOptions(&instance->config.font); - ffDestroyCursorOptions(&instance->config.cursor); - ffDestroyTerminalOptions(&instance->config.terminal); - ffDestroyTerminalFontOptions(&instance->config.terminalFont); - ffDestroyCPUOptions(&instance->config.cpu); - ffDestroyCPUUsageOptions(&instance->config.cpuUsage); - ffDestroyGPUOptions(&instance->config.gpu); - ffDestroyMemoryOptions(&instance->config.memory); - ffDestroySwapOptions(&instance->config.swap); - ffDestroyDiskOptions(&instance->config.disk); - ffDestroyBatteryOptions(&instance->config.battery); - ffDestroyPowerAdapterOptions(&instance->config.powerAdapter); - ffDestroyLMOptions(&instance->config.lm); - ffDestroyLocaleOptions(&instance->config.locale); - ffDestroyLocalIpOptions(&instance->config.localIP); - ffDestroyPublicIpOptions(&instance->config.publicIP); - ffDestroyWallpaperOptions(&instance->config.wallpaper); - ffDestroyWeatherOptions(&instance->config.weather); - ffDestroyWifiOptions(&instance->config.wifi); - ffDestroyPlayerOptions(&instance->config.player); - ffDestroyMediaOptions(&instance->config.media); - ffDestroyDateTimeOptions(&instance->config.dateTime); - ffDestroyVulkanOptions(&instance->config.vulkan); - ffDestroyOpenGLOptions(&instance->config.openGL); - ffDestroyOpenCLOptions(&instance->config.openCL); - ffDestroyUsersOptions(&instance->config.users); - ffDestroyBluetoothOptions(&instance->config.bluetooth); - ffDestroySeparatorOptions(&instance->config.separator); - ffDestroySoundOptions(&instance->config.sound); - ffDestroyGamepadOptions(&instance->config.gamepad); - ffDestroyColorsOptions(&instance->config.colors); + ffDestroyTitleOptions(&instance.config.title); + ffDestroyOSOptions(&instance.config.os); + ffDestroyHostOptions(&instance.config.host); + ffDestroyBiosOptions(&instance.config.bios); + ffDestroyBoardOptions(&instance.config.board); + ffDestroyBrightnessOptions(&instance.config.brightness); + ffDestroyChassisOptions(&instance.config.chassis); + ffDestroyCommandOptions(&instance.config.command); + ffDestroyCustomOptions(&instance.config.custom); + ffDestroyKernelOptions(&instance.config.kernel); + ffDestroyUptimeOptions(&instance.config.uptime); + ffDestroyProcessesOptions(&instance.config.processes); + ffDestroyPackagesOptions(&instance.config.packages); + ffDestroyShellOptions(&instance.config.shell); + ffDestroyDisplayOptions(&instance.config.display); + ffDestroyDEOptions(&instance.config.de); + ffDestroyWMOptions(&instance.config.wm); + ffDestroyWMThemeOptions(&instance.config.wmTheme); + ffDestroyThemeOptions(&instance.config.theme); + ffDestroyIconsOptions(&instance.config.icons); + ffDestroyFontOptions(&instance.config.font); + ffDestroyCursorOptions(&instance.config.cursor); + ffDestroyTerminalOptions(&instance.config.terminal); + ffDestroyTerminalFontOptions(&instance.config.terminalFont); + ffDestroyCPUOptions(&instance.config.cpu); + ffDestroyCPUUsageOptions(&instance.config.cpuUsage); + ffDestroyGPUOptions(&instance.config.gpu); + ffDestroyMemoryOptions(&instance.config.memory); + ffDestroySwapOptions(&instance.config.swap); + ffDestroyDiskOptions(&instance.config.disk); + ffDestroyBatteryOptions(&instance.config.battery); + ffDestroyPowerAdapterOptions(&instance.config.powerAdapter); + ffDestroyLMOptions(&instance.config.lm); + ffDestroyLocaleOptions(&instance.config.locale); + ffDestroyLocalIpOptions(&instance.config.localIP); + ffDestroyPublicIpOptions(&instance.config.publicIP); + ffDestroyWallpaperOptions(&instance.config.wallpaper); + ffDestroyWeatherOptions(&instance.config.weather); + ffDestroyWifiOptions(&instance.config.wifi); + ffDestroyPlayerOptions(&instance.config.player); + ffDestroyMediaOptions(&instance.config.media); + ffDestroyDateTimeOptions(&instance.config.dateTime); + ffDestroyVulkanOptions(&instance.config.vulkan); + ffDestroyOpenGLOptions(&instance.config.openGL); + ffDestroyOpenCLOptions(&instance.config.openCL); + ffDestroyUsersOptions(&instance.config.users); + ffDestroyBluetoothOptions(&instance.config.bluetooth); + ffDestroySeparatorOptions(&instance.config.separator); + ffDestroySoundOptions(&instance.config.sound); + ffDestroyGamepadOptions(&instance.config.gamepad); + ffDestroyColorsOptions(&instance.config.colors); - ffStrbufDestroy(&instance->config.libPCI); - ffStrbufDestroy(&instance->config.libVulkan); - ffStrbufDestroy(&instance->config.libWayland); - ffStrbufDestroy(&instance->config.libXcbRandr); - ffStrbufDestroy(&instance->config.libXcb); - ffStrbufDestroy(&instance->config.libXrandr); - ffStrbufDestroy(&instance->config.libX11); - ffStrbufDestroy(&instance->config.libGIO); - ffStrbufDestroy(&instance->config.libDConf); - ffStrbufDestroy(&instance->config.libDBus); - ffStrbufDestroy(&instance->config.libXFConf); - ffStrbufDestroy(&instance->config.libSQLite3); - ffStrbufDestroy(&instance->config.librpm); - ffStrbufDestroy(&instance->config.libImageMagick); - ffStrbufDestroy(&instance->config.libZ); - ffStrbufDestroy(&instance->config.libChafa); - ffStrbufDestroy(&instance->config.libEGL); - ffStrbufDestroy(&instance->config.libGLX); - ffStrbufDestroy(&instance->config.libOSMesa); - ffStrbufDestroy(&instance->config.libOpenCL); - ffStrbufDestroy(&instance->config.libfreetype); - ffStrbufDestroy(&instance->config.libPulse); - ffStrbufDestroy(&instance->config.libnm); + ffStrbufDestroy(&instance.config.libPCI); + ffStrbufDestroy(&instance.config.libVulkan); + ffStrbufDestroy(&instance.config.libWayland); + ffStrbufDestroy(&instance.config.libXcbRandr); + ffStrbufDestroy(&instance.config.libXcb); + ffStrbufDestroy(&instance.config.libXrandr); + ffStrbufDestroy(&instance.config.libX11); + ffStrbufDestroy(&instance.config.libGIO); + ffStrbufDestroy(&instance.config.libDConf); + ffStrbufDestroy(&instance.config.libDBus); + ffStrbufDestroy(&instance.config.libXFConf); + ffStrbufDestroy(&instance.config.libSQLite3); + ffStrbufDestroy(&instance.config.librpm); + ffStrbufDestroy(&instance.config.libImageMagick); + ffStrbufDestroy(&instance.config.libZ); + ffStrbufDestroy(&instance.config.libChafa); + ffStrbufDestroy(&instance.config.libEGL); + ffStrbufDestroy(&instance.config.libGLX); + ffStrbufDestroy(&instance.config.libOSMesa); + ffStrbufDestroy(&instance.config.libOpenCL); + ffStrbufDestroy(&instance.config.libfreetype); + ffStrbufDestroy(&instance.config.libPulse); + ffStrbufDestroy(&instance.config.libnm); } -static void destroyState(FFinstance* instance) +static void destroyState(void) { - ffPlatformDestroy(&instance->state.platform); - yyjson_doc_free(instance->state.configDoc); + ffPlatformDestroy(&instance.state.platform); + yyjson_doc_free(instance.state.configDoc); } -void ffDestroyInstance(FFinstance* instance) +void ffDestroyInstance(void) { - destroyConfig(instance); - destroyState(instance); + destroyConfig(); + destroyState(); } //Must be in a file compiled with the libfastfetch target, because the FF_HAVE* macros are not defined for the executable targets -void ffListFeatures() +void ffListFeatures(void) { fputs( #ifdef FF_HAVE_THREADS diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 98ae8a2d3..13b6e514f 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -65,154 +65,154 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p return "Invalid enum value type; must be a string or integer"; } -static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module)) +static inline bool tryModule(const char* type, yyjson_val* module, const char* moduleName, void (*const f)(yyjson_val *module)) { if (ffStrEqualsIgnCase(type, moduleName)) { - f(instance, module); + f(module); return true; } return false; } -static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson_val* module) +static bool parseModuleJsonObject(const char* type, yyjson_val* module) { switch (toupper(type[0])) { case 'B': { return - tryModule(instance, type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) || - tryModule(instance, type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) || - tryModule(instance, type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) || - tryModule(instance, type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) || - tryModule(instance, type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) || - tryModule(instance, type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) || + tryModule(type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) || + tryModule(type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) || + tryModule(type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) || + tryModule(type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) || + tryModule(type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) || + tryModule(type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) || false; } case 'C': { return - tryModule(instance, type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || - tryModule(instance, type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || - tryModule(instance, type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || - tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || - tryModule(instance, type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || - tryModule(instance, type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || - tryModule(instance, type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || + tryModule(type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || + tryModule(type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || + tryModule(type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || + tryModule(type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || + tryModule(type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || + tryModule(type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || + tryModule(type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || false; } case 'D': { return - tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || - tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || - tryModule(instance, type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || - tryModule(instance, type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || + tryModule(type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || + tryModule(type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || + tryModule(type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || + tryModule(type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || false; } case 'F': { return - tryModule(instance, type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) || + tryModule(type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) || false; } case 'G': { return - tryModule(instance, type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || - tryModule(instance, type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || + tryModule(type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) || + tryModule(type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) || false; } case 'H': { return - tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || + tryModule(type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) || false; } case 'I': { return - tryModule(instance, type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) || + tryModule(type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) || false; } case 'K': { return - tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || + tryModule(type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) || false; } case 'L': { return - tryModule(instance, type, module, FF_LM_MODULE_NAME, ffParseLMJsonObject) || - tryModule(instance, type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || - tryModule(instance, type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || + tryModule(type, module, FF_LM_MODULE_NAME, ffParseLMJsonObject) || + tryModule(type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) || + tryModule(type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) || false; } case 'M': { return - tryModule(instance, type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || - tryModule(instance, type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || + tryModule(type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || + tryModule(type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || false; } case 'O': { return - tryModule(instance, type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || - tryModule(instance, type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || - tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || + tryModule(type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || + tryModule(type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) || + tryModule(type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) || false; } case 'P': { return - tryModule(instance, type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || - tryModule(instance, type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || - tryModule(instance, type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || - tryModule(instance, type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) || - tryModule(instance, type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || + tryModule(type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) || + tryModule(type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) || + tryModule(type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) || + tryModule(type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) || + tryModule(type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) || false; } case 'S': { return - tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || - tryModule(instance, type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) || - tryModule(instance, type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || - tryModule(instance, type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || + tryModule(type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) || + tryModule(type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) || + tryModule(type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) || + tryModule(type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) || false; } case 'T': { return - tryModule(instance, type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || - tryModule(instance, type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || - tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || - tryModule(instance, type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || + tryModule(type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || + tryModule(type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || + tryModule(type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || + tryModule(type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || false; } case 'U': { return - tryModule(instance, type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || - tryModule(instance, type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) || + tryModule(type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) || + tryModule(type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) || false; } case 'V': { return - tryModule(instance, type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) || + tryModule(type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) || false; } case 'W': { return - tryModule(instance, type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || - tryModule(instance, type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) || - tryModule(instance, type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || - tryModule(instance, type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || - tryModule(instance, type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || + tryModule(type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) || + tryModule(type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) || + tryModule(type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) || + tryModule(type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) || + tryModule(type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) || false; } @@ -221,9 +221,9 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson } } -static const char* printJsonConfig(FFinstance* instance) +static const char* printJsonConfig(void) { - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc); assert(root); if (!yyjson_is_obj(root)) @@ -238,7 +238,7 @@ static const char* printJsonConfig(FFinstance* instance) yyjson_arr_foreach(modules, idx, max, item) { uint64_t ms = 0; - if(__builtin_expect(instance->config.stat, false)) + if(__builtin_expect(instance.config.stat, false)) ms = ffTimeGetTick(); yyjson_val* module = item; @@ -255,32 +255,32 @@ static const char* printJsonConfig(FFinstance* instance) else return "modules must be an array of strings or objects"; - if(!parseModuleJsonObject(instance, type, module)) + if(!parseModuleJsonObject(type, module)) return "Unknown module type"; - if(__builtin_expect(instance->config.stat, false)) + if(__builtin_expect(instance.config.stat, false)) { char str[32]; int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms); - if(instance->config.pipe) + if(instance.config.pipe) puts(str); else printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } #if defined(_WIN32) - if (!instance->config.noBuffer) fflush(stdout); + if (!instance.config.noBuffer) fflush(stdout); #endif } return NULL; } -const char* ffParseGeneralJsonConfig(FFinstance* instance) +const char* ffParseGeneralJsonConfig(void) { - FFconfig* config = &instance->config; + FFconfig* config = &instance.config; - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc); assert(root); if (!yyjson_is_obj(root)) @@ -321,11 +321,11 @@ const char* ffParseGeneralJsonConfig(FFinstance* instance) return NULL; } -const char* ffParseDisplayJsonConfig(FFinstance* instance) +const char* ffParseDisplayJsonConfig(void) { - FFconfig* config = &instance->config; + FFconfig* config = &instance.config; - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc); assert(root); if (!yyjson_is_obj(root)) @@ -391,11 +391,11 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance) return NULL; } -const char* ffParseLibraryJsonConfig(FFinstance* instance) +const char* ffParseLibraryJsonConfig(void) { - FFconfig* config = &instance->config; + FFconfig* config = &instance.config; - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc); assert(root); if (!yyjson_is_obj(root)) @@ -464,9 +464,9 @@ const char* ffParseLibraryJsonConfig(FFinstance* instance) return NULL; } -void ffPrintJsonConfig(FFinstance* instance) +void ffPrintJsonConfig(void) { - const char* error = printJsonConfig(instance); + const char* error = printJsonConfig(); if (error) - ffPrintErrorString(instance, "JsonConfig", 0, NULL, NULL, "%s", error); + ffPrintErrorString("JsonConfig", 0, NULL, NULL, "%s", error); } diff --git a/src/common/jsonconfig.h b/src/common/jsonconfig.h index 8a72408bc..7cf6a96e0 100644 --- a/src/common/jsonconfig.h +++ b/src/common/jsonconfig.h @@ -4,7 +4,7 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs); const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]); -void ffPrintJsonConfig(FFinstance* instance); -const char* ffParseGeneralJsonConfig(FFinstance* instance); -const char* ffParseDisplayJsonConfig(FFinstance* instance); -const char* ffParseLibraryJsonConfig(FFinstance* instance); +void ffPrintJsonConfig(); +const char* ffParseGeneralJsonConfig(); +const char* ffParseDisplayJsonConfig(); +const char* ffParseLibraryJsonConfig(); diff --git a/src/common/printing.c b/src/common/printing.c index 97aacb62b..538698550 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -2,21 +2,21 @@ #include "common/printing.h" #include "util/textModifier.h" -void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor) +void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor) { - ffLogoPrintLine(instance); + ffLogoPrintLine(); //This is used by --set-keyless, in this case we wan't neither the module name nor the separator if(moduleName == NULL) return; - if(!instance->config.pipe) + if(!instance.config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout); if(customKeyColor != NULL && customKeyColor->length > 0) ffPrintColor(customKeyColor); else - ffPrintColor(&instance->config.colorKeys); + ffPrintColor(&instance.config.colorKeys); } //NULL check is required for modules with custom keys, e.g. disk with the folder path @@ -36,64 +36,64 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod ffPrintUserString(key.chars); } - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); - ffStrbufWriteTo(&instance->config.keyValueSeparator, stdout); + ffStrbufWriteTo(&instance.config.keyValueSeparator, stdout); - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); } -void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) +void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(256); ffParseFormatString(&buffer, format, numArgs, arguments); if(buffer.length > 0) { - ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor); + ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor); ffPrintUserString(buffer.chars); putchar('\n'); } } -void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) +void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) { - ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, &moduleArgs->outputFormat, numArgs, arguments); + ffPrintFormatString(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, &moduleArgs->outputFormat, numArgs, arguments); } -static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, va_list arguments) +static void printError(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, va_list arguments) { - if(!instance->config.showErrors) + if(!instance.config.showErrors) return; - ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor); + ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor); - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); vprintf(message, arguments); - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); putchar('\n'); } -void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...) +void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...) { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, customKeyFormat, customKeyColor, message, arguments); + printError(moduleName, moduleIndex, customKeyFormat, customKeyColor, message, arguments); va_end(arguments); } -void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...) +void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...) { va_list arguments; va_start(arguments, message); - printError(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, message, arguments); + printError(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, message, arguments); va_end(arguments); } diff --git a/src/common/printing.h b/src/common/printing.h index 801ef7e8e..8019a01cc 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -6,11 +6,11 @@ #include "fastfetch.h" #include "common/format.h" -void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor); -void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); -void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments); -FF_C_PRINTF(6, 7) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...); -FF_C_PRINTF(5, 6) void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); +void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor); +void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); +void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments); +FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...); +FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); void ffPrintUserString(const char* str); diff --git a/src/common/properties.c b/src/common/properties.c index 6543d14a4..c91f107eb 100644 --- a/src/common/properties.c +++ b/src/common/properties.c @@ -144,9 +144,9 @@ done: return true; } -bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries) +bool ffParsePropFileHomeValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) { - FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateF("%s/%s", instance->state.platform.homeDir.chars, relativeFile); + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateF("%s/%s", instance.state.platform.homeDir.chars, relativeFile); return ffParsePropFileValues(absolutePath.chars, numQueries, queries); } diff --git a/src/common/properties.h b/src/common/properties.h index ea78ed903..8b65e419c 100644 --- a/src/common/properties.h +++ b/src/common/properties.h @@ -14,7 +14,7 @@ typedef struct FFpropquery bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer); bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer); bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries); -bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries); +bool ffParsePropFileHomeValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries); bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uint32_t numQueries, FFpropquery* queries); static inline bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer) @@ -22,9 +22,9 @@ static inline bool ffParsePropFile(const char* filename, const char* start, FFst return ffParsePropFileValues(filename, 1, (FFpropquery[]){{start, buffer}}); } -static inline bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer) +static inline bool ffParsePropFileHome(const char* relativeFile, const char* start, FFstrbuf* buffer) { - return ffParsePropFileHomeValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}}); + return ffParsePropFileHomeValues(relativeFile, 1, (FFpropquery[]){{start, buffer}}); } static inline bool ffParsePropFileList(const FFlist* list, const char* relativeFile, const char* start, FFstrbuf* buffer) @@ -32,24 +32,24 @@ static inline bool ffParsePropFileList(const FFlist* list, const char* relativeF return ffParsePropFileListValues(list, relativeFile, 1, (FFpropquery[]){{start, buffer}}); } -static inline bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries) +static inline bool ffParsePropFileConfigValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) { - return ffParsePropFileListValues(&instance->state.platform.configDirs, relativeFile, numQueries, queries); + return ffParsePropFileListValues(&instance.state.platform.configDirs, relativeFile, numQueries, queries); } -static inline bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer) +static inline bool ffParsePropFileConfig(const char* relativeFile, const char* start, FFstrbuf* buffer) { - return ffParsePropFileConfigValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}}); + return ffParsePropFileConfigValues(relativeFile, 1, (FFpropquery[]){{start, buffer}}); } -static inline bool ffParsePropFileDataValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries) +static inline bool ffParsePropFileDataValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) { - return ffParsePropFileListValues(&instance->state.platform.dataDirs, relativeFile, numQueries, queries); + return ffParsePropFileListValues(&instance.state.platform.dataDirs, relativeFile, numQueries, queries); } -static inline bool ffParsePropFileData(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer) +static inline bool ffParsePropFileData(const char* relativeFile, const char* start, FFstrbuf* buffer) { - return ffParsePropFileDataValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}}); + return ffParsePropFileDataValues(relativeFile, 1, (FFpropquery[]){{start, buffer}}); } #endif diff --git a/src/common/settings.c b/src/common/settings.c index f8e88b10a..dda3fe62d 100644 --- a/src/common/settings.c +++ b/src/common/settings.c @@ -97,9 +97,9 @@ typedef struct GSettingsData GVariantGetters variantGetters; } GSettingsData; -static const GSettingsData* getGSettingsData(const FFinstance* instance) +static const GSettingsData* getGSettingsData(void) { - FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance->config.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance.config.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_lookup) FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_has_key) @@ -123,9 +123,9 @@ static const GSettingsData* getGSettingsData(const FFinstance* instance) FF_LIBRARY_DATA_LOAD_RETURN } -FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type) +FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type) { - const GSettingsData* data = getGSettingsData(instance); + const GSettingsData* data = getGSettingsData(); if(data == NULL) return FF_VARIANT_NULL; @@ -152,9 +152,9 @@ FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaN return getGVariantValue(variant, type, &data->variantGetters); } #else //FF_HAVE_GIO -FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type) +FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type) { - FF_UNUSED(instance, schemaName, path, key, type) + FF_UNUSED(schemaName, path, key, type) return FF_VARIANT_NULL; } #endif //FF_HAVE_GIO @@ -170,9 +170,9 @@ typedef struct DConfData DConfClient* client; } DConfData; -static const DConfData* getDConfData(const FFinstance* instance) +static const DConfData* getDConfData(void) { - FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance->config.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2); + FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance.config.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2); FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_read_full) FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new) @@ -191,9 +191,9 @@ static const DConfData* getDConfData(const FFinstance* instance) FF_LIBRARY_DATA_LOAD_RETURN } -FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type) +FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type) { - const DConfData* data = getDConfData(instance); + const DConfData* data = getDConfData(); if(data == NULL) return FF_VARIANT_NULL; @@ -209,23 +209,23 @@ FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvari return getGVariantValue(variant, type, &data->variantGetters); } #else //FF_HAVE_DCONF -FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type) +FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type) { - FF_UNUSED(instance, key, type) + FF_UNUSED(key, type) return FF_VARIANT_NULL; } #endif //FF_HAVE_DCONF -FFvariant ffSettingsGet(const FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type) +FFvariant ffSettingsGet(const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type) { - FFvariant gsettings = ffSettingsGetGSettings(instance, gsettingsSchemaName, gsettingsPath, gsettingsKey, type); + FFvariant gsettings = ffSettingsGetGSettings(gsettingsSchemaName, gsettingsPath, gsettingsKey, type); if( (type == FF_VARIANT_TYPE_BOOL && gsettings.boolValueSet) || (type != FF_VARIANT_TYPE_BOOL && gsettings.strValue != NULL) ) return gsettings; - return ffSettingsGetDConf(instance, dconfKey, type); + return ffSettingsGetDConf(dconfKey, type); } #ifdef FF_HAVE_XFCONF @@ -241,9 +241,9 @@ typedef struct XFConfData FF_LIBRARY_SYMBOL(xfconf_init) } XFConfData; -static const XFConfData* getXFConfData(const FFinstance* instance) +static const XFConfData* getXFConfData(void) { - FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance->config.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance.config.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get) FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_has_property) @@ -258,9 +258,9 @@ static const XFConfData* getXFConfData(const FFinstance* instance) FF_LIBRARY_DATA_LOAD_RETURN } -FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type) +FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) { - const XFConfData* data = getXFConfData(instance); + const XFConfData* data = getXFConfData(); if(data == NULL) return FF_VARIANT_NULL; @@ -281,9 +281,9 @@ FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelNam return FF_VARIANT_NULL; } #else //FF_HAVE_XFCONF -FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type) +FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) { - FF_UNUSED(instance, channelName, propertyName, type) + FF_UNUSED(channelName, propertyName, type) return FF_VARIANT_NULL; } #endif //FF_HAVE_XFCONF @@ -303,9 +303,9 @@ typedef struct SQLiteData FF_LIBRARY_SYMBOL(sqlite3_close) } SQLiteData; -static const SQLiteData* getSQLiteData(const FFinstance* instance) +static const SQLiteData* getSQLiteData(void) { - FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance->config.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance.config.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_open_v2) FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_prepare_v2) @@ -319,12 +319,12 @@ static const SQLiteData* getSQLiteData(const FFinstance* instance) FF_LIBRARY_DATA_LOAD_RETURN } -int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query) +int ffSettingsGetSQLite3Int(const char* dbPath, const char* query) { if(!ffPathExists(dbPath, FF_PATHTYPE_FILE)) return 0; - const SQLiteData* data = getSQLiteData(instance); + const SQLiteData* data = getSQLiteData(); if(data == NULL) return 0; @@ -354,12 +354,12 @@ int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, cons return result; } -bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result) +bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* result) { if(!ffPathExists(dbPath, FF_PATHTYPE_FILE)) return false; - const SQLiteData* data = getSQLiteData(instance); + const SQLiteData* data = getSQLiteData(); if(data == NULL) return false; @@ -389,14 +389,14 @@ bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, return true; } #else //FF_HAVE_SQLITE3 -int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query) +int ffSettingsGetSQLite3Int(const char* dbPath, const char* query) { - FF_UNUSED(instance, dbPath, query) + FF_UNUSED(dbPath, query) return 0; } -bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result) +bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* result) { - FF_UNUSED(instance, dbPath, query, result) + FF_UNUSED(dbPath, query, result) return false; } #endif //FF_HAVE_SQLITE3 diff --git a/src/common/settings.h b/src/common/settings.h index 7cb4fd46e..212727fe9 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -25,13 +25,13 @@ typedef union FFvariant #define FF_VARIANT_NULL ((FFvariant){.strValue = NULL}) -FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type); -FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type); -FFvariant ffSettingsGet(const FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type); -FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type); +FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type); +FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type); +FFvariant ffSettingsGet(const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type); +FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type); -int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query); -bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result); +int ffSettingsGetSQLite3Int(const char* dbPath, const char* query); +bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* result); #ifdef __ANDROID__ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result); diff --git a/src/common/thread.h b/src/common/thread.h index 0b9bcb7e1..0b8989c4e 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -19,6 +19,7 @@ return (FFThreadType)_beginthreadex(NULL, 0, func, data, 0, NULL); } #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; } + #define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static __stdcall unsigned fn ## ThreadMain () { fn(); return 0; } static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); } static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, 0xffffffff /*INFINITE*/); } #else @@ -34,6 +35,7 @@ return newThread; } #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static void* fn ## ThreadMain (void* data) { fn((paramType)data); return NULL; } + #define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static void* fn ## ThreadMain () { fn(); return NULL; } static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); } static inline void ffThreadJoin(FFThreadType thread) { pthread_join(thread, NULL); } #endif diff --git a/src/detection/battery/battery.h b/src/detection/battery/battery.h index e83bf78d8..5667af76c 100644 --- a/src/detection/battery/battery.h +++ b/src/detection/battery/battery.h @@ -17,6 +17,6 @@ typedef struct BatteryResult double temperature; } BatteryResult; -const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results); +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results); #endif diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index eb05fefe4..d163f0894 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -7,7 +7,7 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "BatteryStatus" -const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index 1ddec8d43..82b020179 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -5,7 +5,7 @@ #include -static double detectBatteryTemp() +static double detectBatteryTemp(void) { FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); @@ -27,7 +27,7 @@ static double detectBatteryTemp() return result; } -const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery"); if (matchDict == NULL) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 0430f2c33..29799fec2 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -7,7 +7,7 @@ #include #include -const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { //https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) //https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index bca7fbfdc..41d49db62 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -68,7 +68,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results) result->temperature = FF_BATTERY_TEMP_UNSET; } -const char* ffDetectBattery(FF_MAYBE_UNUSED FFinstance* instance, FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); diff --git a/src/detection/battery/battery_nosupport.c b/src/detection/battery/battery_nosupport.c index 1cc9f79fb..02f084748 100644 --- a/src/detection/battery/battery_nosupport.c +++ b/src/detection/battery/battery_nosupport.c @@ -1,8 +1,8 @@ #include "fastfetch.h" #include "battery.h" -const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { - FF_UNUSED(instance, options, results) + FF_UNUSED(options, results) return "Not supported on this platform"; } diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index 16bedad17..3afbb996e 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -30,9 +30,9 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) SetupDiDestroyDeviceInfoList(*hdev); } -const char* ffDetectBattery(FFinstance* instance, FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { - if(instance->config.allowSlowOperations) + if(instance.config.allowSlowOperations) { //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = diff --git a/src/detection/bluetooth/bluetooth.h b/src/detection/bluetooth/bluetooth.h index a2aad630f..4aecdfc6f 100644 --- a/src/detection/bluetooth/bluetooth.h +++ b/src/detection/bluetooth/bluetooth.h @@ -14,6 +14,6 @@ typedef struct FFBluetoothDevice bool connected; } FFBluetoothDevice; -const char* ffDetectBluetooth(const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */); +const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothDevice */); #endif diff --git a/src/detection/bluetooth/bluetooth_apple.m b/src/detection/bluetooth/bluetooth_apple.m index 061bf2cf3..d6f3e9878 100644 --- a/src/detection/bluetooth/bluetooth_apple.m +++ b/src/detection/bluetooth/bluetooth_apple.m @@ -2,7 +2,7 @@ #import -const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) +const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothDevice */) { NSArray* ioDevices = IOBluetoothDevice.pairedDevices; if(!ioDevices) diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index f429387e1..3938cafbd 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -167,10 +167,10 @@ static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIt } } -static const char* detectBluetooth(const FFinstance* instance, FFlist* devices) +static const char* detectBluetooth(FFlist* devices) { FFDBusData dbus; - const char* error = ffDBusLoadData(instance, DBUS_BUS_SYSTEM, &dbus); + const char* error = ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus); if(error) return error; @@ -193,12 +193,11 @@ static const char* detectBluetooth(const FFinstance* instance, FFlist* devices) #endif -const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) +const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothDevice */) { #ifdef FF_HAVE_DBUS - return detectBluetooth(instance, devices); + return detectBluetooth(devices); #else - FF_UNUSED(instance); return "Fastfetch was compiled without DBus support"; #endif } diff --git a/src/detection/bluetooth/bluetooth_nosupport.c b/src/detection/bluetooth/bluetooth_nosupport.c index 4fbc5353c..4ae74ac3e 100644 --- a/src/detection/bluetooth/bluetooth_nosupport.c +++ b/src/detection/bluetooth/bluetooth_nosupport.c @@ -1,6 +1,6 @@ #include "bluetooth.h" -const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothDevice */) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index 698eb86db..0066cebb3 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -7,7 +7,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpointer-sign" -const char* ffDetectBluetooth(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* FFBluetoothDevice */) +const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothDevice */) { BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { .fReturnConnected = TRUE, diff --git a/src/detection/chassis/chassis_windows.cpp b/src/detection/chassis/chassis_windows.cpp index 3264381c0..99731889a 100644 --- a/src/detection/chassis/chassis_windows.cpp +++ b/src/detection/chassis/chassis_windows.cpp @@ -52,5 +52,5 @@ extern "C" const char* ffDetectChassis(FFChassisResult* result) { return detectWithRegistry(result); - // TODO: if (instance->config.allowSlowOperations) detectWithWmi(result); + // TODO: if (instance.config.allowSlowOperations) detectWithWmi(result); } diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 7410dbbee..4fc6d34bc 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -1,11 +1,11 @@ #include "cpu.h" #include "detection/internal.h" -const char* ffDetectCPUImpl(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu); +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu); -const char* ffDetectCPU(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu) { - const char* error = ffDetectCPUImpl(instance, options, cpu); + const char* error = ffDetectCPUImpl(options, cpu); if (error) return error; const char* removeStrings[] = { diff --git a/src/detection/cpu/cpu.h b/src/detection/cpu/cpu.h index 6c5a3188c..7dd1c29d2 100644 --- a/src/detection/cpu/cpu.h +++ b/src/detection/cpu/cpu.h @@ -22,6 +22,6 @@ typedef struct FFCPUResult double temperature; } FFCPUResult; -const char* ffDetectCPU(const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu); +const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu); #endif diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index 51d485699..6de492132 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -40,7 +40,7 @@ static double detectCpuTemp(const FFstrbuf* cpuName) return result; } -const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != NULL) return "sysctlbyname(machdep.cpu.brand_string) failed"; diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index fe3315e61..835bdd4f6 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -2,7 +2,7 @@ #include "common/sysctl.h" #include "detection/temps/temps_bsd.h" -const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { if (ffSysctlGetString("hw.model", &cpu->name)) return "sysctlbyname(hw.model) failed"; diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index f9abd1d32..00c332a26 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -104,7 +104,7 @@ static void parseIsa(FFstrbuf* cpuIsa) } } -const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { cpu->temperature = options->temp ? detectCPUTemp() : FF_CPU_TEMP_UNSET; diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 8c9246d2f..231ea342e 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -3,7 +3,7 @@ #include "util/windows/registry.h" #include "util/mallocHelper.h" -const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu) +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { { DWORD length = 0; diff --git a/src/detection/cpuusage/cpuusage.c b/src/detection/cpuusage/cpuusage.c index 7342bbc55..f12cec257 100644 --- a/src/detection/cpuusage/cpuusage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -9,7 +9,7 @@ const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll); static uint64_t inUseAll1, totalAll1; -void ffPrepareCPUUsage() +void ffPrepareCPUUsage(void) { ffGetCpuUsageInfo(&inUseAll1, &totalAll1); } diff --git a/src/detection/cursor/cursor.h b/src/detection/cursor/cursor.h index 268631240..793721f0b 100644 --- a/src/detection/cursor/cursor.h +++ b/src/detection/cursor/cursor.h @@ -12,6 +12,6 @@ typedef struct FFCursorResult FFstrbuf error; } FFCursorResult; -void ffDetectCursor(const FFinstance* instance, FFCursorResult* result); +void ffDetectCursor(FFCursorResult* result); #endif diff --git a/src/detection/cursor/cursor_apple.m b/src/detection/cursor/cursor_apple.m index 3873e979a..40d4b90c9 100644 --- a/src/detection/cursor/cursor_apple.m +++ b/src/detection/cursor/cursor_apple.m @@ -17,10 +17,10 @@ static void appendColor(FFstrbuf* str, NSDictionary* color) ffStrbufAppendF(str, "#%02X%02X%02X%02X", r, g, b, a); } -void ffDetectCursor(const FFinstance* instance, FFCursorResult* result) +void ffDetectCursor(FFCursorResult* result) { NSError* error; - NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.apple.universalaccess.plist", instance->state.platform.homeDir.chars]; + NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.apple.universalaccess.plist", instance.state.platform.homeDir.chars]; NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName] error:&error]; if(error) diff --git a/src/detection/cursor/cursor_linux.c b/src/detection/cursor/cursor_linux.c index 3ca696091..17ff04765 100644 --- a/src/detection/cursor/cursor_linux.c +++ b/src/detection/cursor/cursor_linux.c @@ -9,15 +9,15 @@ #include -static bool detectCursorGTK(const FFinstance* instance, FFCursorResult* result) +static bool detectCursorGTK(FFCursorResult* result) { - const FFGTKResult* gtk = ffDetectGTK4(instance); + const FFGTKResult* gtk = ffDetectGTK4(); if(gtk->cursor.length == 0) - gtk = ffDetectGTK3(instance); + gtk = ffDetectGTK3(); if(gtk->cursor.length == 0) - gtk = ffDetectGTK2(instance); + gtk = ffDetectGTK2(); if(gtk->cursor.length == 0) return false; @@ -27,9 +27,9 @@ static bool detectCursorGTK(const FFinstance* instance, FFCursorResult* result) return true; } -static void detectCursorFromConfigFile(const FFinstance* instance, const char* relativeFilePath, const char* themeStart, const char* themeDefault, const char* sizeStart, const char* sizeDefault, FFCursorResult* result) +static void detectCursorFromConfigFile(const char* relativeFilePath, const char* themeStart, const char* themeDefault, const char* sizeStart, const char* sizeDefault, FFCursorResult* result) { - if(ffParsePropFileConfigValues(instance, relativeFilePath, 2, (FFpropquery[]) { + if(ffParsePropFileConfigValues(relativeFilePath, 2, (FFpropquery[]) { {themeStart, &result->theme}, {sizeStart, &result->size} })) { @@ -45,9 +45,9 @@ static void detectCursorFromConfigFile(const FFinstance* instance, const char* r ffStrbufAppendF(&result->error, "Couldn't find cursor in %s", relativeFilePath); } -static bool detectCursorFromXResources(const FFinstance* instance, FFCursorResult* result) +static bool detectCursorFromXResources(FFCursorResult* result) { - ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) { + ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) { {"Xcursor.theme :", &result->theme}, {"Xcursor.size :", &result->size} }); @@ -55,9 +55,8 @@ static bool detectCursorFromXResources(const FFinstance* instance, FFCursorResul return result->theme.length > 0; } -static bool detectCursorFromEnv(const FFinstance* instance, FFCursorResult* result) +static bool detectCursorFromEnv(FFCursorResult* result) { - FF_UNUSED(instance); const char* xcursor_theme = getenv("XCURSOR_THEME"); if(!ffStrSet(xcursor_theme)) @@ -69,23 +68,23 @@ static bool detectCursorFromEnv(const FFinstance* instance, FFCursorResult* resu return true; } -void ffDetectCursor(const FFinstance* instance, FFCursorResult* result) +void ffDetectCursor(FFCursorResult* result) { - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufCompS(&wmde->wmPrettyName, FF_WM_PRETTY_WSLG) == 0) ffStrbufAppendS(&result->error, "WSLg uses native windows cursor"); else if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) ffStrbufAppendS(&result->error, "Cursor isn't supported in TTY"); else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA) == 0) - detectCursorFromConfigFile(instance, "kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); + detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) - detectCursorFromConfigFile(instance, "lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); + detectCursorFromConfigFile("lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); else if( - !detectCursorGTK(instance, result) && - !detectCursorFromEnv(instance, result) && - !ffParsePropFileHome(instance, ".icons/default/index.theme", "Inherits =", &result->theme) && - !detectCursorFromXResources(instance, result) && - !ffParsePropFileData(instance, "icons/default/index.theme", "Inherits =", &result->theme) + !detectCursorGTK(result) && + !detectCursorFromEnv(result) && + !ffParsePropFileHome(".icons/default/index.theme", "Inherits =", &result->theme) && + !detectCursorFromXResources(result) && + !ffParsePropFileData("icons/default/index.theme", "Inherits =", &result->theme) ) ffStrbufAppendS(&result->error, "Couldn't find cursor"); } diff --git a/src/detection/cursor/cursor_nosupport.c b/src/detection/cursor/cursor_nosupport.c index c54637c96..6e36e55ca 100644 --- a/src/detection/cursor/cursor_nosupport.c +++ b/src/detection/cursor/cursor_nosupport.c @@ -1,7 +1,6 @@ #include "cursor.h" -void ffDetectCursor(const FFinstance* instance, FFCursorResult* result) +void ffDetectCursor(FF_MAYBE_UNUSED FFCursorResult* result) { - FF_UNUSED(instance, result); ffStrbufInitS(&result->error, "Not supported on this platform"); } diff --git a/src/detection/cursor/cursor_windows.c b/src/detection/cursor/cursor_windows.c index c3d6c644a..6cb8f8985 100644 --- a/src/detection/cursor/cursor_windows.c +++ b/src/detection/cursor/cursor_windows.c @@ -2,10 +2,8 @@ #include "util/windows/registry.h" -void ffDetectCursor(const FFinstance* instance, FFCursorResult* result) +void ffDetectCursor(FFCursorResult* result) { - FF_UNUSED(instance); - FF_HKEY_AUTO_DESTROY hKey; if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error)) { diff --git a/src/detection/datetime/datetime.c b/src/detection/datetime/datetime.c index 317fdcf85..60cc1f658 100644 --- a/src/detection/datetime/datetime.c +++ b/src/detection/datetime/datetime.c @@ -4,10 +4,8 @@ #include -const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance) +const FFDateTimeResult* ffDetectDateTime(void) { - FF_UNUSED(instance); //We may need it later for additional configuration - static FFDateTimeResult result; static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; static bool init = false; diff --git a/src/detection/datetime/datetime.h b/src/detection/datetime/datetime.h index 418f14fb2..fd47ba03b 100644 --- a/src/detection/datetime/datetime.h +++ b/src/detection/datetime/datetime.h @@ -30,6 +30,6 @@ typedef struct FFDateTimeResult FFstrbuf secondPretty; //37 } FFDateTimeResult; -const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance); +const FFDateTimeResult* ffDetectDateTime(); #endif diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index b535012d2..538ff7d89 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -30,11 +30,11 @@ bool ffdsAppendDisplay( return true; } -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance); +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds); -const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance) +const FFDisplayServerResult* ffConnectDisplayServer() { FF_DETECTION_INTERNAL_GUARD(FFDisplayServerResult, - ffConnectDisplayServerImpl(&result, instance); + ffConnectDisplayServerImpl(&result); ); } diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index ba874dc25..d45f43070 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -71,7 +71,7 @@ typedef struct FFDisplayServerResult FFlist displays; //List of FFDisplayResult } FFDisplayServerResult; -const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance); +const FFDisplayServerResult* ffConnectDisplayServer(); bool ffdsAppendDisplay( FFDisplayServerResult* result, diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 15e423330..0a7ddde5a 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -100,15 +100,13 @@ static void detectWMPlugin(FFstrbuf* name) } } -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { - FF_UNUSED(instance); - ffStrbufInitS(&ds->wmProcessName, "WindowServer"); ffStrbufInitS(&ds->wmPrettyName, "Quartz Compositor"); ffStrbufInit(&ds->wmProtocolName); - if(instance->config.allowSlowOperations) + if(instance.config.allowSlowOperations) { FF_STRBUF_AUTO_DESTROY name; ffStrbufInit(&name); diff --git a/src/detection/displayserver/displayserver_nosupport.c b/src/detection/displayserver/displayserver_nosupport.c index bef1e4554..20e121e65 100644 --- a/src/detection/displayserver/displayserver_nosupport.c +++ b/src/detection/displayserver/displayserver_nosupport.c @@ -1,9 +1,7 @@ #include "displayserver.h" -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { - FF_UNUSED(instance); - ffStrbufInit(&ds->wmProcessName); ffStrbufInit(&ds->wmPrettyName); ffStrbufInit(&ds->wmProtocolName); diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 565c8fcce..0a91eedb1 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -131,7 +131,7 @@ static void detectDisplays(FFDisplayServerResult* ds) } } -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { BOOL enabled; if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE) @@ -153,7 +153,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins detectDisplays(ds); //https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067 - const FFOSResult* os = ffDetectOS(instance); + const FFOSResult* os = ffDetectOS(); if( ffStrbufEqualS(&os->version, "11") || ffStrbufEqualS(&os->version, "10") || diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index f2101e010..65f1075ba 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -64,7 +64,7 @@ static void parseDRM(FFDisplayServerResult* result) closedir(dirp); } -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { ffStrbufInit(&ds->wmProcessName); ffStrbufInit(&ds->wmPrettyName); @@ -76,23 +76,23 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins //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, ds); + ffdsConnectWayland(ds); //Try the x11 libs, from most feature rich to least. //We use the display list to detect if a connection is needed. //They respect wmProtocolName, and only detect display if it is set. if(ds->displays.length == 0) - ffdsConnectXcbRandr(instance, ds); + ffdsConnectXcbRandr(ds); if(ds->displays.length == 0) - ffdsConnectXrandr(instance, ds); + ffdsConnectXrandr(ds); if(ds->displays.length == 0) - ffdsConnectXcb(instance, ds); + ffdsConnectXcb(ds); if(ds->displays.length == 0) - ffdsConnectXlib(instance, ds); + ffdsConnectXlib(ds); //This display detection method is display server independent. //Use it if all connections failed @@ -100,5 +100,5 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins parseDRM(ds); //This fills in missing information about WM / DE by using env vars and iterating processes - ffdsDetectWMDE(instance, ds); + ffdsDetectWMDE(ds); } diff --git a/src/detection/displayserver/linux/displayserver_linux.h b/src/detection/displayserver/linux/displayserver_linux.h index aee7c25ff..695fcede9 100644 --- a/src/detection/displayserver/linux/displayserver_linux.h +++ b/src/detection/displayserver/linux/displayserver_linux.h @@ -5,14 +5,14 @@ #include "detection/displayserver/displayserver.h" -void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* result); +void ffdsConnectWayland(FFDisplayServerResult* result); -void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* result); -void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result); +void ffdsConnectXcbRandr(FFDisplayServerResult* result); +void ffdsConnectXcb(FFDisplayServerResult* result); -void ffdsConnectXrandr(const FFinstance* instance, FFDisplayServerResult* result); -void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result); +void ffdsConnectXrandr(FFDisplayServerResult* result); +void ffdsConnectXlib(FFDisplayServerResult* result); -void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result); +void ffdsDetectWMDE(FFDisplayServerResult* result); #endif diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 5ab460efd..0f2ec77c6 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -201,9 +201,9 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u waylandOutputHandler(wldata, registry, name, version); } -bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) +bool detectWayland(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(wayland, &instance->config.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(wayland, &instance.config.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect, false) FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_get_fd, false) @@ -255,17 +255,15 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) } #endif -void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectWayland(FFDisplayServerResult* result) { //Wayland requires this to be set if(getenv("XDG_RUNTIME_DIR") == NULL) return; #ifdef FF_HAVE_WAYLAND - if(detectWayland(instance, result)) + if(detectWayland(result)) return; - #else - FF_UNUSED(instance); #endif const char* xdgSessionType = getenv("XDG_SESSION_TYPE"); diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index aa9c2c112..91af20511 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -11,7 +11,7 @@ #include #include -static const char* parseEnv() +static const char* parseEnv(void) { const char* env; @@ -126,7 +126,7 @@ static void applyBetterWM(FFDisplayServerResult* result, const char* processName ffStrbufAppend(&result->wmPrettyName, &result->wmProcessName); } -static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) +static void getKDE(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "plasmashell"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_PLASMA); @@ -135,9 +135,9 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) {"X-KDE-PluginInfo-Version =", &result->deVersion} }); if(result->deVersion.length == 0) - ffParsePropFileData(instance, "xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + ffParsePropFileData("xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) - ffParsePropFileData(instance, "xsessions/plasma5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + ffParsePropFileData("xsessions/plasma5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) { ffParsePropFileValues("/usr/share/wayland-sessions/plasma.desktop", 1, (FFpropquery[]) { @@ -145,11 +145,11 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) }); } if(result->deVersion.length == 0) - ffParsePropFileData(instance, "wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + ffParsePropFileData("wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); if(result->deVersion.length == 0) - ffParsePropFileData(instance, "wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); + ffParsePropFileData("wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - if(result->deVersion.length == 0 && instance->config.allowSlowOperations) + if(result->deVersion.length == 0 && instance.config.allowSlowOperations) { if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ "plasmashell", @@ -163,7 +163,7 @@ static void getKDE(const FFinstance* instance, FFDisplayServerResult* result) applyBetterWM(result, getenv("KDEWM")); } -static void getGnome(const FFinstance* instance, FFDisplayServerResult* result) +static void getGnome(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "gnome-shell"); const char* sessionMode = getenv("GNOME_SHELL_SESSION_MODE"); @@ -172,7 +172,7 @@ static void getGnome(const FFinstance* instance, FFDisplayServerResult* result) else ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME); - ffParsePropFileData(instance, "gnome-shell/org.gnome.Extensions", "version :", &result->deVersion); + ffParsePropFileData("gnome-shell/org.gnome.Extensions", "version :", &result->deVersion); if (result->deVersion.length == 0) { @@ -185,14 +185,14 @@ static void getGnome(const FFinstance* instance, FFDisplayServerResult* result) } } -static void getCinnamon(const FFinstance* instance, FFDisplayServerResult* result) +static void getCinnamon(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "cinnamon"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_CINNAMON); - ffParsePropFileData(instance, "applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", &result->deVersion); + ffParsePropFileData("applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", &result->deVersion); } -static void getMate(const FFinstance* instance, FFDisplayServerResult* result) +static void getMate(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "mate-session"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_MATE); @@ -201,7 +201,7 @@ static void getMate(const FFinstance* instance, FFDisplayServerResult* result) FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate(); - ffParsePropFileDataValues(instance, "mate-about/mate-version.xml", 3, (FFpropquery[]) { + ffParsePropFileDataValues("mate-about/mate-version.xml", 3, (FFpropquery[]) { {"", &major}, {"", &minor}, {"", µ} @@ -209,7 +209,7 @@ static void getMate(const FFinstance* instance, FFDisplayServerResult* result) ffParseSemver(&result->deVersion, &major, &minor, µ); - if(result->deVersion.length == 0 && instance->config.allowSlowOperations) + if(result->deVersion.length == 0 && instance.config.allowSlowOperations) { ffProcessAppendStdOut(&result->deVersion, (char* const[]){ "mate-session", @@ -222,13 +222,13 @@ static void getMate(const FFinstance* instance, FFDisplayServerResult* result) } } -static void getXFCE4(const FFinstance* instance, FFDisplayServerResult* result) +static void getXFCE4(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "xfce4-session"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_XFCE4); - ffParsePropFileData(instance, "gtk-doc/html/libxfce4ui/index.html", "

Version", &result->deVersion); + ffParsePropFileData("gtk-doc/html/libxfce4ui/index.html", "

Version", &result->deVersion); - if(result->deVersion.length == 0 && instance->config.allowSlowOperations) + if(result->deVersion.length == 0 && instance.config.allowSlowOperations) { //This is somewhat slow ffProcessAppendStdOut(&result->deVersion, (char* const[]){ @@ -243,18 +243,18 @@ static void getXFCE4(const FFinstance* instance, FFDisplayServerResult* result) } } -static void getLXQt(const FFinstance* instance, FFDisplayServerResult* result) +static void getLXQt(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "lxqt-session"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_LXQT); - ffParsePropFileData(instance, "gconfig/lxqt.pc", "Version:", &result->deVersion); + ffParsePropFileData("gconfig/lxqt.pc", "Version:", &result->deVersion); if(result->deVersion.length == 0) - ffParsePropFileData(instance, "cmake/lxqt/lxqt-config.cmake", "set ( LXQT_VERSION", &result->deVersion); + ffParsePropFileData("cmake/lxqt/lxqt-config.cmake", "set ( LXQT_VERSION", &result->deVersion); if(result->deVersion.length == 0) - ffParsePropFileData(instance, "cmake/lxqt/lxqt-config-version.cmake", "set ( PACKAGE_VERSION", &result->deVersion); + ffParsePropFileData("cmake/lxqt/lxqt-config-version.cmake", "set ( PACKAGE_VERSION", &result->deVersion); - if(result->deVersion.length == 0 && instance->config.allowSlowOperations) + if(result->deVersion.length == 0 && instance.config.allowSlowOperations) { //This is really, really, really slow. Thank you, LXQt developers ffProcessAppendStdOut(&result->deVersion, (char* const[]){ @@ -269,39 +269,39 @@ static void getLXQt(const FFinstance* instance, FFDisplayServerResult* result) FF_STRBUF_AUTO_DESTROY wmProcessNameBuffer = ffStrbufCreate(); - ffParsePropFileConfig(instance, "lxqt/session.conf", "window_manager =", &wmProcessNameBuffer); + ffParsePropFileConfig("lxqt/session.conf", "window_manager =", &wmProcessNameBuffer); applyBetterWM(result, wmProcessNameBuffer.chars); } -static void getBudgie(const FFinstance* instance, FFDisplayServerResult* result) +static void getBudgie(FFDisplayServerResult* result) { ffStrbufSetS(&result->deProcessName, "budgie-desktop"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_BUDGIE); - ffParsePropFileData(instance, "budgie/budgie-version.xml", "", &result->deVersion); + ffParsePropFileData("budgie/budgie-version.xml", "", &result->deVersion); } -static void applyPrettyNameIfDE(const FFinstance* instance, FFDisplayServerResult* result, const char* name) +static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) { if(!ffStrSet(name)) return; else if(strcasestr(name, "plasma") != NULL) - getKDE(instance, result); + getKDE(result); else if( strcasecmp(name, "polkit-gnome") != 0 && strcasecmp(name, "gnome-keyring") != 0 && strcasestr(name, "gnome") != NULL ) - getGnome(instance, result); + getGnome(result); else if(strcasestr(name, "cinnamon") != NULL) - getCinnamon(instance, result); + getCinnamon(result); else if(strcasestr(name, "xfce") != NULL) - getXFCE4(instance, result); + getXFCE4(result); else if(strcasestr(name, "mate") != NULL) - getMate(instance, result); + getMate(result); else if(strcasestr(name, "lxqt") != NULL) - getLXQt(instance, result); + getLXQt(result); else if(strcasestr(name, "budgie") != NULL) - getBudgie(instance, result); + getBudgie(result); } static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) @@ -337,7 +337,7 @@ static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) } } -static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* result) +static void getFromProcDir(FFDisplayServerResult* result) { DIR* proc = opendir("/proc"); if(proc == NULL) @@ -382,7 +382,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re ffStrbufSubstrBefore(&procPath, procPathLength); if(result->dePrettyName.length == 0) - applyPrettyNameIfDE(instance, result, processName.chars); + applyPrettyNameIfDE(result, processName.chars); if(result->wmPrettyName.length == 0) applyNameIfWM(result, processName.chars); @@ -394,7 +394,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re closedir(proc); } -void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsDetectWMDE(FFDisplayServerResult* result) { //If all connections failed, use the environment variables to detect protocol name if(result->wmProtocolName.length == 0) @@ -423,7 +423,7 @@ void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result) //Connecting to a display server only gives WM results, not DE results. //If we find it in the environment, use that. - applyPrettyNameIfDE(instance, result, env); + applyPrettyNameIfDE(result, env); //If WM was found by connection to the sever, and DE in the environment, we can return //This way we never call getFromProcDir(), which has slow initalization time @@ -431,7 +431,7 @@ void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result) return; //Get missing WM / DE from processes. - getFromProcDir(instance, result); + getFromProcDir(result); //Return if both wm and de are set, or if env doesn't contain anything if( diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 8812e1b98..47c5ec851 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -96,9 +96,9 @@ static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connect free(wmName); } -void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXcb(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xcb, &instance->config.libXcb, , "libxcb" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(xcb, &instance.config.libXcb, , "libxcb" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_connect,) FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_get_setup,) FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_setup_roots_iterator,) @@ -142,10 +142,10 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) #else -void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXcb(FFDisplayServerResult* result) { //Do nothing. There are other implementations coming - FF_UNUSED(instance, result) + FF_UNUSED(result) } #endif @@ -383,9 +383,9 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) ); } -void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXcbRandr(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xcbRandr, &instance->config.libXcbRandr, , "libxcb-randr" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(xcbRandr, &instance.config.libXcbRandr, , "libxcb-randr" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_connect,) FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_get_setup,) FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_setup_roots_iterator,) @@ -440,10 +440,10 @@ void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* resu #else -void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXcbRandr(FFDisplayServerResult* result) { //Do nothing. There are other implementations coming - FF_UNUSED(instance, result) + FF_UNUSED(result) } #endif diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 9045a7e53..288763ee6 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -58,9 +58,9 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl data->ffXFree(wmWindow); } -void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXlib(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(x11, &instance->config.libX11, , "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(x11, &instance.config.libX11, , "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL(x11, XOpenDisplay,) FF_LIBRARY_LOAD_SYMBOL(x11, XCloseDisplay,) @@ -99,10 +99,10 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) #else -void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXlib(FFDisplayServerResult* result) { //Do nothing. WM / DE detection will use environment vars to detect as much as possible. - FF_UNUSED(instance, result); + FF_UNUSED(result); } #endif //FF_HAVE_X11 @@ -286,9 +286,9 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) ); } -void ffdsConnectXrandr(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXrandr(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xrandr, &instance->config.libXrandr, , "libXrandr" FF_LIBRARY_EXTENSION, 3) + FF_LIBRARY_LOAD(xrandr, &instance.config.libXrandr, , "libXrandr" FF_LIBRARY_EXTENSION, 3) FF_LIBRARY_LOAD_SYMBOL(xrandr, XOpenDisplay,) FF_LIBRARY_LOAD_SYMBOL(xrandr, XCloseDisplay,) @@ -331,10 +331,10 @@ void ffdsConnectXrandr(const FFinstance* instance, FFDisplayServerResult* result #else -void ffdsConnectXrandr(const FFinstance* instance, FFDisplayServerResult* result) +void ffdsConnectXrandr(FFDisplayServerResult* result) { //Do nothing here. There are more x11 implementaions to come. - FF_UNUSED(instance, result); + FF_UNUSED(result); } #endif // FF_HAVE_XRANDR diff --git a/src/detection/font/font.c b/src/detection/font/font.c index 4455ea45f..6de21cfdf 100644 --- a/src/detection/font/font.c +++ b/src/detection/font/font.c @@ -1,11 +1,11 @@ #include "font.h" #include "detection/internal.h" -const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* font); +const char* ffDetectFontImpl(FFFontResult* font); -const char* ffDetectFont(const FFinstance* instance, FFFontResult* font) +const char* ffDetectFont(FFFontResult* font) { - const char* error = ffDetectFontImpl(instance, font); + const char* error = ffDetectFontImpl(font); if(error) return error; diff --git a/src/detection/font/font.h b/src/detection/font/font.h index 9b7e4e237..22e402652 100644 --- a/src/detection/font/font.h +++ b/src/detection/font/font.h @@ -19,6 +19,6 @@ typedef struct FFFontResult FFstrbuf display; } FFFontResult; -const char* ffDetectFont(const FFinstance* instance, FFFontResult* font); +const char* ffDetectFont(FFFontResult* font); #endif diff --git a/src/detection/font/font_apple.m b/src/detection/font/font_apple.m index 818047a97..9a9888e5f 100644 --- a/src/detection/font/font_apple.m +++ b/src/detection/font/font_apple.m @@ -21,7 +21,7 @@ static void generateString(FFFontResult* font) } } -const char* ffDetectFontImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FFFontResult* result) { ffStrbufAppendS(&result->fonts[0], [NSFont systemFontOfSize:12].familyName.UTF8String); ffStrbufAppendS(&result->fonts[1], [NSFont userFontOfSize:12].familyName.UTF8String); diff --git a/src/detection/font/font_linux.c b/src/detection/font/font_linux.c index 304450c70..7cee52ccd 100644 --- a/src/detection/font/font_linux.c +++ b/src/detection/font/font_linux.c @@ -24,30 +24,30 @@ static void generateString(FFFontResult* font) ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]); } -const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FFFontResult* result) { - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) return "Font isn't supported in TTY"; FFfont qt; - ffFontInitQt(&qt, ffDetectQt(instance)->font.chars); + ffFontInitQt(&qt, ffDetectQt()->font.chars); ffStrbufAppend(&result->fonts[0], &qt.pretty); ffFontDestroy(&qt); FFfont gtk2; - ffFontInitPango(>k2, ffDetectGTK2(instance)->font.chars); + ffFontInitPango(>k2, ffDetectGTK2()->font.chars); ffStrbufAppend(&result->fonts[1], >k2.pretty); ffFontDestroy(>k2); FFfont gtk3; - ffFontInitPango(>k3, ffDetectGTK3(instance)->font.chars); + ffFontInitPango(>k3, ffDetectGTK3()->font.chars); ffStrbufAppend(&result->fonts[2], >k3.pretty); ffFontDestroy(>k3); FFfont gtk4; - ffFontInitPango(>k4, ffDetectGTK4(instance)->font.chars); + ffFontInitPango(>k4, ffDetectGTK4()->font.chars); ffStrbufAppend(&result->fonts[3], >k4.pretty); ffFontDestroy(>k4); diff --git a/src/detection/font/font_nosupport.c b/src/detection/font/font_nosupport.c index c64936584..cce3904ff 100644 --- a/src/detection/font/font_nosupport.c +++ b/src/detection/font/font_nosupport.c @@ -1,8 +1,8 @@ #include "fastfetch.h" #include "font.h" -const char* ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FF_MAYBE_UNUSED FFFontResult* result) { - FF_UNUSED(instance, result); + FF_UNUSED(result); return "Not supported on this platform"; } diff --git a/src/detection/font/font_windows.c b/src/detection/font/font_windows.c index 202aa8b51..46a63f520 100644 --- a/src/detection/font/font_windows.c +++ b/src/detection/font/font_windows.c @@ -23,7 +23,7 @@ static void generateString(FFFontResult* font) ffStrbufAppendC(&font->display, ']'); } -const char* ffDetectFontImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFFontResult* result) +const char* ffDetectFontImpl(FFFontResult* result) { NONCLIENTMETRICSW info = { .cbSize = sizeof(info) }; if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0)) diff --git a/src/detection/gamepad/gamepad.h b/src/detection/gamepad/gamepad.h index 1def1b430..59519bb16 100644 --- a/src/detection/gamepad/gamepad.h +++ b/src/detection/gamepad/gamepad.h @@ -11,6 +11,6 @@ typedef struct FFGamepadDevice FFstrbuf name; } FFGamepadDevice; -const char* ffDetectGamepad(const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */); +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */); #endif diff --git a/src/detection/gamepad/gamepad_apple.c b/src/detection/gamepad/gamepad_apple.c index 154f1c587..b1a8436ca 100644 --- a/src/detection/gamepad/gamepad_apple.c +++ b/src/detection/gamepad/gamepad_apple.c @@ -15,7 +15,7 @@ static void enumSet(const void* value, void *context) ffCfStrGetString(product, &device->name); } -const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */) +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { IOHIDManagerRef FF_CFTYPE_AUTO_RELEASE manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index 49f49bf58..9ede2280b 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -8,7 +8,7 @@ #define MAX_UHID_JOYS 64 -const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */) +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { char path[16]; for (int i = 0; i < MAX_UHID_JOYS; i++) diff --git a/src/detection/gamepad/gamepad_linux.c b/src/detection/gamepad/gamepad_linux.c index 8bbd53939..c68a31d74 100644 --- a/src/detection/gamepad/gamepad_linux.c +++ b/src/detection/gamepad/gamepad_linux.c @@ -5,7 +5,7 @@ #include #include -const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */) +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { DIR* dirp = opendir("/sys/class/input/"); if(dirp == NULL) diff --git a/src/detection/gamepad/gamepad_nosupport.c b/src/detection/gamepad/gamepad_nosupport.c index d921d3552..7c323142a 100644 --- a/src/detection/gamepad/gamepad_nosupport.c +++ b/src/detection/gamepad/gamepad_nosupport.c @@ -1,6 +1,6 @@ #include "gamepad.h" -const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFlist* devices /* List of FFGamepadDevice */) +const char* ffDetectGamepad(FF_MAYBE_UNUSED FFlist* devices /* List of FFGamepadDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/gamepad/gamepad_windows.c b/src/detection/gamepad/gamepad_windows.c index 216bde8e8..e115782aa 100644 --- a/src/detection/gamepad/gamepad_windows.c +++ b/src/detection/gamepad/gamepad_windows.c @@ -87,7 +87,7 @@ static const char* detectKnownGamepad(uint32_t vendorId, uint32_t productId) } } -const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */) +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { UINT nDevices = 0; if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST))) diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index f78eeb433..9300b2484 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -30,14 +30,14 @@ const char* ffGetGPUVendorString(unsigned vendorId) return NULL; } -const char* ffDetectGPU(const FFinstance* instance, const FFGPUOptions* options, FFlist* result) +const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { if (!options->forceVulkan) { - const char* error = ffDetectGPUImpl(instance, options, result); + const char* error = ffDetectGPUImpl(options, result); if (!error) return NULL; } - FFVulkanResult* vulkan = ffDetectVulkan(instance); + FFVulkanResult* vulkan = ffDetectVulkan(); if (vulkan->error) return "GPU detection failed"; ffListDestroy(result); ffListInitMove(result, &vulkan->gpus); diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 444e68f87..c0f5dfaa8 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -33,8 +33,8 @@ typedef struct FFGPUResult uint32_t vulkanDeviceId; // Only used for vulkan } FFGPUResult; -const char* ffDetectGPU(const FFinstance* instance, const FFGPUOptions* options, FFlist* result); -const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus); +const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result); +const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus); const char* ffGetGPUVendorString(unsigned vendorId); diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index cdb8b8f79..00ee7422b 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -38,7 +38,7 @@ static double detectGpuTemp(const FFstrbuf* gpuName) return result; } -const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) +const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { CFMutableDictionaryRef matchDict = IOServiceMatching(kIOAcceleratorClassName); io_iterator_t iterator; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 8b9478e1b..8374e418b 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -44,7 +44,7 @@ static void pciDetectVendorName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA); } -static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) +static void drmDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) { u8 revId = 0; bool revIdSet = false; @@ -65,7 +65,7 @@ static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PC } FF_STRBUF_AUTO_DESTROY query = ffStrbufCreateF("%X, %X,", device->device_id, revId); - ffParsePropFileData(instance, "libdrm/amdgpu.ids", query.chars, &gpu->name); + ffParsePropFileData("libdrm/amdgpu.ids", query.chars, &gpu->name); const char* removeStrings[] = { "AMD ", "ATI ", @@ -75,11 +75,11 @@ static void drmDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PC ffStrbufRemoveStringsA(&gpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); } -static void pciDetectDeviceName(const FFinstance* instance, FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) +static void pciDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) { if(ffStrbufCompS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD) == 0) { - drmDetectDeviceName(instance, gpu, pci, device); + drmDetectDeviceName(gpu, pci, device); if(gpu->name.length > 0) return; } @@ -171,7 +171,7 @@ static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* dev gpu->type = FF_GPU_TYPE_INTEGRATED; } -static void pciHandleDevice(const FFinstance* instance, FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) +static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) { pci->ffpci_fill_info(device, PCI_FILL_CLASS); @@ -196,7 +196,7 @@ static void pciHandleDevice(const FFinstance* instance, FF_MAYBE_UNUSED const FF pciDetectVendorName(gpu, pci, device); ffStrbufInit(&gpu->name); - pciDetectDeviceName(instance, gpu, pci, device); + pciDetectDeviceName(gpu, pci, device); ffStrbufInit(&gpu->driver); pciDetectDriverName(gpu, pci, device); @@ -237,11 +237,11 @@ static void handlePciWarning(FF_MAYBE_UNUSED char *msg, ...) // noop } -static const char* pciDetectGPUs(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) +static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) { PCIData pci; - FF_LIBRARY_LOAD(libpci, &instance->config.libPCI, "dlopen libpci.so failed", "libpci" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD(libpci, &instance.config.libPCI, "dlopen libpci.so failed", "libpci" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libpci, pci_alloc); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libpci, pci_init); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libpci, pci_scan_bus); @@ -270,7 +270,7 @@ static const char* pciDetectGPUs(const FFinstance* instance, const FFGPUOptions* struct pci_dev* device = pci.access->devices; while(device != NULL) { - pciHandleDevice(instance, options, gpus, &pci, device); + pciHandleDevice(options, gpus, &pci, device); device = device->next; } @@ -280,12 +280,12 @@ static const char* pciDetectGPUs(const FFinstance* instance, const FFGPUOptions* #endif -const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) +const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { #ifdef FF_HAVE_LIBPCI - return pciDetectGPUs(instance, options, gpus); + return pciDetectGPUs(options, gpus); #else - FF_UNUSED(instance, options, gpus); + FF_UNUSED(options, gpus); return "fastfetch is built without libpci support"; #endif } diff --git a/src/detection/gpu/gpu_nosupport.c b/src/detection/gpu/gpu_nosupport.c index c32574c56..28daf5fa6 100644 --- a/src/detection/gpu/gpu_nosupport.c +++ b/src/detection/gpu/gpu_nosupport.c @@ -1,7 +1,7 @@ #include "gpu.h" -const char* ffDetectGPUImpl(const FFinstance* instance, const FFGPUOptions* options, FFlist* gpus) +const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { - FF_UNUSED(instance, options, gpus); + FF_UNUSED(options, gpus); return "Not supported on this platform"; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 2866ff5f3..a018bafca 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -4,7 +4,7 @@ #include -const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF_MAYBE_UNUSED FFGPUOptions* options, FFlist* gpus) +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { DISPLAY_DEVICEW displayDevice = {.cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index b611827f4..8c7debe01 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -34,7 +34,7 @@ static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, ffStrbufAppendS(&result->wallpaper, wallpaper); } -static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* result) +static void detectGTKFromSettings(FFGTKResult* result) { static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; @@ -58,36 +58,36 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul init = true; - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_XFCE4) == 0) { - themeName = ffSettingsGetXFConf(instance, "xsettings", "/Net/ThemeName", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGetXFConf(instance, "xsettings", "/Net/IconThemeName", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGetXFConf(instance, "xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGetXFConf("xsettings", "/Net/ThemeName", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGetXFConf("xsettings", "/Net/IconThemeName", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGetXFConf("xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGetXFConf("xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGetXFConf("xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGetXFConf("xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; if (!wallpaper) // FIXME: find a way to enumerate possible properties - wallpaper = ffSettingsGetXFConf(instance, "xfce4-desktop", "/backdrop/screen0/monitoreDP-1/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; + wallpaper = ffSettingsGetXFConf("xfce4-desktop", "/backdrop/screen0/monitoreDP-1/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue; } else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_CINNAMON) == 0) { - 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; - cursorTheme = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/cursor-theme", "org.cinnamon.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/cursor-size", "org.cinnamon.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGet(instance, "/org/cinnamon/desktop/background/picture-uri", "org.cinnamon.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGet("/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGet("/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGet("/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGet("/org/cinnamon/desktop/interface/cursor-theme", "org.cinnamon.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGet("/org/cinnamon/desktop/interface/cursor-size", "org.cinnamon.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGet("/org/cinnamon/desktop/background/picture-uri", "org.cinnamon.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; } else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_MATE) == 0) { - themeName = ffSettingsGet(instance, "/org/mate/interface/gtk-theme", "org.mate.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGet(instance, "/org/mate/interface/icon-theme", "org.mate.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGet(instance, "/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGet(instance, "/org/mate/desktop/background", "org.mate.background", NULL, "picture-filename", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGet("/org/mate/interface/gtk-theme", "org.mate.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGet("/org/mate/interface/icon-theme", "org.mate.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGet("/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGet("/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGet("/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGet("/org/mate/desktop/background", "org.mate.background", NULL, "picture-filename", FF_VARIANT_TYPE_STRING).strValue; } else if( ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_GNOME) == 0 || @@ -95,12 +95,12 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_UNITY) == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_BUDGIE) == 0 ) { - themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; - iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; - fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; - cursorTheme = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; - cursorSize = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; - wallpaper = ffSettingsGet(instance, "/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; + themeName = ffSettingsGet("/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue; + iconsName = ffSettingsGet("/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue; + fontName = ffSettingsGet("/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue; + cursorTheme = ffSettingsGet("/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; + cursorSize = ffSettingsGet("/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; + wallpaper = ffSettingsGet("/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; } ffThreadMutexUnlock(&mutex); @@ -157,18 +157,18 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG ffStrbufSubstrBefore(configDir, configDirLength); } -static void detectGTK(const FFinstance* instance, const char* version, FFGTKResult* result) +static void detectGTK(const char* version, FFGTKResult* result) { //Mate, Cinnamon, Gnome, Unity, Budgie use dconf to save theme config //On other DEs, this will do nothing - detectGTKFromSettings(instance, result); + detectGTKFromSettings(result); if(allPropertiesSet(result)) return; //We need to do this because we use multiple threads on configDirs FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); - FF_LIST_FOR_EACH(FFstrbuf, configDir, instance->state.platform.configDirs) + FF_LIST_FOR_EACH(FFstrbuf, configDir, instance.state.platform.configDirs) { ffStrbufSet(&baseDir, configDir); detectGTKFromConfigDir(&baseDir, version, result); @@ -193,21 +193,21 @@ static void detectGTK(const FFinstance* instance, const char* version, FFGTKResu ffStrbufInit(&result.cursor); \ ffStrbufInit(&result.cursorSize); \ ffStrbufInit(&result.wallpaper); \ - detectGTK(instance, #version, &result); \ + detectGTK(#version, &result); \ ffThreadMutexUnlock(&mutex); \ return &result; -const FFGTKResult* ffDetectGTK2(const FFinstance* instance) +const FFGTKResult* ffDetectGTK2(void) { FF_DETECT_GTK_IMPL(2) } -const FFGTKResult* ffDetectGTK3(const FFinstance* instance) +const FFGTKResult* ffDetectGTK3(void) { FF_DETECT_GTK_IMPL(3) } -const FFGTKResult* ffDetectGTK4(const FFinstance* instance) +const FFGTKResult* ffDetectGTK4(void) { FF_DETECT_GTK_IMPL(4) } diff --git a/src/detection/gtk_qt/gtk_qt.h b/src/detection/gtk_qt/gtk_qt.h index 8a115e5b0..ef329f03a 100644 --- a/src/detection/gtk_qt/gtk_qt.h +++ b/src/detection/gtk_qt/gtk_qt.h @@ -24,9 +24,9 @@ typedef struct FFQtResult FFstrbuf wallpaper; } FFQtResult; -const FFGTKResult* ffDetectGTK2(const FFinstance* instance); -const FFGTKResult* ffDetectGTK4(const FFinstance* instance); -const FFGTKResult* ffDetectGTK3(const FFinstance* instance); -const FFQtResult* ffDetectQt(const FFinstance* instance); +const FFGTKResult* ffDetectGTK2(void); +const FFGTKResult* ffDetectGTK4(void); +const FFGTKResult* ffDetectGTK3(void); +const FFQtResult* ffDetectQt(void); #endif diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 7955be14c..71b0536c7 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -81,14 +81,14 @@ static bool detectPlasmaFromFile(const char* filename, FFQtResult* result) return true; } -static void detectPlasma(const FFinstance* instance, FFQtResult* result) +static void detectPlasma(FFQtResult* result) { bool foundAFile = false; //We need to do this because we use multiple threads on configDirs FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); - FF_LIST_FOR_EACH(FFstrbuf, configDir, instance->state.platform.configDirs) + FF_LIST_FOR_EACH(FFstrbuf, configDir, instance.state.platform.configDirs) { ffStrbufSet(&baseDir, configDir); ffStrbufAppendS(&baseDir, "kdeglobals"); @@ -123,18 +123,18 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result) ffStrbufAppendS(&result->font, "Noto Sans, 10"); } -static void detectLXQt(const FFinstance* instance, FFQtResult* result) +static void detectLXQt(FFQtResult* result) { - ffParsePropFileConfigValues(instance, "lxqt/lxqt.conf", 3, (FFpropquery[]) { + ffParsePropFileConfigValues("lxqt/lxqt.conf", 3, (FFpropquery[]) { {"style = ", &result->widgetStyle}, {"icon_theme = ", &result->icons}, {"font = ", &result->font} }); - ffParsePropFileConfig(instance, "pcmanfm-qt/lxqt/settings.conf", "Wallpaper=", &result->wallpaper); + ffParsePropFileConfig("pcmanfm-qt/lxqt/settings.conf", "Wallpaper=", &result->wallpaper); } -const FFQtResult* ffDetectQt(const FFinstance* instance) +const FFQtResult* ffDetectQt(void) { static FFQtResult result; @@ -154,12 +154,12 @@ const FFQtResult* ffDetectQt(const FFinstance* instance) ffStrbufInit(&result.font); ffStrbufInit(&result.wallpaper); - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA) == 0) - detectPlasma(instance, &result); + detectPlasma(&result); else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT) == 0) - detectLXQt(instance, &result); + detectLXQt(&result); ffThreadMutexUnlock(&mutex); return &result; diff --git a/src/detection/icons/icons.h b/src/detection/icons/icons.h index 4f948cdad..744dc3f5f 100644 --- a/src/detection/icons/icons.h +++ b/src/detection/icons/icons.h @@ -5,6 +5,6 @@ #include "fastfetch.h" -const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result); +const char* ffDetectIcons(FFstrbuf* result); #endif diff --git a/src/detection/icons/icons_linux.c b/src/detection/icons/icons_linux.c index 5246950db..357cfadb6 100644 --- a/src/detection/icons/icons_linux.c +++ b/src/detection/icons/icons_linux.c @@ -3,17 +3,17 @@ #include "detection/gtk_qt/gtk_qt.h" #include "detection/displayserver/displayserver.h" -const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result) +const char* ffDetectIcons(FFstrbuf* result) { - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) return "Icons aren't supported in TTY"; - const FFstrbuf* plasma = &ffDetectQt(instance)->icons; - const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons; - const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons; - const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons; + const FFstrbuf* plasma = &ffDetectQt()->icons; + const FFstrbuf* gtk2 = &ffDetectGTK2()->icons; + const FFstrbuf* gtk3 = &ffDetectGTK3()->icons; + const FFstrbuf* gtk4 = &ffDetectGTK4()->icons; if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) return "No icons could be found"; diff --git a/src/detection/icons/icons_nosupport.c b/src/detection/icons/icons_nosupport.c index 9a47a0183..f0a0ebe8c 100644 --- a/src/detection/icons/icons_nosupport.c +++ b/src/detection/icons/icons_nosupport.c @@ -1,6 +1,6 @@ #include "icons.h" -const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result) +const char* ffDetectIcons(FF_MAYBE_UNUSED FFstrbuf* result) { return "Not supported on this platform"; } diff --git a/src/detection/icons/icons_windows.c b/src/detection/icons/icons_windows.c index 881589bc1..0008d04af 100644 --- a/src/detection/icons/icons_windows.c +++ b/src/detection/icons/icons_windows.c @@ -1,7 +1,7 @@ #include "icons.h" #include "util/windows/registry.h" -const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result) +const char* ffDetectIcons(FFstrbuf* result) { FF_HKEY_AUTO_DESTROY hKey = NULL; if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, NULL)) diff --git a/src/detection/media/media.c b/src/detection/media/media.c index 7bb38d0e5..50604342b 100644 --- a/src/detection/media/media.c +++ b/src/detection/media/media.c @@ -1,9 +1,9 @@ #include "media.h" #include "detection/internal.h" -void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media); +void ffDetectMediaImpl(FFMediaResult* media); -const FFMediaResult* ffDetectMedia(const FFinstance* instance) +const FFMediaResult* ffDetectMedia(void) { FF_DETECTION_INTERNAL_GUARD(FFMediaResult, ffStrbufInit(&result.error); @@ -15,7 +15,7 @@ const FFMediaResult* ffDetectMedia(const FFinstance* instance) ffStrbufInit(&result.url); ffStrbufInit(&result.status); - ffDetectMediaImpl(instance, &result); + ffDetectMediaImpl(&result); if(result.song.length == 0 && result.error.length == 0) ffStrbufAppendS(&result.error, "No media found"); diff --git a/src/detection/media/media.h b/src/detection/media/media.h index f82fa4359..8043e0d93 100644 --- a/src/detection/media/media.h +++ b/src/detection/media/media.h @@ -17,6 +17,6 @@ typedef struct FFMediaResult FFstrbuf status; } FFMediaResult; -const FFMediaResult* ffDetectMedia(const FFinstance* instance); +const FFMediaResult* ffDetectMedia(); #endif diff --git a/src/detection/media/media_apple.m b/src/detection/media/media_apple.m index 3e4bf3d75..741301273 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -77,7 +77,7 @@ static const char* getMedia(FFMediaResult* result) return error; } -void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media) +void ffDetectMediaImpl(FFMediaResult* media) { FF_UNUSED(instance) const char* error = getMedia(media); diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 9eb92bf73..2552fdab2 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -152,17 +152,17 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) data->lib->ffdbus_message_unref(reply); } -static const char* getMedia(const FFinstance* instance, FFMediaResult* result) +static const char* getMedia(FFMediaResult* result) { FFDBusData data; - const char* error = ffDBusLoadData(instance, DBUS_BUS_SESSION, &data); + const char* error = ffDBusLoadData(DBUS_BUS_SESSION, &data); if(error != NULL) return error; // FIXME: This is shared for both player and media module. // However it uses an option in one specific module - if(instance->config.playerName.length > 0) - getCustomBus(&data, &instance->config.playerName, result); + if(instance.config.playerName.length > 0) + getCustomBus(&data, &instance.config.playerName, result); else getBestBus(&data, result); @@ -171,13 +171,12 @@ static const char* getMedia(const FFinstance* instance, FFMediaResult* result) #endif -void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media) +void ffDetectMediaImpl(FFMediaResult* media) { #ifdef FF_HAVE_DBUS - const char* error = getMedia(instance, media); + const char* error = getMedia(media); ffStrbufAppendS(&media->error, error); #else - FF_UNUSED(instance); ffStrbufAppendS(&media->error, "Fastfetch was compiled without DBus support"); #endif } diff --git a/src/detection/media/media_nosupport.c b/src/detection/media/media_nosupport.c index e3d038186..b0c19a652 100644 --- a/src/detection/media/media_nosupport.c +++ b/src/detection/media/media_nosupport.c @@ -1,7 +1,6 @@ #include "media.h" -void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media) +void ffDetectMediaImpl(FFMediaResult* media) { - FF_UNUSED(instance); ffStrbufAppendS(&media->error, "Not supported on this platform"); } diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 2e5949af9..d8cb4a66b 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -63,13 +63,13 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) #endif // defined(FF_HAVE_OPENCL) || defined(__APPLE__) -const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result) +const char* ffDetectOpenCL(FFOpenCLResult* result) { #ifdef FF_HAVE_OPENCL OpenCLData data; - FF_LIBRARY_LOAD(opencl, &instance->config.libOpenCL, "dlopen libOpenCL"FF_LIBRARY_EXTENSION" failed", + FF_LIBRARY_LOAD(opencl, &instance.config.libOpenCL, "dlopen libOpenCL"FF_LIBRARY_EXTENSION" failed", #ifdef _WIN32 "OpenCL"FF_LIBRARY_EXTENSION, -1, #endif @@ -83,8 +83,6 @@ const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result) #elif defined(__APPLE__) // FF_HAVE_OPENCL - FF_UNUSED(instance); - OpenCLData data; data.ffclGetPlatformIDs = clGetPlatformIDs; data.ffclGetDeviceIDs = clGetDeviceIDs; @@ -94,7 +92,7 @@ const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result) #else - FF_UNUSED(instance, result); + FF_UNUSED(result); return "Fastfetch was build without OpenCL support"; #endif // FF_HAVE_OPENCL diff --git a/src/detection/opencl/opencl.h b/src/detection/opencl/opencl.h index 93cceecc8..56a96c98f 100644 --- a/src/detection/opencl/opencl.h +++ b/src/detection/opencl/opencl.h @@ -12,6 +12,6 @@ typedef struct FFOpenCLResult FFstrbuf vendor; } FFOpenCLResult; -const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result); +const char* ffDetectOpenCL(FFOpenCLResult* result); #endif diff --git a/src/detection/opengl/opengl.h b/src/detection/opengl/opengl.h index 206347184..b4426856b 100644 --- a/src/detection/opengl/opengl.h +++ b/src/detection/opengl/opengl.h @@ -13,6 +13,6 @@ typedef struct FFOpenGLResult FFstrbuf slv; } FFOpenGLResult; -const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result); +const char* ffDetectOpenGL(FFOpenGLResult* result); #endif diff --git a/src/detection/opengl/opengl_apple.c b/src/detection/opengl/opengl_apple.c index 4ccbb5fe6..b6f4fe257 100644 --- a/src/detection/opengl/opengl_apple.c +++ b/src/detection/opengl/opengl_apple.c @@ -35,10 +35,8 @@ static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatOb return error; } -const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) +const char* ffDetectOpenGL(FFOpenGLResult* result) { - FF_UNUSED(instance); - CGLPixelFormatObj pixelFormat; CGLPixelFormatAttribute attrs[] = { kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core, diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 9a4f42bec..43378be63 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -118,11 +118,11 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data) return error; } -static const char* eglPrint(FFinstance* instance, FFOpenGLResult* result) +static const char* eglPrint(FFOpenGLResult* result) { EGLData eglData; - FF_LIBRARY_LOAD(egl, &instance->config.libEGL, "dlopen egl failed", "libEGL" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(egl, &instance.config.libEGL, "dlopen egl failed", "libEGL" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetDisplay); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglInitialize); @@ -235,11 +235,11 @@ static const char* glxHandleData(FFOpenGLResult* result, GLXData* data) return error; } -static const char* glxPrint(FFinstance* instance, FFOpenGLResult* result) +static const char* glxPrint(FFOpenGLResult* result) { GLXData data; - FF_LIBRARY_LOAD(glx, &instance->config.libGLX, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(glx, &instance.config.libGLX, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XOpenDisplay); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXChooseVisual); @@ -299,11 +299,11 @@ static const char* osMesaHandleData(FFOpenGLResult* result, OSMesaData* data) return error; } -static const char* osMesaPrint(FFinstance* instance, FFOpenGLResult* result) +static const char* osMesaPrint(FFOpenGLResult* result) { OSMesaData data; - FF_LIBRARY_LOAD(osmesa, &instance->config.libOSMesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8); + FF_LIBRARY_LOAD(osmesa, &instance.config.libOSMesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaCreateContext); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaMakeCurrent); @@ -314,32 +314,32 @@ static const char* osMesaPrint(FFinstance* instance, FFOpenGLResult* result) #endif //FF_HAVE_OSMESA -const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) +const char* ffDetectOpenGL(FFOpenGLResult* result) { #if FF_HAVE_GL - if(instance->config.openGL.library == FF_OPENGL_LIBRARY_GLX) + if(instance.config.openGL.library == FF_OPENGL_LIBRARY_GLX) { #ifdef FF_HAVE_GLX - return glxPrint(instance, result); + return glxPrint(result); #else return "fastfetch was compiled without glx support"; #endif } - if(instance->config.openGL.library == FF_OPENGL_LIBRARY_EGL) + if(instance.config.openGL.library == FF_OPENGL_LIBRARY_EGL) { #ifdef FF_HAVE_EGL - return eglPrint(instance, result); + return eglPrint(result); #else return "fastfetch was compiled without egl support"; #endif } - if(instance->config.openGL.library == FF_OPENGL_LIBRARY_OSMESA) + if(instance.config.openGL.library == FF_OPENGL_LIBRARY_OSMESA) { #ifdef FF_HAVE_OSMESA - return osMesaPrint(instance, result); + return osMesaPrint(result); #else return "fastfetch was compiled without osmesa support"; #endif @@ -348,12 +348,12 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) const char* error = ""; // not NULL dummy value #ifdef FF_HAVE_EGL - error = eglPrint(instance, result); + error = eglPrint(result); #endif #ifdef FF_HAVE_GLX if(error != NULL) - error = glxPrint(instance, result); + error = glxPrint(result); #endif //We don't use osmesa in auto mode here, because it is a software implementation, @@ -363,7 +363,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #else - FF_UNUSED(instance, result); + FF_UNUSED(result); return "Fastfetch was built without gl support."; #endif //FF_HAVE_GL diff --git a/src/detection/opengl/opengl_windows.c b/src/detection/opengl/opengl_windows.c index a3865e550..11d608db5 100644 --- a/src/detection/opengl/opengl_windows.c +++ b/src/detection/opengl/opengl_windows.c @@ -82,10 +82,8 @@ LRESULT CALLBACK wglHandleWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM } } -const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) +const char* ffDetectOpenGL(FFOpenGLResult* result) { - FF_UNUSED(instance); - MSG msg = {0}; WNDCLASSW wc = { .lpfnWndProc = wglHandleWndProc, diff --git a/src/detection/os/os.c b/src/detection/os/os.c index dee22a566..c09935954 100644 --- a/src/detection/os/os.c +++ b/src/detection/os/os.c @@ -1,11 +1,11 @@ #include "os.h" #include "detection/internal.h" -void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance); +void ffDetectOSImpl(FFOSResult* os); -const FFOSResult* ffDetectOS(const FFinstance* instance) +const FFOSResult* ffDetectOS(void) { FF_DETECTION_INTERNAL_GUARD(FFOSResult, - ffDetectOSImpl(&result, instance) + ffDetectOSImpl(&result) ); } diff --git a/src/detection/os/os.h b/src/detection/os/os.h index 80fb6b2af..87af406a9 100644 --- a/src/detection/os/os.h +++ b/src/detection/os/os.h @@ -19,6 +19,6 @@ typedef struct FFOSResult FFstrbuf buildID; } FFOSResult; -const FFOSResult* ffDetectOS(const FFinstance* instance); +const FFOSResult* ffDetectOS(); #endif diff --git a/src/detection/os/os_android.c b/src/detection/os/os_android.c index 890486ab7..18b491283 100644 --- a/src/detection/os/os_android.c +++ b/src/detection/os/os_android.c @@ -1,10 +1,8 @@ #include "os.h" #include "common/settings.h" -void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) +void ffDetectOSImpl(FFOSResult* os) { - FF_UNUSED(instance); - ffStrbufInitS(&os->name, "Android"); ffStrbufInitS(&os->prettyName, "Android"); diff --git a/src/detection/os/os_apple.m b/src/detection/os/os_apple.m index dac09ddcd..98e639bad 100644 --- a/src/detection/os/os_apple.m +++ b/src/detection/os/os_apple.m @@ -96,10 +96,8 @@ static void parseOSXSoftwareLicense(FFOSResult* os) fclose(rtf); } -void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) +void ffDetectOSImpl(FFOSResult* os) { - FF_UNUSED(instance); - ffStrbufInit(&os->name); ffStrbufInit(&os->version); ffStrbufInit(&os->buildID); diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 063e8455b..eb37a5bad 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -94,15 +94,15 @@ static void getUbuntuFlavour(FFOSResult* result) } } -static void detectOS(FFOSResult* os, const FFinstance* instance) +static void detectOS(FFOSResult* os) { - if(instance->config.osFile.length > 0) + if(instance.config.osFile.length > 0) { - parseFile(instance->config.osFile.chars, os); + parseFile(instance.config.osFile.chars, os); return; } - if(instance->config.escapeBedrock && parseFile(FASTFETCH_TARGET_DIR_ROOT"/bedrock"FASTFETCH_TARGET_DIR_ETC"/bedrock-release", os)) + if(instance.config.escapeBedrock && parseFile(FASTFETCH_TARGET_DIR_ROOT"/bedrock"FASTFETCH_TARGET_DIR_ETC"/bedrock-release", os)) { if(os->id.length == 0) ffStrbufAppendS(&os->id, "bedrock"); @@ -127,7 +127,7 @@ static void detectOS(FFOSResult* os, const FFinstance* instance) parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os); } -void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) +void ffDetectOSImpl(FFOSResult* os) { ffStrbufInit(&os->name); ffStrbufInit(&os->prettyName); @@ -140,7 +140,7 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) ffStrbufInit(&os->codename); ffStrbufInit(&os->buildID); - detectOS(os, instance); + detectOS(os); if(ffStrbufIgnCaseCompS(&os->id, "ubuntu") == 0) getUbuntuFlavour(os); diff --git a/src/detection/os/os_windows.cpp b/src/detection/os/os_windows.cpp index aa25e90ae..addb61f17 100644 --- a/src/detection/os/os_windows.cpp +++ b/src/detection/os/os_windows.cpp @@ -44,10 +44,8 @@ static const char* getOsNameByWinbrand(FFstrbuf* osName) } extern "C" -void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance) +void ffDetectOSImpl(FFOSResult* os) { - FF_UNUSED(instance); - ffStrbufInit(&os->name); ffStrbufInit(&os->prettyName); ffStrbufInit(&os->id); diff --git a/src/detection/packages/packages.c b/src/detection/packages/packages.c index b820be2ba..ce7c778c3 100644 --- a/src/detection/packages/packages.c +++ b/src/detection/packages/packages.c @@ -3,11 +3,11 @@ #include -void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result); +void ffDetectPackagesImpl(FFPackagesResult* result); -const char* ffDetectPackages(const FFinstance* instance, FFPackagesResult* result) +const char* ffDetectPackages(FFPackagesResult* result) { - ffDetectPackagesImpl(instance, result); + ffDetectPackagesImpl(result); for(uint32_t i = 0; i < offsetof(FFPackagesResult, all) / sizeof(uint32_t); ++i) result->all += ((uint32_t *)result)[i]; diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index 1a83645e9..ef1cf1d4f 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -32,6 +32,6 @@ typedef struct FFPackagesResult FFstrbuf pacmanBranch; } FFPackagesResult; -const char* ffDetectPackages(const FFinstance* instance, FFPackagesResult* result); +const char* ffDetectPackages(FFPackagesResult* result); #endif diff --git a/src/detection/packages/packages_apple.c b/src/detection/packages/packages_apple.c index 0f7ab36e0..97e858fbe 100644 --- a/src/detection/packages/packages_apple.c +++ b/src/detection/packages/packages_apple.c @@ -68,9 +68,8 @@ static uint32_t getMacPortsPackages() return countMacPortsPackages(FASTFETCH_TARGET_DIR_ROOT"/opt/local"); } -void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result) +void ffDetectPackagesImpl(FFPackagesResult* result) { - FF_UNUSED(instance); getBrewPackages(result); result->port = getMacPortsPackages(); } diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 3fc5c9816..d67a05a74 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -74,11 +74,11 @@ static uint32_t getNumStrings(FFstrbuf* baseDir, const char* filename, const cha return num_elements; } -static uint32_t getSQLite3Int(const FFinstance* instance, FFstrbuf* baseDir, const char* dbPath, const char* query) +static uint32_t getSQLite3Int(FFstrbuf* baseDir, const char* dbPath, const char* query) { uint32_t baseDirLength = baseDir->length; ffStrbufAppendS(baseDir, dbPath); - uint32_t num_elements = (uint32_t) ffSettingsGetSQLite3Int(instance, baseDir->chars, query); + uint32_t num_elements = (uint32_t) ffSettingsGetSQLite3Int(baseDir->chars, query); ffStrbufSubstrBefore(baseDir, baseDirLength); return num_elements; } @@ -221,9 +221,9 @@ static uint32_t getFlatpak(FFstrbuf* baseDir, const char* dirname) #include #include -static uint32_t getRpmFromLibrpm(const FFinstance* instance) +static uint32_t getRpmFromLibrpm(void) { - FF_LIBRARY_LOAD(rpm, &instance->config.librpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12) + FF_LIBRARY_LOAD(rpm, &instance.config.librpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmReadConfigFiles, 0) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsCreate, 0) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsInitIterator, 0) @@ -259,7 +259,7 @@ static uint32_t getRpmFromLibrpm(const FFinstance* instance) #endif //FF_HAVE_RPM -static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, FFPackagesResult* packageCounts) +static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts) { packageCounts->apk += getNumStrings(baseDir, "/lib/apk/db/installed", "C:Q"); packageCounts->dpkg += getNumStrings(baseDir, "/var/lib/dpkg/status", "Status: "); @@ -269,17 +269,17 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, FFPa packageCounts->nixDefault += getNixPackages(baseDir, "/nix/var/nix/profiles/default"); packageCounts->nixSystem += getNixPackages(baseDir, "/run/current-system"); packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", DT_DIR); - packageCounts->pkg += getSQLite3Int(instance, baseDir, "/var/db/pkg/local.sqlite", "SELECT count(id) FROM packages"); - packageCounts->rpm += getSQLite3Int(instance, baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(blob) FROM Packages"); + packageCounts->pkg += getSQLite3Int(baseDir, "/var/db/pkg/local.sqlite", "SELECT count(id) FROM packages"); + packageCounts->rpm += getSQLite3Int(baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(blob) FROM Packages"); packageCounts->snap += getSnap(baseDir); packageCounts->xbps += getXBPS(baseDir, "/var/db/xbps"); packageCounts->brewCask += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Caskroom", DT_DIR); packageCounts->brew += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Cellar", DT_DIR); } -static void getPackageCountsRegular(const FFinstance* instance, FFstrbuf* baseDir, FFPackagesResult* packageCounts) +static void getPackageCountsRegular(FFstrbuf* baseDir, FFPackagesResult* packageCounts) { - getPackageCounts(instance, baseDir, packageCounts); + getPackageCounts(baseDir, packageCounts); uint32_t baseDirLength = baseDir->length; ffStrbufAppendS(baseDir, FASTFETCH_TARGET_DIR_ETC"/pacman-mirrors.conf"); @@ -288,7 +288,7 @@ static void getPackageCountsRegular(const FFinstance* instance, FFstrbuf* baseDi ffStrbufSubstrBefore(baseDir, baseDirLength); } -static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDir, FFPackagesResult* packageCounts) +static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* packageCounts) { uint32_t baseDirLength = baseDir->length; @@ -313,7 +313,7 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi continue; ffStrbufAppendS(baseDir, entry->d_name); - getPackageCounts(instance, baseDir, packageCounts); + getPackageCounts(baseDir, packageCounts); ffStrbufSubstrBefore(baseDir, baseDirLength2); } @@ -321,25 +321,25 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi ffStrbufSubstrBefore(baseDir, baseDirLength); } -void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result) +void ffDetectPackagesImpl(FFPackagesResult* result) { FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(512); ffStrbufAppendS(&baseDir, FASTFETCH_TARGET_DIR_ROOT); - if(ffStrbufIgnCaseEqualS(&ffDetectOS(instance)->id, "bedrock")) - getPackageCountsBedrock(instance, &baseDir, result); + if(ffStrbufIgnCaseEqualS(&ffDetectOS()->id, "bedrock")) + getPackageCountsBedrock(&baseDir, result); else - getPackageCountsRegular(instance, &baseDir, result); + getPackageCountsRegular(&baseDir, result); // If SQL failed, we can still try with librpm. // This is needed on openSUSE, which seems to use a proprietary database file // This method doesn't work on bedrock, so we do it here. #ifdef FF_HAVE_RPM if(result->rpm == 0) - result->rpm = getRpmFromLibrpm(instance); + result->rpm = getRpmFromLibrpm(); #endif - ffStrbufSet(&baseDir, &instance->state.platform.homeDir); + ffStrbufSet(&baseDir, &instance.state.platform.homeDir); result->nixUser = getNixPackages(&baseDir, "/.nix-profile"); result->flatpakUser = getFlatpak(&baseDir, "/.local/share/flatpak"); } diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index 30870ce5d..5b5343f79 100644 --- a/src/detection/packages/packages_windows.c +++ b/src/detection/packages/packages_windows.c @@ -32,7 +32,7 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix * return counter; } -static void detectScoop(const FFinstance* instance, FFPackagesResult* result) +static void detectScoop(FFPackagesResult* result) { FF_STRBUF_AUTO_DESTROY scoopPath = ffStrbufCreateA(MAX_PATH + 3); @@ -44,13 +44,13 @@ static void detectScoop(const FFinstance* instance, FFPackagesResult* result) } else { - ffStrbufAppendS(&scoopPath, instance->state.platform.homeDir.chars); + ffStrbufAppendS(&scoopPath, instance.state.platform.homeDir.chars); ffStrbufAppendS(&scoopPath, "/scoop/apps/*"); } result->scoop = getNumElements(scoopPath.chars, FILE_ATTRIBUTE_DIRECTORY, "scoop"); } -static void detectChoco(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result) +static void detectChoco(FF_MAYBE_UNUSED FFPackagesResult* result) { const char* chocoInstall = getenv("ChocolateyInstall"); if(!chocoInstall || chocoInstall[0] == '\0') @@ -62,7 +62,7 @@ static void detectChoco(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesRe result->choco = getNumElements(chocoPath, FILE_ATTRIBUTE_DIRECTORY, "choco"); } -static void detectPacman(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesResult* result) +static void detectPacman(FF_MAYBE_UNUSED FFPackagesResult* result) { const char* msystemPrefix = getenv("MSYSTEM_PREFIX"); if(!msystemPrefix) @@ -75,9 +75,9 @@ static void detectPacman(FF_MAYBE_UNUSED const FFinstance* instance, FFPackagesR result->pacman = getNumElements(pacmanPath, FILE_ATTRIBUTE_DIRECTORY, NULL); } -void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result) +void ffDetectPackagesImpl(FFPackagesResult* result) { - detectScoop(instance, result); - detectChoco(instance, result); - detectPacman(instance, result); + detectScoop(result); + detectChoco(result); + detectPacman(result); } diff --git a/src/detection/poweradapter/poweradapter.h b/src/detection/poweradapter/poweradapter.h index 1b9abd513..9abdd48ec 100644 --- a/src/detection/poweradapter/poweradapter.h +++ b/src/detection/poweradapter/poweradapter.h @@ -14,7 +14,7 @@ typedef struct PowerAdapterResult int watts; } PowerAdapterResult; -const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results); +const char* ffDetectPowerAdapterImpl(FFlist* results); #define FF_POWERADAPTER_UNSET -2 #define FF_POWERADAPTER_NOT_CONNECTED -1 diff --git a/src/detection/poweradapter/poweradapter_apple.c b/src/detection/poweradapter/poweradapter_apple.c index 9c550d95d..de3025a40 100644 --- a/src/detection/poweradapter/poweradapter_apple.c +++ b/src/detection/poweradapter/poweradapter_apple.c @@ -4,10 +4,8 @@ #include -const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results) +const char* ffDetectPowerAdapterImpl(FFlist* results) { - FF_UNUSED(instance); - CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery"); if (matchDict == NULL) return "IOServiceMatching(\"AppleSmartBattery\") failed"; diff --git a/src/detection/poweradapter/poweradapter_nosupport.c b/src/detection/poweradapter/poweradapter_nosupport.c index cf6d1c841..80730810d 100644 --- a/src/detection/poweradapter/poweradapter_nosupport.c +++ b/src/detection/poweradapter/poweradapter_nosupport.c @@ -1,7 +1,7 @@ #include "fastfetch.h" -const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results) +const char* ffDetectPowerAdapterImpl(FFlist* results) { - FF_UNUSED(instance, results); + FF_UNUSED(results); return "Not supported on this platform"; } diff --git a/src/detection/sound/sound.h b/src/detection/sound/sound.h index 7603110f6..350a4f3e6 100644 --- a/src/detection/sound/sound.h +++ b/src/detection/sound/sound.h @@ -16,6 +16,6 @@ typedef struct FFSoundDevice bool active; } FFSoundDevice; -const char* ffDetectSound(const FFinstance* instance, FFlist* devices /* List of FFSoundDevice */); +const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */); #endif diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index 862ee523a..8f23f2a3a 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -8,7 +8,7 @@ #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster #endif -const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFSoundDevice */) +const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { AudioDeviceID mainDeviceId; UInt32 dataSize = sizeof(mainDeviceId); diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index bba07c13b..8f14ab49e 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -36,9 +36,9 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u } } -static const char* detectSound(const FFinstance* instance, FFlist* devices) +static const char* detectSound(FFlist* devices) { - FF_LIBRARY_LOAD(pulse, &instance->config.libPulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0) + FF_LIBRARY_LOAD(pulse, &instance.config.libPulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_new) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_get_api) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_iterate) @@ -119,12 +119,12 @@ static const char* detectSound(const FFinstance* instance, FFlist* devices) #endif // FF_HAVE_PULSE -const char* ffDetectSound(const FFinstance* instance, FFlist* devices) +const char* ffDetectSound(FFlist* devices) { #ifdef FF_HAVE_PULSE - return detectSound(instance, devices); + return detectSound(devices); #else - FF_UNUSED(instance, devices); + FF_UNUSED(devices); return "Fastfetch was built without libpulse support"; #endif } diff --git a/src/detection/sound/sound_nosupport.c b/src/detection/sound/sound_nosupport.c index 8f8014341..7b23b2fa4 100644 --- a/src/detection/sound/sound_nosupport.c +++ b/src/detection/sound/sound_nosupport.c @@ -1,6 +1,6 @@ #include "sound.h" -const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) +const char* ffDetectSound(FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index faa7328f4..6990615ab 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -9,7 +9,7 @@ extern "C" { #include #include -const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) +const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { const char* error = ffInitCom(); if (error) diff --git a/src/detection/temps/temps_linux.c b/src/detection/temps/temps_linux.c index 55506c384..ee30a85c4 100644 --- a/src/detection/temps/temps_linux.c +++ b/src/detection/temps/temps_linux.c @@ -41,7 +41,7 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value) return value->name.length > 0 || value->deviceClass > 0; } -const FFTempsResult* ffDetectTemps() +const FFTempsResult* ffDetectTemps(void) { static FFTempsResult result; static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 46c390955..58320d223 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -4,7 +4,7 @@ #include "detection/internal.h" #include "detection/terminalshell/terminalshell.h" -static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectAlacritty(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); @@ -15,11 +15,11 @@ static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* te }; // alacritty parses config files in this order - ffParsePropFileConfigValues(instance, "alacritty/alacritty.yml", 2, fontQuery); + ffParsePropFileConfigValues("alacritty/alacritty.yml", 2, fontQuery); if(fontName.length == 0 || fontSize.length == 0) - ffParsePropFileConfigValues(instance, "alacritty.yml", 2, fontQuery); + ffParsePropFileConfigValues("alacritty.yml", 2, fontQuery); if(fontName.length == 0 || fontSize.length == 0) - ffParsePropFileConfigValues(instance, ".alacritty.yml", 2, fontQuery); + ffParsePropFileConfigValues(".alacritty.yml", 2, fontQuery); //by default alacritty uses its own font called alacritty if(fontName.length == 0) @@ -238,7 +238,7 @@ static void detectFromWindowsTeriminal(const FFstrbuf* terminalExe, FFTerminalFo #endif //defined(_WIN32) || defined(__linux__) -FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result) +FF_MAYBE_UNUSED static bool detectKitty(FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); @@ -248,7 +248,7 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFo {"font_size ", &fontSize}, }; - if(!ffParsePropFileConfigValues(instance, "kitty/kitty.conf", 2, fontQuery)) + if(!ffParsePropFileConfigValues("kitty/kitty.conf", 2, fontQuery)) return false; if(fontName.length == 0) @@ -261,7 +261,7 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFo return true; } -static void detectTerminator(const FFinstance* instance, FFTerminalFontResult* result) +static void detectTerminator(FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); @@ -271,7 +271,7 @@ static void detectTerminator(const FFinstance* instance, FFTerminalFontResult* r {"font =", &fontName}, }; - if(!ffParsePropFileConfigValues(instance, "terminator/config", 2, fontQuery)) + if(!ffParsePropFileConfigValues("terminator/config", 2, fontQuery)) { ffStrbufAppendS(&result->error, "Couldn't read Terminator config file"); return; @@ -289,7 +289,7 @@ static void detectTerminator(const FFinstance* instance, FFTerminalFontResult* r ffFontInitPango(&result->font, fontName.chars); } -static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result) +static bool detectWezterm(FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); @@ -316,7 +316,7 @@ static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminal return true; } -static bool detectTabby(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result) +static bool detectTabby(FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); @@ -326,7 +326,7 @@ static bool detectTabby(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFo {"fontSize: ", &fontSize}, }; - if(!ffParsePropFileConfigValues(instance, "tabby/config.yaml", 2, fontQuery)) + if(!ffParsePropFileConfigValues("tabby/config.yaml", 2, fontQuery)) return false; if(fontName.length == 0) @@ -339,24 +339,24 @@ static bool detectTabby(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFo return true; } -void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont); +void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont); -static bool detectTerminalFontCommon(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) +static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "alacritty")) - detectAlacritty(instance, terminalFont); + detectAlacritty(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "terminator")) - detectTerminator(instance, terminalFont); + detectTerminator(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "wezterm-gui")) - detectWezterm(instance, terminalFont); + detectWezterm(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "tabby")) - detectTabby(instance, terminalFont); + detectTabby(terminalFont); #ifndef _WIN32 else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/")) ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS"); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty")) - detectKitty(instance, terminalFont); + detectKitty(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); #endif @@ -374,15 +374,15 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina return true; } -bool ffDetectTerminalFont(const FFinstance* instance, FFTerminalFontResult* result) +bool ffDetectTerminalFont(FFTerminalFontResult* result) { - const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance); + const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(); if(terminalShell->terminalProcessName.length == 0) ffStrbufAppendS(&result->error, "Terminal font needs successful terminal detection"); - else if(!detectTerminalFontCommon(instance, terminalShell, result)) - ffDetectTerminalFontPlatform(instance, terminalShell, result); + else if(!detectTerminalFontCommon(terminalShell, result)) + ffDetectTerminalFontPlatform(terminalShell, result); if(result->error.length == 0 && result->font.pretty.length == 0) ffStrbufAppendF(&result->error, "Unknown terminal: %s", terminalShell->terminalProcessName.chars); diff --git a/src/detection/terminalfont/terminalfont.h b/src/detection/terminalfont/terminalfont.h index a542d3226..9b15dede4 100644 --- a/src/detection/terminalfont/terminalfont.h +++ b/src/detection/terminalfont/terminalfont.h @@ -12,6 +12,6 @@ typedef struct FFTerminalFontResult FFfont font; } FFTerminalFontResult; -bool ffDetectTerminalFont(const FFinstance* instance, FFTerminalFontResult* result); +bool ffDetectTerminalFont(FFTerminalFontResult* result); #endif diff --git a/src/detection/terminalfont/terminalfont_android.c b/src/detection/terminalfont/terminalfont_android.c index 251ada6c7..ae79a4517 100644 --- a/src/detection/terminalfont/terminalfont_android.c +++ b/src/detection/terminalfont/terminalfont_android.c @@ -11,11 +11,11 @@ #define FF_TERMUX_FONT_PATH FASTFETCH_TARGET_DIR_HOME "/.termux/font.ttf" -const char* detectTermux(const FFinstance* instance, FFTerminalFontResult* terminalFont) +const char* detectTermux(FFTerminalFontResult* terminalFont) { #ifdef FF_HAVE_FREETYPE - FF_LIBRARY_LOAD(freetype, &instance->config.libfreetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(freetype, &instance.config.libfreetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Init_FreeType); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_New_Face); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face); @@ -53,7 +53,7 @@ exit: #endif } -void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) +void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufCompS(&terminalShell->terminalProcessName, "Termux") != 0) { @@ -67,5 +67,5 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh return; } - ffStrbufSetS(&terminalFont->error, detectTermux(instance, terminalFont)); + ffStrbufSetS(&terminalFont->error, detectTermux(terminalFont)); } diff --git a/src/detection/terminalfont/terminalfont_apple.m b/src/detection/terminalfont/terminalfont_apple.m index f95503585..c89b4135f 100644 --- a/src/detection/terminalfont/terminalfont_apple.m +++ b/src/detection/terminalfont/terminalfont_apple.m @@ -7,7 +7,7 @@ #include #import -static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectIterm2(FFTerminalFontResult* terminalFont) { const char* profile = getenv("ITERM_PROFILE"); if (profile == NULL) @@ -17,7 +17,7 @@ static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* termi } NSError* error; - NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.googlecode.iterm2.plist", instance->state.platform.homeDir.chars]; + NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.googlecode.iterm2.plist", instance.state.platform.homeDir.chars]; NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName] error:&error]; if(error) @@ -58,10 +58,10 @@ static void detectAppleTerminal(FFTerminalFontResult* terminalFont) ffFontInitWithSpace(&terminalFont->font, font.chars); } -static void detectWarpTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectWarpTerminal(FFTerminalFontResult* terminalFont) { NSError* error; - NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/dev.warp.Warp-Stable.plist", instance->state.platform.homeDir.chars]; + NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/dev.warp.Warp-Stable.plist", instance.state.platform.homeDir.chars]; NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName] error:&error]; if(error) @@ -83,13 +83,13 @@ static void detectWarpTerminal(const FFinstance* instance, FFTerminalFontResult* ffFontInitValues(&terminalFont->font, fontName.UTF8String, fontSize.UTF8String); } -void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) +void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "iterm.app") == 0 || ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "iTermServer-")) - detectIterm2(instance, terminalFont); + detectIterm2(terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Apple_Terminal") == 0) detectAppleTerminal(terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "WarpTerminal") == 0) - detectWarpTerminal(instance, terminalFont); + detectWarpTerminal(terminalFont); } diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 32cb3b847..fabca6902 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -7,29 +7,29 @@ #include "util/mallocHelper.h" #include "util/stringUtils.h" -static const char* getSystemMonospaceFont(const FFinstance* instance) +static const char* getSystemMonospaceFont(void) { - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Cinnamon")) { - const char* systemMonospaceFont = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + const char* systemMonospaceFont = ffSettingsGet("/org/cinnamon/desktop/interface/monospace-font-name", "org.cinnamon.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(systemMonospaceFont)) return systemMonospaceFont; } else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, "Mate")) { - const char* systemMonospaceFont = ffSettingsGet(instance, "/org/mate/interface/monospace-font-name", "org.mate.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + const char* systemMonospaceFont = ffSettingsGet("/org/mate/interface/monospace-font-name", "org.mate.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(systemMonospaceFont)) return systemMonospaceFont; } - return ffSettingsGet(instance, "/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; + return ffSettingsGet("/org/gnome/desktop/interface/monospace-font-name", "org.gnome.desktop.interface", NULL, "monospace-font-name", FF_VARIANT_TYPE_STRING).strValue; } -static void detectFromGSettings(const FFinstance* instance, const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) +static void detectFromGSettings(const char* profilePath, const char* profileList, const char* profile, const char* defaultProfileKey, FFTerminalFontResult* terminalFont) { - FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(instance, profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* defaultProfile = ffSettingsGetGSettings(profileList, NULL, defaultProfileKey, FF_VARIANT_TYPE_STRING).strValue; if(!ffStrSet(defaultProfile)) { ffStrbufAppendF(&terminalFont->error, "Could not get default profile from gsettings: %s", profileList); @@ -41,9 +41,9 @@ static void detectFromGSettings(const FFinstance* instance, const char* profileP ffStrbufAppendS(&path, defaultProfile); ffStrbufAppendC(&path, '/'); - if(!ffSettingsGetGSettings(instance, profile, path.chars, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) + if(!ffSettingsGetGSettings(profile, path.chars, "use-system-font", FF_VARIANT_TYPE_BOOL).boolValue) { - FF_AUTO_FREE const char* fontName = ffSettingsGetGSettings(instance, profile, path.chars, "font", FF_VARIANT_TYPE_STRING).strValue; + FF_AUTO_FREE const char* fontName = ffSettingsGetGSettings(profile, path.chars, "font", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(fontName)) ffFontInitPango(&terminalFont->font, fontName); else @@ -51,7 +51,7 @@ static void detectFromGSettings(const FFinstance* instance, const char* profileP } else { - const char* fontName = getSystemMonospaceFont(instance); + const char* fontName = getSystemMonospaceFont(); if(ffStrSet(fontName)) ffFontInitPango(&terminalFont->font, fontName); else @@ -59,10 +59,10 @@ static void detectFromGSettings(const FFinstance* instance, const char* profileP } } -static void detectFromConfigFile(const FFinstance* instance, const char* configFile, const char* start, FFTerminalFontResult* terminalFont) +static void detectFromConfigFile(const char* configFile, const char* start, FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); - ffParsePropFileConfig(instance, configFile, start, &fontName); + ffParsePropFileConfig(configFile, start, &fontName); if(fontName.length == 0) ffStrbufAppendF(&terminalFont->error, "Couldn't find %s in .config/%s", start, configFile); @@ -70,10 +70,10 @@ static void detectFromConfigFile(const FFinstance* instance, const char* configF ffFontInitPango(&terminalFont->font, fontName.chars); } -static void detectKonsole(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectKonsole(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY profile = ffStrbufCreate(); - ffParsePropFileConfig(instance, "konsolerc", "DefaultProfile =", &profile); + ffParsePropFileConfig("konsolerc", "DefaultProfile =", &profile); if(profile.length == 0) { @@ -86,7 +86,7 @@ static void detectKonsole(const FFinstance* instance, FFTerminalFontResult* term ffStrbufAppend(&profilePath, &profile); FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); - ffParsePropFileData(instance, profilePath.chars, "Font =", &fontName); + ffParsePropFileData(profilePath.chars, "Font =", &fontName); if(fontName.length == 0) ffStrbufAppendF(&terminalFont->error, "Couldn't find \"Font=%%[^\\n]\" in \"%s\"", profilePath.chars); @@ -94,12 +94,12 @@ static void detectKonsole(const FFinstance* instance, FFTerminalFontResult* term ffFontInitQt(&terminalFont->font, fontName.chars); } -static void detectXFCETerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectXFCETerminal(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY useSysFont = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); - ffParsePropFileConfigValues(instance, "xfce4/terminal/terminalrc", 2, (FFpropquery[]) { + ffParsePropFileConfigValues("xfce4/terminal/terminalrc", 2, (FFpropquery[]) { {"FontUseSystem = ", &useSysFont}, {"FontName = ", &fontName} }); @@ -113,7 +113,7 @@ static void detectXFCETerminal(const FFinstance* instance, FFTerminalFontResult* } else { - const char* systemFontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/MonospaceFontName", FF_VARIANT_TYPE_STRING).strValue; + const char* systemFontName = ffSettingsGetXFConf("xsettings", "/Gtk/MonospaceFontName", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(systemFontName)) ffFontInitPango(&terminalFont->font, systemFontName); else @@ -121,13 +121,13 @@ static void detectXFCETerminal(const FFinstance* instance, FFTerminalFontResult* } } -static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectDeepinTerminal(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY profile = ffStrbufCreate(); - ffStrbufAppend(&profile, &instance->state.platform.homeDir); + ffStrbufAppend(&profile, &instance.state.platform.homeDir); ffStrbufAppendS(&profile, ".config/deepin/deepin-terminal/config.conf"); //TODO: Use config dirs FILE* file = fopen(profile.chars, "r"); @@ -164,11 +164,11 @@ static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResul ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } -static void detectFootTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectFootTerminal(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate(); - if (!ffParsePropFileConfig(instance, "foot/foot.ini", "font=", &font) || !ffStrSet(font.chars)) + if (!ffParsePropFileConfig("foot/foot.ini", "font=", &font) || !ffStrSet(font.chars)) { ffFontInitValues(&terminalFont->font, "monospace", "8"); return; @@ -191,12 +191,12 @@ static void detectFootTerminal(const FFinstance* instance, FFTerminalFontResult* ffFontInitValues(&terminalFont->font, font.chars, &font.chars[equal + strlen("size=")]); } -static void detectQTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectQTerminal(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); - ffParsePropFileConfigValues(instance, "qterminal.org/qterminal.ini", 2, (FFpropquery[]) { + ffParsePropFileConfigValues("qterminal.org/qterminal.ini", 2, (FFpropquery[]) { {"fontFamily=", &fontName}, {"fontSize=", &fontSize}, }); @@ -208,24 +208,24 @@ static void detectQTerminal(const FFinstance* instance, FFTerminalFontResult* te ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } -void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) +void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "konsole")) - detectKonsole(instance, terminalFont); + detectKonsole(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "xfce4-terminal")) - detectXFCETerminal(instance, terminalFont); + detectXFCETerminal(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "lxterminal")) - detectFromConfigFile(instance, "lxterminal/lxterminal.conf", "fontname =", terminalFont); + detectFromConfigFile("lxterminal/lxterminal.conf", "fontname =", terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "tilix")) - detectFromGSettings(instance, "/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", "default", terminalFont); + detectFromGSettings("/com/gexperts/Tilix/profiles/", "com.gexperts.Tilix.ProfilesList", "com.gexperts.Tilix.Profile", "default", terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "gnome-terminal-")) - detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", "default", terminalFont); + detectFromGSettings("/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", "default", terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "mate-terminal")) - detectFromGSettings(instance, "/org/mate/terminal/profiles/", "org.mate.terminal.global", "org.mate.terminal.profile", "default-profile", terminalFont); + detectFromGSettings("/org/mate/terminal/profiles/", "org.mate.terminal.global", "org.mate.terminal.profile", "default-profile", terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "deepin-terminal")) - detectDeepinTerminal(instance, terminalFont); + detectDeepinTerminal(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "foot")) - detectFootTerminal(instance, terminalFont); + detectFootTerminal(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "qterminal")) - detectQTerminal(instance, terminalFont); + detectQTerminal(terminalFont); } diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index 3a10e1bd6..704efa5d5 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -6,16 +6,16 @@ #include -static void detectMintty(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectMintty(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); - if(!ffParsePropFileConfigValues(instance, "mintty/config", 2, (FFpropquery[]) { + if(!ffParsePropFileConfigValues("mintty/config", 2, (FFpropquery[]) { {"Font=", &fontName}, {"FontHeight=", &fontSize} })) - ffParsePropFileConfigValues(instance, ".minttyrc", 2, (FFpropquery[]) { + ffParsePropFileConfigValues(".minttyrc", 2, (FFpropquery[]) { {"Font=", &fontName}, {"FontHeight=", &fontSize} }); @@ -27,10 +27,8 @@ static void detectMintty(const FFinstance* instance, FFTerminalFontResult* termi ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } -static void detectConhost(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectConhost(FFTerminalFontResult* terminalFont) { - FF_UNUSED(instance); - CONSOLE_FONT_INFOEX cfi = { .cbSize = sizeof(cfi) }; if(!GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi)) { @@ -46,10 +44,8 @@ static void detectConhost(const FFinstance* instance, FFTerminalFontResult* term ffFontInitValues(&terminalFont->font, fontName.chars, fontSize); } -static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* terminalFont) +static void detectConEmu(FFTerminalFontResult* terminalFont) { - FF_UNUSED(instance) - //https://conemu.github.io/en/ConEmuXml.html#search-sequence FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); @@ -89,12 +85,12 @@ static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* termi ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } -void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) +void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "mintty") == 0) - detectMintty(instance, terminalFont); + detectMintty(terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "conhost.exe") == 0) - detectConhost(instance, terminalFont); + detectConhost(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "ConEmuC")) - detectConEmu(instance, terminalFont); + detectConEmu(terminalFont); } diff --git a/src/detection/terminalshell/terminalshell.h b/src/detection/terminalshell/terminalshell.h index f506381bb..c727b5fdf 100644 --- a/src/detection/terminalshell/terminalshell.h +++ b/src/detection/terminalshell/terminalshell.h @@ -26,6 +26,6 @@ typedef struct FFTerminalShellResult FFstrbuf userShellVersion; } FFTerminalShellResult; -const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance); +const FFTerminalShellResult* ffDetectTerminalShell(); #endif diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 9e60aacda..770df3c09 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -262,9 +262,9 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) } } -static void getUserShellFromEnv(const FFinstance* instance, FFTerminalShellResult* result) +static void getUserShellFromEnv(FFTerminalShellResult* result) { - ffStrbufSet(&result->userShellExe, &instance->state.platform.userShell); + ffStrbufSet(&result->userShellExe, &instance.state.platform.userShell); if(result->userShellExe.length == 0) return; @@ -309,10 +309,8 @@ static void getShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* versio bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version); -const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) +const FFTerminalShellResult* ffDetectTerminalShell() { - FF_UNUSED(instance); - static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; static FFTerminalShellResult result; static bool init = false; @@ -350,7 +348,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getTerminalShell(&result, getppid()); getTerminalFromEnv(&result); - getUserShellFromEnv(instance, &result); + getUserShellFromEnv(&result); ffStrbufClear(&result.shellVersion); getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 35a3af0f7..ac06bed6e 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -119,7 +119,7 @@ static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* re bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); -static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* result, uint32_t pid) +static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) { uint32_t ppid; @@ -148,7 +148,7 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* ffStrbufClear(&result->shellPrettyName); ffStrbufClear(&result->shellExe); result->shellExeName = NULL; - return getShellInfo(instance, result, ppid); + return getShellInfo(result, ppid); } ffStrbufClear(&result->shellVersion); @@ -199,7 +199,7 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* return ppid; } -static uint32_t getTerminalInfo(const FFinstance* instance, FFTerminalShellResult* result, uint32_t pid) +static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) { uint32_t ppid; @@ -225,7 +225,7 @@ static uint32_t getTerminalInfo(const FFinstance* instance, FFTerminalShellResul ffStrbufClear(&result->terminalPrettyName); ffStrbufClear(&result->terminalExe); result->terminalExeName = ""; - return getTerminalInfo(instance, result, ppid); + return getTerminalInfo(result, ppid); } if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "sihost") || @@ -306,10 +306,8 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version); -const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) +const FFTerminalShellResult* ffDetectTerminalShell(void) { - FF_UNUSED(instance); - static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; static FFTerminalShellResult result; static bool init = false; @@ -342,9 +340,9 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) if(!getProcessInfo(0, &ppid, NULL, NULL, NULL)) goto exit; - ppid = getShellInfo(instance, &result, ppid); + ppid = getShellInfo(&result, ppid); if(ppid) - getTerminalInfo(instance, &result, ppid); + getTerminalInfo(&result, ppid); if(result.terminalProcessName.length == 0) getTerminalFromEnv(&result); diff --git a/src/detection/theme/theme.h b/src/detection/theme/theme.h index 252b4873f..ec4c596e8 100644 --- a/src/detection/theme/theme.h +++ b/src/detection/theme/theme.h @@ -5,6 +5,6 @@ #include "fastfetch.h" -const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result); +const char* ffDetectTheme(FFstrbuf* result); #endif diff --git a/src/detection/theme/theme_linux.c b/src/detection/theme/theme_linux.c index d59c6d2de..1a97f49f4 100644 --- a/src/detection/theme/theme_linux.c +++ b/src/detection/theme/theme_linux.c @@ -3,17 +3,17 @@ #include "detection/gtk_qt/gtk_qt.h" #include "detection/displayserver/displayserver.h" -const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result) +const char* ffDetectTheme(FFstrbuf* result) { - const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) return "Theme isn't supported in TTY"; - const FFQtResult* plasma = ffDetectQt(instance); - const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->theme; - const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->theme; - const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->theme; + const FFQtResult* plasma = ffDetectQt(); + const FFstrbuf* gtk2 = &ffDetectGTK2()->theme; + const FFstrbuf* gtk3 = &ffDetectGTK3()->theme; + const FFstrbuf* gtk4 = &ffDetectGTK4()->theme; if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) return "No themes found"; diff --git a/src/detection/theme/theme_nosupport.c b/src/detection/theme/theme_nosupport.c index d0e9fd073..c946833e6 100644 --- a/src/detection/theme/theme_nosupport.c +++ b/src/detection/theme/theme_nosupport.c @@ -1,6 +1,6 @@ #include "theme.h" -const char* ffDetectTheme(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result) +const char* ffDetectTheme(FF_MAYBE_UNUSED FFstrbuf* result) { return "Not supported on this platform"; } diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 9ab2319dd..88d687c8e 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -38,9 +38,9 @@ static void applyDriverName(VkPhysicalDeviceDriverProperties* properties, FFstrb ffStrbufAppendC(result, ']'); } -static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* result) +static const char* detectVulkan(FFVulkanResult* result) { - FF_LIBRARY_LOAD(vulkan, &instance->config.libVulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed", + FF_LIBRARY_LOAD(vulkan, &instance.config.libVulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed", #ifdef __APPLE__ "libMoltenVK"FF_LIBRARY_EXTENSION, -1 #elif defined(_WIN32) @@ -119,7 +119,7 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu PFN_vkGetPhysicalDeviceMemoryProperties ffvkGetPhysicalDeviceMemoryProperties = NULL; PFN_vkGetPhysicalDeviceMemoryProperties2 ffvkGetPhysicalDeviceMemoryProperties2 = - instance->config.allowSlowOperations ? (PFN_vkGetPhysicalDeviceMemoryProperties2) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties2") : NULL; // 1.1 + instance.config.allowSlowOperations ? (PFN_vkGetPhysicalDeviceMemoryProperties2) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties2") : NULL; // 1.1 if(!ffvkGetPhysicalDeviceMemoryProperties2) ffvkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) ffvkGetInstanceProcAddr(vkInstance, "vkGetPhysicalDeviceMemoryProperties"); @@ -245,7 +245,7 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu #endif -FFVulkanResult* ffDetectVulkan(const FFinstance* instance) +FFVulkanResult* ffDetectVulkan(void) { static FFVulkanResult result; static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; @@ -265,9 +265,8 @@ FFVulkanResult* ffDetectVulkan(const FFinstance* instance) ffListInit(&result.gpus, sizeof(FFGPUResult)); #ifdef FF_HAVE_VULKAN - result.error = detectVulkan(instance, &result); + result.error = detectVulkan(&result); #else - FF_UNUSED(instance); result.error = "fastfetch was compiled without vulkan support"; #endif diff --git a/src/detection/vulkan/vulkan.h b/src/detection/vulkan/vulkan.h index 1da50b969..560fcdc53 100644 --- a/src/detection/vulkan/vulkan.h +++ b/src/detection/vulkan/vulkan.h @@ -14,6 +14,6 @@ typedef struct FFVulkanResult const char* error; } FFVulkanResult; -FFVulkanResult* ffDetectVulkan(const FFinstance* instance); +FFVulkanResult* ffDetectVulkan(); #endif diff --git a/src/detection/wallpaper/wallpaper.h b/src/detection/wallpaper/wallpaper.h index 72208eb5b..f75ad77dd 100644 --- a/src/detection/wallpaper/wallpaper.h +++ b/src/detection/wallpaper/wallpaper.h @@ -5,6 +5,6 @@ #include "fastfetch.h" -const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result); +const char* ffDetectWallpaper(FFstrbuf* result); #endif diff --git a/src/detection/wallpaper/wallpaper_apple.c b/src/detection/wallpaper/wallpaper_apple.c index 7d2fb84dc..4ec131417 100644 --- a/src/detection/wallpaper/wallpaper_apple.c +++ b/src/detection/wallpaper/wallpaper_apple.c @@ -2,15 +2,15 @@ #include "common/settings.h" #include "util/apple/osascript.h" -const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result) +const char* ffDetectWallpaper(FFstrbuf* result) { // https://stackoverflow.com/questions/301215/getting-desktop-background-on-mac #ifdef FF_HAVE_SQLITE3 - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&instance->state.platform.homeDir); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&instance.state.platform.homeDir); ffStrbufAppendS(&path, "Library/Application Support/Dock/desktoppicture.db"); - if (ffSettingsGetSQLite3String(instance, path.chars, + if (ffSettingsGetSQLite3String(path.chars, "SELECT value\n" "FROM preferences\n" "JOIN data ON preferences.data_id=data.ROWID\n" diff --git a/src/detection/wallpaper/wallpaper_linux.c b/src/detection/wallpaper/wallpaper_linux.c index 7ae5b480d..d2aa65b6c 100644 --- a/src/detection/wallpaper/wallpaper_linux.c +++ b/src/detection/wallpaper/wallpaper_linux.c @@ -2,15 +2,15 @@ #include "common/settings.h" #include "detection/gtk_qt/gtk_qt.h" -const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result) +const char* ffDetectWallpaper(FFstrbuf* result) { const FFstrbuf* wallpaper = NULL; - const FFGTKResult* gtk = ffDetectGTK4(instance); + const FFGTKResult* gtk = ffDetectGTK4(); if (gtk->wallpaper.length) wallpaper = >k->wallpaper; else { - const FFQtResult* qt = ffDetectQt(instance); + const FFQtResult* qt = ffDetectQt(); if (qt->wallpaper.length) wallpaper = &qt->wallpaper; } diff --git a/src/detection/wallpaper/wallpaper_nosupport.c b/src/detection/wallpaper/wallpaper_nosupport.c index 92278511d..787b106af 100644 --- a/src/detection/wallpaper/wallpaper_nosupport.c +++ b/src/detection/wallpaper/wallpaper_nosupport.c @@ -1,6 +1,6 @@ #include "wallpaper.h" -const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result) +const char* ffDetectWallpaper(FF_MAYBE_UNUSED FFstrbuf* result) { return "Not supported on this platform"; } diff --git a/src/detection/wallpaper/wallpaper_windows.c b/src/detection/wallpaper/wallpaper_windows.c index aa8b696ad..7a099cb40 100644 --- a/src/detection/wallpaper/wallpaper_windows.c +++ b/src/detection/wallpaper/wallpaper_windows.c @@ -1,7 +1,7 @@ #include "wallpaper.h" #include "util/windows/registry.h" -const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result) +const char* ffDetectWallpaper(FFstrbuf* result) { FF_HKEY_AUTO_DESTROY hKey = NULL; if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, NULL)) diff --git a/src/detection/wifi/wifi.h b/src/detection/wifi/wifi.h index fae5c46ce..d3257a9ef 100644 --- a/src/detection/wifi/wifi.h +++ b/src/detection/wifi/wifi.h @@ -29,6 +29,6 @@ typedef struct FFWifiResult struct FFWifiConnection conn; } FFWifiResult; -const char* ffDetectWifi(const FFinstance* instance, FFlist* result /*list of FFWifiItem*/); +const char* ffDetectWifi(FFlist* result /*list of FFWifiItem*/); #endif diff --git a/src/detection/wifi/wifi_android.c b/src/detection/wifi/wifi_android.c index 39ae35541..b04796d6e 100644 --- a/src/detection/wifi/wifi_android.c +++ b/src/detection/wifi/wifi_android.c @@ -6,7 +6,7 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "WifiConnectionInfo" -const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); diff --git a/src/detection/wifi/wifi_apple.m b/src/detection/wifi/wifi_apple.m index a83f79485..c6b572012 100644 --- a/src/detection/wifi/wifi_apple.m +++ b/src/detection/wifi/wifi_apple.m @@ -2,10 +2,8 @@ #import -const char* ffDetectWifi(const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FFlist* result) { - FF_UNUSED(instance); - NSArray* interfaces = CWWiFiClient.sharedWiFiClient.interfaces; if(!interfaces) return "CWWiFiClient.sharedWiFiClient.interfaces is nil"; diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c index 31ba488a2..663c6a4be 100644 --- a/src/detection/wifi/wifi_bsd.c +++ b/src/detection/wifi/wifi_bsd.c @@ -7,7 +7,7 @@ #include #include -const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FFlist* result) { struct if_nameindex* infs = if_nameindex(); if(!infs) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 871b9be50..23534f3b9 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -20,9 +20,9 @@ #define NM_802_11_AP_SEC_KEY_MGMT_OWE_TM 0x00001000 #endif -static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* result) +static const char* detectWifiWithLibnm(FFlist* result) { - FF_LIBRARY_LOAD(nm, &instance->config.libnm, "dlopen libnm failed", "libnm" FF_LIBRARY_EXTENSION, 0); + FF_LIBRARY_LOAD(nm, &instance.config.libnm, "dlopen libnm failed", "libnm" FF_LIBRARY_EXTENSION, 0); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_client_new); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_client_get_devices); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_device_get_iface); @@ -143,7 +143,7 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul item->conn.signalQuality = ffnm_access_point_get_strength(ap); item->conn.rxRate = ffnm_access_point_get_max_bitrate(ap); - if(instance->config.allowSlowOperations) + if(instance.config.allowSlowOperations) { FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); if(!ffProcessAppendStdOut(&output, (char* const[]){ @@ -213,7 +213,7 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul #include #include //TODO: Don't depend on kernel headers -static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) +static const char* detectWifiWithIoctls(FFlist* result) { struct if_nameindex* infs = if_nameindex(); if(!infs) @@ -315,15 +315,15 @@ static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instan #endif -const char* ffDetectWifi(const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FFlist* result) { #ifdef FF_HAVE_LIBNM - if(!detectWifiWithLibnm(instance, result)) + if(!detectWifiWithLibnm(result)) return NULL; #endif #ifdef FF_DETECT_WIFI_WITH_IOCTLS - detectWifiWithIoctls(instance, result); + detectWifiWithIoctls(result); #endif return "linux/wireless.h not found during compilation"; diff --git a/src/detection/wifi/wifi_windows.c b/src/detection/wifi/wifi_windows.c index a0bd0af4b..3b7ac5a1c 100644 --- a/src/detection/wifi/wifi_windows.c +++ b/src/detection/wifi/wifi_windows.c @@ -41,7 +41,7 @@ static void convertIfStateToString(WLAN_INTERFACE_STATE state, FFstrbuf* result) } } -const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FFlist* result) { FF_LIBRARY_LOAD(wlanapi, NULL, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanOpenHandle) diff --git a/src/detection/wmtheme/wmtheme.h b/src/detection/wmtheme/wmtheme.h index 33a15dd0f..baf3e1ede 100644 --- a/src/detection/wmtheme/wmtheme.h +++ b/src/detection/wmtheme/wmtheme.h @@ -5,6 +5,6 @@ #include "fastfetch.h" -bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError); +bool ffDetectWmTheme(FFstrbuf* themeOrError); #endif diff --git a/src/detection/wmtheme/wmtheme_apple.m b/src/detection/wmtheme/wmtheme_apple.m index 817a2cd65..08810b6cc 100644 --- a/src/detection/wmtheme/wmtheme_apple.m +++ b/src/detection/wmtheme/wmtheme_apple.m @@ -3,10 +3,10 @@ #import -bool ffDetectWmTheme(FF_MAYBE_UNUSED FFinstance* instance, FFstrbuf* themeOrError) +bool ffDetectWmTheme(FFstrbuf* themeOrError) { NSError* error; - NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/.GlobalPreferences.plist", instance->state.platform.homeDir.chars]; + NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/.GlobalPreferences.plist", instance.state.platform.homeDir.chars]; NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName] error:&error]; if(error) diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index 055dc91ca..ba1e172a1 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -6,9 +6,9 @@ #include "detection/displayserver/displayserver.h" #include "util/stringUtils.h" -static bool detectWMThemeFromConfigFile(FFinstance* instance, const char* configFile, const char* themeRegex, const char* defaultValue, FFstrbuf* themeOrError) +static bool detectWMThemeFromConfigFile(const char* configFile, const char* themeRegex, const char* defaultValue, FFstrbuf* themeOrError) { - if(!ffParsePropFileConfig(instance, configFile, themeRegex, themeOrError)) + if(!ffParsePropFileConfig(configFile, themeRegex, themeOrError)) { ffStrbufAppendF(themeOrError, "Config file %s doesn't exist", configFile); return false; @@ -40,9 +40,9 @@ static bool detectWMThemeFromConfigFile(FFinstance* instance, const char* config return true; } -static bool detectWMThemeFromSettings(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFstrbuf* themeOrError) +static bool detectWMThemeFromSettings(const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFstrbuf* themeOrError) { - const char* theme = ffSettingsGet(instance, dconfKey, gsettingsSchemaName, gsettingsPath, gsettingsKey, FF_VARIANT_TYPE_STRING).strValue; + const char* theme = ffSettingsGet(dconfKey, gsettingsSchemaName, gsettingsPath, gsettingsKey, FF_VARIANT_TYPE_STRING).strValue; if(!ffStrSet(theme)) { @@ -54,17 +54,17 @@ static bool detectWMThemeFromSettings(FFinstance* instance, const char* dconfKey return true; } -static bool detectGTKThemeAsWMTheme(FFinstance* instance, FFstrbuf* themeOrError) +static bool detectGTKThemeAsWMTheme(FFstrbuf* themeOrError) { - const FFGTKResult* gtk = ffDetectGTK4(instance); + const FFGTKResult* gtk = ffDetectGTK4(); if(gtk->theme.length > 0) goto ok; - gtk = ffDetectGTK3(instance); + gtk = ffDetectGTK3(); if(gtk->theme.length > 0) goto ok; - gtk = ffDetectGTK2(instance); + gtk = ffDetectGTK2(); if(gtk->theme.length > 0) goto ok; @@ -76,22 +76,22 @@ ok: return true; } -static bool detectMutter(FFinstance* instance, FFstrbuf* themeOrError) +static bool detectMutter(FFstrbuf* themeOrError) { - 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; + const char* theme = ffSettingsGet("/org/gnome/shell/extensions/user-theme/name", "org.gnome.shell.extensions.user-theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue; if(ffStrSet(theme)) { ffStrbufAppendS(themeOrError, theme); return true; } - return detectGTKThemeAsWMTheme(instance, themeOrError); + return detectGTKThemeAsWMTheme(themeOrError); } -static bool detectMuffin(FFinstance* instance, FFstrbuf* themeOrError) +static bool detectMuffin(FFstrbuf* themeOrError) { - 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; + const char* name = ffSettingsGet("/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name", FF_VARIANT_TYPE_STRING).strValue; + const char* theme = ffSettingsGet("/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme", FF_VARIANT_TYPE_STRING).strValue; if(name == NULL && theme == NULL) { @@ -115,9 +115,9 @@ static bool detectMuffin(FFinstance* instance, FFstrbuf* themeOrError) return true; } -static bool detectXFWM4(FFinstance* instance, FFstrbuf* themeOrError) +static bool detectXFWM4(FFstrbuf* themeOrError) { - const char* theme = ffSettingsGetXFConf(instance, "xfwm4", "/general/theme", FF_VARIANT_TYPE_STRING).strValue; + const char* theme = ffSettingsGetXFConf("xfwm4", "/general/theme", FF_VARIANT_TYPE_STRING).strValue; if(theme == NULL) { @@ -129,10 +129,10 @@ static bool detectXFWM4(FFinstance* instance, FFstrbuf* themeOrError) return true; } -static bool detectOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) +static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) { FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(64); - ffStrbufAppend(&absolutePath, &instance->state.platform.homeDir); + ffStrbufAppend(&absolutePath, &instance.state.platform.homeDir); //TODO: use config dirs if(ffStrbufIgnCaseCompS(dePrettyName, "LXQT") == 0) @@ -188,9 +188,9 @@ static bool detectOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName, FF return true; } -bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) +bool ffDetectWmTheme(FFstrbuf* themeOrError) { - const FFDisplayServerResult* wm = ffConnectDisplayServer(instance); + const FFDisplayServerResult* wm = ffConnectDisplayServer(); if(wm->wmPrettyName.length == 0) { @@ -199,10 +199,10 @@ bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) } if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_KWIN) == 0) - return detectWMThemeFromConfigFile(instance, "kwinrc", "theme =", "Breeze", themeOrError); + return detectWMThemeFromConfigFile("kwinrc", "theme =", "Breeze", themeOrError); if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_XFWM4) == 0) - return detectXFWM4(instance, themeOrError); + return detectXFWM4(themeOrError); if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_MUTTER) == 0) { @@ -210,19 +210,19 @@ bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) ffStrbufIgnCaseCompS(&wm->dePrettyName, FF_DE_PRETTY_GNOME) == 0 || ffStrbufIgnCaseEqualS(&wm->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC) ) - return detectMutter(instance, themeOrError); + return detectMutter(themeOrError); else - return detectGTKThemeAsWMTheme(instance, themeOrError); + return detectGTKThemeAsWMTheme(themeOrError); } if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_MUFFIN) == 0) - return detectMuffin(instance, themeOrError); + return detectMuffin(themeOrError); if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_MARCO) == 0) - return detectWMThemeFromSettings(instance, "/org/mate/Marco/general/theme", "org.mate.Marco.general", NULL, "theme", themeOrError); + return detectWMThemeFromSettings("/org/mate/Marco/general/theme", "org.mate.Marco.general", NULL, "theme", themeOrError); if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, FF_WM_PRETTY_OPENBOX) == 0) - return detectOpenbox(instance, &wm->dePrettyName, themeOrError); + return detectOpenbox(&wm->dePrettyName, themeOrError); ffStrbufAppendS(themeOrError, "Unknown WM: "); ffStrbufAppend(themeOrError, &wm->wmPrettyName); diff --git a/src/detection/wmtheme/wmtheme_nosupport.c b/src/detection/wmtheme/wmtheme_nosupport.c index 1f1dca61c..2b899e98c 100644 --- a/src/detection/wmtheme/wmtheme_nosupport.c +++ b/src/detection/wmtheme/wmtheme_nosupport.c @@ -1,9 +1,8 @@ #include "fastfetch.h" #include "wmtheme.h" -bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) +bool ffDetectWmTheme(FFstrbuf* themeOrError) { - FF_UNUSED(instance); ffStrbufAppendS(themeOrError, "Not supported on this platform"); return false; } diff --git a/src/detection/wmtheme/wmtheme_windows.c b/src/detection/wmtheme/wmtheme_windows.c index 67ea08f83..5e5cc26e1 100644 --- a/src/detection/wmtheme/wmtheme_windows.c +++ b/src/detection/wmtheme/wmtheme_windows.c @@ -60,7 +60,7 @@ const char* colorHexToString(DWORD hex) } } -bool ffDetectWmTheme(FF_MAYBE_UNUSED FFinstance* instance, FFstrbuf* themeOrError) +bool ffDetectWmTheme(FFstrbuf* themeOrError) { { FF_HKEY_AUTO_DESTROY hKey = NULL; diff --git a/src/fastfetch.c b/src/fastfetch.c index 8de3e4f14..7fc96cdcb 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -485,27 +485,27 @@ static inline void printCommandHelp(const char* command) fprintf(stderr, "No specific help for command %s provided\n", command); } -static void listAvailablePresets(FFinstance* instance) +static void listAvailablePresets(void) { - FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs) + FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { ffStrbufAppendS(path, "fastfetch/presets/"); ffListFilesRecursively(path->chars); } } -static void listAvailableLogos(FFinstance* instance) +static void listAvailableLogos(void) { - FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs) + FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { ffStrbufAppendS(path, "fastfetch/logos/"); ffListFilesRecursively(path->chars); } } -static void listConfigPaths(FFinstance* instance) +static void listConfigPaths(void) { - FF_LIST_FOR_EACH(FFstrbuf, folder, instance->state.platform.configDirs) + FF_LIST_FOR_EACH(FFstrbuf, folder, instance.state.platform.configDirs) { bool exists = false; ffStrbufAppendS(folder, "fastfetch/config.jsonc"); @@ -520,31 +520,31 @@ static void listConfigPaths(FFinstance* instance) } } -static void listDataPaths(FFinstance* instance) +static void listDataPaths(void) { - FF_LIST_FOR_EACH(FFstrbuf, folder, instance->state.platform.dataDirs) + FF_LIST_FOR_EACH(FFstrbuf, folder, instance.state.platform.dataDirs) { ffStrbufAppendS(folder, "fastfetch/"); puts(folder->chars); } } -static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value); +static void parseOption(FFdata* data, const char* key, const char* value); -static bool parseJsoncFile(FFinstance* instance, const char* path) +static bool parseJsoncFile(const char* path) { yyjson_read_err error; yyjson_doc* doc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, &error); if (doc) { - instance->state.configDoc = doc; + instance.state.configDoc = doc; const char* error = NULL; if ( - (error = ffParseLogoJsonConfig(instance)) || - (error = ffParseGeneralJsonConfig(instance)) || - (error = ffParseDisplayJsonConfig(instance)) || - (error = ffParseLibraryJsonConfig(instance)) || + (error = ffParseLogoJsonConfig()) || + (error = ffParseGeneralJsonConfig()) || + (error = ffParseDisplayJsonConfig()) || + (error = ffParseLibraryJsonConfig()) || false ) { fputs(error, stderr); @@ -560,7 +560,7 @@ static bool parseJsoncFile(FFinstance* instance, const char* path) return false; } -static bool parseConfigFile(FFinstance* instance, FFdata* data, const char* path) +static bool parseConfigFile(FFdata* data, const char* path) { FILE* file = fopen(path, "r"); if(file == NULL) @@ -593,7 +593,7 @@ static bool parseConfigFile(FFinstance* instance, FFdata* data, const char* path //If the line has no white space, it is only a key if(valueStart == NULL) { - parseOption(instance, data, lineStart, NULL); + parseOption(data, lineStart, NULL); continue; } @@ -613,7 +613,7 @@ static bool parseConfigFile(FFinstance* instance, FFdata* data, const char* path --lineEnd; } - parseOption(instance, data, lineStart, valueStart); + parseOption(data, lineStart, valueStart); } if(line != NULL) @@ -623,9 +623,9 @@ static bool parseConfigFile(FFinstance* instance, FFdata* data, const char* path return true; } -static void generateConfigFile(FFinstance* instance, bool force) +static void generateConfigFile(bool force) { - FFstrbuf* filename = (FFstrbuf*) ffListGet(&instance->state.platform.configDirs, 0); + FFstrbuf* filename = (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0); // Paths generated in `init.c/initConfigDirs` end with `/` ffStrbufAppendS(filename, "fastfetch/config.conf"); @@ -642,7 +642,7 @@ static void generateConfigFile(FFinstance* instance, bool force) } } -static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char* key, const char* value) +static void optionParseConfigFile(FFdata* data, const char* key, const char* value) { if(value == NULL) { @@ -652,21 +652,21 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char //Try to load as an absolute path - if(parseConfigFile(instance, data, value)) + if(parseConfigFile(data, value)) return; //Try to load as a relative path FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); - FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs) + FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { //We need to copy it, because if a config file loads a config file, the value of path must be unchanged ffStrbufSet(&absolutePath, path); ffStrbufAppendS(&absolutePath, "fastfetch/presets/"); ffStrbufAppendS(&absolutePath, value); - bool success = parseConfigFile(instance, data, absolutePath.chars); + bool success = parseConfigFile(data, absolutePath.chars); if(success) return; @@ -688,7 +688,7 @@ static inline void optionCheckString(const char* key, const char* value, FFstrbu ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance } -static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value) +static void parseOption(FFdata* data, const char* key, const char* value) { /////////////////////// //Informative options// @@ -759,7 +759,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(ffStrEqualsIgnCase(subkey, "-logos")) { - ffLogoBuiltinPrint(instance); + ffLogoBuiltinPrint(); exit(0); } else @@ -775,17 +775,17 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con } else if(ffStrEqualsIgnCase(subkey, "-presets")) { - listAvailablePresets(instance); + listAvailablePresets(); exit(0); } else if(ffStrEqualsIgnCase(subkey, "-config-paths")) { - listConfigPaths(instance); + listConfigPaths(); exit(0); } else if(ffStrEqualsIgnCase(subkey, "-data-paths")) { - listDataPaths(instance); + listDataPaths(); exit(0); } else if(ffStrEqualsIgnCase(subkey, "-features")) @@ -798,7 +798,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con puts("Builtin logos:"); ffLogoBuiltinList(); puts("\nCustom logos:"); - listAvailableLogos(instance); + listAvailableLogos(); exit(0); } else if(ffStrEqualsIgnCase(subkey, "-logos-autocompletion")) @@ -815,75 +815,75 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con /////////////////// else if(ffStrEqualsIgnCase(key, "-r") || ffStrEqualsIgnCase(key, "--recache")) - instance->config.recache = ffOptionParseBoolean(value); + instance.config.recache = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--load-config")) - optionParseConfigFile(instance, data, key, value); + optionParseConfigFile(data, key, value); else if(ffStrEqualsIgnCase(key, "--gen-config")) - generateConfigFile(instance, false); + generateConfigFile(false); else if(ffStrEqualsIgnCase(key, "--gen-config-force")) - generateConfigFile(instance, true); + generateConfigFile(true); else if(ffStrEqualsIgnCase(key, "--thread") || ffStrEqualsIgnCase(key, "--multithreading")) - instance->config.multithreading = ffOptionParseBoolean(value); + instance.config.multithreading = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--stat")) { - if((instance->config.stat = ffOptionParseBoolean(value))) - instance->config.showErrors = true; + if((instance.config.stat = ffOptionParseBoolean(value))) + instance.config.showErrors = true; } else if(ffStrEqualsIgnCase(key, "--allow-slow-operations")) - instance->config.allowSlowOperations = ffOptionParseBoolean(value); + instance.config.allowSlowOperations = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) - instance->config.escapeBedrock = ffOptionParseBoolean(value); + instance.config.escapeBedrock = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--pipe")) - instance->config.pipe = ffOptionParseBoolean(value); + instance.config.pipe = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--load-user-config")) data->loadUserConfig = ffOptionParseBoolean(value); #if defined(__linux__) || defined(__FreeBSD__) else if(ffStrEqualsIgnCase(key, "--player-name")) - ffOptionParseString(key, value, &instance->config.playerName); + ffOptionParseString(key, value, &instance.config.playerName); else if (ffStrEqualsIgnCase(key, "--os-file")) - ffOptionParseString(key, value, &instance->config.osFile); + ffOptionParseString(key, value, &instance.config.osFile); #endif //////////////// //Logo options// //////////////// - else if(ffParseLogoCommandOptions(&instance->config.logo, key, value)) {} + else if(ffParseLogoCommandOptions(&instance.config.logo, key, value)) {} /////////////////// //Display options// /////////////////// else if(ffStrEqualsIgnCase(key, "--show-errors")) - instance->config.showErrors = ffOptionParseBoolean(value); + instance.config.showErrors = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--disable-linewrap")) - instance->config.disableLinewrap = ffOptionParseBoolean(value); + instance.config.disableLinewrap = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--hide-cursor")) - instance->config.hideCursor = ffOptionParseBoolean(value); + instance.config.hideCursor = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "-s") || ffStrEqualsIgnCase(key, "--structure")) ffOptionParseString(key, value, &data->structure); else if(ffStrEqualsIgnCase(key, "--separator")) - ffOptionParseString(key, value, &instance->config.keyValueSeparator); + ffOptionParseString(key, value, &instance.config.keyValueSeparator); else if(ffStrEqualsIgnCase(key, "--color-keys")) { - optionCheckString(key, value, &instance->config.colorKeys); - ffOptionParseColor(value, &instance->config.colorKeys); + optionCheckString(key, value, &instance.config.colorKeys); + ffOptionParseColor(value, &instance.config.colorKeys); } else if(ffStrEqualsIgnCase(key, "--color-title")) { - optionCheckString(key, value, &instance->config.colorTitle); - ffOptionParseColor(value, &instance->config.colorTitle); + optionCheckString(key, value, &instance.config.colorTitle); + ffOptionParseColor(value, &instance.config.colorTitle); } else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color")) { - optionCheckString(key, value, &instance->config.colorKeys); - ffOptionParseColor(value, &instance->config.colorKeys); - ffStrbufSet(&instance->config.colorTitle, &instance->config.colorKeys); + optionCheckString(key, value, &instance.config.colorKeys); + ffOptionParseColor(value, &instance.config.colorKeys); + ffStrbufSet(&instance.config.colorTitle, &instance.config.colorKeys); } else if(ffStrEqualsIgnCase(key, "--binary-prefix")) { - instance->config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + instance.config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "iec", FF_BINARY_PREFIX_TYPE_IEC }, { "si", FF_BINARY_PREFIX_TYPE_SI }, { "jedec", FF_BINARY_PREFIX_TYPE_JEDEC }, @@ -891,64 +891,64 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con }); } else if(ffStrEqualsIgnCase(key, "--percent-type")) - instance->config.percentType = ffOptionParseUInt32(key, value); + instance.config.percentType = ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--no-buffer")) - instance->config.noBuffer = ffOptionParseBoolean(value); + instance.config.noBuffer = ffOptionParseBoolean(value); /////////////////////// //Module args options// /////////////////////// - else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} - else if(ffParseHostCommandOptions(&instance->config.host, key, value)) {} - else if(ffParseOSCommandOptions(&instance->config.os, key, value)) {} - else if(ffParseBiosCommandOptions(&instance->config.bios, key, value)) {} - else if(ffParseBoardCommandOptions(&instance->config.board, key, value)) {} - else if(ffParseChassisCommandOptions(&instance->config.chassis, key, value)) {} - else if(ffParseCommandCommandOptions(&instance->config.command, key, value)) {} - else if(ffParseCustomCommandOptions(&instance->config.custom, key, value)) {} - else if(ffParseKernelCommandOptions(&instance->config.kernel, key, value)) {} - else if(ffParseUptimeCommandOptions(&instance->config.uptime, key, value)) {} - else if(ffParseProcessesCommandOptions(&instance->config.processes, key, value)) {} - else if(ffParsePackagesCommandOptions(&instance->config.packages, key, value)) {} - else if(ffParseShellCommandOptions(&instance->config.shell, key, value)) {} - else if(ffParseDisplayCommandOptions(&instance->config.display, key, value)) {} - else if(ffParseBrightnessCommandOptions(&instance->config.brightness, key, value)) {} - else if(ffParseDECommandOptions(&instance->config.de, key, value)) {} - else if(ffParseWifiCommandOptions(&instance->config.wifi, key, value)) {} - else if(ffParseWMCommandOptions(&instance->config.wm, key, value)) {} - else if(ffParseWMThemeCommandOptions(&instance->config.wmTheme, key, value)) {} - else if(ffParseThemeCommandOptions(&instance->config.theme, key, value)) {} - else if(ffParseIconsCommandOptions(&instance->config.icons, key, value)) {} - else if(ffParseWallpaperCommandOptions(&instance->config.wallpaper, key, value)) {} - else if(ffParseFontCommandOptions(&instance->config.font, key, value)) {} - else if(ffParseCursorCommandOptions(&instance->config.cursor, key, value)) {} - else if(ffParseTerminalCommandOptions(&instance->config.terminal, key, value)) {} - else if(ffParseTerminalFontCommandOptions(&instance->config.terminalFont, key, value)) {} - else if(ffParseCPUCommandOptions(&instance->config.cpu, key, value)) {} - else if(ffParseCPUUsageCommandOptions(&instance->config.cpuUsage, key, value)) {} - else if(ffParseGPUCommandOptions(&instance->config.gpu, key, value)) {} - else if(ffParseMemoryCommandOptions(&instance->config.memory, key, value)) {} - else if(ffParseSwapCommandOptions(&instance->config.swap, key, value)) {} - else if(ffParseDiskCommandOptions(&instance->config.disk, key, value)) {} - else if(ffParseBatteryCommandOptions(&instance->config.battery, key, value)) {} - else if(ffParsePowerAdapterCommandOptions(&instance->config.powerAdapter, key, value)) {} - else if(ffParseLocaleCommandOptions(&instance->config.locale, key, value)) {} - else if(ffParseLocalIpCommandOptions(&instance->config.localIP, key, value)) {} - else if(ffParsePublicIpCommandOptions(&instance->config.publicIP, key, value)) {} - else if(ffParseWeatherCommandOptions(&instance->config.weather, key, value)) {} - else if(ffParsePlayerCommandOptions(&instance->config.player, key, value)) {} - else if(ffParseMediaCommandOptions(&instance->config.media, key, value)) {} - else if(ffParseDateTimeCommandOptions(&instance->config.dateTime, key, value)) {} - else if(ffParseVulkanCommandOptions(&instance->config.vulkan, key, value)) {} - else if(ffParseOpenGLCommandOptions(&instance->config.openGL, key, value)) {} - else if(ffParseOpenCLCommandOptions(&instance->config.openCL, key, value)) {} - else if(ffParseUsersCommandOptions(&instance->config.users, key, value)) {} - else if(ffParseBluetoothCommandOptions(&instance->config.bluetooth, key, value)) {} - else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} - else if(ffParseSoundCommandOptions(&instance->config.sound, key, value)) {} - else if(ffParseGamepadCommandOptions(&instance->config.gamepad, key, value)) {} - else if(ffParseColorsCommandOptions(&instance->config.colors, key, value)) {} + else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {} + else if(ffParseHostCommandOptions(&instance.config.host, key, value)) {} + else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {} + else if(ffParseBiosCommandOptions(&instance.config.bios, key, value)) {} + else if(ffParseBoardCommandOptions(&instance.config.board, key, value)) {} + else if(ffParseChassisCommandOptions(&instance.config.chassis, key, value)) {} + else if(ffParseCommandCommandOptions(&instance.config.command, key, value)) {} + else if(ffParseCustomCommandOptions(&instance.config.custom, key, value)) {} + else if(ffParseKernelCommandOptions(&instance.config.kernel, key, value)) {} + else if(ffParseUptimeCommandOptions(&instance.config.uptime, key, value)) {} + else if(ffParseProcessesCommandOptions(&instance.config.processes, key, value)) {} + else if(ffParsePackagesCommandOptions(&instance.config.packages, key, value)) {} + else if(ffParseShellCommandOptions(&instance.config.shell, key, value)) {} + else if(ffParseDisplayCommandOptions(&instance.config.display, key, value)) {} + else if(ffParseBrightnessCommandOptions(&instance.config.brightness, key, value)) {} + else if(ffParseDECommandOptions(&instance.config.de, key, value)) {} + else if(ffParseWifiCommandOptions(&instance.config.wifi, key, value)) {} + else if(ffParseWMCommandOptions(&instance.config.wm, key, value)) {} + else if(ffParseWMThemeCommandOptions(&instance.config.wmTheme, key, value)) {} + else if(ffParseThemeCommandOptions(&instance.config.theme, key, value)) {} + else if(ffParseIconsCommandOptions(&instance.config.icons, key, value)) {} + else if(ffParseWallpaperCommandOptions(&instance.config.wallpaper, key, value)) {} + else if(ffParseFontCommandOptions(&instance.config.font, key, value)) {} + else if(ffParseCursorCommandOptions(&instance.config.cursor, key, value)) {} + else if(ffParseTerminalCommandOptions(&instance.config.terminal, key, value)) {} + else if(ffParseTerminalFontCommandOptions(&instance.config.terminalFont, key, value)) {} + else if(ffParseCPUCommandOptions(&instance.config.cpu, key, value)) {} + else if(ffParseCPUUsageCommandOptions(&instance.config.cpuUsage, key, value)) {} + else if(ffParseGPUCommandOptions(&instance.config.gpu, key, value)) {} + else if(ffParseMemoryCommandOptions(&instance.config.memory, key, value)) {} + else if(ffParseSwapCommandOptions(&instance.config.swap, key, value)) {} + else if(ffParseDiskCommandOptions(&instance.config.disk, key, value)) {} + else if(ffParseBatteryCommandOptions(&instance.config.battery, key, value)) {} + else if(ffParsePowerAdapterCommandOptions(&instance.config.powerAdapter, key, value)) {} + else if(ffParseLocaleCommandOptions(&instance.config.locale, key, value)) {} + else if(ffParseLocalIpCommandOptions(&instance.config.localIP, key, value)) {} + else if(ffParsePublicIpCommandOptions(&instance.config.publicIP, key, value)) {} + else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {} + else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {} + else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {} + else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {} + else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {} + else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {} + else if(ffParseOpenCLCommandOptions(&instance.config.openCL, key, value)) {} + else if(ffParseUsersCommandOptions(&instance.config.users, key, value)) {} + else if(ffParseBluetoothCommandOptions(&instance.config.bluetooth, key, value)) {} + else if(ffParseSeparatorCommandOptions(&instance.config.separator, key, value)) {} + else if(ffParseSoundCommandOptions(&instance.config.sound, key, value)) {} + else if(ffParseGamepadCommandOptions(&instance.config.gamepad, key, value)) {} + else if(ffParseColorsCommandOptions(&instance.config.colors, key, value)) {} /////////////////// //Library options// @@ -958,51 +958,51 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con { const char* subkey = key + strlen("--lib"); if(ffStrEqualsIgnCase(subkey, "-PCI")) - ffOptionParseString(key, value, &instance->config.libPCI); + ffOptionParseString(key, value, &instance.config.libPCI); else if(ffStrEqualsIgnCase(subkey, "-vulkan")) - ffOptionParseString(key, value, &instance->config.libVulkan); + ffOptionParseString(key, value, &instance.config.libVulkan); else if(ffStrEqualsIgnCase(subkey, "-freetype")) - ffOptionParseString(key, value, &instance->config.libfreetype); + ffOptionParseString(key, value, &instance.config.libfreetype); else if(ffStrEqualsIgnCase(subkey, "-wayland")) - ffOptionParseString(key, value, &instance->config.libWayland); + ffOptionParseString(key, value, &instance.config.libWayland); else if(ffStrEqualsIgnCase(subkey, "-xcb-randr")) - ffOptionParseString(key, value, &instance->config.libXcbRandr); + ffOptionParseString(key, value, &instance.config.libXcbRandr); else if(ffStrEqualsIgnCase(subkey, "-xcb")) - ffOptionParseString(key, value, &instance->config.libXcb); + ffOptionParseString(key, value, &instance.config.libXcb); else if(ffStrEqualsIgnCase(subkey, "-Xrandr")) - ffOptionParseString(key, value, &instance->config.libXrandr); + ffOptionParseString(key, value, &instance.config.libXrandr); else if(ffStrEqualsIgnCase(subkey, "-X11")) - ffOptionParseString(key, value, &instance->config.libX11); + ffOptionParseString(key, value, &instance.config.libX11); else if(ffStrEqualsIgnCase(subkey, "-gio")) - ffOptionParseString(key, value, &instance->config.libGIO); + ffOptionParseString(key, value, &instance.config.libGIO); else if(ffStrEqualsIgnCase(subkey, "-DConf")) - ffOptionParseString(key, value, &instance->config.libDConf); + ffOptionParseString(key, value, &instance.config.libDConf); else if(ffStrEqualsIgnCase(subkey, "-dbus")) - ffOptionParseString(key, value, &instance->config.libDBus); + ffOptionParseString(key, value, &instance.config.libDBus); else if(ffStrEqualsIgnCase(subkey, "-XFConf")) - ffOptionParseString(key, value, &instance->config.libXFConf); + ffOptionParseString(key, value, &instance.config.libXFConf); else if(ffStrEqualsIgnCase(subkey, "-sqlite") || ffStrEqualsIgnCase(subkey, "-sqlite3")) - ffOptionParseString(key, value, &instance->config.libSQLite3); + ffOptionParseString(key, value, &instance.config.libSQLite3); else if(ffStrEqualsIgnCase(subkey, "-rpm")) - ffOptionParseString(key, value, &instance->config.librpm); + ffOptionParseString(key, value, &instance.config.librpm); else if(ffStrEqualsIgnCase(subkey, "-imagemagick")) - ffOptionParseString(key, value, &instance->config.libImageMagick); + ffOptionParseString(key, value, &instance.config.libImageMagick); else if(ffStrEqualsIgnCase(subkey, "-z")) - ffOptionParseString(key, value, &instance->config.libZ); + ffOptionParseString(key, value, &instance.config.libZ); else if(ffStrEqualsIgnCase(subkey, "-chafa")) - ffOptionParseString(key, value, &instance->config.libChafa); + ffOptionParseString(key, value, &instance.config.libChafa); else if(ffStrEqualsIgnCase(subkey, "-egl")) - ffOptionParseString(key, value, &instance->config.libEGL); + ffOptionParseString(key, value, &instance.config.libEGL); else if(ffStrEqualsIgnCase(subkey, "-glx")) - ffOptionParseString(key, value, &instance->config.libGLX); + ffOptionParseString(key, value, &instance.config.libGLX); else if(ffStrEqualsIgnCase(subkey, "-osmesa")) - ffOptionParseString(key, value, &instance->config.libOSMesa); + ffOptionParseString(key, value, &instance.config.libOSMesa); else if(ffStrEqualsIgnCase(subkey, "-opencl")) - ffOptionParseString(key, value, &instance->config.libOpenCL); + ffOptionParseString(key, value, &instance.config.libOpenCL); else if(ffStrEqualsIgnCase(key, "-pulse")) - ffOptionParseString(key, value, &instance->config.libPulse); + ffOptionParseString(key, value, &instance.config.libPulse); else if(ffStrEqualsIgnCase(subkey, "-nm")) - ffOptionParseString(key, value, &instance->config.libnm); + ffOptionParseString(key, value, &instance.config.libnm); else goto error; } @@ -1019,34 +1019,34 @@ error: } } -static void parseConfigFiles(FFinstance* instance, FFdata* data) +static void parseConfigFiles(FFdata* data) { - for(uint32_t i = instance->state.platform.configDirs.length; i > 0; --i) + for(uint32_t i = instance.state.platform.configDirs.length; i > 0; --i) { - FFstrbuf* dir = ffListGet(&instance->state.platform.configDirs, i - 1); + FFstrbuf* dir = ffListGet(&instance.state.platform.configDirs, i - 1); uint32_t dirLength = dir->length; ffStrbufAppendS(dir, "fastfetch/config.jsonc"); - bool success = parseJsoncFile(instance, dir->chars); + bool success = parseJsoncFile(dir->chars); ffStrbufSubstrBefore(dir, dirLength); if (success) return; } - for(uint32_t i = instance->state.platform.configDirs.length; i > 0; --i) + for(uint32_t i = instance.state.platform.configDirs.length; i > 0; --i) { if(!data->loadUserConfig) return; - FFstrbuf* dir = ffListGet(&instance->state.platform.configDirs, i - 1); + FFstrbuf* dir = ffListGet(&instance.state.platform.configDirs, i - 1); uint32_t dirLength = dir->length; ffStrbufAppendS(dir, "fastfetch/config.conf"); - parseConfigFile(instance, data, dir->chars); + parseConfigFile(data, dir->chars); ffStrbufSubstrBefore(dir, dirLength); } } -static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv) +static void parseArguments(FFdata* data, int argc, const char** argv) { if(!data->loadUserConfig) return; @@ -1057,139 +1057,138 @@ static void parseArguments(FFinstance* instance, FFdata* data, int argc, const c *argv[i + 1] == '-' && strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a - )) { - parseOption(instance, data, argv[i], NULL); + parseOption(data, argv[i], NULL); } else { - parseOption(instance, data, argv[i], argv[i + 1]); + parseOption(data, argv[i], argv[i + 1]); ++i; } } } -static void parseStructureCommand(FFinstance* instance, const char* line) +static void parseStructureCommand(const char* line) { if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME)) - ffPrintBreak(instance); + ffPrintBreak(); else if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME)) - ffPrintTitle(instance, &instance->config.title); + ffPrintTitle(&instance.config.title); else if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME)) - ffPrintSeparator(instance, &instance->config.separator); + ffPrintSeparator(&instance.config.separator); else if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME)) - ffPrintOS(instance, &instance->config.os); + ffPrintOS(&instance.config.os); else if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME)) - ffPrintHost(instance, &instance->config.host); + ffPrintHost(&instance.config.host); else if(ffStrEqualsIgnCase(line, FF_BIOS_MODULE_NAME)) - ffPrintBios(instance, &instance->config.bios); + ffPrintBios(&instance.config.bios); else if(ffStrEqualsIgnCase(line, FF_BOARD_MODULE_NAME)) - ffPrintBoard(instance, &instance->config.board); + ffPrintBoard(&instance.config.board); else if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME)) - ffPrintBrightness(instance, &instance->config.brightness); + ffPrintBrightness(&instance.config.brightness); else if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME)) - ffPrintChassis(instance, &instance->config.chassis); + ffPrintChassis(&instance.config.chassis); else if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME)) - ffPrintKernel(instance, &instance->config.kernel); + ffPrintKernel(&instance.config.kernel); else if(ffStrEqualsIgnCase(line, FF_PROCESSES_MODULE_NAME)) - ffPrintProcesses(instance, &instance->config.processes); + ffPrintProcesses(&instance.config.processes); else if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME)) - ffPrintUptime(instance, &instance->config.uptime); + ffPrintUptime(&instance.config.uptime); else if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME)) - ffPrintPackages(instance, &instance->config.packages); + ffPrintPackages(&instance.config.packages); else if(ffStrEqualsIgnCase(line, FF_SHELL_MODULE_NAME)) - ffPrintShell(instance, &instance->config.shell); + ffPrintShell(&instance.config.shell); else if(ffStrEqualsIgnCase(line, FF_DISPLAY_MODULE_NAME)) - ffPrintDisplay(instance, &instance->config.display); + ffPrintDisplay(&instance.config.display); else if(ffStrEqualsIgnCase(line, FF_DE_MODULE_NAME)) - ffPrintDE(instance, &instance->config.de); + ffPrintDE(&instance.config.de); else if(ffStrEqualsIgnCase(line, FF_WM_MODULE_NAME)) - ffPrintWM(instance, &instance->config.wm); + ffPrintWM(&instance.config.wm); else if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME)) - ffPrintTheme(instance, &instance->config.theme); + ffPrintTheme(&instance.config.theme); else if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME)) - ffPrintWMTheme(instance, &instance->config.wmTheme); + ffPrintWMTheme(&instance.config.wmTheme); else if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME)) - ffPrintIcons(instance, &instance->config.icons); + ffPrintIcons(&instance.config.icons); else if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME)) - ffPrintWallpaper(instance, &instance->config.wallpaper); + ffPrintWallpaper(&instance.config.wallpaper); else if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME)) - ffPrintFont(instance, &instance->config.font); + ffPrintFont(&instance.config.font); else if(ffStrEqualsIgnCase(line, FF_CURSOR_MODULE_NAME)) - ffPrintCursor(instance, &instance->config.cursor); + ffPrintCursor(&instance.config.cursor); else if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME)) - ffPrintTerminal(instance, &instance->config.terminal); + ffPrintTerminal(&instance.config.terminal); else if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME)) - ffPrintTerminalFont(instance, &instance->config.terminalFont); + ffPrintTerminalFont(&instance.config.terminalFont); else if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME)) - ffPrintCPU(instance, &instance->config.cpu); + ffPrintCPU(&instance.config.cpu); else if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME)) - ffPrintCPUUsage(instance, &instance->config.cpuUsage); + ffPrintCPUUsage(&instance.config.cpuUsage); else if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME)) - ffPrintCustom(instance, &instance->config.custom); + ffPrintCustom(&instance.config.custom); else if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME)) - ffPrintGPU(instance, &instance->config.gpu); + ffPrintGPU(&instance.config.gpu); else if(ffStrEqualsIgnCase(line, FF_MEMORY_MODULE_NAME)) - ffPrintMemory(instance, &instance->config.memory); + ffPrintMemory(&instance.config.memory); else if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME)) - ffPrintSwap(instance, &instance->config.swap); + ffPrintSwap(&instance.config.swap); else if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME)) - ffPrintDisk(instance, &instance->config.disk); + ffPrintDisk(&instance.config.disk); else if(ffStrEqualsIgnCase(line, FF_BATTERY_MODULE_NAME)) - ffPrintBattery(instance, &instance->config.battery); + ffPrintBattery(&instance.config.battery); else if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME)) - ffPrintPowerAdapter(instance, &instance->config.powerAdapter); + ffPrintPowerAdapter(&instance.config.powerAdapter); else if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME)) - ffPrintLM(instance, &instance->config.lm); + ffPrintLM(&instance.config.lm); else if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME)) - ffPrintLocale(instance, &instance->config.locale); + ffPrintLocale(&instance.config.locale); else if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) - ffPrintLocalIp(instance, &instance->config.localIP); + ffPrintLocalIp(&instance.config.localIP); else if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME)) - ffPrintPublicIp(instance, &instance->config.publicIP); + ffPrintPublicIp(&instance.config.publicIP); else if(ffStrEqualsIgnCase(line, FF_WIFI_MODULE_NAME)) - ffPrintWifi(instance, &instance->config.wifi); + ffPrintWifi(&instance.config.wifi); else if(ffStrEqualsIgnCase(line, FF_WEATHER_MODULE_NAME)) - ffPrintWeather(instance, &instance->config.weather); + ffPrintWeather(&instance.config.weather); else if(ffStrEqualsIgnCase(line, FF_PLAYER_MODULE_NAME)) - ffPrintPlayer(instance, &instance->config.player); + ffPrintPlayer(&instance.config.player); else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) - ffPrintMedia(instance, &instance->config.media); + ffPrintMedia(&instance.config.media); else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) - ffPrintDateTime(instance, &instance->config.dateTime); + ffPrintDateTime(&instance.config.dateTime); else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) - ffPrintColors(instance, &instance->config.colors); + ffPrintColors(&instance.config.colors); else if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME)) - ffPrintVulkan(instance, &instance->config.vulkan); + ffPrintVulkan(&instance.config.vulkan); else if(ffStrEqualsIgnCase(line, FF_OPENGL_MODULE_NAME)) - ffPrintOpenGL(instance, &instance->config.openGL); + ffPrintOpenGL(&instance.config.openGL); else if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME)) - ffPrintOpenCL(instance, &instance->config.openCL); + ffPrintOpenCL(&instance.config.openCL); else if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME)) - ffPrintUsers(instance, &instance->config.users); + ffPrintUsers(&instance.config.users); else if(ffStrEqualsIgnCase(line, FF_COMMAND_MODULE_NAME)) - ffPrintCommand(instance, &instance->config.command); + ffPrintCommand(&instance.config.command); else if(ffStrEqualsIgnCase(line, FF_BLUETOOTH_MODULE_NAME)) - ffPrintBluetooth(instance, &instance->config.bluetooth); + ffPrintBluetooth(&instance.config.bluetooth); else if(ffStrEqualsIgnCase(line, FF_SOUND_MODULE_NAME)) - ffPrintSound(instance, &instance->config.sound); + ffPrintSound(&instance.config.sound); else if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME)) - ffPrintGamepad(instance, &instance->config.gamepad); + ffPrintGamepad(&instance.config.gamepad); else - ffPrintErrorString(instance, line, 0, NULL, NULL, ""); + ffPrintErrorString(line, 0, NULL, NULL, ""); } int main(int argc, const char** argv) { - FFinstance instance; - ffInitInstance(&instance); + ffInitInstance(); //Data stores things only needed for the configuration of fastfetch FFdata data; - ffStrbufInitA(&data.structure, 256); + ffStrbufInit(&data.structure); data.loadUserConfig = true; if(!getenv("NO_CONFIG")) - parseConfigFiles(&instance, &data); - parseArguments(&instance, &data, argc, argv); + parseConfigFiles(&data); + parseArguments(&data, argc, argv); if(data.structure.length > 0 || !instance.state.configDoc) { @@ -1210,7 +1209,7 @@ int main(int argc, const char** argv) } } - ffStart(&instance); + ffStart(); #if defined(_WIN32) if (!instance.config.noBuffer) fflush(stdout); @@ -1218,7 +1217,7 @@ int main(int argc, const char** argv) if (data.structure.length == 0 && instance.state.configDoc) { - ffPrintJsonConfig(&instance); + ffPrintJsonConfig(); } else { @@ -1233,7 +1232,7 @@ int main(int argc, const char** argv) if(__builtin_expect(instance.config.stat, false)) ms = ffTimeGetTick(); - parseStructureCommand(&instance, data.structure.chars + startIndex); + parseStructureCommand(data.structure.chars + startIndex); if(__builtin_expect(instance.config.stat, false)) { @@ -1253,9 +1252,9 @@ int main(int argc, const char** argv) } } - ffFinish(&instance); + ffFinish(); ffStrbufDestroy(&data.structure); - ffDestroyInstance(&instance); + ffDestroyInstance(); } diff --git a/src/fastfetch.h b/src/fastfetch.h index 48d7dfa37..c76882c15 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -152,16 +152,17 @@ typedef struct FFinstance FFconfig config; FFstate state; } FFinstance; +extern FFinstance instance; // Defined in `common/init.c` ////////////////////// // Init functions // ////////////////////// //common/init.c -void ffInitInstance(FFinstance* instance); -void ffStart(FFinstance* instance); -void ffFinish(FFinstance* instance); -void ffDestroyInstance(FFinstance* instance); +void ffInitInstance(); +void ffStart(); +void ffFinish(); +void ffDestroyInstance(); void ffListFeatures(); @@ -169,11 +170,11 @@ void ffListFeatures(); // Logo functions // //////////////////// -void ffLogoPrint(FFinstance* instance); -void ffLogoPrintRemaining(FFinstance* instance); -void ffLogoPrintLine(FFinstance* instance); +void ffLogoPrint(); +void ffLogoPrintRemaining(); +void ffLogoPrintLine(); -void ffLogoBuiltinPrint(FFinstance* instance); +void ffLogoBuiltinPrint(); void ffLogoBuiltinList(); void ffLogoBuiltinListAutocompletion(); diff --git a/src/flashfetch.c b/src/flashfetch.c index b7b18fc9f..3417548f5 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -2,76 +2,70 @@ #include "modules/modules.h" -int main(int argc, char** argv) +int main(void) { - //Disable compiler warnings - FF_UNUSED(argc, argv); - - FFinstance instance; - ffInitInstance(&instance); //This also applys default configuration to instance.config + ffInitInstance(); //This also applys default configuration to instance.config //Modify instance.config here // ffPrepareCPUUsage(); // ffPreparePublicIp(&instance.config.publicIP); - // ffPrepareWeather(&instance); + // ffPrepareWeather(&instance.config.weather); //Does things like starting detection threads, disabling line wrap, etc - ffStart(&instance); + ffStart(); //Printing - ffPrintTitle(&instance, &instance.config.title); - ffPrintSeparator(&instance, &instance.config.separator); - ffPrintOS(&instance, &instance.config.os); - ffPrintHost(&instance, &instance.config.host); - //ffPrintBios(&instance, &instance.config.bios); - //ffPrintBoard(&instance, &instance.config.board); - //ffPrintChassis(&instance, &instance.config.chassis); - ffPrintKernel(&instance, &instance.config.kernel); - //ffPrintProcesses(&instance, &instance.config.processes); - ffPrintUptime(&instance, &instance.config.uptime); - ffPrintPackages(&instance, &instance.config.packages); - ffPrintShell(&instance, &instance.config.shell); - ffPrintDisplay(&instance, &instance.config.display); - // ffPrintBrightness(&instance); - ffPrintDE(&instance, &instance.config.de); - ffPrintWM(&instance, &instance.config.wm); - ffPrintWMTheme(&instance, &instance.config.wmTheme); - ffPrintTheme(&instance, &instance.config.theme); - ffPrintIcons(&instance, &instance.config.icons); - ffPrintFont(&instance, &instance.config.font); - ffPrintCursor(&instance, &instance.config.cursor); - ffPrintTerminal(&instance, &instance.config.terminal); - ffPrintTerminalFont(&instance, &instance.config.terminalFont); - ffPrintCPU(&instance, &instance.config.cpu); - ffPrintGPU(&instance, &instance.config.gpu); - ffPrintMemory(&instance, &instance.config.memory); - ffPrintSwap(&instance, &instance.config.swap); - ffPrintDisk(&instance, &instance.config.disk); - ffPrintBattery(&instance, &instance.config.battery); - ffPrintPowerAdapter(&instance, &instance.config.powerAdapter); - //ffPrintPlayer(&instance, &instance.config.player); - //ffPrintMedia(&instance, &instance.config.media); - //ffPrintLocalIp(&instance); - //ffPrintPublicIp(&instance, &instance.config.publicIp); - //ffPrintWifi(&instance); - //ffPrintCPUUsage(&instance, &instance.config.cpuUsage); - ffPrintLocale(&instance, &instance.config.locale); - //ffPrintDateTime(&instance); - //ffPrintDate(&instance); - //ffPrintTime(&instance); - //ffPrintVulkan(&instance, &instance.config.vulkan); - //ffPrintOpenGL(&instance, &instance.config.openGL); - //ffPrintOpenCL(&instance, &instance.config.openCL); - //ffPrintUsers(&instance, &instance.config.users); - //ffPrintWeather(&instance, &instance.config.weather); - //ffPrintBluetooth(&instance); - //ffPrintSound(&instance, &instance.config.sound); - //ffPrintGamepad(&instance); - ffPrintBreak(&instance); - ffPrintColors(&instance, &instance.config.colors); + ffPrintTitle(&instance.config.title); + ffPrintSeparator(&instance.config.separator); + ffPrintOS(&instance.config.os); + ffPrintHost(&instance.config.host); + //ffPrintBios(&instance.config.bios); + //ffPrintBoard(&instance.config.board); + //ffPrintChassis(&instance.config.chassis); + ffPrintKernel(&instance.config.kernel); + //ffPrintProcesses(&instance.config.processes); + ffPrintUptime(&instance.config.uptime); + ffPrintPackages(&instance.config.packages); + ffPrintShell(&instance.config.shell); + ffPrintDisplay(&instance.config.display); + // ffPrintBrightness(&instance.config.brightness); + ffPrintDE(&instance.config.de); + ffPrintWM(&instance.config.wm); + ffPrintWMTheme(&instance.config.wmTheme); + ffPrintTheme(&instance.config.theme); + ffPrintIcons(&instance.config.icons); + ffPrintFont(&instance.config.font); + ffPrintCursor(&instance.config.cursor); + ffPrintTerminal(&instance.config.terminal); + ffPrintTerminalFont(&instance.config.terminalFont); + ffPrintCPU(&instance.config.cpu); + ffPrintGPU(&instance.config.gpu); + ffPrintMemory(&instance.config.memory); + ffPrintSwap(&instance.config.swap); + ffPrintDisk(&instance.config.disk); + ffPrintBattery(&instance.config.battery); + ffPrintPowerAdapter(&instance.config.powerAdapter); + //ffPrintPlayer(&instance.config.player); + //ffPrintMedia(&instance.config.media); + //ffPrintLocalIp(&instance.config.localIp); + //ffPrintPublicIp(&instance.config.publicIp); + //ffPrintWifi(&instance.config.wifi); + //ffPrintCPUUsage(&instance.config.cpuUsage); + ffPrintLocale(&instance.config.locale); + //ffPrintDateTime(&instance.config.dateTime); + //ffPrintVulkan(&instance.config.vulkan); + //ffPrintOpenGL(&instance.config.openGL); + //ffPrintOpenCL(&instance.config.openCL); + //ffPrintUsers(&instance.config.users); + //ffPrintWeather(&instance.config.weather); + //ffPrintBluetooth(&instance.config.bluetooth); + //ffPrintSound(&instance.config.sound); + //ffPrintGamepad(&instance.config.gamepad); + ffPrintBreak(); + ffPrintColors(&instance.config.colors); - ffFinish(&instance); - ffDestroyInstance(&instance); + ffFinish(); + ffDestroyInstance(); return 0; } diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4962331e3..a86cdfdf1 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -8,7 +8,7 @@ #define FF_LOGO_COLOR_TITLE(x) logo.colorTitle = x; #define FF_LOGO_RETURN return &logo; -const FFlogo* ffLogoBuiltinGetUnknown() +const FFlogo* ffLogoBuiltinGetUnknown(void) { FF_LOGO_INIT FF_LOGO_NAMES("unknown", "question mark", "?") @@ -38,7 +38,7 @@ const FFlogo* ffLogoBuiltinGetUnknown() FF_LOGO_RETURN } -static const FFlogo* getLogoAlmaLinux() +static const FFlogo* getLogoAlmaLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("almalinux") @@ -76,7 +76,7 @@ static const FFlogo* getLogoAlmaLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoAlpine() +static const FFlogo* getLogoAlpine(void) { FF_LOGO_INIT FF_LOGO_NAMES("alpine", "alpinelinux", "alpine-linux") @@ -110,7 +110,7 @@ static const FFlogo* getLogoAlpine() FF_LOGO_RETURN } -static const FFlogo* getLogoAlpineSmall() +static const FFlogo* getLogoAlpineSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("alpine_small", "alpine-linux-small") @@ -130,7 +130,7 @@ static const FFlogo* getLogoAlpineSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoAndroid() +static const FFlogo* getLogoAndroid(void) { FF_LOGO_INIT FF_LOGO_NAMES("android") @@ -163,7 +163,7 @@ static const FFlogo* getLogoAndroid() FF_LOGO_RETURN } -static const FFlogo* getLogoAndroidSmall() +static const FFlogo* getLogoAndroidSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("android-small", "android_small") @@ -183,7 +183,7 @@ static const FFlogo* getLogoAndroidSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoArch() +static const FFlogo* getLogoArch(void) { FF_LOGO_INIT FF_LOGO_NAMES("arch", "archlinux", "arch-linux") @@ -217,7 +217,7 @@ static const FFlogo* getLogoArch() FF_LOGO_RETURN } -static const FFlogo* getLogoArchSmall() +static const FFlogo* getLogoArchSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("arch_small", "archlinux_small", "arch-linux-small") @@ -238,7 +238,7 @@ static const FFlogo* getLogoArchSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoArtix() +static const FFlogo* getLogoArtix(void) { FF_LOGO_INIT FF_LOGO_NAMES("artix", "artixlinux", "artix-linux") @@ -272,7 +272,7 @@ static const FFlogo* getLogoArtix() FF_LOGO_RETURN } -static const FFlogo* getLogoArtixSmall() +static const FFlogo* getLogoArtixSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("artix_small", "artixlinux_small", "artix-linux-small") @@ -293,7 +293,7 @@ static const FFlogo* getLogoArtixSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoArcoLinux() +static const FFlogo* getLogoArcoLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("arco", "arcolinux", "arco-linux") @@ -328,7 +328,7 @@ static const FFlogo* getLogoArcoLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoBSD() +static const FFlogo* getLogoBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("bsd") @@ -365,7 +365,7 @@ static const FFlogo* getLogoBSD() FF_LOGO_RETURN } -static const FFlogo* getLogoBedrock() +static const FFlogo* getLogoBedrock(void) { FF_LOGO_INIT FF_LOGO_NAMES("bedrock", "bedrocklinux", "bedrock-linux") @@ -397,7 +397,7 @@ static const FFlogo* getLogoBedrock() FF_LOGO_RETURN } -static const FFlogo* getLogoCachyOS() +static const FFlogo* getLogoCachyOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cachy", "cachyos", "cachy-linux", "cachyos-linux") @@ -435,7 +435,7 @@ static const FFlogo* getLogoCachyOS() FF_LOGO_RETURN } -static const FFlogo* getLogoCachyOSSmall() +static const FFlogo* getLogoCachyOSSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small") @@ -458,7 +458,7 @@ static const FFlogo* getLogoCachyOSSmall() } -static const FFlogo* getLogoCelOS() +static const FFlogo* getLogoCelOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cel", "celos", "cel-linux", "celos-linux") @@ -488,7 +488,7 @@ static const FFlogo* getLogoCelOS() FF_LOGO_RETURN } -static const FFlogo* getLogoCentOS() +static const FFlogo* getLogoCentOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cent", "centos", "cent-linux", "centos-linux") @@ -525,7 +525,7 @@ static const FFlogo* getLogoCentOS() FF_LOGO_RETURN } -static const FFlogo* getLogoCentOSSmall() +static const FFlogo* getLogoCentOSSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small") @@ -549,7 +549,7 @@ static const FFlogo* getLogoCentOSSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoCRUX() +static const FFlogo* getLogoCRUX(void) { FF_LOGO_INIT FF_LOGO_NAMES("CRUX", "crux") @@ -583,7 +583,7 @@ static const FFlogo* getLogoCRUX() FF_LOGO_RETURN } -static const FFlogo* getLogoCrystalLinux() +static const FFlogo* getLogoCrystalLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("crystal", "Crystal", "crystal-linux", "Crystal-Linux") @@ -619,7 +619,7 @@ static const FFlogo* getLogoCrystalLinux() -static const FFlogo* getLogoDebian() +static const FFlogo* getLogoDebian(void) { FF_LOGO_INIT FF_LOGO_NAMES("debian", "debian-linux") @@ -651,7 +651,7 @@ static const FFlogo* getLogoDebian() FF_LOGO_RETURN } -static const FFlogo* getLogoDebianSmall() +static const FFlogo* getLogoDebianSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("debian_small", "debian-linux-small") @@ -671,7 +671,7 @@ static const FFlogo* getLogoDebianSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoDevuan() +static const FFlogo* getLogoDevuan(void) { FF_LOGO_INIT FF_LOGO_NAMES("devuan", "devuan-linux") @@ -700,7 +700,7 @@ static const FFlogo* getLogoDevuan() FF_LOGO_RETURN } -static const FFlogo* getLogoDevuanSmall() +static const FFlogo* getLogoDevuanSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("devuan_small", "devuan-linux-small") @@ -721,7 +721,7 @@ static const FFlogo* getLogoDevuanSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoDeepin() +static const FFlogo* getLogoDeepin(void) { FF_LOGO_INIT FF_LOGO_NAMES("deepin", "deepin-linux") @@ -753,7 +753,7 @@ static const FFlogo* getLogoDeepin() FF_LOGO_RETURN } -static const FFlogo* getLogoEndeavour() +static const FFlogo* getLogoEndeavour(void) { FF_LOGO_INIT FF_LOGO_NAMES("endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux") @@ -784,7 +784,7 @@ static const FFlogo* getLogoEndeavour() FF_LOGO_RETURN } -static const FFlogo* getLogoEnso() +static const FFlogo* getLogoEnso(void) { FF_LOGO_INIT FF_LOGO_NAMES("enso", "uqc") @@ -817,7 +817,7 @@ static const FFlogo* getLogoEnso() FF_LOGO_RETURN } -static const FFlogo* getLogoFedora() +static const FFlogo* getLogoFedora(void) { FF_LOGO_INIT FF_LOGO_NAMES("fedora", "fedora-linux") @@ -851,7 +851,7 @@ static const FFlogo* getLogoFedora() FF_LOGO_RETURN } -static const FFlogo* getLogoFedoraSmall() +static const FFlogo* getLogoFedoraSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("fedora_small", "fedora-linux-small") @@ -874,7 +874,7 @@ static const FFlogo* getLogoFedoraSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoFedoraOld() +static const FFlogo* getLogoFedoraOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old") @@ -906,7 +906,7 @@ static const FFlogo* getLogoFedoraOld() FF_LOGO_RETURN } -static const FFlogo* getLogoFreeBSD() +static const FFlogo* getLogoFreeBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("freebsd") @@ -936,7 +936,7 @@ static const FFlogo* getLogoFreeBSD() FF_LOGO_RETURN } -static const FFlogo* getLogoFreeBSDSmall() +static const FFlogo* getLogoFreeBSDSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("freebsd_small") @@ -956,7 +956,7 @@ static const FFlogo* getLogoFreeBSDSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoGaruda() +static const FFlogo* getLogoGaruda(void) { FF_LOGO_INIT FF_LOGO_NAMES("garuda", "garuda-linux") @@ -988,7 +988,7 @@ static const FFlogo* getLogoGaruda() FF_LOGO_RETURN } -static const FFlogo* getLogoGarudaSmall() +static const FFlogo* getLogoGarudaSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("garuda_small", "garudalinux_small", "garuda-linux-small") @@ -1007,7 +1007,7 @@ static const FFlogo* getLogoGarudaSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoGentoo() +static const FFlogo* getLogoGentoo(void) { FF_LOGO_INIT FF_LOGO_NAMES("gentoo", "gentoo-linux") @@ -1040,7 +1040,7 @@ static const FFlogo* getLogoGentoo() FF_LOGO_RETURN } -static const FFlogo* getLogoGentooSmall() +static const FFlogo* getLogoGentooSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("gentoo_small", "gentoo-linux-small") @@ -1064,7 +1064,7 @@ static const FFlogo* getLogoGentooSmall() #define FF_RAW_STRING(x) #x -static const FFlogo* getLogoGhostBSD() +static const FFlogo* getLogoGhostBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("ghostbsd") @@ -1091,7 +1091,7 @@ static const FFlogo* getLogoGhostBSD() FF_LOGO_RETURN } -static const FFlogo* getLogoKDENeon() +static const FFlogo* getLogoKDENeon(void) { FF_LOGO_INIT FF_LOGO_NAMES("kde", "kde-neon", "neon") @@ -1124,7 +1124,7 @@ static const FFlogo* getLogoKDENeon() FF_LOGO_RETURN } -static const FFlogo* getLogoKISSLinux() +static const FFlogo* getLogoKISSLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("kiss", "kiss-linux", "kisslinux") @@ -1147,7 +1147,7 @@ static const FFlogo* getLogoKISSLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoKubuntu() +static const FFlogo* getLogoKubuntu(void) { FF_LOGO_INIT FF_LOGO_NAMES("kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma") @@ -1182,7 +1182,7 @@ static const FFlogo* getLogoKubuntu() FF_LOGO_RETURN } -static const FFlogo* getLogoLangitKetujuh() +static const FFlogo* getLogoLangitKetujuh(void) { FF_LOGO_INIT FF_LOGO_NAMES("l7", "langitketujuh", "LangitKetujuh") @@ -1210,7 +1210,7 @@ static const FFlogo* getLogoLangitKetujuh() FF_LOGO_RETURN } -static const FFlogo* getLogoLinux() +static const FFlogo* getLogoLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("linux", "linux-generic") @@ -1238,7 +1238,7 @@ static const FFlogo* getLogoLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoMacOS() +static const FFlogo* getLogoMacOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("macos", "mac", "apple", "darwin", "osx") @@ -1273,7 +1273,7 @@ static const FFlogo* getLogoMacOS() FF_LOGO_RETURN } -static const FFlogo* getLogoMacOSSmall() +static const FFlogo* getLogoMacOSSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("macos_small", "mac_small", "apple_small", "darwin_small", "osx_small") @@ -1298,7 +1298,7 @@ static const FFlogo* getLogoMacOSSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoMacOSSmall2() +static const FFlogo* getLogoMacOSSmall2(void) { FF_LOGO_INIT FF_LOGO_NAMES("macos_small2", "mac_small2", "apple_small2", "darwin_small2", "osx_small2") @@ -1323,7 +1323,7 @@ static const FFlogo* getLogoMacOSSmall2() FF_LOGO_RETURN } -static const FFlogo* getLogoManjaro() +static const FFlogo* getLogoManjaro(void) { FF_LOGO_INIT FF_LOGO_NAMES("manjaro", "manjaro-linux") @@ -1351,7 +1351,7 @@ static const FFlogo* getLogoManjaro() FF_LOGO_RETURN } -static const FFlogo* getLogoManjaroSmall() +static const FFlogo* getLogoManjaroSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("manjaro_small", "manjaro-linux-small") @@ -1372,7 +1372,7 @@ static const FFlogo* getLogoManjaroSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoMint() +static const FFlogo* getLogoMint(void) { FF_LOGO_INIT FF_LOGO_NAMES("mint", "linuxmint", "mint-linux", "linux-mint") @@ -1406,7 +1406,7 @@ static const FFlogo* getLogoMint() FF_LOGO_RETURN } -static const FFlogo* getLogoMintSmall() +static const FFlogo* getLogoMintSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("mint_small", "linuxmint_small", "mint-linux-small") @@ -1428,7 +1428,7 @@ static const FFlogo* getLogoMintSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoMintOld() +static const FFlogo* getLogoMintOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old") @@ -1459,7 +1459,7 @@ static const FFlogo* getLogoMintOld() FF_LOGO_RETURN } -static const FFlogo* getLogoMsys2() +static const FFlogo* getLogoMsys2(void) { FF_LOGO_INIT FF_LOGO_NAMES("msys2") @@ -1500,7 +1500,7 @@ static const FFlogo* getLogoMsys2() FF_LOGO_RETURN } -static const FFlogo* getLogoWindows11() +static const FFlogo* getLogoWindows11(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows 11", "Windows Server 2022") @@ -1534,7 +1534,7 @@ static const FFlogo* getLogoWindows11() FF_LOGO_RETURN } -static const FFlogo* getLogoWindows11Small() +static const FFlogo* getLogoWindows11Small(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") @@ -1557,7 +1557,7 @@ static const FFlogo* getLogoWindows11Small() FF_LOGO_RETURN } -static const FFlogo* getLogoWindows8() +static const FFlogo* getLogoWindows8(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019") @@ -1593,7 +1593,7 @@ static const FFlogo* getLogoWindows8() FF_LOGO_RETURN } -static const FFlogo* getLogoWindows() +static const FFlogo* getLogoWindows(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2") @@ -1626,7 +1626,7 @@ static const FFlogo* getLogoWindows() FF_LOGO_RETURN } -static const FFlogo* getLogoNixOS() +static const FFlogo* getLogoNixOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux") @@ -1661,7 +1661,7 @@ static const FFlogo* getLogoNixOS() FF_LOGO_RETURN } -static const FFlogo* getLogoNixOsOld() +static const FFlogo* getLogoNixOsOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old") @@ -1704,7 +1704,7 @@ static const FFlogo* getLogoNixOsOld() FF_LOGO_RETURN } -static const FFlogo* getLogoNixOsSmall() +static const FFlogo* getLogoNixOsSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small") @@ -1725,7 +1725,7 @@ static const FFlogo* getLogoNixOsSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoNobara() +static const FFlogo* getLogoNobara(void) { FF_LOGO_INIT FF_LOGO_NAMES("nobara", "nobara-linux"); @@ -1756,7 +1756,7 @@ static const FFlogo* getLogoNobara() FF_LOGO_RETURN } -static const FFlogo* getLogoOpenSuse() +static const FFlogo* getLogoOpenSuse(void) { FF_LOGO_INIT FF_LOGO_NAMES("suse", "opensuse", "open_suse", "open-suse", "suse-linux") @@ -1789,7 +1789,7 @@ static const FFlogo* getLogoOpenSuse() FF_LOGO_RETURN } -static const FFlogo* getLogoOpenSuseSmall() +static const FFlogo* getLogoOpenSuseSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("suse_small", "opensuse_small", "open_suse_small", "open-suse_small") @@ -1810,7 +1810,7 @@ static const FFlogo* getLogoOpenSuseSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoOpenSuseLeap() +static const FFlogo* getLogoOpenSuseLeap(void) { FF_LOGO_INIT FF_LOGO_NAMES("opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap") @@ -1840,7 +1840,7 @@ static const FFlogo* getLogoOpenSuseLeap() FF_LOGO_RETURN } -static const FFlogo* getLogoOpenSuseTumbleweed() +static const FFlogo* getLogoOpenSuseTumbleweed(void) { FF_LOGO_INIT FF_LOGO_NAMES("opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed") @@ -1867,7 +1867,7 @@ static const FFlogo* getLogoOpenSuseTumbleweed() FF_LOGO_RETURN } -static const FFlogo* getLogoOpenMandriva() +static const FFlogo* getLogoOpenMandriva(void) { FF_LOGO_INIT FF_LOGO_NAMES("openmandriva", "open-mandriva", "open_mandriva") @@ -1906,7 +1906,7 @@ static const FFlogo* getLogoOpenMandriva() FF_LOGO_RETURN } -static const FFlogo* getLogoPop() +static const FFlogo* getLogoPop(void) { FF_LOGO_INIT FF_LOGO_NAMES("pop", "popos", "pop_os", "pop-linux") @@ -1941,7 +1941,7 @@ static const FFlogo* getLogoPop() FF_LOGO_RETURN } -static const FFlogo* getLogoParabola() +static const FFlogo* getLogoParabola(void) { FF_LOGO_INIT FF_LOGO_NAMES("parabola", "parabola-gnulinux") @@ -1971,7 +1971,7 @@ static const FFlogo* getLogoParabola() FF_LOGO_RETURN } -static const FFlogo* getLogoParabolaSmall() +static const FFlogo* getLogoParabolaSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("parabola_small", "parabola-gnulinux_small") @@ -1991,7 +1991,7 @@ static const FFlogo* getLogoParabolaSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoPopSmall() +static const FFlogo* getLogoPopSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("pop_small", "popos_small", "pop_os_small", "pop-linux-small") @@ -2012,7 +2012,7 @@ static const FFlogo* getLogoPopSmall() FF_LOGO_COLOR_TITLE("36"); //cyan FF_LOGO_RETURN } -static const FFlogo* getLogoRaspbian() +static const FFlogo* getLogoRaspbian(void) { FF_LOGO_INIT FF_LOGO_NAMES("raspbian", "raspi", "raspberrypi" "raspberrypios" "pios") @@ -2050,7 +2050,7 @@ static const FFlogo* getLogoRaspbian() FF_LOGO_RETURN } -static const FFlogo* getLogoRaspbianSmall() +static const FFlogo* getLogoRaspbianSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small") @@ -2075,7 +2075,7 @@ static const FFlogo* getLogoRaspbianSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoReborn() +static const FFlogo* getLogoReborn(void) { FF_LOGO_INIT FF_LOGO_NAMES("reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux") @@ -2110,7 +2110,7 @@ static const FFlogo* getLogoReborn() FF_LOGO_RETURN } -static const FFlogo* getLogoRebornSmall() +static const FFlogo* getLogoRebornSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small") @@ -2135,7 +2135,7 @@ static const FFlogo* getLogoRebornSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoRedHatEnterpriseLinux() +static const FFlogo* getLogoRedHatEnterpriseLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rhel", "redhat", "redhat-linux") @@ -2167,7 +2167,7 @@ static const FFlogo* getLogoRedHatEnterpriseLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoRedstarOS() +static const FFlogo* getLogoRedstarOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux") @@ -2199,7 +2199,7 @@ static const FFlogo* getLogoRedstarOS() FF_LOGO_RETURN } -static const FFlogo* getLogoRockyLinux() +static const FFlogo* getLogoRockyLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rocky", "rocky-linux", "rockylinux") @@ -2232,7 +2232,7 @@ static const FFlogo* getLogoRockyLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoRosaLinux() +static const FFlogo* getLogoRosaLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rosa", "rosa-linux", "rosalinux") @@ -2266,7 +2266,7 @@ static const FFlogo* getLogoRosaLinux() FF_LOGO_RETURN } -static const FFlogo* getLogoSlackware() +static const FFlogo* getLogoSlackware(void) { FF_LOGO_INIT FF_LOGO_NAMES("slackware", "slackware-linux", "slackwarelinux") @@ -2302,7 +2302,7 @@ static const FFlogo* getLogoSlackware() FF_LOGO_RETURN } -static const FFlogo* getLogoSlackwareSmall() +static const FFlogo* getLogoSlackwareSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small") @@ -2323,7 +2323,7 @@ static const FFlogo* getLogoSlackwareSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoSolus() +static const FFlogo* getLogoSolus(void) { FF_LOGO_INIT FF_LOGO_NAMES("solus", "solus-linux") @@ -2358,7 +2358,7 @@ static const FFlogo* getLogoSolus() FF_LOGO_RETURN } -static const FFlogo* getLogoSteamOS() +static const FFlogo* getLogoSteamOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("steamos") @@ -2391,7 +2391,7 @@ static const FFlogo* getLogoSteamOS() FF_LOGO_RETURN } -static const FFlogo* getLogoUbuntu() +static const FFlogo* getLogoUbuntu(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu", "ubuntu-linux") @@ -2427,7 +2427,7 @@ static const FFlogo* getLogoUbuntu() FF_LOGO_RETURN } -static const FFlogo* getLogoUbuntuOld() +static const FFlogo* getLogoUbuntuOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu_old", "ubuntu-linux_old") @@ -2462,7 +2462,7 @@ static const FFlogo* getLogoUbuntuOld() FF_LOGO_RETURN } -static const FFlogo* getLogoUbuntuSmall() +static const FFlogo* getLogoUbuntuSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu_small", "ubuntu-linux-small") @@ -2482,7 +2482,7 @@ static const FFlogo* getLogoUbuntuSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoVanilla() +static const FFlogo* getLogoVanilla(void) { FF_LOGO_INIT @@ -2515,7 +2515,7 @@ static const FFlogo* getLogoVanilla() FF_LOGO_RETURN } -static const FFlogo* getLogoVoid() +static const FFlogo* getLogoVoid(void) { FF_LOGO_INIT FF_LOGO_NAMES("void", "void-linux") @@ -2548,7 +2548,7 @@ static const FFlogo* getLogoVoid() FF_LOGO_RETURN } -static const FFlogo* getLogoVoidSmall() +static const FFlogo* getLogoVoidSmall(void) { FF_LOGO_INIT FF_LOGO_NAMES("void_small", "void-linux-small") @@ -2569,7 +2569,7 @@ static const FFlogo* getLogoVoidSmall() FF_LOGO_RETURN } -static const FFlogo* getLogoZorin() +static const FFlogo* getLogoZorin(void) { FF_LOGO_INIT FF_LOGO_NAMES("zorin", "zorin-linux", "zorinos", "zorinos-linux") @@ -2600,7 +2600,7 @@ static const FFlogo* getLogoZorin() FF_LOGO_RETURN } -GetLogoMethod* ffLogoBuiltinGetAll() +GetLogoMethod* ffLogoBuiltinGetAll(void) { static GetLogoMethod logoMethods[] = { ffLogoBuiltinGetUnknown, diff --git a/src/logo/image/im6.c b/src/logo/image/im6.c index ba652a370..c9a1e56a4 100644 --- a/src/logo/image/im6.c +++ b/src/logo/image/im6.c @@ -12,12 +12,12 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex return ffResizeImage(image, width, height, UndefinedFilter, 1.0, exceptionInfo); } -FFLogoImageResult ffLogoPrintImageIM6(FFinstance* instance, FFLogoRequestData* requestData) +FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData) { - FF_LIBRARY_LOAD(imageMagick, &instance->config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8) + FF_LIBRARY_LOAD(imageMagick, &instance.config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(imageMagick, ffResizeImage, ResizeImage, FF_LOGO_IMAGE_RESULT_INIT_ERROR); - return ffLogoPrintImageImpl(instance, requestData, &(FFIMData) { + return ffLogoPrintImageImpl(requestData, &(FFIMData) { .resizeFunc = logoResize, .library = imageMagick, }); diff --git a/src/logo/image/im7.c b/src/logo/image/im7.c index 0677b4911..394e124df 100644 --- a/src/logo/image/im7.c +++ b/src/logo/image/im7.c @@ -12,16 +12,16 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex return ffResizeImage(image, width, height, UndefinedFilter, exceptionInfo); } -FFLogoImageResult ffLogoPrintImageIM7(FFinstance* instance, FFLogoRequestData* requestData) +FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData) { - FF_LIBRARY_LOAD(imageMagick, &instance->config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, + FF_LIBRARY_LOAD(imageMagick, &instance.config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-7.Q16HDRI" FF_LIBRARY_EXTENSION, 11, "libMagickCore-7.Q16" FF_LIBRARY_EXTENSION, 11, "libMagickCore-7.Q16HDRI-10" FF_LIBRARY_EXTENSION, -1 // Required for Windows ) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(imageMagick, ffResizeImage, ResizeImage, FF_LOGO_IMAGE_RESULT_INIT_ERROR); - return ffLogoPrintImageImpl(instance, requestData, &(FFIMData) { + return ffLogoPrintImageImpl(requestData, &(FFIMData) { .resizeFunc = logoResize, .library = imageMagick, }); diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 6c84a9b3b..79dad505b 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -34,51 +34,51 @@ static FFstrbuf base64Encode(FFstrbuf* in) return out; } -static bool printImageIterm(FFinstance* instance) +static bool printImageIterm(void) { - if(instance->config.logo.width == 0 || instance->config.logo.height == 0) + if(instance.config.logo.width == 0 || instance.config.logo.height == 0) { fputs("Logo: `iterm` protocol only works when both `--logo-width` and `--logo-height` being specified\n", stderr); return false; } FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); - if(!ffAppendFileBuffer(instance->config.logo.source.chars, &buf)) + if(!ffAppendFileBuffer(instance.config.logo.source.chars, &buf)) { fputs("Logo: Failed to load image file\n", stderr); return false; } - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes('\n', instance.config.logo.paddingTop); + ffPrintCharTimes(' ', instance.config.logo.paddingLeft); FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&buf); - instance->state.logoWidth = instance->config.logo.width + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; - instance->state.logoHeight = instance->config.logo.paddingTop + instance->config.logo.height; + instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; + instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; printf("\033]1337;File=inline=1;width=%u;height=%u;preserveAspectRatio=%u:%s\a\033[9999999D\n\033[%uA", - (unsigned) instance->config.logo.width, - (unsigned) instance->config.logo.height, - (unsigned) instance->config.logo.preserveAspectRadio, + (unsigned) instance.config.logo.width, + (unsigned) instance.config.logo.height, + (unsigned) instance.config.logo.preserveAspectRadio, base64.chars, - (unsigned) instance->state.logoHeight + (unsigned) instance.state.logoHeight ); return true; } -static bool printImageKittyDirect(FFinstance* instance) +static bool printImageKittyDirect(void) { - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - FFstrbuf base64 = base64Encode(&instance->config.logo.source); + ffPrintCharTimes(' ', instance.config.logo.paddingLeft); + ffPrintCharTimes('\n', instance.config.logo.paddingTop); + FFstrbuf base64 = base64Encode(&instance.config.logo.source); printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D", - (unsigned) instance->config.logo.width, - (unsigned) instance->config.logo.height, + (unsigned) instance.config.logo.width, + (unsigned) instance.config.logo.height, base64.chars ); - instance->state.logoWidth = instance->config.logo.width + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; - instance->state.logoHeight = instance->config.logo.paddingTop + instance->config.logo.height; + instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; + instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; ffStrbufDestroy(&base64); @@ -122,9 +122,9 @@ static inline char* realpath(const char* restrict file_name, char* restrict reso #include #include -static bool compressBlob(const FFinstance* instance, void** blob, size_t* length) +static bool compressBlob(void** blob, size_t* length) { - FF_LIBRARY_LOAD(zlib, &instance->config.libZ, false, "libz" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(zlib, &instance.config.libZ, false, "libz" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL(zlib, compressBound, false) FF_LIBRARY_LOAD_SYMBOL(zlib, compress2, false) @@ -202,36 +202,36 @@ static void writeCacheUint32(FFLogoRequestData* requestData, uint32_t value, con writeCacheStrbuf(requestData, &content, cacheFileName); } -static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestData, const FFstrbuf* result, const char* cacheFileName) +static void printImagePixels(FFLogoRequestData* requestData, const FFstrbuf* result, const char* cacheFileName) { //Calculate character dimensions - instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; + instance.state.logoWidth = requestData->logoCharacterWidth + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; - instance->state.logoHeight = requestData->logoCharacterHeight + instance->config.logo.paddingTop; + instance.state.logoHeight = requestData->logoCharacterHeight + instance.config.logo.paddingTop; if(requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) - instance->state.logoHeight -= 1; + instance.state.logoHeight -= 1; //Write cache files writeCacheStrbuf(requestData, result, cacheFileName); - if(instance->config.logo.width == 0) - writeCacheUint32(requestData, instance->state.logoWidth, FF_CACHE_FILE_WIDTH); + if(instance.config.logo.width == 0) + writeCacheUint32(requestData, instance.state.logoWidth, FF_CACHE_FILE_WIDTH); - if(instance->config.logo.height == 0) - writeCacheUint32(requestData, instance->state.logoHeight, FF_CACHE_FILE_HEIGHT); + if(instance.config.logo.height == 0) + writeCacheUint32(requestData, instance.state.logoHeight, FF_CACHE_FILE_HEIGHT); //Write result to stdout - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes('\n', instance.config.logo.paddingTop); + ffPrintCharTimes(' ', instance.config.logo.paddingLeft); fflush(stdout); ffWriteFDBuffer(FFUnixFD2NativeFD(STDOUT_FILENO), result); //Go to upper left corner fputs("\033[9999999D", stdout); - printf("\033[%uA", instance->state.logoHeight); + printf("\033[%uA", instance.state.logoHeight); } -static bool printImageSixel(FFinstance* instance, FFLogoRequestData* requestData, const ImageData* imageData) +static bool printImageSixel(FFLogoRequestData* requestData, const ImageData* imageData) { imageData->ffCopyMagickString(imageData->imageInfo->magick, "SIXEL", 6); @@ -244,7 +244,7 @@ static bool printImageSixel(FFinstance* instance, FFLogoRequestData* requestData result.chars = (char*) blob; result.length = (uint32_t) length; - printImagePixels(instance, requestData, &result, FF_CACHE_FILE_SIXEL); + printImagePixels(requestData, &result, FF_CACHE_FILE_SIXEL); free(blob); return true; @@ -267,7 +267,7 @@ static void appendKittyChunk(FFstrbuf* result, const char** blob, size_t* length *blob += chunkSize; } -static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData, const ImageData* imageData) +static bool printImageKitty(FFLogoRequestData* requestData, const ImageData* imageData) { imageData->ffCopyMagickString(imageData->imageInfo->magick, "RGBA", 5); @@ -277,7 +277,7 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData return false; #ifdef FF_HAVE_ZLIB - bool isCompressed = compressBlob(instance, &blob, &length); + bool isCompressed = compressBlob(&blob, &length); #else bool isCompressed = false; #endif @@ -299,7 +299,7 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData while(remainingLength > 0) appendKittyChunk(&result, ¤tPos, &remainingLength, true); - printImagePixels(instance, requestData, &result, isCompressed ? FF_CACHE_FILE_KITTY_COMPRESSED : FF_CACHE_FILE_KITTY_UNCOMPRESSED); + printImagePixels(requestData, &result, isCompressed ? FF_CACHE_FILE_KITTY_COMPRESSED : FF_CACHE_FILE_KITTY_UNCOMPRESSED); free(chars); return true; @@ -307,9 +307,9 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData #ifdef FF_HAVE_CHAFA #include -static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData, const ImageData* imageData) +static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* imageData) { - FF_LIBRARY_LOAD(chafa, &instance->config.libChafa, false, + FF_LIBRARY_LOAD(chafa, &instance.config.libChafa, false, "libchafa" FF_LIBRARY_EXTENSION, 1, "libchafa-0" FF_LIBRARY_EXTENSION, -1 // Required for Windows ) @@ -333,36 +333,36 @@ static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData ChafaSymbolMap* symbolMap = ffchafa_symbol_map_new(); GError* error = NULL; - if(!ffchafa_symbol_map_apply_selectors(symbolMap, instance->config.logo.chafaSymbols.chars, &error)) + if(!ffchafa_symbol_map_apply_selectors(symbolMap, instance.config.logo.chafaSymbols.chars, &error)) fputs(error->message, stderr); ChafaCanvasConfig* canvasConfig = ffchafa_canvas_config_new(); ffchafa_canvas_config_set_geometry(canvasConfig, (gint) requestData->logoCharacterWidth, (gint) requestData->logoCharacterHeight); ffchafa_canvas_config_set_symbol_map(canvasConfig, symbolMap); - if(instance->config.logo.chafaFgOnly) + if(instance.config.logo.chafaFgOnly) { FF_LIBRARY_LOAD_SYMBOL_LAZY(chafa, chafa_canvas_config_set_fg_only_enabled); if(ffchafa_canvas_config_set_fg_only_enabled) ffchafa_canvas_config_set_fg_only_enabled(canvasConfig, true); } - if(instance->config.logo.chafaCanvasMode < CHAFA_CANVAS_MODE_MAX) + if(instance.config.logo.chafaCanvasMode < CHAFA_CANVAS_MODE_MAX) { FF_LIBRARY_LOAD_SYMBOL_LAZY(chafa, chafa_canvas_config_set_canvas_mode); if(ffchafa_canvas_config_set_canvas_mode) - ffchafa_canvas_config_set_canvas_mode(canvasConfig, (ChafaCanvasMode) instance->config.logo.chafaCanvasMode); + ffchafa_canvas_config_set_canvas_mode(canvasConfig, (ChafaCanvasMode) instance.config.logo.chafaCanvasMode); } - if(instance->config.logo.chafaColorSpace < CHAFA_COLOR_SPACE_MAX) + if(instance.config.logo.chafaColorSpace < CHAFA_COLOR_SPACE_MAX) { FF_LIBRARY_LOAD_SYMBOL_LAZY(chafa, chafa_canvas_config_set_color_space) if(ffchafa_canvas_config_set_color_space) - ffchafa_canvas_config_set_color_space(canvasConfig, (ChafaColorSpace) instance->config.logo.chafaColorSpace); + ffchafa_canvas_config_set_color_space(canvasConfig, (ChafaColorSpace) instance.config.logo.chafaColorSpace); } - if(instance->config.logo.chafaDitherMode < CHAFA_DITHER_MODE_MAX) + if(instance.config.logo.chafaDitherMode < CHAFA_DITHER_MODE_MAX) { FF_LIBRARY_LOAD_SYMBOL_LAZY(chafa, chafa_canvas_config_set_dither_mode) if(ffchafa_canvas_config_set_dither_mode) - ffchafa_canvas_config_set_dither_mode(canvasConfig, (ChafaDitherMode) instance->config.logo.chafaDitherMode); + ffchafa_canvas_config_set_dither_mode(canvasConfig, (ChafaDitherMode) instance.config.logo.chafaDitherMode); } ChafaCanvas* canvas = ffchafa_canvas_new(canvasConfig); @@ -381,7 +381,7 @@ static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData result.length = (uint32_t) str->len; result.chars = str->str; - ffLogoPrintChars(instance, result.chars, false); + ffLogoPrintChars(result.chars, false); writeCacheStrbuf(requestData, &result, FF_CACHE_FILE_CHAFA); // FIXME: These functions must be imported from `libglib` dlls on Windows @@ -403,7 +403,7 @@ static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData } #endif -FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData* requestData, const FFIMData* imData) +FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFIMData* imData) { FF_LIBRARY_LOAD_SYMBOL(imData->library, MagickCoreGenesis, FF_LOGO_IMAGE_RESULT_INIT_ERROR); FF_LIBRARY_LOAD_SYMBOL(imData->library, MagickCoreTerminus, FF_LOGO_IMAGE_RESULT_INIT_ERROR); @@ -438,7 +438,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData* } //+1, because we need to copy the null byte too - imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logo.source.chars, instance->config.logo.source.length + 1); + imageData.ffCopyMagickString(imageInfoIn->filename, instance.config.logo.source.chars, instance.config.logo.source.length + 1); imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo); ffDestroyImageInfo(imageInfoIn); @@ -493,13 +493,13 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData* if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) { #ifdef FF_HAVE_CHAFA - printSuccessful = printImageChafa(instance, requestData, &imageData); + printSuccessful = printImageChafa(requestData, &imageData); #endif } else if(requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) - printSuccessful = printImageKitty(instance, requestData, &imageData); + printSuccessful = printImageKitty(requestData, &imageData); else if(requestData->type == FF_LOGO_TYPE_IMAGE_SIXEL) - printSuccessful = printImageSixel(instance, requestData, &imageData); + printSuccessful = printImageSixel(requestData, &imageData); ffDestroyImageInfo(imageData.imageInfo); ffDestroyImage(imageData.image); @@ -544,7 +544,7 @@ static uint32_t readCachedUint32(FFLogoRequestData* requestData, const char* cac return result; } -static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestData) +static bool printCachedChars(FFLogoRequestData* requestData) { FF_STRBUF_AUTO_DESTROY content = ffStrbufCreateA(32768); @@ -554,13 +554,13 @@ static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestDat if(content.length == 0) return false; - ffLogoPrintChars(instance, content.chars, false); + ffLogoPrintChars(content.chars, false); return true; } -static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestData) +static bool printCachedPixel(FFLogoRequestData* requestData) { - requestData->logoCharacterWidth = instance->config.logo.width; + requestData->logoCharacterWidth = instance.config.logo.width; if(requestData->logoCharacterWidth == 0) { requestData->logoCharacterWidth = readCachedUint32(requestData, FF_CACHE_FILE_WIDTH); @@ -568,7 +568,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat return false; } - requestData->logoCharacterHeight = instance->config.logo.height; + requestData->logoCharacterHeight = instance.config.logo.height; if(requestData->logoCharacterHeight == 0) { requestData->logoCharacterHeight = readCachedUint32(requestData, FF_CACHE_FILE_HEIGHT); @@ -589,8 +589,8 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat if(fd == -1) return false; - ffPrintCharTimes('\n', instance->config.logo.paddingTop); - ffPrintCharTimes(' ', instance->config.logo.paddingLeft); + ffPrintCharTimes('\n', instance.config.logo.paddingTop); + ffPrintCharTimes(' ', instance.config.logo.paddingLeft); fflush(stdout); char buffer[32768]; @@ -600,21 +600,21 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat close(fd); - instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; - instance->state.logoHeight = requestData->logoCharacterHeight + instance->config.logo.paddingTop; + instance.state.logoWidth = requestData->logoCharacterWidth + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; + instance.state.logoHeight = requestData->logoCharacterHeight + instance.config.logo.paddingTop; //Go to upper left corner fputs("\033[9999999D", stdout); - printf("\033[%uA", instance->state.logoHeight); + printf("\033[%uA", instance.state.logoHeight); return true; } -static bool printCached(FFinstance* instance, FFLogoRequestData* requestData) +static bool printCached(FFLogoRequestData* requestData) { if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) - return printCachedChars(instance, requestData); + return printCachedChars(requestData); else - return printCachedPixel(instance, requestData); + return printCachedPixel(requestData); } static bool getCharacterPixelDimensions(FFLogoRequestData* requestData) @@ -654,7 +654,7 @@ static bool getCharacterPixelDimensions(FFLogoRequestData* requestData) return requestData->characterPixelWidth > 1.0 && requestData->characterPixelHeight > 1.0; } -static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bool printError) +static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) { FFLogoRequestData requestData; requestData.type = type; @@ -662,7 +662,7 @@ static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bo requestData.characterPixelHeight = 1; if( - (type != FF_LOGO_TYPE_IMAGE_CHAFA || instance->config.logo.width == 0 || instance->config.logo.height == 0) && + (type != FF_LOGO_TYPE_IMAGE_CHAFA || instance.config.logo.width == 0 || instance.config.logo.height == 0) && !getCharacterPixelDimensions(&requestData) ) { if(printError) @@ -670,15 +670,15 @@ static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bo return false; } - requestData.logoPixelWidth = simpleCeil((double) instance->config.logo.width * requestData.characterPixelWidth); - requestData.logoPixelHeight = simpleCeil((double) instance->config.logo.height * requestData.characterPixelHeight); + requestData.logoPixelWidth = simpleCeil((double) instance.config.logo.width * requestData.characterPixelWidth); + requestData.logoPixelHeight = simpleCeil((double) instance.config.logo.height * requestData.characterPixelHeight); ffStrbufInit(&requestData.cacheDir); - ffStrbufAppend(&requestData.cacheDir, &instance->state.platform.cacheDir); + ffStrbufAppend(&requestData.cacheDir, &instance.state.platform.cacheDir); ffStrbufAppendS(&requestData.cacheDir, "fastfetch/images"); ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX); - if(realpath(instance->config.logo.source.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL) + if(realpath(instance.config.logo.source.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL) { //We can safely return here, because if realpath failed, we surely won't be able to read the file ffStrbufDestroy(&requestData.cacheDir); @@ -694,7 +694,7 @@ static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bo ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight); ffStrbufAppendC(&requestData.cacheDir, '/'); - if(!instance->config.recache && printCached(instance, &requestData)) + if(!instance.config.recache && printCached(&requestData)) { ffStrbufDestroy(&requestData.cacheDir); return true; @@ -703,12 +703,12 @@ static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bo FFLogoImageResult result = FF_LOGO_IMAGE_RESULT_INIT_ERROR; #ifdef FF_HAVE_IMAGEMAGICK7 - result = ffLogoPrintImageIM7(instance, &requestData); + result = ffLogoPrintImageIM7(&requestData); #endif #ifdef FF_HAVE_IMAGEMAGICK6 if(result == FF_LOGO_IMAGE_RESULT_INIT_ERROR) - result = ffLogoPrintImageIM6(instance, &requestData); + result = ffLogoPrintImageIM6(&requestData); #endif ffStrbufDestroy(&requestData.cacheDir); @@ -729,25 +729,25 @@ static bool printImageIfExistsSlowPath(FFinstance* instance, FFLogoType type, bo #endif //FF_HAVE_IMAGEMAGICK{6, 7} -bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type, bool printError) +bool ffLogoPrintImageIfExists(FFLogoType type, bool printError) { - if(!ffPathExists(instance->config.logo.source.chars, FF_PATHTYPE_FILE)) + if(!ffPathExists(instance.config.logo.source.chars, FF_PATHTYPE_FILE)) { if(printError) - fprintf(stderr, "Logo: Image source \"%s\" does not exist\n", instance->config.logo.source.chars); + fprintf(stderr, "Logo: Image source \"%s\" does not exist\n", instance.config.logo.source.chars); return false; } if(type == FF_LOGO_TYPE_IMAGE_ITERM) - return printImageIterm(instance); + return printImageIterm(); if( type == FF_LOGO_TYPE_IMAGE_KITTY && - ffStrbufEndsWithIgnCaseS(&instance->config.logo.source, ".png") && - instance->config.logo.width && - instance->config.logo.height + ffStrbufEndsWithIgnCaseS(&instance.config.logo.source, ".png") && + instance.config.logo.width && + instance.config.logo.height ) - return printImageKittyDirect(instance); + return printImageKittyDirect(); #if !defined(FF_HAVE_CHAFA) if(type == FF_LOGO_TYPE_IMAGE_CHAFA) @@ -763,6 +763,6 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type, bool printE fputs("Logo: Image Magick support is not compiled in\n", stderr); return false; #else - return printImageIfExistsSlowPath(instance, type, printError); + return printImageIfExistsSlowPath(type, printError); #endif } diff --git a/src/logo/image/image.h b/src/logo/image/image.h index 83d77131a..7d54edd8a 100644 --- a/src/logo/image/image.h +++ b/src/logo/image/image.h @@ -35,17 +35,17 @@ typedef struct FFIMData void*(*resizeFunc)(const void* image, size_t width, size_t height, void* exceptionInfo); } FFIMData; -FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData* requestData, const FFIMData* imData); +FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFIMData* imData); #endif #ifdef FF_HAVE_IMAGEMAGICK7 -FFLogoImageResult ffLogoPrintImageIM7(FFinstance* instance, FFLogoRequestData* requestData); +FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData); #endif #ifdef FF_HAVE_IMAGEMAGICK6 #include -FFLogoImageResult ffLogoPrintImageIM6(FFinstance* instance, FFLogoRequestData* requestData); +FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData); #endif #endif diff --git a/src/logo/logo.c b/src/logo/logo.c index 2e2e54f8f..17e91b24a 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -8,21 +8,21 @@ #include #include -static void ffLogoPrintCharsRaw(FFinstance* instance, const char* data, size_t length) +static void ffLogoPrintCharsRaw(const char* data, size_t length) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); fwrite(data, length, 1, stdout); - instance->state.logoHeight = options->paddingTop + options->height; - instance->state.logoWidth = options->paddingLeft + options->width + options->paddingRight; - printf("\033[9999999D\n\033[%uA", instance->state.logoHeight); + instance.state.logoHeight = options->paddingTop + options->height; + instance.state.logoWidth = options->paddingLeft + options->width + options->paddingRight; + printf("\033[9999999D\n\033[%uA", instance.state.logoHeight); } -void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplacement) +void ffLogoPrintChars(const char* data, bool doColorReplacement) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; uint32_t currentlineLength = 0; @@ -30,7 +30,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); - instance->state.logoHeight = options->paddingTop; + instance.state.logoHeight = options->paddingTop; //Use logoColor[0] as the default color if(doColorReplacement) @@ -52,11 +52,11 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac ffPrintCharTimes(' ', options->paddingLeft); - if(currentlineLength > instance->state.logoWidth) - instance->state.logoWidth = currentlineLength; + if(currentlineLength > instance.state.logoWidth) + instance.state.logoWidth = currentlineLength; currentlineLength = 0; - ++instance->state.logoHeight; + ++instance.state.logoHeight; continue; } @@ -155,26 +155,26 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); //Happens if the last line is the longest - if(currentlineLength > instance->state.logoWidth) - instance->state.logoWidth = currentlineLength; + if(currentlineLength > instance.state.logoWidth) + instance.state.logoWidth = currentlineLength; - instance->state.logoWidth += options->paddingLeft + options->paddingRight; + instance.state.logoWidth += options->paddingLeft + options->paddingRight; //Go to the leftmost position fputs("\033[9999999D", stdout); //If the logo height is > 1, go up the height - if(instance->state.logoHeight > 0) - printf("\033[%uA", instance->state.logoHeight); + if(instance.state.logoHeight > 0) + printf("\033[%uA", instance.state.logoHeight); } -static void logoApplyColors(FFinstance* instance, const FFlogo* logo) +static void logoApplyColors(const FFlogo* logo) { - if(instance->config.colorKeys.length == 0) - ffStrbufAppendS(&instance->config.colorKeys, logo->colorKeys); + if(instance.config.colorKeys.length == 0) + ffStrbufAppendS(&instance.config.colorKeys, logo->colorKeys); - if(instance->config.colorTitle.length == 0) - ffStrbufAppendS(&instance->config.colorTitle, logo->colorTitle); + if(instance.config.colorTitle.length == 0) + ffStrbufAppendS(&instance.config.colorTitle, logo->colorTitle); } static bool logoHasName(const FFlogo* logo, const char* name) @@ -208,9 +208,9 @@ static const FFlogo* logoGetBuiltin(const char* name) return NULL; } -static const FFlogo* logoGetBuiltinDetected(const FFinstance* instance) +static const FFlogo* logoGetBuiltinDetected(void) { - const FFOSResult* os = ffDetectOS(instance); + const FFOSResult* os = ffDetectOS(); const FFlogo* logo = logoGetBuiltin(os->id.chars); if(logo != NULL) @@ -228,23 +228,23 @@ static const FFlogo* logoGetBuiltinDetected(const FFinstance* instance) if(logo != NULL) return logo; - logo = logoGetBuiltin(instance->state.platform.systemName.chars); + logo = logoGetBuiltin(instance.state.platform.systemName.chars); if(logo != NULL) return logo; return ffLogoBuiltinGetUnknown(); } -static inline void logoApplyColorsDetected(FFinstance* instance) +static inline void logoApplyColorsDetected(void) { - logoApplyColors(instance, logoGetBuiltinDetected(instance)); + logoApplyColors(logoGetBuiltinDetected()); } -static void logoPrintStruct(FFinstance* instance, const FFlogo* logo) +static void logoPrintStruct(const FFlogo* logo) { - logoApplyColors(instance, logo); + logoApplyColors(logo); - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; const char** colors = logo->builtinColors; for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) @@ -253,21 +253,21 @@ static void logoPrintStruct(FFinstance* instance, const FFlogo* logo) ffStrbufAppendS(&options->colors[i], *colors); } - ffLogoPrintChars(instance, logo->data, true); + ffLogoPrintChars(logo->data, true); } -static void logoPrintNone(FFinstance* instance) +static void logoPrintNone(void) { - logoApplyColorsDetected(instance); - instance->state.logoHeight = 0; - instance->state.logoWidth = 0; + logoApplyColorsDetected(); + instance.state.logoHeight = 0; + instance.state.logoWidth = 0; } -static bool logoPrintBuiltinIfExists(FFinstance* instance, const char* name) +static bool logoPrintBuiltinIfExists(const char* name) { if(strcasecmp(name, "none") == 0) { - logoPrintNone(instance); + logoPrintNone(); return true; } @@ -275,36 +275,36 @@ static bool logoPrintBuiltinIfExists(FFinstance* instance, const char* name) if(logo == NULL) return false; - logoPrintStruct(instance, logo); + logoPrintStruct(logo); return true; } -static inline void logoPrintDetected(FFinstance* instance) +static inline void logoPrintDetected(void) { - logoPrintStruct(instance, logoGetBuiltinDetected(instance)); + logoPrintStruct(logoGetBuiltinDetected()); } -static bool logoPrintData(FFinstance* instance, bool doColorReplacement) { - FFLogoOptions* options = &instance->config.logo; +static bool logoPrintData(bool doColorReplacement) { + FFLogoOptions* options = &instance.config.logo; if(options->source.length == 0) return false; - ffLogoPrintChars(instance, options->source.chars, doColorReplacement); - logoApplyColorsDetected(instance); + ffLogoPrintChars(options->source.chars, doColorReplacement); + logoApplyColorsDetected(); return true; } -static void updateLogoPath(FFinstance* instance) +static void updateLogoPath(void) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; if(ffPathExists(options->source.chars, FF_PATHTYPE_FILE)) return; FF_STRBUF_AUTO_DESTROY fullPath = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFstrbuf, dataDir, instance->state.platform.dataDirs) + FF_LIST_FOR_EACH(FFstrbuf, dataDir, instance.state.platform.dataDirs) { //We need to copy it, because multiple threads might be using dataDirs at the same time ffStrbufSet(&fullPath, dataDir); @@ -319,9 +319,9 @@ static void updateLogoPath(FFinstance* instance) } } -static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, bool raw) +static bool logoPrintFileIfExists(bool doColorReplacement, bool raw) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); @@ -331,50 +331,50 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement, return false; } - logoApplyColorsDetected(instance); + logoApplyColorsDetected(); if(raw) - ffLogoPrintCharsRaw(instance, content.chars, content.length); + ffLogoPrintCharsRaw(content.chars, content.length); else - ffLogoPrintChars(instance, content.chars, doColorReplacement); + ffLogoPrintChars(content.chars, doColorReplacement); return true; } -static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo, bool printError) +static bool logoPrintImageIfExists(FFLogoType logo, bool printError) { - if(!ffLogoPrintImageIfExists(instance, logo, printError)) + if(!ffLogoPrintImageIfExists(logo, printError)) return false; - logoApplyColorsDetected(instance); + logoApplyColorsDetected(); return true; } -static bool logoTryKnownType(FFinstance* instance) +static bool logoTryKnownType(void) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; if(options->type == FF_LOGO_TYPE_NONE) { - logoApplyColorsDetected(instance); + logoApplyColorsDetected(); return true; } if(options->type == FF_LOGO_TYPE_BUILTIN) - return logoPrintBuiltinIfExists(instance, options->source.chars); + return logoPrintBuiltinIfExists(options->source.chars); if(options->type == FF_LOGO_TYPE_DATA) - return logoPrintData(instance, true); + return logoPrintData(true); if(options->type == FF_LOGO_TYPE_DATA_RAW) - return logoPrintData(instance, false); + return logoPrintData(false); - updateLogoPath(instance); //We sure have a file, resolve relative paths + updateLogoPath(); //We sure have a file, resolve relative paths if(options->type == FF_LOGO_TYPE_FILE) - return logoPrintFileIfExists(instance, true, false); + return logoPrintFileIfExists(true, false); if(options->type == FF_LOGO_TYPE_FILE_RAW) - return logoPrintFileIfExists(instance, false, false); + return logoPrintFileIfExists(false, false); if(options->type == FF_LOGO_TYPE_IMAGE_RAW) { @@ -384,54 +384,54 @@ static bool logoTryKnownType(FFinstance* instance) return false; } - return logoPrintFileIfExists(instance, false, true); + return logoPrintFileIfExists(false, true); } - return logoPrintImageIfExists(instance, options->type, true); + return logoPrintImageIfExists(options->type, true); } -static void logoPrintKnownType(FFinstance* instance) +static void logoPrintKnownType(void) { - if(!logoTryKnownType(instance)) - logoPrintDetected(instance); + if(!logoTryKnownType()) + logoPrintDetected(); } -void ffLogoPrint(FFinstance* instance) +void ffLogoPrint(void) { //In pipe mode, we don't have a logo or padding. //We also don't need to set main color, because it won't be printed anyway. //So we can return quickly here. - if(instance->config.pipe) + if(instance.config.pipe) { - instance->state.logoHeight = 0; - instance->state.logoWidth = 0; + instance.state.logoHeight = 0; + instance.state.logoWidth = 0; return; } - const FFLogoOptions* options = &instance->config.logo; + const FFLogoOptions* options = &instance.config.logo; //If the source is not set, we can directly print the detected logo. if(options->source.length == 0) { - logoPrintDetected(instance); + logoPrintDetected(); return; } //If the source and source type is set to something else than auto, always print with the set type. if(options->source.length > 0 && options->type != FF_LOGO_TYPE_AUTO) { - logoPrintKnownType(instance); + logoPrintKnownType(); return; } //If source matches the name of a builtin logo, print it and return. - if(logoPrintBuiltinIfExists(instance, options->source.chars)) + if(logoPrintBuiltinIfExists(options->source.chars)) return; //Make sure the logo path is set correctly. - updateLogoPath(instance); + updateLogoPath(); - const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance); + const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(); //Terminal emulators that support kitty graphics protocol. bool supportsKitty = @@ -441,48 +441,48 @@ void ffLogoPrint(FFinstance* instance) ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "wayst") == 0; //Try to load the logo as an image. If it succeeds, print it and return. - if(logoPrintImageIfExists(instance, supportsKitty ? FF_LOGO_TYPE_IMAGE_KITTY : FF_LOGO_TYPE_IMAGE_CHAFA, false)) + if(logoPrintImageIfExists(supportsKitty ? FF_LOGO_TYPE_IMAGE_KITTY : FF_LOGO_TYPE_IMAGE_CHAFA, false)) return; //Try to load the logo as a file. If it succeeds, print it and return. - if(logoPrintFileIfExists(instance, true, false)) + if(logoPrintFileIfExists(true, false)) return; - logoPrintDetected(instance); + logoPrintDetected(); } -void ffLogoPrintLine(FFinstance* instance) +void ffLogoPrintLine(void) { - if(instance->state.logoWidth > 0) - printf("\033[%uC", instance->state.logoWidth); + if(instance.state.logoWidth > 0) + printf("\033[%uC", instance.state.logoWidth); - ++instance->state.keysHeight; + ++instance.state.keysHeight; } -void ffLogoPrintRemaining(FFinstance* instance) +void ffLogoPrintRemaining(void) { - while(instance->state.keysHeight <= instance->state.logoHeight) + while(instance.state.keysHeight <= instance.state.logoHeight) { - ffLogoPrintLine(instance); + ffLogoPrintLine(); putchar('\n'); } } -void ffLogoBuiltinPrint(FFinstance* instance) +void ffLogoBuiltinPrint(void) { GetLogoMethod* methods = ffLogoBuiltinGetAll(); - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; while(*methods != NULL) { const FFlogo* logo = (*methods)(); printf("\033[%sm%s:\033[0m\n", logo->builtinColors[0], logo->names[0]); - logoPrintStruct(instance, logo); - ffLogoPrintRemaining(instance); + logoPrintStruct(logo); + ffLogoPrintRemaining(); //reset everything - instance->state.logoHeight = 0; - instance->state.keysHeight = 0; + instance.state.logoHeight = 0; + instance.state.keysHeight = 0; for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) ffStrbufClear(&options->colors[i]); @@ -491,7 +491,7 @@ void ffLogoBuiltinPrint(FFinstance* instance) } } -void ffLogoBuiltinList() +void ffLogoBuiltinList(void) { GetLogoMethod* methods = ffLogoBuiltinGetAll(); @@ -516,7 +516,7 @@ void ffLogoBuiltinList() } } -void ffLogoBuiltinListAutocompletion() +void ffLogoBuiltinListAutocompletion(void) { GetLogoMethod* methods = ffLogoBuiltinGetAll(); diff --git a/src/logo/logo.h b/src/logo/logo.h index 0bc74ea0e..4c4d42c3f 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -17,19 +17,19 @@ typedef struct FFlogo typedef const FFlogo*(*GetLogoMethod)(); //logo.c -void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplacement); +void ffLogoPrintChars(const char* data, bool doColorReplacement); //builtin.c const FFlogo* ffLogoBuiltinGetUnknown(); GetLogoMethod* ffLogoBuiltinGetAll(); //image/image.c -bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type, bool printError); +bool ffLogoPrintImageIfExists(FFLogoType type, bool printError); //option.c void ffInitLogoOptions(FFLogoOptions* options); bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const char* value); void ffDestroyLogoOptions(FFLogoOptions* options); -const char* ffParseLogoJsonConfig(FFinstance* instance); +const char* ffParseLogoJsonConfig(); #endif diff --git a/src/logo/option.c b/src/logo/option.c index 7882ad669..5fe22176f 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -189,11 +189,11 @@ void ffDestroyLogoOptions(FFLogoOptions* options) ffStrbufDestroy(&options->colors[i]); } -const char* ffParseLogoJsonConfig(FFinstance* instance) +const char* ffParseLogoJsonConfig(void) { - FFLogoOptions* options = &instance->config.logo; + FFLogoOptions* options = &instance.config.logo; - yyjson_val* const root = yyjson_doc_get_root(instance->state.configDoc); + yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc); assert(root); if (!yyjson_is_obj(root)) diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index d326a1584..297d30d50 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -7,14 +7,14 @@ #define FF_BATTERY_NUM_FORMAT_ARGS 5 -static void printBattery(FFinstance* instance, FFBatteryOptions* options, BatteryResult* result, uint8_t index) +static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8_t index) { - if(instance->config.battery.moduleArgs.outputFormat.length == 0) + if(instance.config.battery.moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); bool showStatus = - !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && + !(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && result->status.length > 0 && ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0; @@ -22,22 +22,22 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter if(result->capacity >= 0) { - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { if(result->capacity <= 20) - ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 10, 10, 0); + ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 10, 0); else if(result->capacity <= 50) - ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 10, 0, 10); + ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 0, 10); else - ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 0, 10, 10); + ffAppendPercentBar(&str, (uint8_t)result->capacity, 0, 10, 10); } - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); - ffAppendPercentNum(instance, &str, (uint8_t) result->capacity, 51, 21, str.length > 0); + ffAppendPercentNum(&str, (uint8_t) result->capacity, 51, 21, str.length > 0); } } @@ -61,7 +61,7 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter } else { - ffPrintFormat(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->technology}, @@ -72,23 +72,23 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter } } -void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options) +void ffPrintBattery(FFBatteryOptions* options) { FFlist results; ffListInitA(&results, sizeof(BatteryResult), 0); - const char* error = ffDetectBattery(instance, options, &results); + const char* error = ffDetectBattery(options, &results); if (error) { - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else { for(uint8_t i = 0; i < (uint8_t) results.length; i++) { BatteryResult* result = ffListGet(&results, i); - printBattery(instance, options, result, i); + printBattery(options, result, i); ffStrbufDestroy(&result->manufacturer); ffStrbufDestroy(&result->modelName); @@ -96,7 +96,7 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options) ffStrbufDestroy(&result->status); } if(results.length == 0) - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found"); + ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found"); } ffListDestroy(&results); @@ -146,7 +146,7 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options) #endif } -void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseBatteryJsonObject(yyjson_val* module) { FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options; ffInitBatteryOptions(&options); @@ -178,9 +178,9 @@ void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintBattery(instance, &options); + ffPrintBattery(&options); } diff --git a/src/modules/battery/battery.h b/src/modules/battery/battery.h index d9f39acea..a57a3718c 100644 --- a/src/modules/battery/battery.h +++ b/src/modules/battery/battery.h @@ -4,9 +4,9 @@ #define FF_BATTERY_MODULE_NAME "Battery" -void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options); +void ffPrintBattery(FFBatteryOptions* options); void ffInitBatteryOptions(FFBatteryOptions* options); bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value); void ffDestroyBatteryOptions(FFBatteryOptions* options); -void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseBatteryJsonObject(yyjson_val* module); diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index f24b0ee98..53137c9b3 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -6,7 +6,7 @@ #define FF_BIOS_NUM_FORMAT_ARGS 4 -void ffPrintBios(FFinstance* instance, FFBiosOptions* options) +void ffPrintBios(FFBiosOptions* options) { FFBiosResult bios; ffStrbufInit(&bios.date); @@ -18,19 +18,19 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) if(error) { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } if(bios.version.length == 0) { - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set."); + ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set."); goto exit; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&bios.version, stdout); if (bios.biosRelease.length) printf(" (%s)", bios.biosRelease.chars); @@ -38,7 +38,7 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options) } else { - ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &bios.date}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosRelease}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor}, @@ -74,7 +74,7 @@ void ffDestroyBiosOptions(FFBiosOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseBiosJsonObject(yyjson_val* module) { FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options; ffInitBiosOptions(&options); @@ -92,9 +92,9 @@ void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintBios(instance, &options); + ffPrintBios(&options); } diff --git a/src/modules/bios/bios.h b/src/modules/bios/bios.h index ca01b0902..a82606f03 100644 --- a/src/modules/bios/bios.h +++ b/src/modules/bios/bios.h @@ -4,8 +4,8 @@ #define FF_BIOS_MODULE_NAME "Bios" -void ffPrintBios(FFinstance* instance, FFBiosOptions* options); +void ffPrintBios(FFBiosOptions* options); void ffInitBiosOptions(FFBiosOptions* options); bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value); void ffDestroyBiosOptions(FFBiosOptions* options); -void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseBiosJsonObject(yyjson_val* module); diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 9b386f5ab..c41bf3da4 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -6,11 +6,11 @@ #define FF_BLUETOOTH_NUM_FORMAT_ARGS 4 -static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index) +static void printDevice(FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&device->name, stdout); if(device->battery > 0) @@ -20,7 +20,7 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const } else { - ffPrintFormat(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->address}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, @@ -29,14 +29,14 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const } } -void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) +void ffPrintBluetooth(FFBluetoothOptions* options) { FF_LIST_AUTO_DESTROY devices = ffListCreate(sizeof (FFBluetoothDevice)); - const char* error = ffDetectBluetooth(instance, &devices); + const char* error = ffDetectBluetooth(&devices); if(error) { - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -52,14 +52,14 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options) if(filtered.length == 0) { - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); + ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); return; } for(uint32_t i = 0; i < filtered.length; i++) { uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); - printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); + printDevice(options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); } FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) @@ -94,7 +94,7 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseBluetoothJsonObject(yyjson_val* module) { FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options; ffInitBluetoothOptions(&options); @@ -118,9 +118,9 @@ void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintBluetooth(instance, &options); + ffPrintBluetooth(&options); } diff --git a/src/modules/bluetooth/bluetooth.h b/src/modules/bluetooth/bluetooth.h index 1834330e5..1a54baf1d 100644 --- a/src/modules/bluetooth/bluetooth.h +++ b/src/modules/bluetooth/bluetooth.h @@ -4,8 +4,8 @@ #define FF_BLUETOOTH_MODULE_NAME "Bluetooth" -void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options); +void ffPrintBluetooth(FFBluetoothOptions* options); void ffInitBluetoothOptions(FFBluetoothOptions* options); bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value); void ffDestroyBluetoothOptions(FFBluetoothOptions* options); -void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseBluetoothJsonObject(yyjson_val* module); diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 68802c28e..5c92ef20d 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -6,7 +6,7 @@ #define FF_BOARD_NUM_FORMAT_ARGS 3 -void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) +void ffPrintBoard(FFBoardOptions* options) { FFBoardResult result; ffStrbufInit(&result.name); @@ -16,19 +16,19 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) if(error) { - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } if(result.name.length == 0) { - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set."); + ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set."); goto exit; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.name, stdout); if (result.version.length) printf(" (%s)", result.version.chars); @@ -36,7 +36,7 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options) } else { - ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, @@ -70,7 +70,7 @@ void ffDestroyBoardOptions(FFBoardOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseBoardJsonObject(yyjson_val* module) { FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options; ffInitBoardOptions(&options); @@ -88,9 +88,9 @@ void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintBoard(instance, &options); + ffPrintBoard(&options); } diff --git a/src/modules/board/board.h b/src/modules/board/board.h index e10c4f61b..112eabbf2 100644 --- a/src/modules/board/board.h +++ b/src/modules/board/board.h @@ -4,8 +4,8 @@ #define FF_BOARD_MODULE_NAME "Board" -void ffPrintBoard(FFinstance* instance, FFBoardOptions* options); +void ffPrintBoard(FFBoardOptions* options); void ffInitBoardOptions(FFBoardOptions* options); bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value); void ffDestroyBoardOptions(FFBoardOptions* options); -void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseBoardJsonObject(yyjson_val* module); diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 55b671c19..1dc3c8e0a 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -1,13 +1,13 @@ #include "common/printing.h" #include "modules/break/break.h" -void ffPrintBreak(FFinstance* instance) +void ffPrintBreak(void) { - ffLogoPrintLine(instance); + ffLogoPrintLine(); putchar('\n'); } -void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module) +void ffParseBreakJsonObject(FF_MAYBE_UNUSED yyjson_val* module) { - return ffPrintBreak(instance); + return ffPrintBreak(); } diff --git a/src/modules/break/break.h b/src/modules/break/break.h index 2c534d341..f87c81d3d 100644 --- a/src/modules/break/break.h +++ b/src/modules/break/break.h @@ -4,5 +4,5 @@ #define FF_BREAK_MODULE_NAME "Break" -void ffPrintBreak(FFinstance* instance); -void ffParseBreakJsonObject(FFinstance* instance, yyjson_val* module); +void ffPrintBreak(); +void ffParseBreakJsonObject(yyjson_val* module); diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 32c0ca408..5798b6719 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -7,7 +7,7 @@ #define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2 -void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) +void ffPrintBrightness(FFBrightnessOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); @@ -15,13 +15,13 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) if(error) { - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(result.length == 0) { - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected."); + ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected."); return; } @@ -44,26 +44,26 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - if (instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { - ffAppendPercentBar(instance, &str, (uint8_t) (item->value + 0.5), 0, 10, 10); + ffAppendPercentBar(&str, (uint8_t) (item->value + 0.5), 0, 10, 10); } - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); - ffAppendPercentNum(instance, &str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0); + ffAppendPercentNum(&str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0); } ffStrbufPutTo(&str, stdout); } else { - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &item->value}, {FF_FORMAT_ARG_TYPE_FLOAT, &item->name} }); @@ -95,7 +95,7 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseBrightnessJsonObject(yyjson_val* module) { FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options; ffInitBrightnessOptions(&options); @@ -113,9 +113,9 @@ void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintBrightness(instance, &options); + ffPrintBrightness(&options); } diff --git a/src/modules/brightness/brightness.h b/src/modules/brightness/brightness.h index b4c089424..f9724d65c 100644 --- a/src/modules/brightness/brightness.h +++ b/src/modules/brightness/brightness.h @@ -4,8 +4,8 @@ #define FF_BRIGHTNESS_MODULE_NAME "Brightness" -void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options); +void ffPrintBrightness(FFBrightnessOptions* options); void ffInitBrightnessOptions(FFBrightnessOptions* options); bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value); void ffDestroyBrightnessOptions(FFBrightnessOptions* options); -void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseBrightnessJsonObject(yyjson_val* module); diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 15d6ba959..e229748c8 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -6,7 +6,7 @@ #define FF_CHASSIS_NUM_FORMAT_ARGS 3 -void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) +void ffPrintChassis(FFChassisOptions* options) { FFChassisResult result; ffStrbufInit(&result.type); @@ -17,19 +17,19 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) if(error) { - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } if(result.type.length == 0) { - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); + ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); goto exit; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.type, stdout); if (result.version.length) printf(" (%s)", result.version.chars); @@ -37,7 +37,7 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options) } else { - ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, @@ -71,7 +71,7 @@ void ffDestroyChassisOptions(FFChassisOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseChassisJsonObject(yyjson_val* module) { FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options; ffInitChassisOptions(&options); @@ -89,9 +89,9 @@ void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintChassis(instance, &options); + ffPrintChassis(&options); } diff --git a/src/modules/chassis/chassis.h b/src/modules/chassis/chassis.h index 1a85b2727..0526608da 100644 --- a/src/modules/chassis/chassis.h +++ b/src/modules/chassis/chassis.h @@ -4,8 +4,8 @@ #define FF_CHASSIS_MODULE_NAME "Chassis" -void ffPrintChassis(FFinstance* instance, FFChassisOptions* options); +void ffPrintChassis(FFChassisOptions* options); void ffInitChassisOptions(FFChassisOptions* options); bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value); void ffDestroyChassisOptions(FFChassisOptions* options); -void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseChassisJsonObject(yyjson_val* module); diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 1064f3283..da559b5a3 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -4,12 +4,12 @@ #include "modules/colors/colors.h" #include "util/stringUtils.h" -void ffPrintColors(FFinstance* instance, FFColorsOptions* options) +void ffPrintColors(FFColorsOptions* options) { - if(instance->config.pipe) + if(instance.config.pipe) return; - ffLogoPrintLine(instance); + ffLogoPrintLine(); if(options->paddingLeft > 0) ffPrintCharTimes(' ', options->paddingLeft); @@ -23,7 +23,7 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options) puts(FASTFETCH_TEXT_MODIFIER_RESET); - ffLogoPrintLine(instance); + ffLogoPrintLine(); if(options->paddingLeft > 0) ffPrintCharTimes(' ', options->paddingLeft); @@ -94,7 +94,7 @@ void ffDestroyColorsOptions(FF_MAYBE_UNUSED FFColorsOptions* options) { } -void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseColorsJsonObject(yyjson_val* module) { FFColorsOptions __attribute__((__cleanup__(ffDestroyColorsOptions))) options; ffInitColorsOptions(&options); @@ -122,7 +122,7 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) {}, }); if (error) - ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error); + ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error); else options.symbol = (FFColorsSymbol) value; continue; @@ -134,9 +134,9 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } - ffPrintColors(instance, &options); + ffPrintColors(&options); } diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index bcf2c2315..64ebe96c8 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -4,8 +4,8 @@ #define FF_COLORS_MODULE_NAME "Colors" -void ffPrintColors(FFinstance* instance, FFColorsOptions* options); +void ffPrintColors(FFColorsOptions* options); void ffInitColorsOptions(FFColorsOptions* options); void ffDestroyColorsOptions(FFColorsOptions* options); bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value); -void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseColorsJsonObject(yyjson_val* module); diff --git a/src/modules/command/command.c b/src/modules/command/command.c index d1fe505b4..319aed606 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -4,7 +4,7 @@ #include "modules/command/command.h" #include "util/stringUtils.h" -void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) +void ffPrintCommand(FFCommandOptions* options) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); const char* error = ffProcessAppendStdOut(&result, (char* const[]){ @@ -20,17 +20,17 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options) if(error) { - ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(!result.length) { - ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed"); + ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed"); return; } - ffPrintLogoAndKey(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } @@ -81,7 +81,7 @@ void ffDestroyCommandOptions(FFCommandOptions* options) ffStrbufDestroy(&options->text); } -void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseCommandJsonObject(yyjson_val* module) { FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options; ffInitCommandOptions(&options); @@ -111,9 +111,9 @@ void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintCommand(instance, &options); + ffPrintCommand(&options); } diff --git a/src/modules/command/command.h b/src/modules/command/command.h index 63ca643fb..eca179b35 100644 --- a/src/modules/command/command.h +++ b/src/modules/command/command.h @@ -4,8 +4,8 @@ #define FF_COMMAND_MODULE_NAME "Command" -void ffPrintCommand(FFinstance* instance, FFCommandOptions* options); +void ffPrintCommand(FFCommandOptions* options); void ffInitCommandOptions(FFCommandOptions* options); bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value); void ffDestroyCommandOptions(FFCommandOptions* options); -void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseCommandJsonObject(yyjson_val* module); diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 8c9496fee..f4b41be5c 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -6,7 +6,7 @@ #define FF_CPU_NUM_FORMAT_ARGS 8 -void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) +void ffPrintCPU(FFCPUOptions* options) { FFCPUResult cpu; cpu.temperature = FF_CPU_TEMP_UNSET; @@ -15,21 +15,21 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) ffStrbufInit(&cpu.name); ffStrbufInit(&cpu.vendor); - const char* error = ffDetectCPU(instance, options, &cpu); + const char* error = ffDetectCPU(options, &cpu); if(error) { - ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) { - ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); + ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); } else { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(cpu.name.length > 0) ffStrbufWriteTo(&cpu.name, stdout); @@ -54,7 +54,7 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options) } else { - ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor}, {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, @@ -99,7 +99,7 @@ void ffDestroyCPUOptions(FFCPUOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseCPUJsonObject(yyjson_val* module) { FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options; ffInitCPUOptions(&options); @@ -123,9 +123,9 @@ void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintCPU(instance, &options); + ffPrintCPU(&options); } diff --git a/src/modules/cpu/cpu.h b/src/modules/cpu/cpu.h index 1a8f32922..731149d5b 100644 --- a/src/modules/cpu/cpu.h +++ b/src/modules/cpu/cpu.h @@ -4,8 +4,8 @@ #define FF_CPU_MODULE_NAME "CPU" -void ffPrintCPU(FFinstance* instance, FFCPUOptions* options); +void ffPrintCPU(FFCPUOptions* options); void ffInitCPUOptions(FFCPUOptions* options); bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value); void ffDestroyCPUOptions(FFCPUOptions* options); -void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseCPUJsonObject(yyjson_val* module); diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index 0e2e04608..32f24a462 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -8,35 +8,35 @@ #define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage" #define FF_CPUUSAGE_NUM_FORMAT_ARGS 1 -void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options) +void ffPrintCPUUsage(FFCPUUsageOptions* options) { double percentage = 0.0/0.0; const char* error = ffGetCpuUsageResult(&percentage); if(error) { - ffPrintError(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) - ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + ffAppendPercentBar(&str, (uint8_t)percentage, 0, 5, 8); + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); - ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); + ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0); } ffStrbufPutTo(&str, stdout); } else { - ffPrintFormat(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_DOUBLE, &percentage} }); } @@ -63,7 +63,7 @@ void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseCPUUsageJsonObject(yyjson_val* module) { FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options; ffInitCPUUsageOptions(&options); @@ -81,9 +81,9 @@ void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintCPUUsage(instance, &options); + ffPrintCPUUsage(&options); } diff --git a/src/modules/cpuusage/cpuusage.h b/src/modules/cpuusage/cpuusage.h index bd12de8a6..e0275a5ea 100644 --- a/src/modules/cpuusage/cpuusage.h +++ b/src/modules/cpuusage/cpuusage.h @@ -6,8 +6,8 @@ void ffPrepareCPUUsage(); -void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options); +void ffPrintCPUUsage(FFCPUUsageOptions* options); void ffInitCPUUsageOptions(FFCPUUsageOptions* options); bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value); void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options); -void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseCPUUsageJsonObject(yyjson_val* module); diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index b55934273..06a8d3d91 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -6,17 +6,17 @@ #define FF_CURSOR_NUM_FORMAT_ARGS 2 -void ffPrintCursor(FFinstance* instance, FFCursorOptions* options) +void ffPrintCursor(FFCursorOptions* options) { FFCursorResult result; ffStrbufInit(&result.error); ffStrbufInit(&result.theme); ffStrbufInit(&result.size); - ffDetectCursor(instance, &result); + ffDetectCursor(&result); if(result.error.length) - ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars); + ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars); else { ffStrbufRemoveIgnCaseEndS(&result.theme, "cursors"); @@ -28,7 +28,7 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.theme, stdout); if(result.size.length > 0) @@ -38,7 +38,7 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options) } else { - ffPrintFormat(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.size} }); @@ -71,7 +71,7 @@ void ffDestroyCursorOptions(FFCursorOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseCursorJsonObject(yyjson_val* module) { FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options; ffInitCursorOptions(&options); @@ -89,9 +89,9 @@ void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintCursor(instance, &options); + ffPrintCursor(&options); } diff --git a/src/modules/cursor/cursor.h b/src/modules/cursor/cursor.h index f36975aa7..5c23741a2 100644 --- a/src/modules/cursor/cursor.h +++ b/src/modules/cursor/cursor.h @@ -4,8 +4,8 @@ #define FF_CURSOR_MODULE_NAME "Cursor" -void ffPrintCursor(FFinstance* instance, FFCursorOptions* options); +void ffPrintCursor(FFCursorOptions* options); void ffInitCursorOptions(FFCursorOptions* options); bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value); void ffDestroyCursorOptions(FFCursorOptions* options); -void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseCursorJsonObject(yyjson_val* module); diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index c461a5530..64ab00579 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -4,15 +4,15 @@ #include "util/textModifier.h" #include "util/stringUtils.h" -void ffPrintCustom(FFinstance* instance, FFCustomOptions* options) +void ffPrintCustom(FFCustomOptions* options) { if (options->moduleArgs.outputFormat.length == 0) { - ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module"); + ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module"); return; } - ffPrintLogoAndKey(instance, options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffPrintUserString(options->moduleArgs.outputFormat.chars); puts(FASTFETCH_TEXT_MODIFIER_RESET); } @@ -38,7 +38,7 @@ void ffDestroyCustomOptions(FFCustomOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseCustomJsonObject(yyjson_val* module) { FFCustomOptions __attribute__((__cleanup__(ffDestroyCustomOptions))) options; ffInitCustomOptions(&options); @@ -56,9 +56,9 @@ void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintCustom(instance, &options); + ffPrintCustom(&options); } diff --git a/src/modules/custom/custom.h b/src/modules/custom/custom.h index fec8099b3..6d1981d7c 100644 --- a/src/modules/custom/custom.h +++ b/src/modules/custom/custom.h @@ -4,8 +4,8 @@ #define FF_CUSTOM_MODULE_NAME "Custom" -void ffPrintCustom(FFinstance* instance, FFCustomOptions* options); +void ffPrintCustom(FFCustomOptions* options); void ffInitCustomOptions(FFCustomOptions* options); bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value); void ffDestroyCustomOptions(FFCustomOptions* options); -void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseCustomJsonObject(yyjson_val* module); diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 049102f70..12134c178 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -7,10 +7,10 @@ #define FF_DATETIME_DISPLAY_NAME "Date & Time" #define FF_DATETIME_NUM_FORMAT_ARGS 20 -void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs) +void ffPrintDateTimeFormat(const char* moduleName, const FFModuleArgs* moduleArgs) { - const FFDateTimeResult* result = ffDetectDateTime(instance); - ffPrintFormat(instance, moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) { + const FFDateTimeResult* result = ffDetectDateTime(); + ffPrintFormat(moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_UINT16, &result->year}, // 1 {FF_FORMAT_ARG_TYPE_UINT8, &result->yearShort}, // 2 {FF_FORMAT_ARG_TYPE_UINT8, &result->month}, // 3 @@ -34,16 +34,16 @@ void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const F }); } -void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options) +void ffPrintDateTime(FFDateTimeOptions* options) { if(options->moduleArgs.outputFormat.length > 0) { - ffPrintDateTimeFormat(instance, FF_DATETIME_DISPLAY_NAME, &options->moduleArgs); + ffPrintDateTimeFormat(FF_DATETIME_DISPLAY_NAME, &options->moduleArgs); return; } - const FFDateTimeResult* datetime = ffDetectDateTime(instance); - ffPrintLogoAndKey(instance, FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + const FFDateTimeResult* datetime = ffDetectDateTime(); + ffPrintLogoAndKey(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); //yyyy-MM-dd HH:mm:ss printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); @@ -70,7 +70,7 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseDateTimeJsonObject(yyjson_val* module) { FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options; ffInitDateTimeOptions(&options); @@ -88,9 +88,9 @@ void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintDateTime(instance, &options); + ffPrintDateTime(&options); } diff --git a/src/modules/datetime/datetime.h b/src/modules/datetime/datetime.h index 01b67701b..269343711 100644 --- a/src/modules/datetime/datetime.h +++ b/src/modules/datetime/datetime.h @@ -4,8 +4,8 @@ #define FF_DATETIME_MODULE_NAME "DateTime" -void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options); +void ffPrintDateTime(FFDateTimeOptions* options); void ffInitDateTimeOptions(FFDateTimeOptions* options); bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value); void ffDestroyDateTimeOptions(FFDateTimeOptions* options); -void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseDateTimeJsonObject(yyjson_val* module); diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 3ae6105fd..a32e6dc01 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -6,19 +6,19 @@ #define FF_DE_NUM_FORMAT_ARGS 3 -void ffPrintDE(FFinstance* instance, FFDEOptions* options) +void ffPrintDE(FFDEOptions* options) { - const FFDisplayServerResult* result = ffConnectDisplayServer(instance); + const FFDisplayServerResult* result = ffConnectDisplayServer(); if(result->dePrettyName.length == 0) { - ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found"); + ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->dePrettyName, stdout); @@ -32,7 +32,7 @@ void ffPrintDE(FFinstance* instance, FFDEOptions* options) } else { - ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion} @@ -61,7 +61,7 @@ void ffDestroyDEOptions(FFDEOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseDEJsonObject(yyjson_val* module) { FFDEOptions __attribute__((__cleanup__(ffDestroyDEOptions))) options; ffInitDEOptions(&options); @@ -79,9 +79,9 @@ void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_DE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintDE(instance, &options); + ffPrintDE(&options); } diff --git a/src/modules/de/de.h b/src/modules/de/de.h index 3d7d6f729..267665584 100644 --- a/src/modules/de/de.h +++ b/src/modules/de/de.h @@ -4,8 +4,8 @@ #define FF_DE_MODULE_NAME "DE" -void ffPrintDE(FFinstance* instance, FFDEOptions* options); +void ffPrintDE(FFDEOptions* options); void ffInitDEOptions(FFDEOptions* options); bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value); void ffDestroyDEOptions(FFDEOptions* options); -void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseDEJsonObject(yyjson_val* module); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index f94555b81..ca3e91ce7 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -9,7 +9,7 @@ #define FF_DISK_NUM_FORMAT_ARGS 10 #pragma GCC diagnostic ignored "-Wsign-conversion" -static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk* disk) +static void printDisk(FFDiskOptions* options, const FFDisk* disk) { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); @@ -25,40 +25,40 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty); + ffParseSize(disk->bytesUsed, instance.config.binaryPrefixType, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty); + ffParseSize(disk->bytesTotal, instance.config.binaryPrefixType, &totalPretty); uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0; if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(disk->bytesTotal > 0) { - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { - ffAppendPercentBar(instance, &str, bytesPercentage, 0, 5, 8); + ffAppendPercentBar(&str, bytesPercentage, 0, 5, 8); ffStrbufAppendC(&str, ' '); } - if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { - ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0); + ffAppendPercentNum(&str, (uint8_t) bytesPercentage, 50, 80, str.length > 0); ffStrbufAppendC(&str, ' '); } } else ffStrbufAppendS(&str, "Unknown "); - if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { if(disk->filesystem.length) ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); @@ -80,7 +80,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage}, @@ -95,22 +95,22 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk } } -static void printMountpoint(FFinstance* instance, FFDiskOptions* options, const FFlist* disks, const char* mountpoint) +static void printMountpoint(FFDiskOptions* options, const FFlist* disks, const char* mountpoint) { for(uint32_t i = disks->length; i > 0; i--) { FFDisk* disk = ffListGet(disks, i - 1); if(strncmp(mountpoint, disk->mountpoint.chars, disk->mountpoint.length) == 0) { - printDisk(instance, options, disk); + printDisk(options, disk); return; } } - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint); + ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint); } -static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const FFlist* disks) +static void printMountpoints(FFDiskOptions* options, const FFlist* disks) { #ifdef _WIN32 const char separator = ';'; @@ -127,38 +127,38 @@ static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const uint32_t colonIndex = ffStrbufNextIndexC(&mountpoints, startIndex, separator); mountpoints.chars[colonIndex] = '\0'; - printMountpoint(instance, options, disks, mountpoints.chars + startIndex); + printMountpoint(options, disks, mountpoints.chars + startIndex); startIndex = colonIndex + 1; } } -static void printAutodetected(FFinstance* instance, FFDiskOptions* options, const FFlist* disks) +static void printAutodetected(FFDiskOptions* options, const FFlist* disks) { FF_LIST_FOR_EACH(FFDisk, disk, *disks) { if(!(disk->type & options->showTypes)) continue; - printDisk(instance, options, disk); + printDisk(options, disk); } } -void ffPrintDisk(FFinstance* instance, FFDiskOptions* options) +void ffPrintDisk(FFDiskOptions* options) { FF_LIST_AUTO_DESTROY disks = ffListCreate(sizeof (FFDisk)); const char* error = ffDetectDisks(&disks); if(error) { - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else { if(options->folders.length == 0) - printAutodetected(instance, options, &disks); + printAutodetected(options, &disks); else - printMountpoints(instance, options, &disks); + printMountpoints(options, &disks); } FF_LIST_FOR_EACH(FFDisk, disk, disks) @@ -245,7 +245,7 @@ void ffDestroyDiskOptions(FFDiskOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseDiskJsonObject(yyjson_val* module) { FFDiskOptions __attribute__((__cleanup__(ffDestroyDiskOptions))) options; ffInitDiskOptions(&options); @@ -305,9 +305,9 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_DISK_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintDisk(instance, &options); + ffPrintDisk(&options); } diff --git a/src/modules/disk/disk.h b/src/modules/disk/disk.h index 82886a257..aa508df14 100644 --- a/src/modules/disk/disk.h +++ b/src/modules/disk/disk.h @@ -4,8 +4,8 @@ #define FF_DISK_MODULE_NAME "Disk" -void ffPrintDisk(FFinstance* instance, FFDiskOptions* options); +void ffPrintDisk(FFDiskOptions* options); void ffInitDiskOptions(FFDiskOptions* options); bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value); void ffDestroyDiskOptions(FFDiskOptions* options); -void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseDiskJsonObject(yyjson_val* module); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 3688fa069..abf233316 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -6,24 +6,24 @@ #define FF_DISPLAY_NUM_FORMAT_ARGS 8 -void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) +void ffPrintDisplay(FFDisplayOptions* options) { #ifdef __ANDROID__ - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Display detection is not supported on Android"); + ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Display detection is not supported on Android"); return; #endif - const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance); + const FFDisplayServerResult* dsResult = ffConnectDisplayServer(); if(dsResult->displays.length == 0) { - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Couldn't detect display"); + ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Couldn't detect display"); return; } if (options->compactType != FF_DISPLAY_COMPACT_TYPE_NONE) { - ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); int index = 0; FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays) @@ -72,7 +72,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_STRING, displayType}, }); } - ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); printf("%ix%i", result->width, result->height); @@ -96,7 +96,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) } else { - ffPrintFormat(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_UINT, &result->width}, {FF_FORMAT_ARG_TYPE_UINT, &result->height}, {FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate}, @@ -151,7 +151,7 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseDisplayJsonObject(yyjson_val* module) { FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options; ffInitDisplayOptions(&options); @@ -179,7 +179,7 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) {}, }); if (error) - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else options.compactType = (FFDisplayCompactType) value; continue; @@ -191,9 +191,9 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintDisplay(instance, &options); + ffPrintDisplay(&options); } diff --git a/src/modules/display/display.h b/src/modules/display/display.h index 62a4c210e..66196f063 100644 --- a/src/modules/display/display.h +++ b/src/modules/display/display.h @@ -4,8 +4,8 @@ #define FF_DISPLAY_MODULE_NAME "Display" -void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options); +void ffPrintDisplay(FFDisplayOptions* options); void ffInitDisplayOptions(FFDisplayOptions* options); bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value); void ffDestroyDisplayOptions(FFDisplayOptions* options); -void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseDisplayJsonObject(yyjson_val* module); diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 0d58be3cc..9a8195cd0 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -6,29 +6,29 @@ #define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1) -void ffPrintFont(FFinstance* instance, FFFontOptions* options) +void ffPrintFont(FFFontOptions* options) { FFFontResult font; for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) ffStrbufInit(&font.fonts[i]); ffStrbufInit(&font.display); - const char* error = ffDetectFont(instance, &font); + const char* error = ffDetectFont(&font); if(error) { - ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error); } else { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&font.display, stdout); } else { - ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]}, @@ -64,7 +64,7 @@ void ffDestroyFontOptions(FFFontOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseFontJsonObject(yyjson_val* module) { FFFontOptions __attribute__((__cleanup__(ffDestroyFontOptions))) options; ffInitFontOptions(&options); @@ -82,9 +82,9 @@ void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_FONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintFont(instance, &options); + ffPrintFont(&options); } diff --git a/src/modules/font/font.h b/src/modules/font/font.h index c26987d29..a4e46f65a 100644 --- a/src/modules/font/font.h +++ b/src/modules/font/font.h @@ -4,8 +4,8 @@ #define FF_FONT_MODULE_NAME "Font" -void ffPrintFont(FFinstance* instance, FFFontOptions* options); +void ffPrintFont(FFFontOptions* options); void ffInitFontOptions(FFFontOptions* options); bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value); void ffDestroyFontOptions(FFFontOptions* options); -void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseFontJsonObject(yyjson_val* module); diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 9c228b29b..e5f28704c 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -6,44 +6,44 @@ #define FF_GAMEPAD_NUM_FORMAT_ARGS 2 -static void printDevice(FFinstance* instance, FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index) +static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&device->name, stdout); } else { - ffPrintFormat(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier}, }); } } -void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options) +void ffPrintGamepad(FFGamepadOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFGamepadDevice)); - const char* error = ffDetectGamepad(instance, &result); + const char* error = ffDetectGamepad(&result); if(error) { - ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(!result.length) { - ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected"); + ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected"); return; } uint8_t index = 0; FF_LIST_FOR_EACH(FFGamepadDevice, device, result) { - printDevice(instance, options, device, result.length > 1 ? ++index : 0); + printDevice(options, device, result.length > 1 ? ++index : 0); ffStrbufDestroy(&device->identifier); ffStrbufDestroy(&device->name); } @@ -70,7 +70,7 @@ void ffDestroyGamepadOptions(FFGamepadOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseGamepadJsonObject(yyjson_val* module) { FFGamepadOptions __attribute__((__cleanup__(ffDestroyGamepadOptions))) options; ffInitGamepadOptions(&options); @@ -88,9 +88,9 @@ void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintGamepad(instance, &options); + ffPrintGamepad(&options); } diff --git a/src/modules/gamepad/gamepad.h b/src/modules/gamepad/gamepad.h index f08b01937..df81768d7 100644 --- a/src/modules/gamepad/gamepad.h +++ b/src/modules/gamepad/gamepad.h @@ -4,8 +4,8 @@ #define FF_GAMEPAD_MODULE_NAME "Gamepad" -void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options); +void ffPrintGamepad(FFGamepadOptions* options); void ffInitGamepadOptions(FFGamepadOptions* options); bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value); void ffDestroyGamepadOptions(FFGamepadOptions* options); -void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseGamepadJsonObject(yyjson_val* module); diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 0fa1170ff..6c34aa82c 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -11,11 +11,11 @@ #define FF_GPU_NUM_FORMAT_ARGS 6 -static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu) +static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(gpu->vendor.length + 1 + gpu->name.length); @@ -39,14 +39,14 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) { - ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output); + ffParseSize(gpu->dedicated.used, instance.config.binaryPrefixType, &output); ffStrbufAppendS(&output, " / "); } - ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output); + ffParseSize(gpu->dedicated.total, instance.config.binaryPrefixType, &output); if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) { ffStrbufAppendS(&output, ", "); - ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false); + ffAppendPercentNum(&output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false); } ffStrbufAppendC(&output, ')'); } @@ -63,7 +63,7 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t else type = "Unknown"; - ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver}, @@ -74,13 +74,13 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t } } -void ffPrintGPU(FFinstance* instance, FFGPUOptions* options) +void ffPrintGPU(FFGPUOptions* options) { FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult)); - const char* error = ffDetectGPU(instance, options, &gpus); + const char* error = ffDetectGPU(options, &gpus); if (error) { - ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -99,10 +99,10 @@ void ffPrintGPU(FFinstance* instance, FFGPUOptions* options) } for(uint32_t i = 0; i < selectedGPUs.length; i++) - printGPUResult(instance, options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); + printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); if(selectedGPUs.length == 0) - ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); + ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) { @@ -159,7 +159,7 @@ void ffDestroyGPUOptions(FFGPUOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseGPUJsonObject(yyjson_val* module) { FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options; ffInitGPUOptions(&options); @@ -199,15 +199,15 @@ void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module) {}, }); if (error) - ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + ffPrintError(FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else options.hideType = (FFGPUType) value; continue; } - ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintGPU(instance, &options); + ffPrintGPU(&options); } diff --git a/src/modules/gpu/gpu.h b/src/modules/gpu/gpu.h index ee8a61826..9462e5fa0 100644 --- a/src/modules/gpu/gpu.h +++ b/src/modules/gpu/gpu.h @@ -4,8 +4,8 @@ #define FF_GPU_MODULE_NAME "GPU" -void ffPrintGPU(FFinstance* instance, FFGPUOptions* options); +void ffPrintGPU(FFGPUOptions* options); void ffInitGPUOptions(FFGPUOptions* options); bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value); void ffDestroyGPUOptions(FFGPUOptions* options); -void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseGPUJsonObject(yyjson_val* module); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index a196c2cc7..53526f9ee 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -6,7 +6,7 @@ #define FF_HOST_NUM_FORMAT_ARGS 5 -void ffPrintHost(FFinstance* instance, FFHostOptions* options) +void ffPrintHost(FFHostOptions* options) { FFHostResult host; ffStrbufInit(&host.productFamily); @@ -18,19 +18,19 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) if(error) { - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error); goto exit; } if(host.productFamily.length == 0 && host.productName.length == 0) { - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "neither product_family nor product_name is set by O.E.M."); + ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "neither product_family nor product_name is set by O.E.M."); goto exit; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); @@ -48,7 +48,7 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options) } else { - ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &host.productFamily}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.productName}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.productVersion}, @@ -86,7 +86,7 @@ void ffDestroyHostOptions(FFHostOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseHostJsonObject(yyjson_val* module) { FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options; ffInitHostOptions(&options); @@ -104,9 +104,9 @@ void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintHost(instance, &options); + ffPrintHost(&options); } diff --git a/src/modules/host/host.h b/src/modules/host/host.h index 43d51f3d4..9c9368a27 100644 --- a/src/modules/host/host.h +++ b/src/modules/host/host.h @@ -4,8 +4,8 @@ #define FF_HOST_MODULE_NAME "Host" -void ffPrintHost(FFinstance* instance, FFHostOptions* options); +void ffPrintHost(FFHostOptions* options); void ffInitHostOptions(FFHostOptions* options); bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value); void ffDestroyHostOptions(FFHostOptions* options); -void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseHostJsonObject(yyjson_val* module); diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index cd331e89a..e1defe320 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -6,25 +6,25 @@ #define FF_ICONS_NUM_FORMAT_ARGS 1 -void ffPrintIcons(FFinstance* instance, FFIconsOptions* options) +void ffPrintIcons(FFIconsOptions* options) { FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate(); - const char* error = ffDetectIcons(instance, &icons); + const char* error = ffDetectIcons(&icons); if(error) { - ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&icons, stdout); } else { - ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &icons} }); } @@ -51,7 +51,7 @@ void ffDestroyIconsOptions(FFIconsOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseIconsJsonObject(yyjson_val* module) { FFIconsOptions __attribute__((__cleanup__(ffDestroyIconsOptions))) options; ffInitIconsOptions(&options); @@ -69,9 +69,9 @@ void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_ICONS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintIcons(instance, &options); + ffPrintIcons(&options); } diff --git a/src/modules/icons/icons.h b/src/modules/icons/icons.h index ea49656f7..3d4bd7e0d 100644 --- a/src/modules/icons/icons.h +++ b/src/modules/icons/icons.h @@ -4,8 +4,8 @@ #define FF_ICONS_MODULE_NAME "Icons" -void ffPrintIcons(FFinstance* instance, FFIconsOptions* options); +void ffPrintIcons(FFIconsOptions* options); void ffInitIconsOptions(FFIconsOptions* options); bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value); void ffDestroyIconsOptions(FFIconsOptions* options); -void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseIconsJsonObject(yyjson_val* module); diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index e62430fe4..8cef1ae06 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -5,27 +5,27 @@ #define FF_KERNEL_NUM_FORMAT_ARGS 4 -void ffPrintKernel(FFinstance* instance, FFKernelOptions* options) +void ffPrintKernel(FFKernelOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout); + ffPrintLogoAndKey(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffStrbufWriteTo(&instance.state.platform.systemRelease, stdout); #ifdef _WIN32 - if(instance->state.platform.systemVersion.length > 0) - printf(" (%s)", instance->state.platform.systemVersion.chars); + if(instance.state.platform.systemVersion.length > 0) + printf(" (%s)", instance.state.platform.systemVersion.chars); #endif putchar('\n'); } else { - ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemRelease}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture} + ffPrintFormat(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemName}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemRelease}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture} }); } } @@ -51,7 +51,7 @@ void ffDestroyKernelOptions(FFKernelOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseKernelJsonObject(yyjson_val* module) { FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options; ffInitKernelOptions(&options); @@ -69,9 +69,9 @@ void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintKernel(instance, &options); + ffPrintKernel(&options); } diff --git a/src/modules/kernel/kernel.h b/src/modules/kernel/kernel.h index 4e21eb3dd..906a89c11 100644 --- a/src/modules/kernel/kernel.h +++ b/src/modules/kernel/kernel.h @@ -4,8 +4,8 @@ #define FF_KERNEL_MODULE_NAME "Kernel" -void ffPrintKernel(FFinstance* instance, FFKernelOptions* options); +void ffPrintKernel(FFKernelOptions* options); void ffInitKernelOptions(FFKernelOptions* options); bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value); void ffDestroyKernelOptions(FFKernelOptions* options); -void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseKernelJsonObject(yyjson_val* module); diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index 5f52baf9d..34e28e6fa 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -6,7 +6,7 @@ #define FF_LM_NUM_FORMAT_ARGS 2 -void ffPrintLM(FFinstance* instance, FFLMOptions* options) +void ffPrintLM(FFLMOptions* options) { FFLMResult result; ffStrbufInit(&result.service); @@ -15,19 +15,19 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options) if(error) { - ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(result.service.length == 0) { - ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found"); + ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.service, stdout); if(result.type.length) printf(" (%s)", result.type.chars); @@ -35,7 +35,7 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options) } else { - ffPrintFormat(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result.service}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, }); @@ -65,7 +65,7 @@ void ffDestroyLMOptions(FFLMOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseLMJsonObject(yyjson_val* module) { FFLMOptions __attribute__((__cleanup__(ffDestroyLMOptions))) options; ffInitLMOptions(&options); @@ -83,9 +83,9 @@ void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_LM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintLM(instance, &options); + ffPrintLM(&options); } diff --git a/src/modules/lm/lm.h b/src/modules/lm/lm.h index 862f474e0..788405bed 100644 --- a/src/modules/lm/lm.h +++ b/src/modules/lm/lm.h @@ -4,8 +4,8 @@ #define FF_LM_MODULE_NAME "LM" -void ffPrintLM(FFinstance* instance, FFLMOptions* options); +void ffPrintLM(FFLMOptions* options); void ffInitLMOptions(FFLMOptions* options); bool ffParseLMCommandOptions(FFLMOptions* options, const char* key, const char* value); void ffDestroyLMOptions(FFLMOptions* options); -void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseLMJsonObject(yyjson_val* module); diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 563fdd5f9..46b4377a4 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -6,25 +6,25 @@ #define FF_LOCALE_NUM_FORMAT_ARGS 1 -void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options) +void ffPrintLocale(FFLocaleOptions* options) { FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate(); ffDetectLocale(&locale); if(locale.length == 0) { - ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found"); + ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&locale, stdout); } else { - ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &locale} }); } @@ -51,7 +51,7 @@ void ffDestroyLocaleOptions(FFLocaleOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseLocaleJsonObject(yyjson_val* module) { FFLocaleOptions __attribute__((__cleanup__(ffDestroyLocaleOptions))) options; ffInitLocaleOptions(&options); @@ -69,9 +69,9 @@ void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintLocale(instance, &options); + ffPrintLocale(&options); } diff --git a/src/modules/locale/locale.h b/src/modules/locale/locale.h index 93d3e820c..91e496878 100644 --- a/src/modules/locale/locale.h +++ b/src/modules/locale/locale.h @@ -4,8 +4,8 @@ #define FF_LOCALE_MODULE_NAME "Locale" -void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options); +void ffPrintLocale(FFLocaleOptions* options); void ffInitLocaleOptions(FFLocaleOptions* options); bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value); void ffDestroyLocaleOptions(FFLocaleOptions* options); -void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseLocaleJsonObject(yyjson_val* module); diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index e4c95b7e0..a9c76da0d 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -54,7 +54,7 @@ static void printIp(FFLocalIpResult* ip) } } -void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) +void ffPrintLocalIp(FFLocalIpOptions* options) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult)); @@ -62,13 +62,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) if(error) { - ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); return; } if(results.length == 0) { - ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs"); + ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs"); return; } @@ -76,7 +76,7 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT) { - ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { @@ -94,13 +94,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options) formatKey(options, ip, &key); if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); printIp(ip); putchar('\n'); } else { - ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, @@ -195,7 +195,7 @@ void ffDestroyLocalIpOptions(FFLocalIpOptions* options) ffStrbufDestroy(&options->namePrefix); } -void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseLocalIpJsonObject(yyjson_val* module) { FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options; ffInitLocalIpOptions(&options); @@ -264,9 +264,9 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintLocalIp(instance, &options); + ffPrintLocalIp(&options); } diff --git a/src/modules/localip/localip.h b/src/modules/localip/localip.h index d758f4fab..8d1270c23 100644 --- a/src/modules/localip/localip.h +++ b/src/modules/localip/localip.h @@ -4,8 +4,8 @@ #define FF_LOCALIP_MODULE_NAME "LocalIp" -void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options); +void ffPrintLocalIp(FFLocalIpOptions* options); void ffInitLocalIpOptions(FFLocalIpOptions* options); bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value); void ffDestroyLocalIpOptions(FFLocalIpOptions* options); -void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseLocalIpJsonObject(yyjson_val* module); diff --git a/src/modules/media/media.c b/src/modules/media/media.c index ccb9772db..e60b04698 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -43,13 +43,13 @@ static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist) return false; } -void ffPrintMedia(FFinstance* instance, FFMediaOptions* options) +void ffPrintMedia(FFMediaOptions* options) { - const FFMediaResult* media = ffDetectMedia(instance); + const FFMediaResult* media = ffDetectMedia(); if(media->error.length > 0) { - ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars); + ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars); return; } @@ -80,7 +80,7 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options) if(artistInSongTitle(&songPretty, &artistPretty)) ffStrbufClear(&artistPretty); - ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(artistPretty.length > 0) { @@ -95,7 +95,7 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options) } else { - ffPrintFormat(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &songPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->song}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->artist}, @@ -126,7 +126,7 @@ void ffDestroyMediaOptions(FFMediaOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseMediaJsonObject(yyjson_val* module) { FFMediaOptions __attribute__((__cleanup__(ffDestroyMediaOptions))) options; ffInitMediaOptions(&options); @@ -144,9 +144,9 @@ void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintMedia(instance, &options); + ffPrintMedia(&options); } diff --git a/src/modules/media/media.h b/src/modules/media/media.h index f35421504..52fb6ba50 100644 --- a/src/modules/media/media.h +++ b/src/modules/media/media.h @@ -4,8 +4,8 @@ #define FF_MEDIA_MODULE_NAME "Media" -void ffPrintMedia(FFinstance* instance, FFMediaOptions* options); +void ffPrintMedia(FFMediaOptions* options); void ffInitMediaOptions(FFMediaOptions* options); bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value); void ffDestroyMediaOptions(FFMediaOptions* options); -void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseMediaJsonObject(yyjson_val* module); diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 127987741..6663d9bc4 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -8,22 +8,22 @@ #define FF_MEMORY_NUM_FORMAT_ARGS 3 -void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options) +void ffPrintMemory(FFMemoryOptions* options) { FFMemoryResult storage; const char* error = ffDetectMemory(&storage); if(error) { - ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty); + ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty); + ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 ? 0 @@ -31,24 +31,24 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if (storage.bytesTotal == 0) puts("Disabled"); else { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { - ffAppendPercentBar(instance, &str, percentage, 0, 5, 8); + ffAppendPercentBar(&str, percentage, 0, 5, 8); ffStrbufAppendC(&str, ' '); } - if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0); ffStrbufTrimRight(&str, ' '); ffStrbufPutTo(&str, stdout); @@ -56,7 +56,7 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options) } else { - ffPrintFormat(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &percentage}, @@ -85,7 +85,7 @@ void ffDestroyMemoryOptions(FFMemoryOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseMemoryJsonObject(yyjson_val* module) { FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options; ffInitMemoryOptions(&options); @@ -103,9 +103,9 @@ void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintMemory(instance, &options); + ffPrintMemory(&options); } diff --git a/src/modules/memory/memory.h b/src/modules/memory/memory.h index c5bf8e733..e63a45e28 100644 --- a/src/modules/memory/memory.h +++ b/src/modules/memory/memory.h @@ -4,8 +4,8 @@ #define FF_MEMORY_MODULE_NAME "Memory" -void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options); +void ffPrintMemory(FFMemoryOptions* options); void ffInitMemoryOptions(FFMemoryOptions* options); bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value); void ffDestroyMemoryOptions(FFMemoryOptions* options); -void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseMemoryJsonObject(yyjson_val* module); diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index bf69739fa..3fd3ce1eb 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -6,27 +6,27 @@ #define FF_OPENCL_NUM_FORMAT_ARGS 3 -void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options) +void ffPrintOpenCL(FFOpenCLOptions* options) { FFOpenCLResult opencl; ffStrbufInit(&opencl.version); ffStrbufInit(&opencl.device); ffStrbufInit(&opencl.vendor); - const char* error = ffDetectOpenCL(instance, &opencl); + const char* error = ffDetectOpenCL(&opencl); if(error != NULL) - ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); else { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&opencl.version, stdout); } else { - ffPrintFormat(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor}, @@ -60,7 +60,7 @@ void ffDestroyOpenCLOptions(FFOpenCLOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseOpenCLJsonObject(yyjson_val* module) { FFOpenCLOptions __attribute__((__cleanup__(ffDestroyOpenCLOptions))) options; ffInitOpenCLOptions(&options); @@ -78,9 +78,9 @@ void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintOpenCL(instance, &options); + ffPrintOpenCL(&options); } diff --git a/src/modules/opencl/opencl.h b/src/modules/opencl/opencl.h index 479e2e231..b01a2a480 100644 --- a/src/modules/opencl/opencl.h +++ b/src/modules/opencl/opencl.h @@ -4,8 +4,8 @@ #define FF_OPENCL_MODULE_NAME "OpenCL" -void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options); +void ffPrintOpenCL(FFOpenCLOptions* options); void ffInitOpenCLOptions(FFOpenCLOptions* options); bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value); void ffDestroyOpenCLOptions(FFOpenCLOptions* options); -void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseOpenCLJsonObject(yyjson_val* module); diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 730f1f72d..e5f5bc9fc 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -6,7 +6,7 @@ #define FF_OPENGL_NUM_FORMAT_ARGS 4 -void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options) +void ffPrintOpenGL(FFOpenGLOptions* options) { FFOpenGLResult result; ffStrbufInit(&result.version); @@ -14,21 +14,21 @@ void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options) ffStrbufInit(&result.vendor); ffStrbufInit(&result.slv); - const char* error = ffDetectOpenGL(instance, &result); + const char* error = ffDetectOpenGL(&result); if(error) { - ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(result.version.chars); } else { - ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, @@ -80,7 +80,7 @@ void ffDestroyOpenGLOptions(FFOpenGLOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseOpenGLJsonObject(yyjson_val* module) { FFOpenGLOptions __attribute__((__cleanup__(ffDestroyOpenGLOptions))) options; ffInitOpenGLOptions(&options); @@ -110,16 +110,16 @@ void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) {}, }); if (error) - ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else options.library = (FFOpenGLLibrary) value; continue; } #endif - ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintOpenGL(instance, &options); + ffPrintOpenGL(&options); } diff --git a/src/modules/opengl/opengl.h b/src/modules/opengl/opengl.h index a5b88b23d..5d4f1ab88 100644 --- a/src/modules/opengl/opengl.h +++ b/src/modules/opengl/opengl.h @@ -4,8 +4,8 @@ #define FF_OPENGL_MODULE_NAME "OpenGL" -void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options); +void ffPrintOpenGL(FFOpenGLOptions* options); void ffInitOpenGLOptions(FFOpenGLOptions* options); bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value); void ffDestroyOpenGLOptions(FFOpenGLOptions* options); -void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseOpenGLJsonObject(yyjson_val* module); diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 6964bed4e..119306742 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -9,7 +9,7 @@ #define FF_OS_NUM_FORMAT_ARGS 12 -static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result) +static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result) { //Create the basic output if(os->name.length > 0) @@ -19,7 +19,7 @@ static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, else if(os->id.length > 0) ffStrbufAppend(result, &os->id); else - ffStrbufAppend(result, &instance->state.platform.systemName); + ffStrbufAppend(result, &instance.state.platform.systemName); #ifdef __APPLE__ if(os->codename.length > 0) @@ -64,14 +64,14 @@ static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, } //Append architecture if it is missing - if(ffStrbufFirstIndex(result, &instance->state.platform.systemArchitecture) == result->length) + if(ffStrbufFirstIndex(result, &instance.state.platform.systemArchitecture) == result->length) { ffStrbufAppendC(result, ' '); - ffStrbufAppend(result, &instance->state.platform.systemArchitecture); + ffStrbufAppend(result, &instance.state.platform.systemArchitecture); } } -static void buildOutputNixOS(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result) +static void buildOutputNixOS(const FFOSResult* os, FFstrbuf* result) { ffStrbufAppendS(result, "NixOS"); @@ -89,20 +89,20 @@ static void buildOutputNixOS(const FFinstance* instance, const FFOSResult* os, F ffStrbufAppendC(result, ')'); } - if(instance->state.platform.systemArchitecture.length > 0) + if(instance.state.platform.systemArchitecture.length > 0) { ffStrbufAppendC(result, ' '); - ffStrbufAppend(result, &instance->state.platform.systemArchitecture); + ffStrbufAppend(result, &instance.state.platform.systemArchitecture); } } -void ffPrintOS(FFinstance* instance, FFOSOptions* options) +void ffPrintOS(FFOSOptions* options) { - const FFOSResult* os = ffDetectOS(instance); + const FFOSResult* os = ffDetectOS(); if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) { - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS"); + ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS"); return; } @@ -111,17 +111,17 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0) - buildOutputNixOS(instance, os, &result); + buildOutputNixOS(os, &result); else - buildOutputDefault(instance, os, &result); + buildOutputDefault(os, &result); - ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else { - ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName}, + ffPrintFormat(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemName}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->id}, @@ -132,7 +132,7 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->codename}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture} + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture} }); } } @@ -158,7 +158,7 @@ void ffDestroyOSOptions(FFOSOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseOSJsonObject(yyjson_val* module) { FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options; ffInitOSOptions(&options); @@ -176,9 +176,9 @@ void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintOS(instance, &options); + ffPrintOS(&options); } diff --git a/src/modules/os/os.h b/src/modules/os/os.h index 55036fed1..36856d9b1 100644 --- a/src/modules/os/os.h +++ b/src/modules/os/os.h @@ -4,8 +4,8 @@ #define FF_OS_MODULE_NAME "OS" -void ffPrintOS(FFinstance* instance, FFOSOptions* options); +void ffPrintOS(FFOSOptions* options); void ffInitOSOptions(FFOSOptions* options); bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value); void ffDestroyOSOptions(FFOSOptions* options); -void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseOSJsonObject(yyjson_val* module); diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index a0269d504..1b3dc7568 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -6,22 +6,22 @@ #define FF_PACKAGES_NUM_FORMAT_ARGS 21 -void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) +void ffPrintPackages(FFPackagesOptions* options) { FFPackagesResult counts = {}; ffStrbufInit(&counts.pacmanBranch); - const char* error = ffDetectPackages(instance, &counts); + const char* error = ffDetectPackages(&counts); if(error) { - ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); #define FF_PRINT_PACKAGE_NAME(var, name) \ if(counts.var > 0) \ @@ -66,7 +66,7 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options) } else { - ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT, &counts.all}, {FF_FORMAT_ARG_TYPE_UINT, &counts.pacman}, {FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch}, @@ -115,7 +115,7 @@ void ffDestroyPackagesOptions(FFPackagesOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module) +void ffParsePackagesJsonObject(yyjson_val* module) { FFPackagesOptions __attribute__((__cleanup__(ffDestroyPackagesOptions))) options; ffInitPackagesOptions(&options); @@ -133,9 +133,9 @@ void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintPackages(instance, &options); + ffPrintPackages(&options); } diff --git a/src/modules/packages/packages.h b/src/modules/packages/packages.h index 8aec1a0fc..87516579a 100644 --- a/src/modules/packages/packages.h +++ b/src/modules/packages/packages.h @@ -4,8 +4,8 @@ #define FF_PACKAGES_MODULE_NAME "Packages" -void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options); +void ffPrintPackages(FFPackagesOptions* options); void ffInitPackagesOptions(FFPackagesOptions* options); bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value); void ffDestroyPackagesOptions(FFPackagesOptions* options); -void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module); +void ffParsePackagesJsonObject(yyjson_val* module); diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 56dfb0820..1503a9cad 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -9,13 +9,13 @@ #define FF_PLAYER_DISPLAY_NAME "Media Player" #define FF_PLAYER_NUM_FORMAT_ARGS 4 -void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options) +void ffPrintPlayer(FFPlayerOptions* options) { - const FFMediaResult* media = ffDetectMedia(instance); + const FFMediaResult* media = ffDetectMedia(); if(media->error.length > 0) { - ffPrintError(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars); + ffPrintError(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars); return; } @@ -59,12 +59,12 @@ void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&playerPretty, stdout); } else { - ffPrintFormat(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->player}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId}, @@ -94,7 +94,7 @@ void ffDestroyPlayerOptions(FFPlayerOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module) +void ffParsePlayerJsonObject(yyjson_val* module) { FFPlayerOptions __attribute__((__cleanup__(ffDestroyPlayerOptions))) options; ffInitPlayerOptions(&options); @@ -112,9 +112,9 @@ void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_PLAYER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintPlayer(instance, &options); + ffPrintPlayer(&options); } diff --git a/src/modules/player/player.h b/src/modules/player/player.h index 1825d2f9e..6f09b425f 100644 --- a/src/modules/player/player.h +++ b/src/modules/player/player.h @@ -5,8 +5,8 @@ #define FF_PLAYER_MODULE_NAME "Player" -void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options); +void ffPrintPlayer(FFPlayerOptions* options); void ffInitPlayerOptions(FFPlayerOptions* options); bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value); void ffDestroyPlayerOptions(FFPlayerOptions* options); -void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module); +void ffParsePlayerJsonObject(yyjson_val* module); diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 6fd67d8b6..629a096b1 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -7,20 +7,20 @@ #define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter" #define FF_POWERADAPTER_MODULE_ARGS 5 -void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options) +void ffPrintPowerAdapter(FFPowerAdapterOptions* options) { FFlist results; ffListInit(&results, sizeof(PowerAdapterResult)); - const char* error = ffDetectPowerAdapterImpl(instance, &results); + const char* error = ffDetectPowerAdapterImpl(&results); if (error) { - ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); } else if(results.length == 0) { - ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found"); + ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found"); } else { @@ -32,7 +32,7 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(result->name.length > 0) puts(result->name.chars); @@ -43,7 +43,7 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options) } else { - ffPrintFormat(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_INT, &result->watts}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, @@ -84,7 +84,7 @@ void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module) +void ffParsePowerAdapterJsonObject(yyjson_val* module) { FFPowerAdapterOptions __attribute__((__cleanup__(ffDestroyPowerAdapterOptions))) options; ffInitPowerAdapterOptions(&options); @@ -102,9 +102,9 @@ void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_POWERADAPTER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_POWERADAPTER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintPowerAdapter(instance, &options); + ffPrintPowerAdapter(&options); } diff --git a/src/modules/poweradapter/poweradapter.h b/src/modules/poweradapter/poweradapter.h index f8cca4c6c..93c6a7704 100644 --- a/src/modules/poweradapter/poweradapter.h +++ b/src/modules/poweradapter/poweradapter.h @@ -4,8 +4,8 @@ #define FF_POWERADAPTER_MODULE_NAME "PowerAdapter" -void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options); +void ffPrintPowerAdapter(FFPowerAdapterOptions* options); void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options); bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value); void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options); -void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module); +void ffParsePowerAdapterJsonObject(yyjson_val* module); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 772994887..bc5cf63b9 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -6,26 +6,26 @@ #define FF_PROCESSES_NUM_FORMAT_ARGS 1 -void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options) +void ffPrintProcesses(FFProcessesOptions* options) { uint32_t numProcesses = 0; const char* error = ffDetectProcesses(&numProcesses); if(error) { - ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); printf("%u\n", numProcesses); } else { - ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT, &numProcesses} }); } @@ -52,7 +52,7 @@ void ffDestroyProcessesOptions(FFProcessesOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseProcessesJsonObject(yyjson_val* module) { FFProcessesOptions __attribute__((__cleanup__(ffDestroyProcessesOptions))) options; ffInitProcessesOptions(&options); @@ -70,9 +70,9 @@ void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintProcesses(instance, &options); + ffPrintProcesses(&options); } diff --git a/src/modules/processes/processes.h b/src/modules/processes/processes.h index 6aa952574..84696356d 100644 --- a/src/modules/processes/processes.h +++ b/src/modules/processes/processes.h @@ -4,8 +4,8 @@ #define FF_PROCESSES_MODULE_NAME "Processes" -void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options); +void ffPrintProcesses(FFProcessesOptions* options); void ffInitProcessesOptions(FFProcessesOptions* options); bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value); void ffDestroyProcessesOptions(FFProcessesOptions* options); -void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseProcessesJsonObject(yyjson_val* module); diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index 920c7c944..3b30e5b66 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -32,14 +32,14 @@ void ffPreparePublicIp(FFPublicIpOptions* options) } } -void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options) +void ffPrintPublicIp(FFPublicIpOptions* options) { if (status == -1) ffPreparePublicIp(options); if (status == 0) { - ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to connect to an IP detection server"); + ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to connect to an IP detection server"); return; } @@ -49,18 +49,18 @@ void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options) if (!success || result.length == 0) { - ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); + ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); return; } if (options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else { - ffPrintFormat(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result} }); } @@ -104,7 +104,7 @@ void ffDestroyPublicIpOptions(FFPublicIpOptions* options) ffStrbufDestroy(&options->url); } -void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module) +void ffParsePublicIpJsonObject(yyjson_val* module) { FFPublicIpOptions __attribute__((__cleanup__(ffDestroyPublicIpOptions))) options; ffInitPublicIpOptions(&options); @@ -134,9 +134,9 @@ void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_PUBLICIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintPublicIp(instance, &options); + ffPrintPublicIp(&options); } diff --git a/src/modules/publicip/publicip.h b/src/modules/publicip/publicip.h index 618d054ff..8328023f5 100644 --- a/src/modules/publicip/publicip.h +++ b/src/modules/publicip/publicip.h @@ -6,8 +6,8 @@ void ffPreparePublicIp(FFPublicIpOptions* options); -void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options); +void ffPrintPublicIp(FFPublicIpOptions* options); void ffInitPublicIpOptions(FFPublicIpOptions* options); bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value); void ffDestroyPublicIpOptions(FFPublicIpOptions* options); -void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module); +void ffParsePublicIpJsonObject(yyjson_val* module); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 1ae369f70..7a28f7bbe 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -3,19 +3,19 @@ #include "modules/separator/separator.h" #include "util/stringUtils.h" -void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options) +void ffPrintSeparator(FFSeparatorOptions* options) { - uint32_t titleLength = instance->state.titleLength; + uint32_t titleLength = instance.state.titleLength; if (titleLength == 0) { // Title was not printed, should we support this case? - titleLength = instance->state.platform.userName.length + 1 + (instance->config.title.fdqn ? - instance->state.platform.domainName.length : - instance->state.platform.hostName.length + titleLength = instance.state.platform.userName.length + 1 + (instance.config.title.fdqn ? + instance.state.platform.domainName.length : + instance.state.platform.hostName.length ); } - ffLogoPrintLine(instance); + ffLogoPrintLine(); if(options->string.length == 0) { @@ -59,7 +59,7 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options) ffStrbufDestroy(&options->string); } -void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseSeparatorJsonObject(yyjson_val* module) { FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options; ffInitSeparatorOptions(&options); @@ -80,9 +80,9 @@ void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } - ffPrintSeparator(instance, &options); + ffPrintSeparator(&options); } diff --git a/src/modules/separator/separator.h b/src/modules/separator/separator.h index 6da53e559..3e97ac464 100644 --- a/src/modules/separator/separator.h +++ b/src/modules/separator/separator.h @@ -4,8 +4,8 @@ #define FF_SEPARATOR_MODULE_NAME "Separator" -void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options); +void ffPrintSeparator(FFSeparatorOptions* options); void ffInitSeparatorOptions(FFSeparatorOptions* options); bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value); void ffDestroySeparatorOptions(FFSeparatorOptions* options); -void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseSeparatorJsonObject(yyjson_val* module); diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index ac76f14a5..efaca7441 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -6,19 +6,19 @@ #define FF_SHELL_NUM_FORMAT_ARGS 7 -void ffPrintShell(FFinstance* instance, FFShellOptions* options) +void ffPrintShell(FFShellOptions* options) { - const FFTerminalShellResult* result = ffDetectTerminalShell(instance); + const FFTerminalShellResult* result = ffDetectTerminalShell(); if(result->shellProcessName.length == 0) { - ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell"); + ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->shellPrettyName, stdout); if(result->shellVersion.length > 0) @@ -31,7 +31,7 @@ void ffPrintShell(FFinstance* instance, FFShellOptions* options) } else { - ffPrintFormat(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe}, {FF_FORMAT_ARG_TYPE_STRING, result->shellExeName}, @@ -64,7 +64,7 @@ void ffDestroyShellOptions(FFShellOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseShellJsonObject(yyjson_val* module) { FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options; ffInitShellOptions(&options); @@ -82,9 +82,9 @@ void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintShell(instance, &options); + ffPrintShell(&options); } diff --git a/src/modules/shell/shell.h b/src/modules/shell/shell.h index 0225b6291..b2579cd49 100644 --- a/src/modules/shell/shell.h +++ b/src/modules/shell/shell.h @@ -4,8 +4,8 @@ #define FF_SHELL_MODULE_NAME "Shell" -void ffPrintShell(FFinstance* instance, FFShellOptions* options); +void ffPrintShell(FFShellOptions* options); void ffInitShellOptions(FFShellOptions* options); bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value); void ffDestroyShellOptions(FFShellOptions* options); -void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseShellJsonObject(yyjson_val* module); diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 786d4ab78..2955c8f5b 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -6,11 +6,11 @@ #define FF_SOUND_NUM_FORMAT_ARGS 4 -static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFSoundDevice* device, uint8_t index) +static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&device->name, stdout); if(device->volume != FF_SOUND_VOLUME_UNKNOWN) @@ -28,7 +28,7 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS } else { - ffPrintFormat(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_BOOL, &device->main}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_UINT8, &device->volume}, @@ -37,15 +37,15 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS } } -void ffPrintSound(FFinstance* instance, FFSoundOptions* options) +void ffPrintSound(FFSoundOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSoundDevice)); - const char* error = ffDetectSound(instance, &result); + const char* error = ffDetectSound(&result); if(error) { - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -65,14 +65,14 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options) if(filtered.length == 0) { - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found"); + ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found"); return; } uint8_t index = 1; FF_LIST_FOR_EACH(FFSoundDevice*, device, filtered) { - printDevice(instance, options, *device, filtered.length == 1 ? 0 : index++); + printDevice(options, *device, filtered.length == 1 ? 0 : index++); } FF_LIST_FOR_EACH(FFSoundDevice, device, result) @@ -117,7 +117,7 @@ void ffDestroySoundOptions(FFSoundOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseSoundJsonObject(yyjson_val* module) { FFSoundOptions __attribute__((__cleanup__(ffDestroySoundOptions))) options; ffInitSoundOptions(&options); @@ -145,15 +145,15 @@ void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module) {}, }); if (error) - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); + ffPrintError(FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else options.soundType = (FFSoundType) value; continue; } - ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintSound(instance, &options); + ffPrintSound(&options); } diff --git a/src/modules/sound/sound.h b/src/modules/sound/sound.h index 0ebfe328f..4b02f4d24 100644 --- a/src/modules/sound/sound.h +++ b/src/modules/sound/sound.h @@ -4,8 +4,8 @@ #define FF_SOUND_MODULE_NAME "Sound" -void ffPrintSound(FFinstance* instance, FFSoundOptions* options); +void ffPrintSound(FFSoundOptions* options); void ffInitSoundOptions(FFSoundOptions* options); bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value); void ffDestroySoundOptions(FFSoundOptions* options); -void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseSoundJsonObject(yyjson_val* module); diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index bf7ebb1fa..99ce0455e 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -8,22 +8,22 @@ #define FF_SWAP_NUM_FORMAT_ARGS 3 -void ffPrintSwap(FFinstance* instance, FFSwapOptions* options) +void ffPrintSwap(FFSwapOptions* options) { FFSwapResult storage; const char* error = ffDetectSwap(&storage); if(error) { - ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty); + ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty); + ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 ? 0 @@ -31,24 +31,24 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if (storage.bytesTotal == 0) puts("Disabled"); else { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { - ffAppendPercentBar(instance, &str, percentage, 0, 5, 8); + ffAppendPercentBar(&str, percentage, 0, 5, 8); ffStrbufAppendC(&str, ' '); } - if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); + if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0); ffStrbufTrimRight(&str, ' '); ffStrbufPutTo(&str, stdout); @@ -56,7 +56,7 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options) } else { - ffPrintFormat(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &percentage}, @@ -85,7 +85,7 @@ void ffDestroySwapOptions(FFSwapOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseSwapJsonObject(yyjson_val* module) { FFSwapOptions __attribute__((__cleanup__(ffDestroySwapOptions))) options; ffInitSwapOptions(&options); @@ -103,9 +103,9 @@ void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_SWAP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintSwap(instance, &options); + ffPrintSwap(&options); } diff --git a/src/modules/swap/swap.h b/src/modules/swap/swap.h index 6945f854c..3cd4f5b14 100644 --- a/src/modules/swap/swap.h +++ b/src/modules/swap/swap.h @@ -4,8 +4,8 @@ #define FF_SWAP_MODULE_NAME "Swap" -void ffPrintSwap(FFinstance* instance, FFSwapOptions* options); +void ffPrintSwap(FFSwapOptions* options); void ffInitSwapOptions(FFSwapOptions* options); bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value); void ffDestroySwapOptions(FFSwapOptions* options); -void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseSwapJsonObject(yyjson_val* module); diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 63de55909..315ede3bc 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -8,19 +8,19 @@ #define FF_TERMINAL_NUM_FORMAT_ARGS 10 -void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options) +void ffPrintTerminal(FFTerminalOptions* options) { - const FFTerminalShellResult* result = ffDetectTerminalShell(instance); + const FFTerminalShellResult* result = ffDetectTerminalShell(); if(result->terminalProcessName.length == 0) { - ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal"); + ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(result->terminalVersion.length) printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); @@ -29,7 +29,7 @@ void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options) } else { - ffPrintFormat(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalProcessName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalExe}, {FF_FORMAT_ARG_TYPE_STRING, result->terminalExeName}, @@ -65,7 +65,7 @@ void ffDestroyTerminalOptions(FFTerminalOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseTerminalJsonObject(yyjson_val* module) { FFTerminalOptions __attribute__((__cleanup__(ffDestroyTerminalOptions))) options; ffInitTerminalOptions(&options); @@ -83,9 +83,9 @@ void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintTerminal(instance, &options); + ffPrintTerminal(&options); } diff --git a/src/modules/terminal/terminal.h b/src/modules/terminal/terminal.h index 5f2045e78..45372754d 100644 --- a/src/modules/terminal/terminal.h +++ b/src/modules/terminal/terminal.h @@ -4,8 +4,8 @@ #define FF_TERMINAL_MODULE_NAME "Terminal" -void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options); +void ffPrintTerminal(FFTerminalOptions* options); void ffInitTerminalOptions(FFTerminalOptions* options); bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value); void ffDestroyTerminalOptions(FFTerminalOptions* options); -void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseTerminalJsonObject(yyjson_val* module); diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index db2177487..6e03ed45c 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -7,26 +7,26 @@ #define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font" #define FF_TERMINALFONT_NUM_FORMAT_ARGS 4 -void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options) +void ffPrintTerminalFont(FFTerminalFontOptions* options) { FFTerminalFontResult terminalFont; ffFontInit(&terminalFont.font); ffStrbufInit(&terminalFont.error); - if(!ffDetectTerminalFont(instance, &terminalFont)) + if(!ffDetectTerminalFont(&terminalFont)) { - ffPrintError(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars); + ffPrintError(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars); } else { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&terminalFont.font.pretty, stdout); } else { - ffPrintFormat(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.pretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size}, @@ -60,7 +60,7 @@ void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseTerminalFontJsonObject(yyjson_val* module) { FFTerminalFontOptions __attribute__((__cleanup__(ffDestroyTerminalFontOptions))) options; ffInitTerminalFontOptions(&options); @@ -78,9 +78,9 @@ void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_TERMINALFONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_TERMINALFONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintTerminalFont(instance, &options); + ffPrintTerminalFont(&options); } diff --git a/src/modules/terminalfont/terminalfont.h b/src/modules/terminalfont/terminalfont.h index 25f974261..a538cd0d7 100644 --- a/src/modules/terminalfont/terminalfont.h +++ b/src/modules/terminalfont/terminalfont.h @@ -4,8 +4,8 @@ #define FF_TERMINALFONT_MODULE_NAME "TerminalFont" -void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options); +void ffPrintTerminalFont(FFTerminalFontOptions* options); void ffInitTerminalFontOptions(FFTerminalFontOptions* options); bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value); void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options); -void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseTerminalFontJsonObject(yyjson_val* module); diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 67edd69ba..741e47c72 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -6,25 +6,25 @@ #define FF_THEME_NUM_FORMAT_ARGS 1 -void ffPrintTheme(FFinstance* instance, FFThemeOptions* options) +void ffPrintTheme(FFThemeOptions* options) { FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate(); - const char* error = ffDetectTheme(instance, &theme); + const char* error = ffDetectTheme(&theme); if(error) { - ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&theme, stdout); } else { - ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &theme} }); } @@ -51,7 +51,7 @@ void ffDestroyThemeOptions(FFThemeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseThemeJsonObject(yyjson_val* module) { FFThemeOptions __attribute__((__cleanup__(ffDestroyThemeOptions))) options; ffInitThemeOptions(&options); @@ -69,9 +69,9 @@ void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_THEME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintTheme(instance, &options); + ffPrintTheme(&options); } diff --git a/src/modules/theme/theme.h b/src/modules/theme/theme.h index ae332f49e..37a006dd4 100644 --- a/src/modules/theme/theme.h +++ b/src/modules/theme/theme.h @@ -4,8 +4,8 @@ #define FF_THEME_MODULE_NAME "Theme" -void ffPrintTheme(FFinstance* instance, FFThemeOptions* options); +void ffPrintTheme(FFThemeOptions* options); void ffInitThemeOptions(FFThemeOptions* options); bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value); void ffDestroyThemeOptions(FFThemeOptions* options); -void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseThemeJsonObject(yyjson_val* module); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 205d526ef..6faacaf67 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -4,32 +4,32 @@ #include "util/textModifier.h" #include "util/stringUtils.h" -static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content) +static inline void printTitlePart(const FFstrbuf* content) { - if(!instance->config.pipe) + if(!instance.config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance->config.colorTitle); + ffPrintColor(&instance.config.colorTitle); } ffStrbufWriteTo(content, stdout); - if(!instance->config.pipe) + if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); } -void ffPrintTitle(FFinstance* instance, FFTitleOptions* options) +void ffPrintTitle(FFTitleOptions* options) { - ffLogoPrintLine(instance); + ffLogoPrintLine(); - printTitlePart(instance, &instance->state.platform.userName); + printTitlePart(&instance.state.platform.userName); putchar('@'); FFstrbuf* host = options->fdqn ? - &instance->state.platform.domainName : - &instance->state.platform.hostName; - printTitlePart(instance, host); + &instance.state.platform.domainName : + &instance.state.platform.hostName; + printTitlePart(host); - instance->state.titleLength = instance->state.platform.userName.length + host->length + 1; + instance.state.titleLength = instance.state.platform.userName.length + host->length + 1; putchar('\n'); } @@ -59,7 +59,7 @@ void ffDestroyTitleOptions(FFTitleOptions* options) FF_UNUSED(options); } -void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseTitleJsonObject(yyjson_val* module) { FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options; ffInitTitleOptions(&options); @@ -80,9 +80,9 @@ void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } - ffPrintTitle(instance, &options); + ffPrintTitle(&options); } diff --git a/src/modules/title/title.h b/src/modules/title/title.h index 1b1c9460b..7bd407243 100644 --- a/src/modules/title/title.h +++ b/src/modules/title/title.h @@ -4,8 +4,8 @@ #define FF_TITLE_MODULE_NAME "Title" -void ffPrintTitle(FFinstance* instance, FFTitleOptions* options); +void ffPrintTitle(FFTitleOptions* options); void ffInitTitleOptions(FFTitleOptions* options); bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value); void ffDestroyTitleOptions(FFTitleOptions* options); -void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseTitleJsonObject(yyjson_val* module); diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index 6c7aaf892..f6a4bd424 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -6,7 +6,7 @@ #define FF_UPTIME_NUM_FORMAT_ARGS 4 -void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) +void ffPrintUptime(FFUptimeOptions* options) { uint64_t uptime; @@ -14,7 +14,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) if(error) { - ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } @@ -25,7 +25,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(days == 0 && hours == 0 && minutes == 0) { @@ -70,7 +70,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options) } else { - ffPrintFormat(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT, &days}, {FF_FORMAT_ARG_TYPE_UINT, &hours}, {FF_FORMAT_ARG_TYPE_UINT, &minutes}, @@ -100,7 +100,7 @@ void ffDestroyUptimeOptions(FFUptimeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseUptimeJsonObject(yyjson_val* module) { FFUptimeOptions __attribute__((__cleanup__(ffDestroyUptimeOptions))) options; ffInitUptimeOptions(&options); @@ -118,9 +118,9 @@ void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintUptime(instance, &options); + ffPrintUptime(&options); } diff --git a/src/modules/uptime/uptime.h b/src/modules/uptime/uptime.h index e19da5157..4708dbd39 100644 --- a/src/modules/uptime/uptime.h +++ b/src/modules/uptime/uptime.h @@ -4,8 +4,8 @@ #define FF_UPTIME_MODULE_NAME "Uptime" -void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options); +void ffPrintUptime(FFUptimeOptions* options); void ffInitUptimeOptions(FFUptimeOptions* options); bool ffParseUptimeCommandOptions(FFUptimeOptions* options, const char* key, const char* value); void ffDestroyUptimeOptions(FFUptimeOptions* options); -void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseUptimeJsonObject(yyjson_val* module); diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 6f81469d3..ed18e7b14 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -6,7 +6,7 @@ #define FF_USERS_NUM_FORMAT_ARGS 1 -void ffPrintUsers(FFinstance* instance, FFUsersOptions* options) +void ffPrintUsers(FFUsersOptions* options) { FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf)); @@ -16,7 +16,7 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options) if(error.length > 0) { - ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%*s", error.length, error.chars); + ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%*s", error.length, error.chars); return; } @@ -32,12 +32,12 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(result.chars); } else { - ffPrintFormat(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result}, }); } @@ -64,7 +64,7 @@ void ffDestroyUsersOptions(FFUsersOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseUsersJsonObject(yyjson_val* module) { FFUsersOptions __attribute__((__cleanup__(ffDestroyUsersOptions))) options; ffInitUsersOptions(&options); @@ -82,9 +82,9 @@ void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_USERS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintUsers(instance, &options); + ffPrintUsers(&options); } diff --git a/src/modules/users/users.h b/src/modules/users/users.h index fa96d0dc4..64aab51b7 100644 --- a/src/modules/users/users.h +++ b/src/modules/users/users.h @@ -4,8 +4,8 @@ #define FF_USERS_MODULE_NAME "Users" -void ffPrintUsers(FFinstance* instance, FFUsersOptions* options); +void ffPrintUsers(FFUsersOptions* options); void ffInitUsersOptions(FFUsersOptions* options); bool ffParseUsersCommandOptions(FFUsersOptions* options, const char* key, const char* value); void ffDestroyUsersOptions(FFUsersOptions* options); -void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseUsersJsonObject(yyjson_val* module); diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index da8897918..b4e51dfb9 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -6,19 +6,19 @@ #define FF_VULKAN_NUM_FORMAT_ARGS 3 -void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options) +void ffPrintVulkan(FFVulkanOptions* options) { - const FFVulkanResult* vulkan = ffDetectVulkan(instance); + const FFVulkanResult* vulkan = ffDetectVulkan(); if(vulkan->error) { - ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error); + ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(vulkan->apiVersion.length > 0) { @@ -35,7 +35,7 @@ void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options) } else { - ffPrintFormat(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->driver}, {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion}, {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion} @@ -64,7 +64,7 @@ void ffDestroyVulkanOptions(FFVulkanOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseVulkanJsonObject(yyjson_val* module) { FFVulkanOptions __attribute__((__cleanup__(ffDestroyVulkanOptions))) options; ffInitVulkanOptions(&options); @@ -82,9 +82,9 @@ void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintVulkan(instance, &options); + ffPrintVulkan(&options); } diff --git a/src/modules/vulkan/vulkan.h b/src/modules/vulkan/vulkan.h index 68a3b8385..5b92ff850 100644 --- a/src/modules/vulkan/vulkan.h +++ b/src/modules/vulkan/vulkan.h @@ -4,8 +4,8 @@ #define FF_VULKAN_MODULE_NAME "Vulkan" -void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options); +void ffPrintVulkan(FFVulkanOptions* options); void ffInitVulkanOptions(FFVulkanOptions* options); bool ffParseVulkanCommandOptions(FFVulkanOptions* options, const char* key, const char* value); void ffDestroyVulkanOptions(FFVulkanOptions* options); -void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseVulkanJsonObject(yyjson_val* module); diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 3325fd6a5..54785f6ca 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -6,10 +6,10 @@ #define FF_WALLPAPER_NUM_FORMAT_ARGS 2 -void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) +void ffPrintWallpaper(FFWallpaperOptions* options) { FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate(); - const char* error = ffDetectWallpaper(instance, &fullpath); + const char* error = ffDetectWallpaper(&fullpath); const uint32_t index = ffStrbufLastIndexC(&fullpath, #ifndef _WIN32 @@ -24,18 +24,18 @@ void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options) if(error) { - ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(filename); } else { - ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRING, filename}, {FF_FORMAT_ARG_TYPE_STRBUF, &fullpath}, }); @@ -63,7 +63,7 @@ void ffDestroyWallpaperOptions(FFWallpaperOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseWallpaperJsonObject(yyjson_val* module) { FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options; ffInitWallpaperOptions(&options); @@ -81,9 +81,9 @@ void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintWallpaper(instance, &options); + ffPrintWallpaper(&options); } diff --git a/src/modules/wallpaper/wallpaper.h b/src/modules/wallpaper/wallpaper.h index bd2dbbbca..b274f037d 100644 --- a/src/modules/wallpaper/wallpaper.h +++ b/src/modules/wallpaper/wallpaper.h @@ -4,8 +4,8 @@ #define FF_WALLPAPER_MODULE_NAME "Wallpaper" -void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options); +void ffPrintWallpaper(FFWallpaperOptions* options); void ffInitWallpaperOptions(FFWallpaperOptions* options); bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value); void ffDestroyWallpaperOptions(FFWallpaperOptions* options); -void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseWallpaperJsonObject(yyjson_val* module); diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index d32095904..84f34ee82 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -16,14 +16,14 @@ void ffPrepareWeather(FFWeatherOptions* options) status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); } -void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options) +void ffPrintWeather(FFWeatherOptions* options) { if(status == -1) ffPrepareWeather(options); if(status == 0) { - ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to connect to 'wttr.in'"); + ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to connect to 'wttr.in'"); return; } @@ -33,18 +33,18 @@ void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options) if(!success || result.length == 0) { - ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); + ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to receive the server response"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufPutTo(&result, stdout); } else { - ffPrintFormat(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &result} }); } @@ -88,7 +88,7 @@ void ffDestroyWeatherOptions(FFWeatherOptions* options) ffStrbufDestroy(&options->outputFormat); } -void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseWeatherJsonObject(yyjson_val* module) { FFWeatherOptions __attribute__((__cleanup__(ffDestroyWeatherOptions))) options; ffInitWeatherOptions(&options); @@ -118,9 +118,9 @@ void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module) continue; } - ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintWeather(instance, &options); + ffPrintWeather(&options); } diff --git a/src/modules/weather/weather.h b/src/modules/weather/weather.h index 70c34b61f..640201176 100644 --- a/src/modules/weather/weather.h +++ b/src/modules/weather/weather.h @@ -6,8 +6,8 @@ void ffPrepareWeather(FFWeatherOptions* options); -void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options); +void ffPrintWeather(FFWeatherOptions* options); void ffInitWeatherOptions(FFWeatherOptions* options); bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, const char* value); void ffDestroyWeatherOptions(FFWeatherOptions* options); -void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseWeatherJsonObject(yyjson_val* module); diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 79e56db11..cda777141 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -6,19 +6,19 @@ #define FF_WIFI_NUM_FORMAT_ARGS 10 -void ffPrintWifi(FFinstance* instance, FFWifiOptions* options) +void ffPrintWifi(FFWifiOptions* options) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult)); - const char* error = ffDetectWifi(instance, &result); + const char* error = ffDetectWifi(&result); if(error) { - ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(!result.length) { - ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found"); + ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found"); return; } @@ -29,7 +29,7 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); if(item->conn.ssid.length) { ffStrbufWriteTo(&item->conn.ssid, stdout); @@ -46,7 +46,7 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options) } else { - ffPrintFormat(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.description}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.status}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.status}, @@ -91,7 +91,7 @@ void ffDestroyWifiOptions(FFWifiOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseWifiJsonObject(yyjson_val* module) { FFWifiOptions __attribute__((__cleanup__(ffDestroyWifiOptions))) options; ffInitWifiOptions(&options); @@ -109,9 +109,9 @@ void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_WIFI_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintWifi(instance, &options); + ffPrintWifi(&options); } diff --git a/src/modules/wifi/wifi.h b/src/modules/wifi/wifi.h index 99070d07b..b8291fdfc 100644 --- a/src/modules/wifi/wifi.h +++ b/src/modules/wifi/wifi.h @@ -4,8 +4,8 @@ #define FF_WIFI_MODULE_NAME "Wifi" -void ffPrintWifi(FFinstance* instance, FFWifiOptions* options); +void ffPrintWifi(FFWifiOptions* options); void ffInitWifiOptions(FFWifiOptions* options); bool ffParseWifiCommandOptions(FFWifiOptions* options, const char* key, const char* value); void ffDestroyWifiOptions(FFWifiOptions* options); -void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseWifiJsonObject(yyjson_val* module); diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 72a8536df..6f60107ff 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -6,19 +6,19 @@ #define FF_WM_NUM_FORMAT_ARGS 3 -void ffPrintWM(FFinstance* instance, FFWMOptions* options) +void ffPrintWM(FFWMOptions* options) { - const FFDisplayServerResult* result = ffConnectDisplayServer(instance); + const FFDisplayServerResult* result = ffConnectDisplayServer(); if(result->wmPrettyName.length == 0) { - ffPrintError(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs, "No WM found"); + ffPrintError(FF_WM_MODULE_NAME, 0, &options->moduleArgs, "No WM found"); return; } if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result->wmPrettyName, stdout); @@ -33,7 +33,7 @@ void ffPrintWM(FFinstance* instance, FFWMOptions* options) } else { - ffPrintFormat(instance, FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProcessName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName} @@ -62,7 +62,7 @@ void ffDestroyWMOptions(FFWMOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseWMJsonObject(yyjson_val* module) { FFWMOptions __attribute__((__cleanup__(ffDestroyWMOptions))) options; ffInitWMOptions(&options); @@ -80,9 +80,9 @@ void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_WM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_WM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintWM(instance, &options); + ffPrintWM(&options); } diff --git a/src/modules/wm/wm.h b/src/modules/wm/wm.h index 2f18b1c16..243d6a647 100644 --- a/src/modules/wm/wm.h +++ b/src/modules/wm/wm.h @@ -4,8 +4,8 @@ #define FF_WM_MODULE_NAME "WM" -void ffPrintWM(FFinstance* instance, FFWMOptions* options); +void ffPrintWM(FFWMOptions* options); void ffInitWMOptions(FFWMOptions* options); bool ffParseWMCommandOptions(FFWMOptions* options, const char* key, const char* value); void ffDestroyWMOptions(FFWMOptions* options); -void ffParseWMJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseWMJsonObject(yyjson_val* module); diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 45d7ead7f..da66e8ad8 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -7,26 +7,26 @@ #define FF_WMTHEME_DISPLAY_NAME "WM Theme" #define FF_WMTHEME_NUM_FORMAT_ARGS 1 -void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options) +void ffPrintWMTheme(FFWMThemeOptions* options) { FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate(); - if(ffDetectWmTheme(instance, &themeOrError)) + if(ffDetectWmTheme(&themeOrError)) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); puts(themeOrError.chars); } else { - ffPrintFormat(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_WMTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormat(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_WMTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &themeOrError} }); } } else { - ffPrintError(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "%*s", themeOrError.length, themeOrError.chars); + ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "%*s", themeOrError.length, themeOrError.chars); } } @@ -51,7 +51,7 @@ void ffDestroyWMThemeOptions(FFWMThemeOptions* options) ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module) +void ffParseWMThemeJsonObject(yyjson_val* module) { FFWMThemeOptions __attribute__((__cleanup__(ffDestroyWMThemeOptions))) options; ffInitWMThemeOptions(&options); @@ -69,9 +69,9 @@ void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(instance, FF_WMTHEME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintWMTheme(instance, &options); + ffPrintWMTheme(&options); } diff --git a/src/modules/wmtheme/wmtheme.h b/src/modules/wmtheme/wmtheme.h index 5bb11cb3f..021408945 100644 --- a/src/modules/wmtheme/wmtheme.h +++ b/src/modules/wmtheme/wmtheme.h @@ -4,8 +4,8 @@ #define FF_WMTHEME_MODULE_NAME "WMTheme" -void ffPrintWMTheme(FFinstance* instance, FFWMThemeOptions* options); +void ffPrintWMTheme(FFWMThemeOptions* options); void ffInitWMThemeOptions(FFWMThemeOptions* options); bool ffParseWMThemeCommandOptions(FFWMThemeOptions* options, const char* key, const char* value); void ffDestroyWMThemeOptions(FFWMThemeOptions* options); -void ffParseWMThemeJsonObject(FFinstance* instance, yyjson_val* module); +void ffParseWMThemeJsonObject(yyjson_val* module); diff --git a/src/util/windows/com.cpp b/src/util/windows/com.cpp index c11cccf95..43c4a5a49 100644 --- a/src/util/windows/com.cpp +++ b/src/util/windows/com.cpp @@ -6,7 +6,7 @@ //https://learn.microsoft.com/en-us/windows/win32/wmisdk/example--getting-wmi-data-from-the-local-computer //https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/computer-system-hardware-classes -static void CoUninitializeWrap() +static void CoUninitializeWrap(void) { CoUninitialize(); } diff --git a/src/util/windows/wmi.cpp b/src/util/windows/wmi.cpp index f1e2e10a1..9b8103fbe 100644 --- a/src/util/windows/wmi.cpp +++ b/src/util/windows/wmi.cpp @@ -15,9 +15,9 @@ namespace struct bstr_t { explicit bstr_t(const wchar_t* str) noexcept: _bstr(SysAllocString(str)) {} - ~bstr_t() noexcept { SysFreeString(_bstr); } - explicit operator const wchar_t*() const noexcept { return _bstr; } - operator BSTR() const noexcept { return _bstr; } + ~bstr_t(void) noexcept { SysFreeString(_bstr); } + explicit operator const wchar_t*(void) const noexcept { return _bstr; } + operator BSTR(void) const noexcept { return _bstr; } private: BSTR _bstr; From 40a487d7ed1574286d17808343b6636452cedcc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 11:47:06 +0800 Subject: [PATCH 226/493] CI (FreeBSD): build with libpulse support --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9c46ce25a..02ce13fdc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -154,7 +154,7 @@ jobs: uses: vmactions/freebsd-vm@v0 with: prepare: | - pkg install -y cmake git pkgconf pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd + pkg install -y cmake git pkgconf pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd pulseaudio run: | cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . cmake --build . --target package From 296eaa592c61d577ce0d67598873fc27689cb107 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 24 Jun 2023 06:25:47 +0000 Subject: [PATCH 227/493] Battery (FreeBSD): tidy --- src/detection/battery/battery_bsd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 29799fec2..287f004a1 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -1,5 +1,6 @@ #include "fastfetch.h" #include "common/sysctl.h" +#include "common/io/io.h" #include "battery.h" #include @@ -19,7 +20,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r if(units == 0) return NULL; - int acpifd = open("/dev/acpi", O_RDONLY); + FF_AUTO_CLOSE_FD int acpifd = open("/dev/acpi", O_RDONLY); if(acpifd < 0) return "open(\"/dev/acpi\", O_RDONLY) failed"; @@ -72,6 +73,5 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufAppendS(&battery->technology, battio.bix.type); } } - close(acpifd); return NULL; } From 75e29726e22a3bd6d00d6e1c8bbc92c83e1995de Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 24 Jun 2023 06:26:55 +0000 Subject: [PATCH 228/493] Brightness (FreeBSD): add support I hope someone can test it --- CMakeLists.txt | 2 +- src/detection/brightness/brightness_bsd.c | 47 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/detection/brightness/brightness_bsd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 426a07cab..76992f71e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -432,7 +432,7 @@ elseif(BSD) src/detection/bios/bios_bsd.c src/detection/bluetooth/bluetooth_linux.c src/detection/board/board_bsd.c - src/detection/brightness/brightness_nosupport.c + src/detection/brightness/brightness_bsd.c src/detection/chassis/chassis_bsd.c src/detection/cpu/cpu_bsd.c src/detection/cpuusage/cpuusage_bsd.c diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c new file mode 100644 index 000000000..8c6a89e2f --- /dev/null +++ b/src/detection/brightness/brightness_bsd.c @@ -0,0 +1,47 @@ +#include "brightness.h" + +#if __has_include() + +#include "common/io/io.h" + +#include +#include +#include +#include + +const char* ffDetectBrightness(FFlist* result) +{ + // https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9 + char path[] = "/dev/backlight/backlight0"; + + for (char i = '0'; i <= '9'; ++i) + { + path[sizeof(path) - 2] = i; + + FF_AUTO_CLOSE_FD int blfd = open(path, O_RDONLY); + if (blfd < 0) + continue; + + struct backlight_props status; + if(ioctl(blfd, BACKLIGHTGETSTATUS, &status) < 0) + continue; + + FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); + ffStrbufInit(&display->name); + display->value = (float) status.brightness / BACKLIGHTMAXLEVELS; + + struct backlight_info info; + if(ioctl(blfd, BACKLIGHTGETINFO, &info) < 0) + ffStrbufAppendS(&display->name, info.name); + } + return NULL; +} + +#else + +const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) +{ + return "Backlight is supported only on FreeBSD 13 and newer"; +} + +#endif \ No newline at end of file From 82ed8c8cfdb08505c38e6890f79912def8f04a8c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 24 Jun 2023 07:20:27 +0000 Subject: [PATCH 229/493] Global: fix `--*-format` keys --- completions/bash | 16 ++++++++-------- presets/examples/2 | 2 +- presets/neofetch | 2 +- presets/verbose | 2 +- src/data/config_user.txt | 12 ++++++------ src/fastfetch.c | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/completions/bash b/completions/bash index 67b2269bc..c340753cd 100644 --- a/completions/bash +++ b/completions/bash @@ -16,13 +16,13 @@ __fastfetch_complete_help() "display-format" "de-format" "wm-format" - "wm-theme-format" + "wmtheme-format" "theme-format" "icons-format" "font-format" "cursor-format" "terminal-format" - "terminal-font-format" + "terminalfont-format" "cpu-format" "cpu-usage-format" "gpu-format" @@ -267,9 +267,9 @@ __fastfetch_completion() "--wm-key" "--wm-format" "--wm-key-color" - "--wm-theme-key" - "--wm-theme-format" - "--wm-theme-key-color" + "--wmtheme-key" + "--wmtheme-format" + "--wmtheme-key-color" "--theme-key" "--theme-format" "--theme-key-color" @@ -285,9 +285,9 @@ __fastfetch_completion() "--terminal-key" "--terminal-format" "--terminal-key-color" - "--terminal-font-key" - "--terminal-font-format" - "--terminal-font-key-color" + "--terminalfont-key" + "--terminalfont-format" + "--terminalfont-key-color" "--cpu-key" "--cpu-format" "--cpu-key-color" diff --git a/presets/examples/2 b/presets/examples/2 index a7eda7fd9..6bd5a0ce3 100644 --- a/presets/examples/2 +++ b/presets/examples/2 @@ -20,5 +20,5 @@ --wm-key " " --shell-key " " --terminal-key " " ---terminal-font-key " " +--terminalfont-key " " --packages-key " " diff --git a/presets/neofetch b/presets/neofetch index 9d42df956..9861e3b99 100644 --- a/presets/neofetch +++ b/presets/neofetch @@ -4,7 +4,7 @@ --display-format "{}x{}" --de-format "{2} {3}" --theme-format "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}" ---terminal-font-format "{/2}{-}{/}{2}{?3} {3}{?}" +--terminalfont-format "{/2}{-}{/}{2}{?3} {3}{?}" --memory-format "{/1}{-}{/}{/2}{-}{/}{} / {}" --gpu-key "GPU" --display-key "Display" diff --git a/presets/verbose b/presets/verbose index 2afad13ea..f84880ad8 100644 --- a/presets/verbose +++ b/presets/verbose @@ -14,7 +14,7 @@ --font-format Font1: {}; Font2: {}; Font3: {}; Font4: {} --cursor-format Theme: {}; Size: {} --terminal-format Process: {}; Path: {}; Exe: {} ---terminal-font-format Pretty: {}; Name: {}; Size: {}; Styles: {} +--terminalfont-format Pretty: {}; Name: {}; Size: {}; Styles: {} --cpu-format Name: {}, Vendor: {}, CoresPhysical: {}, CoresLogical: {}, CoresOnline: {}, FrequencyMin: {}, FrequencyMax: {}, Temperature: {} --cpu-usage-format Percentage: {} --gpu-format Vendor: {}; Name: {}; Driver: {}; Temperature: {}; CoreCount: {}; Type: {} diff --git a/src/data/config_user.txt b/src/data/config_user.txt index c2842ad67..a25ecf913 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -299,13 +299,13 @@ #--brightness-key Brightness ({1}) #--de-key DE #--wm-key WM -#--wm-theme-key WM Theme +#--wmtheme-key WM Theme #--theme-key Theme #--icons-key Icons #--font-key Font #--cursor-key Cursor #--terminal-key Terminal -#--terminal-font-key Terminal Font +#--terminalfont-key Terminal Font #--cpu-key CPU #--cpu-usage-key CPU Usage #--gpu-key GPU {1} @@ -349,13 +349,13 @@ #--brightness-format #--de-format #--wm-format -#--wm-theme-format +#--wmtheme-format #--theme-format #--icons-format #--font-format #--cursor-format #--terminal-format -#--terminal-font-format +#--terminalfont-format #--cpu-format #--cpu-usage-format #--gpu-format @@ -395,13 +395,13 @@ #--brightness-key-color #--de-key-color #--wm-key-color -#--wm-theme-key-color +#--wmtheme-key-color #--theme-key-color #--icons-key-color #--font-key-color #--cursor-key-color #--terminal-key-color -#--terminal-font-key-color +#--terminalfont-key-color #--cpu-key-color #--cpu-usage-key-color #--gpu-key-color diff --git a/src/fastfetch.c b/src/fastfetch.c index 7fc96cdcb..07efb414a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -204,9 +204,9 @@ static inline void printCommandHelp(const char* command) "WM protocol name" ); } - else if(ffStrEqualsIgnCase(command, "wm-theme-format")) + else if(ffStrEqualsIgnCase(command, "wmtheme-format")) { - constructAndPrintCommandHelpFormat("wm-theme", "{}", 1, + constructAndPrintCommandHelpFormat("wmtheme", "{}", 1, "WM theme name" ); } @@ -259,9 +259,9 @@ static inline void printCommandHelp(const char* command) "User shell version" ); } - else if(ffStrEqualsIgnCase(command, "terminal-font-format")) + else if(ffStrEqualsIgnCase(command, "terminalfont-format")) { - constructAndPrintCommandHelpFormat("terminal-font", "{}", 4, + constructAndPrintCommandHelpFormat("terminalfont", "{}", 4, "Terminal font", "Terminal font name", "Termianl font size", From 726ed35f610de1b3d1bb5be5219ea63631557627 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 24 Jun 2023 07:38:31 +0000 Subject: [PATCH 230/493] Doc: update issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0c595ee2e..8a64fb180 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,14 +7,15 @@ assignees: '' --- + + # General description of bug: * What happened: * What should happen: -* Did it work in an older version: +* Did it work in an older version: * Where did you get the binary: - -- [ ] The issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/) +* Does this issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/)? # Often helpful information: @@ -28,12 +29,12 @@ The content of the configuration file you use (if any) //paste here ``` -Output of `fastfetch --load-config devinfo-verbose --show-errors --multithreading false --disable-linewrap false`: +Output of `env NO_CONFIG=1 fastfetch --load-config all --show-errors --stat --multithreading false --disable-linewrap false --hide-cursor false`: ``` From b84720c04001991f184dd0129714b07544919c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 15:58:37 +0800 Subject: [PATCH 231/493] Bluetooth: improvements 1. fix memleaks 2. fix `show-disconnected` option parsing 3. print `[disconnected]` for disconnected device --- src/modules/bluetooth/bluetooth.c | 45 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index c41bf3da4..bbd5e0e11 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -16,7 +16,10 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothDevice* de if(device->battery > 0) printf(" (%d%%)", device->battery); - putchar('\n'); + if(!device->connected) + puts(" [disconnected]"); + else + putchar('\n'); } else { @@ -37,29 +40,29 @@ void ffPrintBluetooth(FFBluetoothOptions* options) if(error) { ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error); - return; } - - FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFBluetoothDevice*)); - - FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) + else { - if(!device->connected && !options->showDisconnected) - continue; + FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFBluetoothDevice*)); - *(FFBluetoothDevice**)ffListAdd(&filtered) = device; - } + FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) + { + if(!device->connected && !options->showDisconnected) + continue; - if(filtered.length == 0) - { - ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); - return; - } + *(FFBluetoothDevice**)ffListAdd(&filtered) = device; + } - for(uint32_t i = 0; i < filtered.length; i++) - { - uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); - printDevice(options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); + if(filtered.length == 0) + { + ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); + } + + for(uint32_t i = 0; i < filtered.length; i++) + { + uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); + printDevice(options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index); + } } FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices) @@ -85,7 +88,11 @@ bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key return true; if (ffStrEqualsIgnCase(subKey, "show-disconnected")) + { options->showDisconnected = ffOptionParseBoolean(value); + return true; + } + return false; } From 9ab5ed9a86cc7ca33d5108f4452442c139205745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 19:38:12 +0800 Subject: [PATCH 232/493] GPU (Linux): detect memory; fix type detection The GPU type detection is based on memory size. For accurate results, use `--gpu-force-vulkan` --- src/detection/gpu/gpu_linux.c | 82 ++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 8374e418b..a567b1285 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -12,6 +12,14 @@ #include #include +// Fix building on Ubuntu 20.04 +#ifndef PCI_IORESOURCE_MEM + #define PCI_IORESOURCE_MEM 0x00000200 +#endif +#ifndef PCI_IORESOURCE_PREFETCH + #define PCI_IORESOURCE_PREFETCH 0x00002000 +#endif + typedef struct PCIData { struct pci_access* access; @@ -77,7 +85,7 @@ static void drmDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* static void pciDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) { - if(ffStrbufCompS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD) == 0) + if(ffStrbufEqualS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD)) { drmDetectDeviceName(gpu, pci, device); if(gpu->name.length > 0) @@ -122,7 +130,7 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* } } -FF_MAYBE_UNUSED static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device) +FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, struct pci_dev* device) { const FFTempsResult* tempsResult = ffDetectTemps(); @@ -139,36 +147,53 @@ FF_MAYBE_UNUSED static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev } } -static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device) +static bool pciDetectMemory(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device) +{ + gpu->dedicated.used = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; + + uint32_t flags = (uint32_t) pci->ffpci_fill_info(device, PCI_FILL_IO_FLAGS | PCI_FILL_SIZES); + if (!(flags & PCI_FILL_IO_FLAGS) || !(flags & PCI_FILL_SIZES)) + { + gpu->dedicated.total = gpu->shared.total = FF_GPU_VMEM_SIZE_UNSET; + return false; + } + + gpu->dedicated.total = gpu->shared.total = 0; + for (uint32_t i = 0; i < sizeof(device->size) / sizeof(device->size[0]); i++) + { + if (!(device->flags[i] & PCI_IORESOURCE_MEM)) continue; + + // Assume dedicated memories are prefetchable + // At least it's true for my laptop + if (device->flags[i] & PCI_IORESOURCE_PREFETCH) + gpu->dedicated.total += device->size[i]; + else + gpu->shared.total += device->size[i]; + } + + if (gpu->dedicated.total == 0 && gpu->shared.total == 0) + { + gpu->dedicated.total = gpu->shared.total = FF_GPU_VMEM_SIZE_UNSET; + return false; + } + + return true; +} + +static void pciDetectType(FFGPUResult* gpu) { //There is no straightforward way to detect the type of a GPU. //The approach taken here is to look at the memory sizes of the device. //Since integrated GPUs usually use the system ram, they don't have expansive ROMs //and their memory sizes are usually smaller than 1GB. - - if(!(pci->ffpci_fill_info(device, PCI_FILL_SIZES) & PCI_FILL_SIZES)) + if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET) { + gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 // 1GB + ? FF_GPU_TYPE_DISCRETE + : FF_GPU_TYPE_INTEGRATED; + } + else gpu->type = FF_GPU_TYPE_UNKNOWN; - return; - } - - if(device->rom_size > 0) - { - gpu->type = FF_GPU_TYPE_DISCRETE; - return; - } - - uint32_t numSizes = sizeof(device->size) / sizeof(device->size[0]); - for(uint32_t i = 0; i < numSizes; i++) - { - if(device->size[i] >= 1024 * 1024 * 1024) //1GB - { - gpu->type = FF_GPU_TYPE_DISCRETE; - return; - } - } - - gpu->type = FF_GPU_TYPE_INTEGRATED; } static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device) @@ -190,8 +215,6 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* FFGPUResult* gpu = ffListAdd(results); - gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; - ffStrbufInit(&gpu->vendor); pciDetectVendorName(gpu, pci, device); @@ -201,7 +224,8 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInit(&gpu->driver); pciDetectDriverName(gpu, pci, device); - detectType(gpu, pci, device); + pciDetectMemory(gpu, pci, device); + pciDetectType(gpu); gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; @@ -209,7 +233,7 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* #ifdef __linux__ if(options->temp) - pciDetectTemperatur(gpu, device); + pciDetectTemp(gpu, device); #endif } From 59bcf5206daadd1c775255c1fcf582f9e7347987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 19:49:53 +0800 Subject: [PATCH 233/493] GPU: print GPU type by default --- src/modules/gpu/gpu.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 6c34aa82c..d7ec2d246 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -13,6 +13,14 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu) { + const char* type; + switch (gpu->type) + { + case FF_GPU_TYPE_INTEGRATED: type = "Integrated"; break; + case FF_GPU_TYPE_DISCRETE: type = "Discrete"; break; + default: type = "Unknown"; break; + } + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); @@ -51,18 +59,13 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu ffStrbufAppendC(&output, ')'); } + if (gpu->type != FF_GPU_TYPE_UNKNOWN) + ffStrbufAppendF(&output, " [%s]", type); + ffStrbufPutTo(&output, stdout); } else { - const char* type; - if(gpu->type == FF_GPU_TYPE_INTEGRATED) - type = "Integrated"; - else if(gpu->type == FF_GPU_TYPE_DISCRETE) - type = "Discrete"; - else - type = "Unknown"; - ffPrintFormat(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name}, From dfc9b15dce058cf68256927eccbd087d3c3f3011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 24 Jun 2023 23:58:57 +0800 Subject: [PATCH 234/493] Chassis (Windows): support get information from WMI --- src/detection/chassis/chassis_windows.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/detection/chassis/chassis_windows.cpp b/src/detection/chassis/chassis_windows.cpp index 99731889a..cd2d1f7f0 100644 --- a/src/detection/chassis/chassis_windows.cpp +++ b/src/detection/chassis/chassis_windows.cpp @@ -1,6 +1,7 @@ extern "C" { #include "chassis.h" #include "util/windows/registry.h" +#include "util/smbiosHelper.h" } #include "util/windows/wmi.hpp" @@ -39,10 +40,17 @@ FF_MAYBE_UNUSED static const char* detectWithWmi(FFChassisResult* result) if(len == 0) return "ChassisTypes contain no data failed"; - ffStrbufAppendS(&result->type, ffChassisTypeToString((uint32_t) *arr)); + for (uint32_t i = 0; i < len; ++i) + { + if (i > 0) + ffStrbufAppendS(&result->type, ", "); + ffStrbufAppendS(&result->type, ffChassisTypeToString((uint32_t) arr[i])); + } record.getString(L"Version", &result->version); + ffCleanUpSmbiosValue(&result->version); record.getString(L"Manufacturer", &result->vendor); + ffCleanUpSmbiosValue(&result->vendor); return NULL; } return "No WMI result returned"; @@ -51,6 +59,7 @@ FF_MAYBE_UNUSED static const char* detectWithWmi(FFChassisResult* result) extern "C" const char* ffDetectChassis(FFChassisResult* result) { + if (instance.config.allowSlowOperations) + return detectWithWmi(result); return detectWithRegistry(result); - // TODO: if (instance.config.allowSlowOperations) detectWithWmi(result); } From 8fc31c700f451da11750e8dd4e2a1403cee2b5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 14:01:50 +0800 Subject: [PATCH 235/493] OS (Windows): code refactor; fix `common/library.h` usage for C++ --- src/common/library.h | 8 ++++---- src/detection/os/os_windows.cpp | 17 ++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/common/library.h b/src/common/library.h index 3f4a8f237..1721ea8d3 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -10,7 +10,7 @@ #include #define FF_DLOPEN_FLAGS 0 FF_C_NODISCARD static inline void* dlopen(const char* path, int mode) { FF_UNUSED(mode); return LoadLibraryA(path); } - FF_C_NODISCARD static inline void* dlsym(void* handle, const char* symbol) { return GetProcAddress((HMODULE)handle, symbol); } + FF_C_NODISCARD static inline void* dlsym(void* handle, const char* symbol) { return (void*) GetProcAddress((HMODULE)handle, symbol); } static inline int dlclose(void* handle) { return !FreeLibrary((HMODULE)handle); } #else #include @@ -40,20 +40,20 @@ static inline void ffLibraryUnload(void** handle) return returnValue; #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ - symbolMapping = dlsym(library, #symbolName); \ + symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \ if(symbolMapping == NULL) \ return returnValue; #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, symbolMapping, symbolName, alternateName, returnValue) \ symbolMapping = dlsym(library, #symbolName); \ - if(symbolMapping == NULL && !(symbolMapping = dlsym(library, #alternateName))) \ + if(symbolMapping == NULL && !(symbolMapping = (__typeof__(&symbolName)) dlsym(library, #alternateName))) \ return returnValue; #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, returnValue); #define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ - __typeof__(&symbolName) ff ## symbolName = dlsym(library, #symbolName); + __typeof__(&symbolName) ff ## symbolName = (__typeof__(&symbolName)) dlsym(library, #symbolName); #define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); diff --git a/src/detection/os/os_windows.cpp b/src/detection/os/os_windows.cpp index addb61f17..2224c5c9b 100644 --- a/src/detection/os/os_windows.cpp +++ b/src/detection/os/os_windows.cpp @@ -20,27 +20,18 @@ static const char* getOsNameByWmi(FFstrbuf* osName) return "No WMI result returned"; } -static inline void wrapFreeLibrary(HMODULE* module) -{ - if(*module) - FreeLibrary(*module); -} +PWSTR WINAPI BrandingFormatString(PCWSTR format); static const char* getOsNameByWinbrand(FFstrbuf* osName) { //https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on#ver_string - if(HMODULE __attribute__((__cleanup__(wrapFreeLibrary))) hWinbrand = LoadLibraryW(L"winbrand.dll")) - { - auto BrandingFormatString = (PWSTR(WINAPI*)(PCWSTR))(void*)GetProcAddress(hWinbrand, "BrandingFormatString"); - if(!BrandingFormatString) - return "GetProcAddress(BrandingFormatString) failed"; + FF_LIBRARY_LOAD(winbrand, nullptr, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(winbrand, BrandingFormatString); - const wchar_t* rawName = BrandingFormatString(L"%WINDOWS_LONG%"); + const wchar_t* rawName = ffBrandingFormatString(L"%WINDOWS_LONG%"); ffStrbufSetWS(osName, rawName); GlobalFree((HGLOBAL)rawName); return NULL; - } - return "LoadLibraryW(winbrand.dll) failed"; } extern "C" From c4c490663b756bd614a523bb9430ab2231fb8f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 14:16:49 +0800 Subject: [PATCH 236/493] WMI (Windows): code refactor --- .../brightness/brightness_windows.cpp | 21 +- src/detection/chassis/chassis_windows.cpp | 38 +-- src/detection/os/os_windows.cpp | 19 +- src/detection/temps/temps_windows.cpp | 19 +- src/util/windows/unicode.hpp | 25 ++ src/util/windows/wmi.cpp | 24 +- src/util/windows/wmi.hpp | 243 ++++++++++-------- 7 files changed, 223 insertions(+), 166 deletions(-) create mode 100644 src/util/windows/unicode.hpp diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index 3139fef4c..0f86ba49e 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -3,6 +3,7 @@ extern "C" #include "brightness.h" } #include "util/windows/wmi.hpp" +#include "util/windows/unicode.hpp" extern "C" const char* ffDetectBrightness(FFlist* result) @@ -13,15 +14,19 @@ const char* ffDetectBrightness(FFlist* result) while(FFWmiRecord record = query.next()) { - FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); - ffStrbufInit(&display->name); - record.getString(L"InstanceName", &display->name); - ffStrbufSubstrAfterFirstC(&display->name, '\\'); - ffStrbufSubstrBeforeFirstC(&display->name, '\\'); + if(FFWmiVariant vtValue = record.get(L"CurrentBrightness")) + { + FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); + display->value = vtValue.get(); - uint64_t brightness; - record.getUnsigned(L"CurrentBrightness", &brightness); - display->value = (float) brightness; + ffStrbufInit(&display->name); + if (FFWmiVariant vtName = record.get(L"InstanceName")) + { + ffStrbufSetWSV(&display->name, vtName.get()); + ffStrbufSubstrAfterFirstC(&display->name, '\\'); + ffStrbufSubstrBeforeFirstC(&display->name, '\\'); + } + } } return NULL; } diff --git a/src/detection/chassis/chassis_windows.cpp b/src/detection/chassis/chassis_windows.cpp index cd2d1f7f0..2332c5b31 100644 --- a/src/detection/chassis/chassis_windows.cpp +++ b/src/detection/chassis/chassis_windows.cpp @@ -3,6 +3,7 @@ extern "C" { #include "util/windows/registry.h" #include "util/smbiosHelper.h" } +#include "util/windows/unicode.hpp" #include "util/windows/wmi.hpp" static const char* detectWithRegistry(FFChassisResult* result) @@ -31,26 +32,33 @@ FF_MAYBE_UNUSED static const char* detectWithWmi(FFChassisResult* result) if (FFWmiRecord record = query.next()) { - FFWmiVariant vtProp; - if(FAILED(record.obj->Get(L"ChassisTypes", 0, &vtProp, nullptr, nullptr))) + if (auto vtProp = record.get(L"ChassisTypes")) + { + auto [arr, len] = vtProp.get>(); + if(len == 0) + return "ChassisTypes contain no data failed"; + for (uint32_t i = 0; i < len; ++i) + { + if (i > 0) + ffStrbufAppendS(&result->type, ", "); + ffStrbufAppendS(&result->type, ffChassisTypeToString((uint32_t) arr[i])); + } + } + else return "Get ChassisTypes failed"; - auto [arr, len] = (std::pair) vtProp; - - if(len == 0) - return "ChassisTypes contain no data failed"; - - for (uint32_t i = 0; i < len; ++i) + if (auto vtProp = record.get(L"Version")) { - if (i > 0) - ffStrbufAppendS(&result->type, ", "); - ffStrbufAppendS(&result->type, ffChassisTypeToString((uint32_t) arr[i])); + ffStrbufSetWSV(&result->version, vtProp.get()); + ffCleanUpSmbiosValue(&result->version); + } + + if (auto vtProp = record.get(L"Manufacturer")) + { + ffStrbufSetWSV(&result->vendor, vtProp.get()); + ffCleanUpSmbiosValue(&result->vendor); } - record.getString(L"Version", &result->version); - ffCleanUpSmbiosValue(&result->version); - record.getString(L"Manufacturer", &result->vendor); - ffCleanUpSmbiosValue(&result->vendor); return NULL; } return "No WMI result returned"; diff --git a/src/detection/os/os_windows.cpp b/src/detection/os/os_windows.cpp index 2224c5c9b..935f86153 100644 --- a/src/detection/os/os_windows.cpp +++ b/src/detection/os/os_windows.cpp @@ -1,7 +1,8 @@ extern "C" { #include "os.h" -#include "util/windows/unicode.h" +#include "common/library.h" } +#include "util/windows/unicode.hpp" #include "util/windows/wmi.hpp" static const char* getOsNameByWmi(FFstrbuf* osName) @@ -12,9 +13,13 @@ static const char* getOsNameByWmi(FFstrbuf* osName) if(FFWmiRecord record = query.next()) { - record.getString(L"Caption", osName); - ffStrbufTrimRight(osName, ' '); - return NULL; + if(auto vtCaption = record.get(L"Caption")) + { + ffStrbufSetWSV(osName, vtCaption.get()); + ffStrbufTrimRight(osName, ' '); + return NULL; + } + return "Get Caption failed"; } return "No WMI result returned"; @@ -29,9 +34,9 @@ static const char* getOsNameByWinbrand(FFstrbuf* osName) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(winbrand, BrandingFormatString); const wchar_t* rawName = ffBrandingFormatString(L"%WINDOWS_LONG%"); - ffStrbufSetWS(osName, rawName); - GlobalFree((HGLOBAL)rawName); - return NULL; + ffStrbufSetWS(osName, rawName); + GlobalFree((HGLOBAL)rawName); + return NULL; } extern "C" diff --git a/src/detection/temps/temps_windows.cpp b/src/detection/temps/temps_windows.cpp index 9c741b4cd..c9cfeac50 100644 --- a/src/detection/temps/temps_windows.cpp +++ b/src/detection/temps/temps_windows.cpp @@ -15,10 +15,21 @@ const char* ffDetectSmbiosTemp(double* current, double* critical) if(FFWmiRecord record = query.next()) { - if (current && record.getReal(L"CurrentTemperature", current)) // In tenth of degrees Kelvin - *current = *current / 10 - 273.15; - if (critical && record.getReal(L"CriticalTripPoint", critical)) // In tenth of degrees Kelvin - *critical = *critical / 10 - 273.15; + if (current) + { + if(auto vtCurrent = record.get(L"CurrentTemperature")) + *current = vtCurrent.get() / 10 - 273.15; // In tenth of degrees Kelvin + else + *current = 0.0/0.0; + } + + if (critical) + { + if(auto vtCritical = record.get(L"CriticalTripPoint")) + *critical = vtCritical.get() / 10 - 273.15; // In tenth of degrees Kelvin + else + *critical = 0.0/0.0; + } } return "No WMI result returned"; diff --git a/src/util/windows/unicode.hpp b/src/util/windows/unicode.hpp new file mode 100644 index 000000000..18441a50d --- /dev/null +++ b/src/util/windows/unicode.hpp @@ -0,0 +1,25 @@ +#pragma once + +#ifndef FASTFETCH_INCLUDED_UNICODE_HPP +#define FASTFETCH_INCLUDED_UNICODE_HPP + +#ifdef __cplusplus + +extern "C" { +#include "unicode.h" +} + +#include + +static inline void ffStrbufSetWSV(FFstrbuf* result, const std::wstring_view source) +{ + return ffStrbufSetNWS(result, (uint32_t) source.size(), source.data()); +} + +#else + + #error Must be included in C++ source file + +#endif + +#endif diff --git a/src/util/windows/wmi.cpp b/src/util/windows/wmi.cpp index 9b8103fbe..af84c7013 100644 --- a/src/util/windows/wmi.cpp +++ b/src/util/windows/wmi.cpp @@ -1,9 +1,6 @@ #include "wmi.hpp" #include "util/windows/com.hpp" - -extern "C" { -#include "util/windows/unicode.h" -} +#include "util/windows/unicode.hpp" #include #include @@ -129,21 +126,6 @@ FFWmiQuery::FFWmiQuery(const wchar_t* queryStr, FFstrbuf* error, FFWmiNamespace } } -static void ffBstrToStrbuf(BSTR bstr, FFstrbuf* strbuf) -{ - int len = (int)SysStringLen(bstr); - if(len <= 0) - { - ffStrbufClear(strbuf); - return; - } - int size_needed = WideCharToMultiByte(CP_UTF8, 0, bstr, len, nullptr, 0, nullptr, nullptr); - ffStrbufEnsureFree(strbuf, (uint32_t)size_needed); - WideCharToMultiByte(CP_UTF8, 0, bstr, len, strbuf->chars, size_needed, nullptr, nullptr); - strbuf->length = (uint32_t)size_needed; - strbuf->chars[size_needed] = '\0'; -} - bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) { bool result = true; @@ -171,11 +153,11 @@ bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) else if(FAILED(pDateTime->GetFileTime(VARIANT_TRUE, &dateStr))) result = false; else - ffBstrToStrbuf(dateStr, strbuf); + ffStrbufSetNWS(strbuf, SysStringLen(dateStr), dateStr); } else { - ffBstrToStrbuf(vtProp.bstrVal, strbuf); + ffStrbufSetWS(strbuf, SysStringLen(vtProp.bstrVal), vtProp.bstrVal); } break; diff --git a/src/util/windows/wmi.hpp b/src/util/windows/wmi.hpp index d5a08f62e..b31b84533 100644 --- a/src/util/windows/wmi.hpp +++ b/src/util/windows/wmi.hpp @@ -25,6 +25,133 @@ enum { FF_WMI_QUERY_TIMEOUT = 5000 }; +struct FFWmiVariant: VARIANT { + explicit FFWmiVariant() { VariantInit(this); } + ~FFWmiVariant() { VariantClear(this); } + + FFWmiVariant(const FFWmiVariant&) = delete; + FFWmiVariant(FFWmiVariant&&); // don't define it to enforce NRVO optimization + + bool hasValue() { + return this->vt != VT_EMPTY; + } + + explicit operator bool() { + return this->hasValue(); + } + + template T get(); + + // boolean + template <> bool get() { + assert(this->vt == VT_BOOL); + return this->boolVal != VARIANT_FALSE; + } + + // signed + template <> int8_t get() { + assert(this->vt == VT_I1); + return this->cVal; + } + template <> int16_t get() { + assert(vt == VT_I2); + return this->iVal; + } + template <> int32_t get() { + assert(this->vt == VT_I4 || vt == VT_INT); + return this->intVal; + } + template <> int64_t get() { + assert(this->vt == VT_I8); + return this->llVal; + } + + // unsigned + template <> uint8_t get() { + assert(this->vt == VT_UI1); + return this->bVal; + } + template <> uint16_t get() { + assert(this->vt == VT_UI2); + return this->uiVal; + } + template <> uint32_t get() { + assert(this->vt == VT_UI4 || vt == VT_UINT); + return this->uintVal; + } + template <> uint64_t get() { + assert(this->vt == VT_UI8); + return this->ullVal; + } + + // decimal + template <> float get() { + assert(this->vt == VT_R4); + return this->fltVal; + } + template <> double get() { + assert(this->vt == VT_R8); + return this->dblVal; + } + + // string + template <> std::string_view get() { + assert(this->vt == VT_LPSTR); + return this->pcVal; + } + template <> std::wstring_view get() { + assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR); + if (this->vt == VT_LPWSTR) + return this->bstrVal; + else + return { this->bstrVal, SysStringLen(this->bstrVal) }; + } + + // array signed + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I1); + return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I2); + return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I4); + return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I8); + return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims); + } + + // array unsigned + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI1); + return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI2); + return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI4); + return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims); + } + template <> std::pair get() { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI8); + return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims); + } +}; + struct FFWmiRecord { IWbemClassObject* obj; @@ -51,6 +178,11 @@ struct FFWmiRecord bool getSigned(const wchar_t* key, int64_t* integer); bool getUnsigned(const wchar_t* key, uint64_t* integer); bool getReal(const wchar_t* key, double* real); + FFWmiVariant get(const wchar_t* key) { + FFWmiVariant result; + obj->Get(key, 0, &result, nullptr, nullptr); + return result; + } }; struct FFWmiQuery @@ -77,117 +209,6 @@ struct FFWmiQuery } }; -struct FFWmiVariant: VARIANT { - explicit FFWmiVariant() { VariantInit(this); } - ~FFWmiVariant() { VariantClear(this); } - - FFWmiVariant(const FFWmiVariant&) = delete; - - // boolean - explicit operator bool() { - assert(this->vt == VT_BOOL); - return this->boolVal != VARIANT_FALSE; - } - - // signed - explicit operator int8_t() { - assert(this->vt == VT_I1); - return this->cVal; - } - explicit operator int16_t() { - assert(vt == VT_I2); - return this->iVal; - } - explicit operator int32_t() { - assert(this->vt == VT_I4 || vt == VT_INT); - return this->intVal; - } - explicit operator int64_t() { - assert(this->vt == VT_I8); - return this->llVal; - } - - // unsigned - explicit operator uint8_t() { - assert(this->vt == VT_I1); - return this->bVal; - } - explicit operator uint16_t() { - assert(this->vt == VT_I2); - return this->uiVal; - } - explicit operator uint32_t() { - assert(this->vt == VT_UI4 || vt == VT_UINT); - return this->uintVal; - } - explicit operator uint64_t() { - assert(this->vt == VT_UI8); - return this->ullVal; - } - explicit operator float() { - assert(this->vt == VT_R4); - return this->fltVal; - } - explicit operator double() { - assert(this->vt == VT_R8); - return this->dblVal; - } - - // string - explicit operator const std::string_view() { - assert(this->vt == VT_LPSTR); - return this->pcVal; - } - explicit operator const std::wstring_view() { - assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR); - return this->bstrVal; - } - - // array signed - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I1); - return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I2); - return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I4); - return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I8); - return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims); - } - - // array unsigned - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI1); - return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI2); - return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI4); - return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims); - } - explicit operator std::pair() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI8); - return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims); - } -}; - #else // Win32 COM headers requires C++ compiler #error Must be included in C++ source file From ab3290d9cbbbdd7fc6e6920fb7dd0db0572ba294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 14:33:13 +0800 Subject: [PATCH 237/493] WMI (Windows): add `--wmi-timeout` option --- CHANGELOG.md | 1 + doc/json_schema.json | 4 ++++ src/common/init.c | 2 ++ src/common/jsonconfig.c | 3 +++ src/common/option.c | 19 +++++++++++++++++++ src/common/option.h | 1 + src/data/config_user.txt | 6 ++++++ src/fastfetch.c | 3 +++ src/fastfetch.h | 2 ++ src/util/windows/wmi.cpp | 2 +- src/util/windows/wmi.hpp | 8 ++------ 11 files changed, 44 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7b57b7a4..54e32c3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Features: * Support `--*-key-color` option to change the key color of specified module * Support `--colors-symbol` and `--colors-padding-left` * Add LM (Login Manager) module +* Add `--wmi-timeout` option (Windows) # 1.11.3 diff --git a/doc/json_schema.json b/doc/json_schema.json index 919c86de6..158a1e5ff 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -220,6 +220,10 @@ "osFile": { "type": "string", "title": "Set the path to the file containing OS information. Linux only" + }, + "wmiTimeout": { + "type": "integer", + "title": "Set the timeout (ms) for WMI queries, `-1` for no timeout. Windows only" } }, "additionalProperties": false diff --git a/src/common/init.c b/src/common/init.c index 423f0de58..061d70344 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -41,6 +41,8 @@ static void defaultConfig(void) #if defined(__linux__) || defined(__FreeBSD__) ffStrbufInit(&instance.config.playerName); ffStrbufInit(&instance.config.osFile); + #elif defined(_WIN32) + instance.config.wmiTimeout = 5000; #endif instance.config.showErrors = false; diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 13b6e514f..171548596 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -312,6 +312,9 @@ const char* ffParseGeneralJsonConfig(void) ffStrbufSetS(&config->playerName, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "osFile")) ffStrbufSetS(&config->osFile, yyjson_get_str(val)); + #elif defined(_WIN32) + else if (ffStrEqualsIgnCase(key, "wmiTimeout")) + config->wmiTimeout = yyjson_get_uint(val); #endif else diff --git a/src/common/option.c b/src/common/option.c index 95c44e3e4..86a3b7363 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -81,6 +81,25 @@ uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value) return num; } +int32_t ffOptionParseInt32(const char* argumentKey, const char* value) +{ + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(480); + } + + char* end; + int32_t num = (int32_t) strtol(value, &end, 10); + if(*end != '\0') + { + fprintf(stderr, "Error: usage: %s \n", argumentKey); + exit(479); + } + + return num; +} + int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]) { if(requestedKey == NULL) diff --git a/src/common/option.h b/src/common/option.h index 07aded18d..bbd956506 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -19,6 +19,7 @@ const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName); bool ffOptionParseModuleArgs(const char* argumentKey, const char* pkey, const char* value, FFModuleArgs* result); void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); +FF_C_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value); FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); FF_C_NODISCARD bool ffOptionParseBoolean(const char* str); void ffOptionParseColor(const char* value, FFstrbuf* buffer); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index a25ecf913..29823779e 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -58,6 +58,12 @@ # Default is true. #--hide-cursor true +# WMI timeout option: +# Sets the timeout (ms) for WMI queries. Windows only +# Must be an integer. +# Default is 5000 +#--wmi-timeout 5000 + # Logo option: # Sets the logo to use. # List available logos with "fastfetch --list-logos". diff --git a/src/fastfetch.c b/src/fastfetch.c index 07efb414a..49c909d22 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -843,6 +843,9 @@ static void parseOption(FFdata* data, const char* key, const char* value) ffOptionParseString(key, value, &instance.config.playerName); else if (ffStrEqualsIgnCase(key, "--os-file")) ffOptionParseString(key, value, &instance.config.osFile); + #elif defined(_WIN32) + else if (ffStrEqualsIgnCase(key, "--wmi-timeout")) + instance.config.wmiTimeout = ffOptionParseInt32(key, value); #endif //////////////// diff --git a/src/fastfetch.h b/src/fastfetch.h index c76882c15..7db8ec8d1 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -53,6 +53,8 @@ typedef struct FFconfig #if defined(__linux__) || defined(__FreeBSD__) FFstrbuf playerName; FFstrbuf osFile; + #elif defined(_WIN32) + int32_t wmiTimeout; #endif FFTitleOptions title; diff --git a/src/util/windows/wmi.cpp b/src/util/windows/wmi.cpp index af84c7013..a131bceb5 100644 --- a/src/util/windows/wmi.cpp +++ b/src/util/windows/wmi.cpp @@ -157,7 +157,7 @@ bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) } else { - ffStrbufSetWS(strbuf, SysStringLen(vtProp.bstrVal), vtProp.bstrVal); + ffStrbufSetNWS(strbuf, SysStringLen(vtProp.bstrVal), vtProp.bstrVal); } break; diff --git a/src/util/windows/wmi.hpp b/src/util/windows/wmi.hpp index b31b84533..29ff621a0 100644 --- a/src/util/windows/wmi.hpp +++ b/src/util/windows/wmi.hpp @@ -6,7 +6,7 @@ #ifdef __cplusplus extern "C" { - #include "util/FFstrbuf.h" + #include "fastfetch.h" } #include @@ -21,10 +21,6 @@ enum class FFWmiNamespace { LAST, }; -enum { - FF_WMI_QUERY_TIMEOUT = 5000 -}; - struct FFWmiVariant: VARIANT { explicit FFWmiVariant() { VariantInit(this); } ~FFWmiVariant() { VariantClear(this); } @@ -160,7 +156,7 @@ struct FFWmiRecord if(!pEnumerator) return; ULONG ret; - bool ok = SUCCEEDED(pEnumerator->Next(FF_WMI_QUERY_TIMEOUT, 1, &obj, &ret)) && ret; + bool ok = SUCCEEDED(pEnumerator->Next(instance.config.wmiTimeout, 1, &obj, &ret)) && ret; if(!ok) obj = nullptr; } FFWmiRecord(const FFWmiRecord&) = delete; From 773c5b04c79d19be0fb61b72b9b1ff285438a58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 20:53:27 +0800 Subject: [PATCH 238/493] Presets: convert some `.conf` files to `.jsonc` files --- presets/all.jsonc | 55 ++++++++++++++++++++++++++++++ presets/btw.jsonc | 42 +++++++++++++++++++++++ presets/devinfo.jsonc | 49 +++++++++++++++++++++++++++ presets/examples/2.jsonc | 73 ++++++++++++++++++++++++++++++++++++++++ presets/examples/3.jsonc | 22 ++++++++++++ presets/examples/4.jsonc | 31 +++++++++++++++++ presets/examples/5.jsonc | 31 +++++++++++++++++ presets/hardware.jsonc | 25 ++++++++++++++ presets/neofetch | 5 ++- presets/neofetch.jsonc | 48 ++++++++++++++++++++++++++ presets/paleofetch.jsonc | 35 +++++++++++++++++++ presets/software.jsonc | 17 ++++++++++ 12 files changed, 430 insertions(+), 3 deletions(-) create mode 100644 presets/all.jsonc create mode 100644 presets/btw.jsonc create mode 100644 presets/devinfo.jsonc create mode 100644 presets/examples/2.jsonc create mode 100644 presets/examples/3.jsonc create mode 100644 presets/examples/4.jsonc create mode 100644 presets/examples/5.jsonc create mode 100644 presets/hardware.jsonc create mode 100644 presets/neofetch.jsonc create mode 100644 presets/paleofetch.jsonc create mode 100644 presets/software.jsonc diff --git a/presets/all.jsonc b/presets/all.jsonc new file mode 100644 index 000000000..b25c8baa8 --- /dev/null +++ b/presets/all.jsonc @@ -0,0 +1,55 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "modules": [ + "title", + "separator", + "os", + "host", + "bios", + "board", + "chassis", + "kernel", + "uptime", + "processes", + "packages", + "shell", + "display", + "brightness", + "lm", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "wallpaper", + "terminal", + "terminalfont", + "cpu", + "cpuusage", + "gpu", + "memory", + "swap", + "disk", + "battery", + "poweradapter", + "player", + "media", + "publicip", + "localip", + "wifi", + "datetime", + "locale", + "vulkan", + "opengl", + "opencl", + "users", + "bluetooth", + "sound", + "gamepad", + "weather", + "break", + "colors" + ] +} diff --git a/presets/btw.jsonc b/presets/btw.jsonc new file mode 100644 index 000000000..8ad31e61a --- /dev/null +++ b/presets/btw.jsonc @@ -0,0 +1,42 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "builtin", + "source": "arch" + }, + "modules": [ + "title", + "separator", + { + "type": "os", + "format": "Arch Linux ({12})" + }, + "host", + "kernel", + "uptime", + { + "type": "packages", + "format": "{} (pacman)" + }, + "shell", + "display", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "terminal", + "terminalfont", + "cpu", + "gpu", + "memory", + "disk", + "battery", + "poweradapter", + "locale", + "break", + "colors" + ] +} diff --git a/presets/devinfo.jsonc b/presets/devinfo.jsonc new file mode 100644 index 000000000..450adb926 --- /dev/null +++ b/presets/devinfo.jsonc @@ -0,0 +1,49 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "builtin", + "source": "arch" + }, + "display": { + "disableLinewrap": false, + "showErrors": true + }, + "general": { + "multithreading": false + }, + "modules": [ + "title", + "separator", + { + "type": "os", + "format": "Arch Linux ({12})" + }, + "host", + "kernel", + "uptime", + { + "type": "packages", + "format": "{} (pacman)" + }, + "shell", + "display", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "terminal", + "terminalfont", + "cpu", + "gpu", + "memory", + "disk", + "battery", + "poweradapter", + "locale", + "break", + "colors" + ] +} diff --git a/presets/examples/2.jsonc b/presets/examples/2.jsonc new file mode 100644 index 000000000..d0e0814c6 --- /dev/null +++ b/presets/examples/2.jsonc @@ -0,0 +1,73 @@ +// Load with --load-config examples/2.jsonc +// Note that you must replace the image path to an existing image to display it. + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "kitty", + "source": "/home/linus/Bilder/Gentoo.png", + "width": 28 + }, + "display": { + "separator": "  " + }, + "modules": [ + { + "type": "custom", // HardwareStart + "format": "┌───────── \u001b[1mHardware Information\u001b[0m ─────────┐" // `\u001b` is `\033`, or `\e` + }, + { + "type": "host", + "key": " " + }, + { + "type": "cpu", + "key": " " + }, + { + "type": "gpu", + "key": " ﬙" + }, + { + "type": "custom", // SoftwareStart + "format": "├───────── \u001b[1mSoftware Information\u001b[0m ─────────┤" + }, + { + "type": "os", + "key": " " + }, + { + "type": "kernel", + "key": " " + }, + { + "type": "wm", + "key": " " + }, + { + "type": "shell", + "key": " " + }, + { + "type": "terminal", + "key": " " + }, + { + "type": "terminalfont", + "key": " " + }, + { + "type": "packages", + "key": " " + }, + { + "type": "custom", // InformationEnd + "format": "└────────────────────────────────────────┘" + }, + { + "type": "colors", + "paddingLeft": 4, + "symbol": "circle" + } + ] +} diff --git a/presets/examples/3.jsonc b/presets/examples/3.jsonc new file mode 100644 index 000000000..6ff5dabb6 --- /dev/null +++ b/presets/examples/3.jsonc @@ -0,0 +1,22 @@ +// Load with --load-config examples/3.jsonc + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "source": "debian_small" + }, + "display": { + "binaryPrefix": "si" + }, + "modules": [ + "vulkan", + "opengl", + "opencl", + "memory", + { + "type": "disk", + "folders": "/:/home:/boot:/efi" + }, + "localip" + ] +} diff --git a/presets/examples/4.jsonc b/presets/examples/4.jsonc new file mode 100644 index 000000000..81040c0d8 --- /dev/null +++ b/presets/examples/4.jsonc @@ -0,0 +1,31 @@ +// Load with --load-config examples/4.jsonc + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "source": "arch_small", + "padding": { + "right": 1 + } + }, + "display": { + "binaryPrefix": "si", + "color": "blue", + "separator": "  " + }, + "modules": [ + { + "type": "datetime", + "key": "Date", + "format": "{1}-{3}-{11}" + }, + { + "type": "datetime", + "key": "Time", + "format": "{14}:{17}:{20}" + }, + "break", + "player", + "media" + ] +} diff --git a/presets/examples/5.jsonc b/presets/examples/5.jsonc new file mode 100644 index 000000000..fefe2441d --- /dev/null +++ b/presets/examples/5.jsonc @@ -0,0 +1,31 @@ +// Load with --load-config examples/5.jsonc + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "none" + }, + "display": { + "color": "reset_magenta" + }, + "modules": [ + { + "type": "theme", + "key": "T", + "format": "{7}" + }, + { + "type": "icons", + "key": "I", + "format": "{5}" + }, + { + "type": "font", + "key": "F" + }, + { + "type": "cursor", + "key": "C" + } + ] +} diff --git a/presets/hardware.jsonc b/presets/hardware.jsonc new file mode 100644 index 000000000..d976285fc --- /dev/null +++ b/presets/hardware.jsonc @@ -0,0 +1,25 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "builtin", + "source": "arch" + }, + "modules": [ + "host", + "display", + "cpu", + "gpu", + { + "type": "memory", + "format": "{?2}{2}{?}" + }, + { + "type": "disk", + "format": "{?2}{2}{?}" + }, + { + "type": "battery", + "format": "{?1}{1} {?}{?2}{2} {?}{?3}({3}){?}" + } + ] +} diff --git a/presets/neofetch b/presets/neofetch index 9861e3b99..925f4705b 100644 --- a/presets/neofetch +++ b/presets/neofetch @@ -1,10 +1,9 @@ --structure "Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Terminal:TerminalFont:CPU:GPU:Memory:Break:Colors" --host-format "{/2}{-}{/}{2}{?3} {3}{?}" --os-format "{3} {12}" ---display-format "{}x{}" +--display-key Resolution +--display-compact-type original --de-format "{2} {3}" --theme-format "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}" --terminalfont-format "{/2}{-}{/}{2}{?3} {3}{?}" --memory-format "{/1}{-}{/}{/2}{-}{/}{} / {}" ---gpu-key "GPU" ---display-key "Display" diff --git a/presets/neofetch.jsonc b/presets/neofetch.jsonc new file mode 100644 index 000000000..b7bbaac47 --- /dev/null +++ b/presets/neofetch.jsonc @@ -0,0 +1,48 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "modules": [ + "title", + "separator", + { + "type": "os", + "format": "{3} {12}" + }, + { + "type": "host", + "format": "{/2}{-}{/}{2}{?3} {3}{?}" + }, + "kernel", + "uptime", + "packages", + "shell", + { + "type": "display", + "compactType": "original", + "key": "Resolution" + }, + "de", + "wm", + "wmtheme", + { + "type": "theme", + "format": "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}" + }, + "icons", + "terminal", + { + "type": "terminalfont", + "format": "{/2}{-}{/}{2}{?3} {3}{?}" + }, + "cpu", + { + "type": "gpu", + "key": "GPU" + }, + { + "type": "memory", + "format": "{/1}{-}{/}{/2}{-}{/}{} / {}" + }, + "break", + "colors" + ] +} diff --git a/presets/paleofetch.jsonc b/presets/paleofetch.jsonc new file mode 100644 index 000000000..7fe9ea0aa --- /dev/null +++ b/presets/paleofetch.jsonc @@ -0,0 +1,35 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "modules": [ + "title", + "separator", + "os", + { + "type": "host", + "format": "{/2}{-}{/}{2}{?3} {3}{?}" + }, + "kernel", + "uptime", + { + "type": "battery", + "format": "{/4}{-}{/}{4}%{?5} [{5}]{?}" + }, + "break", + "packages", + "shell", + { + "type": "display", + "key": "Display" + }, + "terminal", + "break", + "cpu", + { + "type": "gpu", + "key": "GPU" + }, + "memory", + "break", + "colors" + ] +} diff --git a/presets/software.jsonc b/presets/software.jsonc new file mode 100644 index 000000000..b2715adaa --- /dev/null +++ b/presets/software.jsonc @@ -0,0 +1,17 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "modules": [ + "os", + "kernel", + "shell", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "terminal", + "terminalfont" + ] +} From 9021c6ee82243b0b117215779d0f8ba2456a51cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 21:12:27 +0800 Subject: [PATCH 239/493] JsonConfig: fix compiler warnings --- src/common/jsonconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 171548596..2e02384df 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -314,7 +314,7 @@ const char* ffParseGeneralJsonConfig(void) ffStrbufSetS(&config->osFile, yyjson_get_str(val)); #elif defined(_WIN32) else if (ffStrEqualsIgnCase(key, "wmiTimeout")) - config->wmiTimeout = yyjson_get_uint(val); + config->wmiTimeout = (int32_t) yyjson_get_int(val); #endif else From f0844d763675edefc252b5c8e064e8f133ddd515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 25 Jun 2023 21:22:44 +0800 Subject: [PATCH 240/493] JsonConfig: support `"logo": null` and `"logo": "/path/to/logo"` --- doc/json_schema.json | 290 ++++++++++++++++++++------------------- presets/examples/3.jsonc | 4 +- presets/examples/5.jsonc | 4 +- src/logo/logo.c | 6 + src/logo/option.c | 16 +++ 5 files changed, 175 insertions(+), 145 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 158a1e5ff..e169b30cc 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -27,162 +27,174 @@ "format": "uri" }, "logo": { - "title": "Fastfetch logo configurations", - "type": "object", - "properties": { - "type": { - "title": "Set the type of the logo given", - "enum": [ - "auto", - "builtin", - "file", - "file-raw", - "data", - "data-raw", - "sixel", - "kitty", - "iterm", - "chafa", - "raw", - "none" - ], - "default": "auto" + "oneOf": [ + { + "title": "Disable logo", + "type": "null" }, - "source": { - "type": "string", - "title": "Set the source file of the logo" + { + "title": "Set the source file of the logo", + "type": "string" }, - "color": { + { + "title": "Fastfetch logo configurations", "type": "object", - "title": "Overwrite a color in the logo", "properties": { - "1": { - "title": "Color 1", - "$ref": "#/$defs/colors" + "type": { + "title": "Set the type of the logo given", + "enum": [ + "auto", + "builtin", + "file", + "file-raw", + "data", + "data-raw", + "sixel", + "kitty", + "iterm", + "chafa", + "raw", + "none" + ], + "default": "auto" }, - "2": { - "title": "Color 2", - "$ref": "#/$defs/colors" + "source": { + "type": "string", + "title": "Set the source file of the logo" }, - "3": { - "title": "Color 3", - "$ref": "#/$defs/colors" + "color": { + "type": "object", + "title": "Overwrite a color in the logo", + "properties": { + "1": { + "title": "Color 1", + "$ref": "#/$defs/colors" + }, + "2": { + "title": "Color 2", + "$ref": "#/$defs/colors" + }, + "3": { + "title": "Color 3", + "$ref": "#/$defs/colors" + }, + "4": { + "title": "Color 4", + "$ref": "#/$defs/colors" + }, + "5": { + "title": "Color 5", + "$ref": "#/$defs/colors" + }, + "6": { + "title": "Color 6", + "$ref": "#/$defs/colors" + }, + "7": { + "title": "Color 7", + "$ref": "#/$defs/colors" + }, + "8": { + "title": "Color 8", + "$ref": "#/$defs/colors" + }, + "9": { + "title": "Color 9", + "$ref": "#/$defs/colors" + } + } }, - "4": { - "title": "Color 4", - "$ref": "#/$defs/colors" - }, - "5": { - "title": "Color 5", - "$ref": "#/$defs/colors" - }, - "6": { - "title": "Color 6", - "$ref": "#/$defs/colors" - }, - "7": { - "title": "Color 7", - "$ref": "#/$defs/colors" - }, - "8": { - "title": "Color 8", - "$ref": "#/$defs/colors" - }, - "9": { - "title": "Color 9", - "$ref": "#/$defs/colors" - } - } - }, - "width": { - "type": "integer", - "title": "Set the width of the logo (in characters). Required for iTerm image protocol", - "minimum": 1 - }, - "height": { - "type": "integer", - "title": "Set the height of the logo (in characters). Required for iTerm image protocol", - "minimum": 1 - }, - "padding": { - "type": "object", - "title": "Set the padding of the logo", - "properties": { - "top": { + "width": { "type": "integer", - "title": "Set the top padding of the logo", - "minimum": 0 + "title": "Set the width of the logo (in characters). Required for iTerm image protocol", + "minimum": 1 }, - "left": { + "height": { "type": "integer", - "title": "Set the left padding of the logo", - "minimum": 0 + "title": "Set the height of the logo (in characters). Required for iTerm image protocol", + "minimum": 1 }, - "right": { - "type": "integer", - "title": "Set the right padding of the logo", - "minimum": 0 - } - } - }, - "printRemaining": { - "type": "boolean", - "title": "Whether to print the remaining logo, if it has more lines than modules to display", - "default": false - }, - "preserveAspectRadio": { - "type": "boolean", - "title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", - "default": false - }, - "chafa": { - "type": "object", - "title": "Chafa configuration. See chafa document for details", - "properties": { - "fgOnly": { + "padding": { + "type": "object", + "title": "Set the padding of the logo", + "properties": { + "top": { + "type": "integer", + "title": "Set the top padding of the logo", + "minimum": 0 + }, + "left": { + "type": "integer", + "title": "Set the left padding of the logo", + "minimum": 0 + }, + "right": { + "type": "integer", + "title": "Set the right padding of the logo", + "minimum": 0 + } + } + }, + "printRemaining": { "type": "boolean", - "title": "Produce character-cell output using foreground colors only", + "title": "Whether to print the remaining logo, if it has more lines than modules to display", "default": false }, - "symbols": { - "type": "string", - "title": "Specify character symbols to employ in final output" + "preserveAspectRadio": { + "type": "boolean", + "title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol", + "default": false }, - "canvasMode": { - "type": "string", - "title": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", - "enum": [ - "TRUECOLOR", - "INDEXED_256", - "INDEXED_240", - "INDEXED_16", - "FGBG_BGFG", - "FGBG", - "INDEXED_8", - "INDEXED_16_8" - ] - }, - "colorSpace": { - "type": "string", - "title": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", - "enum": [ - "RGB", - "DIN99D" - ] - }, - "ditherMode": { - "type": "string", - "title": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", - "enum": [ - "NONE", - "ORDERED", - "DIFFUSION" - ] + "chafa": { + "type": "object", + "title": "Chafa configuration. See chafa document for details", + "properties": { + "fgOnly": { + "type": "boolean", + "title": "Produce character-cell output using foreground colors only", + "default": false + }, + "symbols": { + "type": "string", + "title": "Specify character symbols to employ in final output" + }, + "canvasMode": { + "type": "string", + "title": "Determine how colors are used in the output. This value maps the value of enum ChafaCanvasMode.", + "enum": [ + "TRUECOLOR", + "INDEXED_256", + "INDEXED_240", + "INDEXED_16", + "FGBG_BGFG", + "FGBG", + "INDEXED_8", + "INDEXED_16_8" + ] + }, + "colorSpace": { + "type": "string", + "title": "Set color space used for quantization. This value maps the value of enum ChafaColorSpace.", + "enum": [ + "RGB", + "DIN99D" + ] + }, + "ditherMode": { + "type": "string", + "title": "Set output dither mode (No effect with 24-bit color). This value maps the value of enum ChafaDitherMode.", + "enum": [ + "NONE", + "ORDERED", + "DIFFUSION" + ] + } + } } - } + }, + "additionalProperties": false } - }, - "additionalProperties": false + ] }, "general": { "title": "Fastfetch general configurations", diff --git a/presets/examples/3.jsonc b/presets/examples/3.jsonc index 6ff5dabb6..89fc93198 100644 --- a/presets/examples/3.jsonc +++ b/presets/examples/3.jsonc @@ -2,9 +2,7 @@ { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { - "source": "debian_small" - }, + "logo": "debian_small", "display": { "binaryPrefix": "si" }, diff --git a/presets/examples/5.jsonc b/presets/examples/5.jsonc index fefe2441d..888c763d7 100644 --- a/presets/examples/5.jsonc +++ b/presets/examples/5.jsonc @@ -2,9 +2,7 @@ { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { - "type": "none" - }, + "logo": null, "display": { "color": "reset_magenta" }, diff --git a/src/logo/logo.c b/src/logo/logo.c index 17e91b24a..f07155936 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -410,6 +410,12 @@ void ffLogoPrint(void) const FFLogoOptions* options = &instance.config.logo; + if (options->type == FF_LOGO_TYPE_NONE) + { + logoPrintNone(); + return; + } + //If the source is not set, we can directly print the detected logo. if(options->source.length == 0) { diff --git a/src/logo/option.c b/src/logo/option.c index 5fe22176f..a277616a8 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -201,6 +201,22 @@ const char* ffParseLogoJsonConfig(void) yyjson_val* object = yyjson_obj_get(root, "logo"); if (!object) return NULL; + if (yyjson_is_null(object)) + { + options->type = FF_LOGO_TYPE_NONE; + options->paddingTop = 0; + options->paddingRight = 0; + options->paddingLeft = 0; + return NULL; + } + + if (yyjson_is_str(object)) + { + const char* value = yyjson_get_str(object); + ffStrbufSetS(&options->source, value); + return NULL; + } + if (!yyjson_is_obj(object)) return "Property 'logo' must be an object"; yyjson_val *key_, *val; From c5b5c0d9fd4a6c8ea8c7d101bf28905e60450d59 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 18 Jun 2023 14:43:02 +0800 Subject: [PATCH 241/493] JsonSchema: fix copy-paste errors --- doc/json_schema.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index e169b30cc..cfb5e3fe0 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -922,8 +922,7 @@ "string": { "title": "Set the string to be printed", "type": "string", - "format": "url", - "default": "http://ipinfo.io/ip" + "default": "-" } }, "additionalProperties": false From c6c6b2a0a670b26329662635ec5f301b0cebfee7 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 25 Jun 2023 23:35:51 +0800 Subject: [PATCH 242/493] GPU (macOS): fix vendor detection for Intel GPU --- src/detection/gpu/gpu_apple.c | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 00ee7422b..5c64f581e 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -60,23 +60,18 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; - ffStrbufInit(&gpu->vendor); - int vendorId; - if(!ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId)) - { - const char* vendorStr = ffGetGPUVendorString((unsigned) vendorId); - ffStrbufAppendS(&gpu->vendor, vendorStr); - if (vendorStr == FF_GPU_VENDOR_NAME_APPLE || vendorStr == FF_GPU_VENDOR_NAME_INTEL) - gpu->type = FF_GPU_TYPE_INTEGRATED; - else if (vendorStr == FF_GPU_VENDOR_NAME_NVIDIA || vendorStr == FF_GPU_VENDOR_NAME_AMD) - gpu->type = FF_GPU_TYPE_DISCRETE; - } - - ffStrbufInit(&gpu->driver); + ffStrbufInit(&gpu->driver); // Ok for both Apple and Intel ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver); + int vram; // Supported on Intel + if(!ffCfDictGetInt(properties, CFSTR("VRAM,totalMB"), &vram)) + gpu->dedicated.total = (uint64_t) vram * 1024 * 1034; + + if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple + gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + ffStrbufInit(&gpu->name); - //IOAccelerator returns model property for Apple Silicon, but not for Intel Iris GPUs. + //IOAccelerator returns model / vendor-id properties for Apple Silicon, but not for Intel Iris GPUs. //Still needs testing for AMD's if(ffCfDictGetString(properties, CFSTR("model"), &gpu->name)) { @@ -93,8 +88,17 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) ffCfDictGetString(properties, CFSTR("model"), &gpu->name); } - if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) - gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + ffStrbufInit(&gpu->vendor); + int vendorId; + if(!ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId)) + { + const char* vendorStr = ffGetGPUVendorString((unsigned) vendorId); + ffStrbufAppendS(&gpu->vendor, vendorStr); + if (vendorStr == FF_GPU_VENDOR_NAME_APPLE || vendorStr == FF_GPU_VENDOR_NAME_INTEL) + gpu->type = FF_GPU_TYPE_INTEGRATED; + else if (vendorStr == FF_GPU_VENDOR_NAME_NVIDIA || vendorStr == FF_GPU_VENDOR_NAME_AMD) + gpu->type = FF_GPU_TYPE_DISCRETE; + } if(options->temp) gpu->temperature = detectGpuTemp(&gpu->name); From 98985e9a27bb88c24fe7848a94d97807d7b95f3c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 25 Jun 2023 23:40:20 +0800 Subject: [PATCH 243/493] GPU (macOS): fix typo --- src/detection/gpu/gpu_apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 5c64f581e..11eaf1da0 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -65,7 +65,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) int vram; // Supported on Intel if(!ffCfDictGetInt(properties, CFSTR("VRAM,totalMB"), &vram)) - gpu->dedicated.total = (uint64_t) vram * 1024 * 1034; + gpu->dedicated.total = (uint64_t) vram * 1024 * 1024; if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; From 0e97df08c28165332b2ec3ecd39b50dbd67b841b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 28 Jun 2023 09:39:48 +0800 Subject: [PATCH 244/493] GPU (macOS): remove an unused `#include` --- src/detection/gpu/gpu_apple.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 11eaf1da0..21c2a0a27 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -5,7 +5,6 @@ #include "util/apple/cf_helpers.h" #include -#include static double detectGpuTemp(const FFstrbuf* gpuName) { From fd4ed07449c5d2cddd5c0325001392c1547e8071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 28 Jun 2023 10:04:10 +0800 Subject: [PATCH 245/493] Logo: simplify ffLogoPrintRemaining --- src/logo/logo.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/logo/logo.c b/src/logo/logo.c index f07155936..c1e2b9f28 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -467,11 +467,9 @@ void ffLogoPrintLine(void) void ffLogoPrintRemaining(void) { - while(instance.state.keysHeight <= instance.state.logoHeight) - { - ffLogoPrintLine(); - putchar('\n'); - } + if (instance.state.keysHeight <= instance.state.logoHeight) + ffPrintCharTimes('\n', instance.state.logoHeight - instance.state.keysHeight + 1); + instance.state.keysHeight = instance.state.logoHeight + 1; } void ffLogoBuiltinPrint(void) From ecfe4287aa0e84ca6f417d086134fdd578c79ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 28 Jun 2023 11:09:39 +0800 Subject: [PATCH 246/493] JsonConfig: set `showErrors=true` implicitly if `stat` is enabled --- src/common/jsonconfig.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 2e02384df..af56b6c57 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -301,7 +301,10 @@ const char* ffParseGeneralJsonConfig(void) else if (ffStrEqualsIgnCase(key, "thread") || ffStrEqualsIgnCase(key, "multithreading")) config->multithreading = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "stat")) + { config->stat = yyjson_get_bool(val); + config->showErrors= config->stat; + } else if (ffStrEqualsIgnCase(key, "escapeBedrock")) config->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "pipe")) From 4c7036a2cef3ea8e84fd7388b3ad1661f38d4a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Jun 2023 09:43:00 +0800 Subject: [PATCH 247/493] FFPlatform: fix ffPlatformPathAddEnv on Windows --- src/util/platform/FFPlatform.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/platform/FFPlatform.c b/src/util/platform/FFPlatform.c index 2a880aed1..811547c52 100644 --- a/src/util/platform/FFPlatform.c +++ b/src/util/platform/FFPlatform.c @@ -98,7 +98,13 @@ void ffPlatformPathAddEnv(FFlist* dirs, const char* env) uint32_t startIndex = 0; while (startIndex < value.length) { - uint32_t colonIndex = ffStrbufNextIndexC(&value, startIndex, ':'); + #ifdef _WIN32 + const char separator = ';'; + #else + const char separator = ':'; + #endif + + uint32_t colonIndex = ffStrbufNextIndexC(&value, startIndex, separator); value.chars[colonIndex] = '\0'; if(!ffStrSet(value.chars + startIndex)) From 13f58f5f1bcda39d2869f9ddd405d1c06b0cdeae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Jun 2023 10:31:20 +0800 Subject: [PATCH 248/493] FFPlatform: only add a path to data dirs if the path exits --- src/util/FFlist.h | 5 +++ src/util/platform/FFPlatform.c | 61 ++++++-------------------- src/util/platform/FFPlatform_private.h | 8 ---- src/util/platform/FFPlatform_unix.c | 36 +++++++++++++-- src/util/platform/FFPlatform_windows.c | 38 +++++++++------- tests/list.c | 6 +++ 6 files changed, 80 insertions(+), 74 deletions(-) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index 25413dd23..4961adda3 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -53,6 +53,11 @@ static inline void* ffListGet(const FFlist* list, uint32_t index) return list->data + (index * list->elementSize); } +static inline bool ffListContains(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*)) +{ + return ffListFirstIndexComp(list, compElement, compFunc) != list->length; +} + static inline void ffListSort(FFlist* list, int(*compar)(const void*, const void*)) { qsort(list->data, list->length, list->elementSize, compar); diff --git a/src/util/platform/FFPlatform.c b/src/util/platform/FFPlatform.c index 811547c52..27b470b3b 100644 --- a/src/util/platform/FFPlatform.c +++ b/src/util/platform/FFPlatform.c @@ -1,5 +1,6 @@ #include "FFPlatform_private.h" #include "util/stringUtils.h" +#include "common/io/io.h" void ffPlatformInit(FFPlatform* platform) { @@ -68,55 +69,21 @@ void ffPlatformDestroy(FFPlatform* platform) void ffPlatformPathAddAbsolute(FFlist* dirs, const char* path) { - FFstrbuf* buffer = (FFstrbuf*) ffListAdd(dirs); - ffStrbufInitA(buffer, 64); - ffStrbufAppendS(buffer, path); - ffStrbufEnsureEndsWithC(buffer, '/'); - FF_PLATFORM_PATH_UNIQUE(dirs, buffer); + if (!ffPathExists(path, FF_PATHTYPE_DIRECTORY)) + return; + + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(path); + ffStrbufEnsureEndsWithC(&buffer, '/'); + if (!ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) + ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer); } void ffPlatformPathAddHome(FFlist* dirs, const FFPlatform* platform, const char* suffix) { - FFstrbuf* buffer = (FFstrbuf*) ffListAdd(dirs); - ffStrbufInitA(buffer, 64); - ffStrbufAppend(buffer, &platform->homeDir); - ffStrbufAppendS(buffer, suffix); - ffStrbufEnsureEndsWithC(buffer, '/'); - FF_PLATFORM_PATH_UNIQUE(dirs, buffer); -} - -void ffPlatformPathAddEnv(FFlist* dirs, const char* env) -{ - const char* envValue = getenv(env); - if(!ffStrSet(envValue)) - return; - - FFstrbuf value; - ffStrbufInitA(&value, 64); - ffStrbufAppendS(&value, envValue); - - uint32_t startIndex = 0; - while (startIndex < value.length) - { - #ifdef _WIN32 - const char separator = ';'; - #else - const char separator = ':'; - #endif - - uint32_t colonIndex = ffStrbufNextIndexC(&value, startIndex, separator); - value.chars[colonIndex] = '\0'; - - if(!ffStrSet(value.chars + startIndex)) - { - startIndex = colonIndex + 1; - continue; - } - - ffPlatformPathAddAbsolute(dirs, value.chars + startIndex); - - startIndex = colonIndex + 1; - } - - ffStrbufDestroy(&value); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(64); + ffStrbufAppend(&buffer, &platform->homeDir); + ffStrbufAppendS(&buffer, suffix); + ffStrbufEnsureEndsWithC(&buffer, '/'); + if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) + ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer); } diff --git a/src/util/platform/FFPlatform_private.h b/src/util/platform/FFPlatform_private.h index 698f07609..d81e6f9cf 100644 --- a/src/util/platform/FFPlatform_private.h +++ b/src/util/platform/FFPlatform_private.h @@ -7,15 +7,7 @@ void ffPlatformInitImpl(FFPlatform* platform); -#define FF_PLATFORM_PATH_UNIQUE(list, element) \ - if(ffListFirstIndexComp(list, element, (bool(*)(const void*, const void*))ffStrbufEqual) < list->length - 1) \ - { \ - ffStrbufDestroy(ffListGet(list, list->length - 1)); \ - --list->length; \ - } - void ffPlatformPathAddAbsolute(FFlist* dirs, const char* path); void ffPlatformPathAddHome(FFlist* dirs, const FFPlatform* platform, const char* suffix); -void ffPlatformPathAddEnv(FFlist* dirs, const char* env); #endif diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 251edef54..a6e5d1b13 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -1,11 +1,39 @@ #include "FFPlatform_private.h" #include "util/stringUtils.h" #include "fastfetch_config.h" +#include "common/io/io.h" #include #include #include +static void platformPathAddEnv(FFlist* dirs, const char* env) +{ + const char* envValue = getenv(env); + if(!ffStrSet(envValue)) + return; + + FF_STRBUF_AUTO_DESTROY value = ffStrbufCreateA(64); + ffStrbufAppendS(&value, envValue); + + uint32_t startIndex = 0; + while (startIndex < value.length) + { + uint32_t colonIndex = ffStrbufNextIndexC(&value, startIndex, ':'); + value.chars[colonIndex] = '\0'; + + if(!ffStrSet(value.chars + startIndex)) + { + startIndex = colonIndex + 1; + continue; + } + + ffPlatformPathAddAbsolute(dirs, value.chars + startIndex); + + startIndex = colonIndex + 1; + } +} + static void getHomeDir(FFPlatform* platform, const struct passwd* pwd) { const char* home = pwd ? pwd->pw_dir : getenv("HOME"); @@ -30,7 +58,7 @@ static void getCacheDir(FFPlatform* platform) static void getConfigDirs(FFPlatform* platform) { - ffPlatformPathAddEnv(&platform->configDirs, "XDG_CONFIG_HOME"); + platformPathAddEnv(&platform->configDirs, "XDG_CONFIG_HOME"); ffPlatformPathAddHome(&platform->configDirs, platform, ".config/"); #if defined(__APPLE__) @@ -39,7 +67,7 @@ static void getConfigDirs(FFPlatform* platform) #endif ffPlatformPathAddHome(&platform->configDirs, platform, ""); - ffPlatformPathAddEnv(&platform->configDirs, "XDG_CONFIG_DIRS"); + platformPathAddEnv(&platform->configDirs, "XDG_CONFIG_DIRS"); #if !defined(__APPLE__) ffPlatformPathAddAbsolute(&platform->configDirs, FASTFETCH_TARGET_DIR_ETC "/xdg/"); @@ -51,7 +79,7 @@ static void getConfigDirs(FFPlatform* platform) static void getDataDirs(FFPlatform* platform) { - ffPlatformPathAddEnv(&platform->dataDirs, "XDG_DATA_HOME"); + platformPathAddEnv(&platform->dataDirs, "XDG_DATA_HOME"); ffPlatformPathAddHome(&platform->dataDirs, platform, ".local/share/"); #if defined(__APPLE__) @@ -59,7 +87,7 @@ static void getDataDirs(FFPlatform* platform) #endif ffPlatformPathAddHome(&platform->dataDirs, platform, ""); - ffPlatformPathAddEnv(&platform->dataDirs, "XDG_DATA_DIRS"); + platformPathAddEnv(&platform->dataDirs, "XDG_DATA_DIRS"); ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/"); ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/"); } diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index bfa5e1a7e..faddd9194 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -1,9 +1,11 @@ #include "FFPlatform_private.h" +#include "common/io/io.h" #include "util/stringUtils.h" #include "util/windows/unicode.h" #include #include + static void getHomeDir(FFPlatform* platform) { PWSTR pPath; @@ -38,11 +40,11 @@ static void platformPathAddKnownFolder(FFlist* dirs, REFKNOWNFOLDERID folderId) PWSTR pPath; if(SUCCEEDED(SHGetKnownFolderPath(folderId, 0, NULL, &pPath))) { - FFstrbuf* buffer = (FFstrbuf*) ffListAdd(dirs); - ffStrbufInitWS(buffer, pPath); - ffStrbufReplaceAllC(buffer, '\\', '/'); - ffStrbufEnsureEndsWithC(buffer, '/'); - FF_PLATFORM_PATH_UNIQUE(dirs, buffer); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateWS(pPath); + ffStrbufReplaceAllC(&buffer, '\\', '/'); + ffStrbufEnsureEndsWithC(&buffer, '/'); + if (!ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) + ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer); } CoTaskMemFree(pPath); } @@ -53,14 +55,18 @@ static void platformPathAddEnvSuffix(FFlist* dirs, const char* env, const char* if(!ffStrSet(value)) return; - FFstrbuf* buffer = ffListAdd(dirs); - ffStrbufInitA(buffer, 64); - ffStrbufAppendS(buffer, value); - ffStrbufReplaceAllC(buffer, '\\', '/'); - ffStrbufEnsureEndsWithC(buffer, '/'); - ffStrbufAppendS(buffer, suffix); - ffStrbufEnsureEndsWithC(buffer, '/'); - FF_PLATFORM_PATH_UNIQUE(dirs, buffer); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(64); + ffStrbufAppendS(&buffer, value); + ffStrbufReplaceAllC(&buffer, '\\', '/'); + ffStrbufEnsureEndsWithC(&buffer, '/'); + if (suffix) + { + ffStrbufAppendS(&buffer, suffix); + ffStrbufEnsureEndsWithC(&buffer, '/'); + } + + if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) + ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer); } static void getConfigDirs(FFPlatform* platform) @@ -69,11 +75,12 @@ static void getConfigDirs(FFPlatform* platform) { // We are in MSYS2 / Git Bash platformPathAddEnvSuffix(&platform->configDirs, "HOME", ".config/"); - platformPathAddEnvSuffix(&platform->configDirs, "HOME", ""); + platformPathAddEnvSuffix(&platform->configDirs, "HOME", NULL); platformPathAddEnvSuffix(&platform->configDirs, "MINGW_PREFIX", "etc"); } ffPlatformPathAddHome(&platform->configDirs, platform, ".config/"); + platformPathAddKnownFolder(&platform->configDirs, &FOLDERID_ProgramData); platformPathAddKnownFolder(&platform->configDirs, &FOLDERID_RoamingAppData); platformPathAddKnownFolder(&platform->configDirs, &FOLDERID_LocalAppData); ffPlatformPathAddHome(&platform->configDirs, platform, ""); @@ -85,10 +92,11 @@ static void getDataDirs(FFPlatform* platform) { // We are in MSYS2 / Git Bash platformPathAddEnvSuffix(&platform->dataDirs, "HOME", ".local/share/"); - platformPathAddEnvSuffix(&platform->dataDirs, "HOME", ""); + platformPathAddEnvSuffix(&platform->dataDirs, "HOME", NULL); platformPathAddEnvSuffix(&platform->dataDirs, "MINGW_PREFIX", "share"); } ffPlatformPathAddHome(&platform->dataDirs, platform, ".local/share/"); + platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_ProgramData); platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_RoamingAppData); platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_LocalAppData); ffPlatformPathAddHome(&platform->dataDirs, platform, ""); diff --git a/tests/list.c b/tests/list.c index 4ba879097..5119b046f 100644 --- a/tests/list.c +++ b/tests/list.c @@ -87,6 +87,12 @@ int main(void) n = 999; VERIFY(ffListFirstIndexComp(&list, &n, numEqualsAdapter) == list.length); + // ffListContains + n = 10; + VERIFY(ffListContains(&list, &n, numEqualsAdapter)); + n = 999; + VERIFY(!ffListContains(&list, &n, numEqualsAdapter)); + //shift VERIFY(ffListShift(&list, &n)); VERIFY(n == 1); From 0f8ebd2269430d792e0d06b53d7087fa6a0da31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Jun 2023 10:46:41 +0800 Subject: [PATCH 249/493] Bios: rename biosRelease to release --- src/detection/bios/bios.h | 2 +- src/detection/bios/bios_apple.c | 8 ++++---- src/detection/bios/bios_bsd.c | 4 ++-- src/detection/bios/bios_linux.c | 2 +- src/detection/bios/bios_windows.c | 2 +- src/modules/bios/bios.c | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/detection/bios/bios.h b/src/detection/bios/bios.h index 423ef3798..84046ad40 100644 --- a/src/detection/bios/bios.h +++ b/src/detection/bios/bios.h @@ -8,7 +8,7 @@ typedef struct FFBiosResult { FFstrbuf date; - FFstrbuf biosRelease; + FFstrbuf release; FFstrbuf vendor; FFstrbuf version; } FFBiosResult; diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index 5983a60d1..e939ac369 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -24,8 +24,8 @@ const char* ffDetectBios(FFBiosResult* bios) ffCfDictGetString(properties, CFSTR("version"), &bios->version); ffCfDictGetString(properties, CFSTR("release-date"), &bios->date); if(!ffStrbufContainC(&bios->date, '-')) - ffStrbufAppendS(&bios->biosRelease, "Efi-"); - ffStrbufAppend(&bios->biosRelease, &bios->version); + ffStrbufAppendS(&bios->release, "Efi-"); + ffStrbufAppend(&bios->release, &bios->version); CFRelease(properties); IOObjectRelease(registryEntry); @@ -52,8 +52,8 @@ const char* ffDetectBios(FFBiosResult* bios) CFMutableDictionaryRef properties; if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess) { - ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease); - ffStrbufAppend(&bios->version, &bios->biosRelease); + ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->release); + ffStrbufAppend(&bios->version, &bios->release); ffStrbufSubstrAfterFirstC(&bios->version, '-'); CFRelease(properties); } diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 4d8f61002..26c0dd1b5 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -7,8 +7,8 @@ const char* ffDetectBios(FFBiosResult* result) { ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &result->date); ffCleanUpSmbiosValue(&result->date); - ffSettingsGetFreeBSDKenv("smbios.bios.revision", &result->biosRelease); - ffCleanUpSmbiosValue(&result->biosRelease); + ffSettingsGetFreeBSDKenv("smbios.bios.revision", &result->release); + ffCleanUpSmbiosValue(&result->release); ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &result->vendor); ffCleanUpSmbiosValue(&result->vendor); ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->version); diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index bf8427bae..fc8cba62b 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -20,7 +20,7 @@ static void getSmbiosValue(const char* devicesPath, const char* classPath, FFstr const char* ffDetectBios(FFBiosResult* bios) { getSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->date); - getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease); + getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release); getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->vendor); getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->version); return NULL; diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index b154b290d..482ed48c2 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -18,7 +18,7 @@ const char* ffDetectBios(FFBiosResult* bios) ffRegReadUint(hKey, L"BiosMajorRelease", &major, NULL) && ffRegReadUint(hKey, L"BiosMinorRelease", &minor, NULL) ) - ffStrbufAppendF(&bios->biosRelease, "%u.%u", (unsigned)major, (unsigned)minor); + ffStrbufAppendF(&bios->release, "%u.%u", (unsigned)major, (unsigned)minor); return NULL; } diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 53137c9b3..398a7cc83 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -10,7 +10,7 @@ void ffPrintBios(FFBiosOptions* options) { FFBiosResult bios; ffStrbufInit(&bios.date); - ffStrbufInit(&bios.biosRelease); + ffStrbufInit(&bios.release); ffStrbufInit(&bios.vendor); ffStrbufInit(&bios.version); @@ -32,15 +32,15 @@ void ffPrintBios(FFBiosOptions* options) { ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&bios.version, stdout); - if (bios.biosRelease.length) - printf(" (%s)", bios.biosRelease.chars); + if (bios.release.length) + printf(" (%s)", bios.release.chars); putchar('\n'); } else { ffPrintFormat(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &bios.date}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosRelease}, + {FF_FORMAT_ARG_TYPE_STRBUF, &bios.release}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.version}, }); @@ -48,7 +48,7 @@ void ffPrintBios(FFBiosOptions* options) exit: ffStrbufDestroy(&bios.date); - ffStrbufDestroy(&bios.biosRelease); + ffStrbufDestroy(&bios.release); ffStrbufDestroy(&bios.vendor); ffStrbufDestroy(&bios.version); } From 651b33082dd4b79ac5095cd505ed1bf1e00ab3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Jun 2023 11:16:07 +0800 Subject: [PATCH 250/493] Bios (macOS): fix bios version detection --- src/detection/bios/bios_apple.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index e939ac369..16a49d319 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -23,9 +23,7 @@ const char* ffDetectBios(FFBiosResult* bios) ffCfDictGetString(properties, CFSTR("vendor"), &bios->vendor); ffCfDictGetString(properties, CFSTR("version"), &bios->version); ffCfDictGetString(properties, CFSTR("release-date"), &bios->date); - if(!ffStrbufContainC(&bios->date, '-')) - ffStrbufAppendS(&bios->release, "Efi-"); - ffStrbufAppend(&bios->release, &bios->version); + ffStrbufAppendS(&bios->release, "Efi"); CFRelease(properties); IOObjectRelease(registryEntry); @@ -44,7 +42,6 @@ const char* ffDetectBios(FFBiosResult* bios) CFRelease(properties); } IOObjectRelease(registryEntry); - return NULL; } if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"))) @@ -52,9 +49,17 @@ const char* ffDetectBios(FFBiosResult* bios) CFMutableDictionaryRef properties; if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess) { - ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->release); - ffStrbufAppend(&bios->version, &bios->release); - ffStrbufSubstrAfterFirstC(&bios->version, '-'); + ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->version); + uint32_t index = ffStrbufFirstIndexC(&bios->version, '-'); + if (index != bios->version.length) + { + ffStrbufAppendNS(&bios->release, index, bios->version.chars); + ffStrbufRemoveSubstr(&bios->version, 0, index + 1); + } + else + { + ffStrbufAppendS(&bios->release, "iBoot"); + } CFRelease(properties); } IOObjectRelease(registryEntry); From 6528f076fa664cdde89b27d928f44f6aba4d444f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 29 Jun 2023 11:26:35 +0800 Subject: [PATCH 251/493] Bios (macOS): support bios date detection --- src/detection/bios/bios_apple.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c index 16a49d319..3ebc1f468 100644 --- a/src/detection/bios/bios_apple.c +++ b/src/detection/bios/bios_apple.c @@ -39,6 +39,7 @@ const char* ffDetectBios(FFBiosResult* bios) if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess) { ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->vendor); + ffCfDictGetString(properties, CFSTR("time-stamp"), &bios->date); CFRelease(properties); } IOObjectRelease(registryEntry); From b4049c195c0ddf8d4fff96e7a2c163a36b6f8df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 30 Jun 2023 16:33:02 +0800 Subject: [PATCH 252/493] fix(DE): fix KDE detection (#481) --- src/detection/displayserver/linux/wmde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 91af20511..3022f8738 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -284,7 +284,7 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) { if(!ffStrSet(name)) return; - else if(strcasestr(name, "plasma") != NULL) + else if(strcasestr(name, "plasma") != NULL || strcasecmp(name, "KDE") == 0) getKDE(result); else if( strcasecmp(name, "polkit-gnome") != 0 && From cf62e6100127c945597ba19cab0a56c0a7c79d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 30 Jun 2023 16:34:19 +0800 Subject: [PATCH 253/493] CMake (Windows): remove an unused dependency --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76992f71e..abe5cf3e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -755,7 +755,6 @@ elseif(WIN32) PRIVATE "setupapi" PRIVATE "hid" PRIVATE "wtsapi32" - PRIVATE "powrprof" ) elseif(BSD) target_link_libraries(libfastfetch From ac07ae739b85122b76d71f33821c9ae79682f5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 14:20:34 +0800 Subject: [PATCH 254/493] LM (Linux): support version detection --- src/detection/lm/lm.h | 3 +- src/detection/lm/lm_linux.c | 92 +++++++++++++++++++++++++++++++++++++ src/modules/lm/lm.c | 7 ++- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/src/detection/lm/lm.h b/src/detection/lm/lm.h index 5fd1919d5..e118419a5 100644 --- a/src/detection/lm/lm.h +++ b/src/detection/lm/lm.h @@ -9,8 +9,7 @@ typedef struct FFLMResult { FFstrbuf service; FFstrbuf type; - // bool isDisplay; - // bool remote; + FFstrbuf version; } FFLMResult; const char* ffDetectLM(FFLMResult* result); diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index dcc65c7c2..b698a2ae4 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -1,6 +1,7 @@ #include "lm.h" #include "common/properties.h" #include "common/dbus.h" +#include "common/processing.h" #include "detection/displayserver/displayserver.h" #include @@ -8,6 +9,90 @@ #define FF_SYSTEMD_SESSIONS_PATH "/var/run/systemd/sessions/" #define FF_SYSTEMD_USERS_PATH "/run/systemd/users/" +static const char* getGdmVersion(FFstrbuf* version) +{ + const char* error = ffProcessAppendStdOut(version, (char* const[]) { + "gdm", + "--version", + NULL + }); + if (error) + return error; + + // GDM 44.1 + ffStrbufSubstrAfterFirstC(version, ' '); + return NULL; +} + +#ifdef FF_HAVE_ZLIB +#include "common/library.h" +#include +#include + +static const char* getSddmVersion(FFstrbuf* version) +{ + FF_LIBRARY_LOAD(zlib, &instance.config.libZ, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzopen); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzread); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzerror); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gztell); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzrewind); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzclose); + + gzFile file = ffgzopen("/usr/share/man/man1/sddm.1.gz", "rb"); + if (file == Z_NULL) + return "ffgzopen(\"/usr/share/man/man1/sddm.1.gz\", \"rb\") failed"; + + ffStrbufEnsureFree(version, 2047); + memset(version->chars, 0, version->allocated); + int size = ffgzread(file, version->chars, version->allocated - 1); + ffgzclose(file); + + if (size <= 0) + return "ffgzread(file, version->chars, version->length) failed"; + + version->length = (uint32_t) size; + uint32_t index = ffStrbufFirstIndexS(version, ".TH "); + if (index == version->length) + { + ffStrbufClear(version); + return ".TH is not found"; + } + + ffStrbufSubstrBefore(version, ffStrbufNextIndexC(version, index, '\n')); + ffStrbufSubstrAfter(version, index + strlen(".TH ")); + + // "SDDM" 1 "May 2014" "sddm 0.20.0" "sddm" + ffStrbufSubstrBeforeLastC(version, ' '); + ffStrbufTrimRight(version, '"'); + ffStrbufSubstrAfterLastC(version, ' '); + + return NULL; +} +#else +static const char* getSddmVersion(FF_MAYBE_UNUSED FFstrbuf* version) +{ + return "Fastfetch is built without libz support"; +} +#endif + +static const char* getXfwmVersion(FFstrbuf* version) +{ + const char* error = ffProcessAppendStdOut(version, (char* const[]) { + "xfwm4", + "--version", + NULL + }); + if (error) + return error; + + // This is xfwm4 version 4.18.0 (revision 7e7473c5b) for Xfce 4.18... + ffStrbufSubstrAfterFirstS(version, "version "); + ffStrbufSubstrBeforeFirstC(version, ' '); + + return NULL; +} + const char* ffDetectLM(FFLMResult* result) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); @@ -38,6 +123,13 @@ const char* ffDetectLM(FFLMResult* result) })) return "Failed to parse /run/systemd/sessions/$XDG_SESSION_ID"; + if (ffStrbufStartsWithS(&result->service, "gdm")) + getGdmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "sddm")) + getSddmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "xfwm")) + getXfwmVersion(&result->version); + // Correct char cases if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND)) ffStrbufSetS(&result->type, FF_WM_PROTOCOL_WAYLAND); diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index 34e28e6fa..adaf7d094 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -4,13 +4,14 @@ #include "modules/lm/lm.h" #include "util/stringUtils.h" -#define FF_LM_NUM_FORMAT_ARGS 2 +#define FF_LM_NUM_FORMAT_ARGS 3 void ffPrintLM(FFLMOptions* options) { FFLMResult result; ffStrbufInit(&result.service); ffStrbufInit(&result.type); + ffStrbufInit(&result.version); const char* error = ffDetectLM(&result); if(error) @@ -29,6 +30,8 @@ void ffPrintLM(FFLMOptions* options) { ffPrintLogoAndKey(FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); ffStrbufWriteTo(&result.service, stdout); + if(result.version.length) + printf(" %s", result.version.chars); if(result.type.length) printf(" (%s)", result.type.chars); putchar('\n'); @@ -38,10 +41,12 @@ void ffPrintLM(FFLMOptions* options) ffPrintFormat(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result.service}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, }); } ffStrbufDestroy(&result.service); ffStrbufDestroy(&result.type); + ffStrbufDestroy(&result.version); } void ffInitLMOptions(FFLMOptions* options) From 1c62a070993f8d8b01edcffba854a879f6c8464d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 14:47:14 +0800 Subject: [PATCH 255/493] GPU (Windows): more strict check --- src/detection/gpu/gpu_windows.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index a018bafca..621681e62 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -6,17 +6,17 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { - DISPLAY_DEVICEW displayDevice = {.cb = sizeof(displayDevice) }; + DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; - const uint32_t regKeyPrefixLength = strlen("SYSTEM\\CurrentControlSet\\Control\\Video\\{"); - const uint32_t deviceKeyPrefixLength = strlen("\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\{"); + const uint32_t regKeyPrefixLength = (uint32_t) wcslen(regKey); + const uint32_t deviceKeyPrefixLength = strlen("\\Registry\\Machine\\") + regKeyPrefixLength; for (DWORD i = 0; EnumDisplayDevicesW(NULL, i, &displayDevice, 0); ++i) { if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey); - if (wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; + if (deviceKeyLength != 100 || wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInit(&gpu->vendor); @@ -27,7 +27,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; - if (deviceKeyLength == 100 && displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') + if (displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') { wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1); FF_HKEY_AUTO_DESTROY hKey = NULL; From 1f799d16c99c7b245a23e6328b1312003d5635c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 15:06:47 +0800 Subject: [PATCH 256/493] GPU (Windows): add debug logs for #484 --- src/detection/gpu/gpu.c | 5 +++++ src/detection/gpu/gpu_windows.c | 12 ++++++++++++ src/modules/gpu/gpu.c | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 9300b2484..28040cd5c 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -32,15 +32,20 @@ const char* ffGetGPUVendorString(unsigned vendorId) const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { + fputs("ffDetectGPU start\n", stderr); if (!options->forceVulkan) { const char* error = ffDetectGPUImpl(options, result); + fputs("ffDetectGPU end 1\n", stderr); if (!error) return NULL; } + fputs("ffDetectVulkan start\n", stderr); FFVulkanResult* vulkan = ffDetectVulkan(); + fputs("ffDetectVulkan end\n", stderr); if (vulkan->error) return "GPU detection failed"; ffListDestroy(result); ffListInitMove(result, &vulkan->gpus); + fputs("ffDetectGPU end 2\n", stderr); return NULL; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 621681e62..ee1f9abf2 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -6,6 +6,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { + fputs("ffDetectGPUImpl: start\n", stderr); DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; const uint32_t regKeyPrefixLength = (uint32_t) wcslen(regKey); @@ -15,9 +16,12 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* { if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; + fwprintf(stderr, L"ffDetectGPUImpl EnumDisplayDevicesW %ls\n", displayDevice.DeviceKey); const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey); + fprintf(stderr, "ffDetectGPUImpl deviceKeyLength %d\n", (int) deviceKeyLength); if (deviceKeyLength != 100 || wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; + fputs("ffDetectGPUImpl ffListAdd\n", stderr); FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInit(&gpu->vendor); ffStrbufInitWS(&gpu->name, displayDevice.DeviceString); @@ -29,12 +33,17 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* if (displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') { + fputs("ffDetectGPUImpl displayDevice.DeviceKey[deviceKeyPrefixLength - 1]\n", stderr); wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1); FF_HKEY_AUTO_DESTROY hKey = NULL; + fputs("ffDetectGPUImpl ffRegOpenKeyForRead start\n", stderr); if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regKey, &hKey, NULL)) continue; + fputs("ffDetectGPUImpl ffRegOpenKeyForRead end\n", stderr); ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL); + fputs("ffDetectGPUImpl DriverVersion end\n", stderr); ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL); + fputs("ffDetectGPUImpl ProviderName end\n", stderr); if(ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD); @@ -43,8 +52,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* else if(ffStrbufContainS(&gpu->vendor, "NVIDIA")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA); + fputs("ffDetectGPUImpl HardwareInformation.qwMemorySize start\n", stderr); if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL)) { + fputs("ffDetectGPUImpl HardwareInformation.MemorySize start\n", stderr); uint32_t vmem = 0; if (ffRegReadUint(hKey, L"HardwareInformation.MemorySize", &vmem, NULL)) gpu->dedicated.total = vmem; @@ -52,6 +63,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; } } + fputs("ffDetectGPUImpl end\n", stderr); return NULL; } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index d7ec2d246..35571a1dd 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -79,6 +79,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu void ffPrintGPU(FFGPUOptions* options) { + fputs("ffPrintGPU start\n", stderr); FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult)); const char* error = ffDetectGPU(options, &gpus); if (error) @@ -86,6 +87,7 @@ void ffPrintGPU(FFGPUOptions* options) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } + fputs("ffPrintGPU 1\n", stderr); FF_LIST_AUTO_DESTROY selectedGPUs; ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus.length); @@ -100,12 +102,15 @@ void ffPrintGPU(FFGPUOptions* options) * (const FFGPUResult**) ffListAdd(&selectedGPUs) = gpu; } + fputs("ffPrintGPU 2\n", stderr); for(uint32_t i = 0; i < selectedGPUs.length; i++) printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); + fputs("ffPrintGPU 3\n", stderr); if(selectedGPUs.length == 0) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); + fputs("ffPrintGPU 4\n", stderr); FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) { From e2cef238ece108186caec9b16a8970971c7d7dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 20:10:32 +0800 Subject: [PATCH 257/493] Revert "GPU (Windows): add debug logs for #484" This reverts commit 1f799d16c99c7b245a23e6328b1312003d5635c0. --- src/detection/gpu/gpu.c | 5 ----- src/detection/gpu/gpu_windows.c | 12 ------------ src/modules/gpu/gpu.c | 5 ----- 3 files changed, 22 deletions(-) diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 28040cd5c..9300b2484 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -32,20 +32,15 @@ const char* ffGetGPUVendorString(unsigned vendorId) const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result) { - fputs("ffDetectGPU start\n", stderr); if (!options->forceVulkan) { const char* error = ffDetectGPUImpl(options, result); - fputs("ffDetectGPU end 1\n", stderr); if (!error) return NULL; } - fputs("ffDetectVulkan start\n", stderr); FFVulkanResult* vulkan = ffDetectVulkan(); - fputs("ffDetectVulkan end\n", stderr); if (vulkan->error) return "GPU detection failed"; ffListDestroy(result); ffListInitMove(result, &vulkan->gpus); - fputs("ffDetectGPU end 2\n", stderr); return NULL; } diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index ee1f9abf2..621681e62 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -6,7 +6,6 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { - fputs("ffDetectGPUImpl: start\n", stderr); DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) }; wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{"; const uint32_t regKeyPrefixLength = (uint32_t) wcslen(regKey); @@ -16,12 +15,9 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* { if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; - fwprintf(stderr, L"ffDetectGPUImpl EnumDisplayDevicesW %ls\n", displayDevice.DeviceKey); const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey); - fprintf(stderr, "ffDetectGPUImpl deviceKeyLength %d\n", (int) deviceKeyLength); if (deviceKeyLength != 100 || wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; - fputs("ffDetectGPUImpl ffListAdd\n", stderr); FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInit(&gpu->vendor); ffStrbufInitWS(&gpu->name, displayDevice.DeviceString); @@ -33,17 +29,12 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* if (displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') { - fputs("ffDetectGPUImpl displayDevice.DeviceKey[deviceKeyPrefixLength - 1]\n", stderr); wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1); FF_HKEY_AUTO_DESTROY hKey = NULL; - fputs("ffDetectGPUImpl ffRegOpenKeyForRead start\n", stderr); if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regKey, &hKey, NULL)) continue; - fputs("ffDetectGPUImpl ffRegOpenKeyForRead end\n", stderr); ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL); - fputs("ffDetectGPUImpl DriverVersion end\n", stderr); ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL); - fputs("ffDetectGPUImpl ProviderName end\n", stderr); if(ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD); @@ -52,10 +43,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* else if(ffStrbufContainS(&gpu->vendor, "NVIDIA")) ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA); - fputs("ffDetectGPUImpl HardwareInformation.qwMemorySize start\n", stderr); if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL)) { - fputs("ffDetectGPUImpl HardwareInformation.MemorySize start\n", stderr); uint32_t vmem = 0; if (ffRegReadUint(hKey, L"HardwareInformation.MemorySize", &vmem, NULL)) gpu->dedicated.total = vmem; @@ -63,7 +52,6 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; } } - fputs("ffDetectGPUImpl end\n", stderr); return NULL; } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 35571a1dd..d7ec2d246 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -79,7 +79,6 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu void ffPrintGPU(FFGPUOptions* options) { - fputs("ffPrintGPU start\n", stderr); FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult)); const char* error = ffDetectGPU(options, &gpus); if (error) @@ -87,7 +86,6 @@ void ffPrintGPU(FFGPUOptions* options) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } - fputs("ffPrintGPU 1\n", stderr); FF_LIST_AUTO_DESTROY selectedGPUs; ffListInitA(&selectedGPUs, sizeof(const FFGPUResult*), gpus.length); @@ -102,15 +100,12 @@ void ffPrintGPU(FFGPUOptions* options) * (const FFGPUResult**) ffListAdd(&selectedGPUs) = gpu; } - fputs("ffPrintGPU 2\n", stderr); for(uint32_t i = 0; i < selectedGPUs.length; i++) printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); - fputs("ffPrintGPU 3\n", stderr); if(selectedGPUs.length == 0) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); - fputs("ffPrintGPU 4\n", stderr); FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) { From b8a9b74978afa016d6596f7c3a7fc5a3dfc78b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 1 Jul 2023 20:27:04 +0800 Subject: [PATCH 258/493] GPU: fix #484 --- src/detection/gpu/gpu_windows.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 621681e62..67211b76c 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -4,6 +4,11 @@ #include +static int isGpuNameEqual(const FFGPUResult* gpu, const FFstrbuf* name) +{ + return ffStrbufEqual(&gpu->name, name); +} + const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) }; @@ -16,7 +21,16 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey); - if (deviceKeyLength != 100 || wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; + if (__builtin_expect(deviceKeyLength == 100, true)) + { + if (wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue; + } + else + { + // DeviceKey can be empty. See #484 + FF_STRBUF_AUTO_DESTROY gpuName = ffStrbufCreateWS(displayDevice.DeviceString); + if (ffListContains(gpus, &gpuName, (void*) isGpuNameEqual)) continue; + } FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInit(&gpu->vendor); @@ -27,7 +41,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; - if (displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') + if (deviceKeyLength == 100 && displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{') { wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1); FF_HKEY_AUTO_DESTROY hKey = NULL; From b294f45a226dfddfe3663c6ed315450c87e18501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 3 Jul 2023 15:38:25 +0800 Subject: [PATCH 259/493] Doc: add CI badge --- .github/workflows/{push.yml => ci.yml} | 2 +- README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename .github/workflows/{push.yml => ci.yml} (99%) diff --git a/.github/workflows/push.yml b/.github/workflows/ci.yml similarity index 99% rename from .github/workflows/push.yml rename to .github/workflows/ci.yml index 02ce13fdc..904dff2a8 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: manage pushes +name: CI on: - push diff --git a/README.md b/README.md index 7a35954ea..390af57cc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Fastfetch +[![CI](https://github.com/fastfetch-cli/fastfetch/actions/workflows/ci.yml/badge.svg)](https://github.com/fastfetch-cli/fastfetch/actions/workflows/ci.yml) + Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written mainly in C, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported. From be5a782598bc6ba5db3f08ccf456d9952c5ae0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 3 Jul 2023 18:19:41 +0800 Subject: [PATCH 260/493] Terminal (Linux): support terminator version detection --- src/detection/terminalshell/terminalshell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 4eccb820b..43cda6746 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -268,6 +268,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal")) return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)... + if(ffStrbufIgnCaseEqualS(processName, "terminator")) + return getExeVersionGeneral(exe, version);//terminator 2.1.3 + if(ffStrbufIgnCaseEqualS(processName, "deepin-terminal")) return getExeVersionGeneral(exe, version);//deepin-terminal 5.4.36 From cf91981d49c9dc659125d5881bfb0b575703e1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 3 Jul 2023 23:18:36 +0800 Subject: [PATCH 261/493] Packages (Linux): try detecting pkgtool fix #486 --- CHANGELOG.md | 1 + README.md | 2 +- presets/verbose | 2 +- src/detection/packages/packages.h | 1 + src/detection/packages/packages_linux.c | 1 + src/fastfetch.c | 5 +++-- src/modules/packages/packages.c | 2 ++ 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e4a1d9e..e74a7dd8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Features: * Support `--colors-symbol` and `--colors-padding-left` * Add LM (Login Manager) module * Add `--wmi-timeout` option (Windows) +* Support `pkgtool` package manager detection (Linux, Packages) # 1.12.1 diff --git a/README.md b/README.md index 390af57cc..208279acd 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CR ##### Package managers ``` -apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, pkg, rpm, scoop, Snap, xbps +apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, pkg, pkgtool, rpm, scoop, Snap, xbps ``` ##### WM themes diff --git a/presets/verbose b/presets/verbose index f84880ad8..833cfd4d9 100644 --- a/presets/verbose +++ b/presets/verbose @@ -3,7 +3,7 @@ --kernel-format Sysname: {}; Release: {}; Version: {} --uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {} --processes-format Count: {} ---packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {} +--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}; pkgtool: {} --shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {} --display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {} --de-format Process name: {}; Pretty name: {}; Version: {} diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index ef1cf1d4f..59b1d1ef6 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -21,6 +21,7 @@ typedef struct FFPackagesResult uint32_t nixUser; uint32_t pacman; uint32_t pkg; + uint32_t pkgtool; uint32_t port; uint32_t rpm; uint32_t scoop; diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index d67a05a74..ed8080fd7 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -270,6 +270,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts) packageCounts->nixSystem += getNixPackages(baseDir, "/run/current-system"); packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", DT_DIR); packageCounts->pkg += getSQLite3Int(baseDir, "/var/db/pkg/local.sqlite", "SELECT count(id) FROM packages"); + packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", DT_DIR); packageCounts->rpm += getSQLite3Int(baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(blob) FROM Packages"); packageCounts->snap += getSnap(baseDir); packageCounts->xbps += getXBPS(baseDir, "/var/db/xbps"); diff --git a/src/fastfetch.c b/src/fastfetch.c index 49c909d22..2722b59c9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -139,7 +139,7 @@ static inline void printCommandHelp(const char* command) } else if(ffStrEqualsIgnCase(command, "packages-format")) { - constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco)", 21, + constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco), {22} (pkgtool)", 22, "Number of all packages", "Number of pacman packages", "Pacman branch on manjaro", @@ -160,7 +160,8 @@ static inline void printCommandHelp(const char* command) "Number of brew-cask packages", "Number of macports packages", "Number of scoop packages", - "Number of choco packages" + "Number of choco packages", + "Number of pkgtool packages" ); } else if(ffStrEqualsIgnCase(command, "shell-format")) diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 1b3dc7568..928624b7c 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -61,6 +61,7 @@ void ffPrintPackages(FFPackagesOptions* options) FF_PRINT_PACKAGE(port) FF_PRINT_PACKAGE(scoop) FF_PRINT_PACKAGE(choco) + FF_PRINT_PACKAGE(pkgtool) putchar('\n'); } @@ -88,6 +89,7 @@ void ffPrintPackages(FFPackagesOptions* options) {FF_FORMAT_ARG_TYPE_UINT, &counts.port}, {FF_FORMAT_ARG_TYPE_UINT, &counts.scoop}, {FF_FORMAT_ARG_TYPE_UINT, &counts.choco}, + {FF_FORMAT_ARG_TYPE_UINT, &counts.pkgtool}, }); } From bd3bf9b62357eae7a866a3aa8a6450f23dd6ecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 3 Jul 2023 16:22:16 +0800 Subject: [PATCH 262/493] Fastfetch: add `--set` and `--set-keyless` back, but instead deprecate them Removing them seems to break too many users' configurations. Let's remove them later. --- CHANGELOG.md | 3 ++- src/fastfetch.c | 52 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74a7dd8b..f80840f3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ Changes: * Remove `--shell-version` and `--terminal-version`. They are always enabled * Remove `--*-error-format`, which seems to be useless * Remove `--display-detect-name`. Display name is always detected, and will be printed if multiple displays are detected -* Remove `--set` and `--set-keyless`. Use JSON config with Custom module instead +* Deprecate `--set` and `--set-keyless`; they may be removed in future releases. Use JSON config with Custom module instead +* Remove the special handling of Command module (it can be set once in the triditional `config.conf`). Use JSON config with Command module instead Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine diff --git a/src/fastfetch.c b/src/fastfetch.c index 2722b59c9..a0cad0bfa 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -18,16 +18,18 @@ #include "modules/modules.h" -typedef struct CustomValue +typedef struct FFCustomValue { bool printKey; + FFstrbuf key; FFstrbuf value; -} CustomValue; +} FFCustomValue; // Things only needed by fastfetch typedef struct FFdata { FFstrbuf structure; + FFlist customValues; // List of FFCustomValue bool loadUserConfig; } FFdata; @@ -810,6 +812,26 @@ static void parseOption(FFdata* data, const char* key, const char* value) else goto error; } + else if(ffStrStartsWithIgnCase(key, "--set")) + { + const char* subkey = key + strlen("--set"); + if(*subkey != '\0' && !ffStrEqualsIgnCase(subkey, "-keyless")) + goto error; + + FF_STRBUF_AUTO_DESTROY customValueStr = ffStrbufCreate(); + ffOptionParseString(key, value, &customValueStr); + uint32_t index = ffStrbufFirstIndexC(&customValueStr, '='); + if(index == 0 || index == customValueStr.length) + { + fprintf(stderr, "Error: usage: %s =\n", key); + exit(477); + } + FFCustomValue* customValue = (FFCustomValue*) ffListAdd(&data->customValues); + ffStrbufInitS(&customValue->value, &customValueStr.chars[index + 1]); + ffStrbufSubstrBefore(&customValueStr, index); + ffStrbufInitMove(&customValue->key, &customValueStr); + customValue->printKey = *subkey == '\0'; + } /////////////////// //General options// @@ -1071,8 +1093,23 @@ static void parseArguments(FFdata* data, int argc, const char** argv) } } -static void parseStructureCommand(const char* line) +static void parseStructureCommand(const char* line, FFlist* customValues) { + // handle `--set` and `--set-keyless` + FF_LIST_FOR_EACH(FFCustomValue, customValue, *customValues) + { + if (ffStrbufEqualS(&customValue->key, line)) + { + __attribute__((__cleanup__(ffDestroyCustomOptions))) FFCustomOptions options; + ffInitCustomOptions(&options); + if (customValue->printKey) + ffStrbufAppend(&options.moduleArgs.key, &customValue->key); + ffStrbufAppend(&options.moduleArgs.outputFormat, &customValue->value); + ffPrintCustom(&options); + return; + } + } + if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME)) ffPrintBreak(); else if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME)) @@ -1188,6 +1225,7 @@ int main(int argc, const char** argv) //Data stores things only needed for the configuration of fastfetch FFdata data; ffStrbufInit(&data.structure); + ffListInit(&data.customValues, sizeof(FFCustomValue)); data.loadUserConfig = true; if(!getenv("NO_CONFIG")) @@ -1236,7 +1274,7 @@ int main(int argc, const char** argv) if(__builtin_expect(instance.config.stat, false)) ms = ffTimeGetTick(); - parseStructureCommand(data.structure.chars + startIndex); + parseStructureCommand(data.structure.chars + startIndex, &data.customValues); if(__builtin_expect(instance.config.stat, false)) { @@ -1259,6 +1297,12 @@ int main(int argc, const char** argv) ffFinish(); ffStrbufDestroy(&data.structure); + FF_LIST_FOR_EACH(FFCustomValue, customValue, data.customValues) + { + ffStrbufDestroy(&customValue->key); + ffStrbufDestroy(&customValue->value); + } + ffListDestroy(&data.customValues); ffDestroyInstance(); } From 107b3dc1e3982c4eb5ff1cac7df779c7329985c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Jul 2023 00:16:48 +0800 Subject: [PATCH 263/493] Pckages (Linux): fix pkgtool detection Ref: https://github.com/fastfetch-cli/fastfetch/issues/486#issuecomment-1618808002 --- src/detection/packages/packages_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index ed8080fd7..1c12ad14d 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -270,7 +270,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts) packageCounts->nixSystem += getNixPackages(baseDir, "/run/current-system"); packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", DT_DIR); packageCounts->pkg += getSQLite3Int(baseDir, "/var/db/pkg/local.sqlite", "SELECT count(id) FROM packages"); - packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", DT_DIR); + packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", DT_REG); packageCounts->rpm += getSQLite3Int(baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(blob) FROM Packages"); packageCounts->snap += getSnap(baseDir); packageCounts->xbps += getXBPS(baseDir, "/var/db/xbps"); From c6416b5ccb8c21dca47ed8a3e034d1df0dde325e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Jul 2023 17:53:28 +0800 Subject: [PATCH 264/493] Host (Windows): cleanup useless smbios values --- src/detection/bios/bios_windows.c | 4 ++++ src/detection/board/board_windows.c | 4 ++++ src/detection/host/host_windows.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 482ed48c2..69930a178 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -1,5 +1,6 @@ #include "bios.h" #include "util/windows/registry.h" +#include "util/smbiosHelper.h" const char* ffDetectBios(FFBiosResult* bios) { @@ -10,8 +11,11 @@ const char* ffDetectBios(FFBiosResult* bios) if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->version, NULL)) return "\"HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion\" doesn't exist"; + ffCleanUpSmbiosValue(&bios->version); ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->vendor, NULL); + ffCleanUpSmbiosValue(&bios->vendor); ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->date, NULL); + ffCleanUpSmbiosValue(&bios->date); uint32_t major, minor; if( diff --git a/src/detection/board/board_windows.c b/src/detection/board/board_windows.c index 16db05161..a2bfce4ff 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -1,5 +1,6 @@ #include "board.h" #include "util/windows/registry.h" +#include "util/smbiosHelper.h" const char* ffDetectBoard(FFBoardResult* board) { @@ -11,8 +12,11 @@ const char* ffDetectBoard(FFBoardResult* board) if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->name, NULL)) return "ffRegReadStrbuf(hKey, L\"BaseBoardProduct\") failed"; + ffCleanUpSmbiosValue(&board->name); ffRegReadStrbuf(hKey, L"BaseBoardManufacturer", &board->vendor, NULL); + ffCleanUpSmbiosValue(&board->vendor); ffRegReadStrbuf(hKey, L"BaseBoardVersion", &board->version, NULL); + ffCleanUpSmbiosValue(&board->version); return NULL; } diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index 9498fa5e6..afc2b242c 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -1,5 +1,6 @@ #include "host.h" #include "util/windows/registry.h" +#include "util/smbiosHelper.h" const char* ffDetectHost(FFHostResult* host) { @@ -9,10 +10,15 @@ const char* ffDetectHost(FFHostResult* host) return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed"; ffRegReadStrbuf(hKey, L"SystemProductName", &host->productName, NULL); + ffCleanUpSmbiosValue(&host->productName); ffRegReadStrbuf(hKey, L"SystemFamily", &host->productFamily, NULL); + ffCleanUpSmbiosValue(&host->productFamily); ffRegReadStrbuf(hKey, L"SystemVersion", &host->productVersion, NULL); + ffCleanUpSmbiosValue(&host->productVersion); ffRegReadStrbuf(hKey, L"SystemSKU", &host->productSku, NULL); + ffCleanUpSmbiosValue(&host->productSku); ffRegReadStrbuf(hKey, L"SystemManufacturer", &host->sysVendor, NULL); + ffCleanUpSmbiosValue(&host->sysVendor); return NULL; } From 41cef6274c4fd6c770f83c391e915120066da3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Jul 2023 18:00:50 +0800 Subject: [PATCH 265/493] Shell (Windows): fallback shell version detection to file version --- src/detection/terminalshell/terminalshell.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 43cda6746..96f63bbbf 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -122,11 +122,6 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) ffStrbufSubstrAfterLastC(version, ' '); return true; } - -static bool getShellVersionCmd(FFstrbuf* exe, FFstrbuf* version) -{ - return getFileVersion(exe->chars, version); -} #endif bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) @@ -152,11 +147,11 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) #ifdef _WIN32 if(strcasecmp(exeName, "powershell") == 0 || strcasecmp(exeName, "powershell_ise") == 0) return getShellVersionWinPowerShell(exe, version); - if(strcasecmp(exeName, "cmd") == 0) - return getShellVersionCmd(exe, version); - #endif + return getFileVersion(exe->chars, version); + #else return false; + #endif } FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) From 65dabd392ed612464a19de35d28b8edf8ea3157b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Jul 2023 18:32:02 +0800 Subject: [PATCH 266/493] TerminalShell (Windows): fix #488 --- src/detection/terminalshell/terminalshell_windows.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index ac06bed6e..bf3915d65 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -142,7 +142,8 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufIgnCaseEqualS(&result->shellPrettyName, "guake-wrapped") || ffStrbufIgnCaseEqualS(&result->shellPrettyName, "fastfetch") || //scoop warps the real binaries with a "shim" exe ffStrbufIgnCaseEqualS(&result->shellPrettyName, "flashfetch") || - ffStrbufContainIgnCaseS(&result->shellPrettyName, "debug") + ffStrbufContainIgnCaseS(&result->shellPrettyName, "debug") || + ffStrbufStartsWithIgnCaseS(&result->shellPrettyName, "ConEmuC") // https://github.com/fastfetch-cli/fastfetch/issues/488#issuecomment-1619982014 ) { ffStrbufClear(&result->shellProcessName); ffStrbufClear(&result->shellPrettyName); From 2a20338885f5c511a162581086180b1b4df054ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 08:40:50 +0800 Subject: [PATCH 267/493] Host (macOS): fix incorrect Host on M2 Mac Studio with M2 Max CPU (#490) --- src/detection/host/host_apple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index a07c9d356..1c5789c70 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -109,8 +109,8 @@ static const char* getProductName(const FFstrbuf* hwModel) { const char* version = hwModel->chars + strlen("Mac"); if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)"; - if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; - if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; + if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"; + if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"; if(ffStrEquals(version, "14,8")) return "Mac Pro (2023)"; if(ffStrEquals(version, "14,6") || ffStrEquals(version, "14,10")) return "MacBook Pro (16-inch, 2023)"; From 3b799756dd97adaef6cfea051bfb0111f1778f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 09:07:55 +0800 Subject: [PATCH 268/493] DE (Linux): fix #489 --- src/detection/displayserver/linux/wmde.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 3022f8738..abb39fc91 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -286,6 +286,8 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) return; else if(strcasestr(name, "plasma") != NULL || strcasecmp(name, "KDE") == 0) getKDE(result); + else if(strcasestr(name, "budgie") != NULL) + getBudgie(result); else if( strcasecmp(name, "polkit-gnome") != 0 && strcasecmp(name, "gnome-keyring") != 0 && @@ -300,8 +302,6 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) getMate(result); else if(strcasestr(name, "lxqt") != NULL) getLXQt(result); - else if(strcasestr(name, "budgie") != NULL) - getBudgie(result); } static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) From 763890053b38e9a9e6d6929a56c98fc5d6972cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 14:21:35 +0800 Subject: [PATCH 269/493] JsonConfig: implement `--load-config` for JSON config file --- src/fastfetch.c | 57 +++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index a0cad0bfa..23143c318 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -538,29 +538,20 @@ static bool parseJsoncFile(const char* path) { yyjson_read_err error; yyjson_doc* doc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, &error); - if (doc) + if (!doc) { - instance.state.configDoc = doc; - const char* error = NULL; - - if ( - (error = ffParseLogoJsonConfig()) || - (error = ffParseGeneralJsonConfig()) || - (error = ffParseDisplayJsonConfig()) || - (error = ffParseLibraryJsonConfig()) || - false - ) { - fputs(error, stderr); + if (error.code != YYJSON_READ_ERROR_FILE_OPEN) + { + fprintf(stderr, "ERROR: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg); exit(477); } - return true; + return false; } - else if (error.code != YYJSON_READ_ERROR_FILE_OPEN) - { - fprintf(stderr, "ERROR: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg); - exit(477); - } - return false; + if (instance.state.configDoc) + yyjson_doc_free(instance.state.configDoc); // for `--load-config` + + instance.state.configDoc = doc; + return true; } static bool parseConfigFile(FFdata* data, const char* path) @@ -652,10 +643,18 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val fprintf(stderr, "Error: usage: %s \n", key); exit(413); } + uint32_t fileNameLen = (uint32_t) strlen(value); + if(fileNameLen == 0) + { + fprintf(stderr, "Error: usage: %s \n", key); + exit(413); + } + + bool isJsonConfig = fileNameLen > strlen(".jsonc") && strcasecmp(value + fileNameLen - strlen(".jsonc"), ".jsonc") == 0; //Try to load as an absolute path - if(parseConfigFile(data, value)) + if(isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, value)) return; //Try to load as a relative path @@ -669,7 +668,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val ffStrbufAppendS(&absolutePath, "fastfetch/presets/"); ffStrbufAppendS(&absolutePath, value); - bool success = parseConfigFile(data, absolutePath.chars); + bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars); if(success) return; @@ -1232,6 +1231,22 @@ int main(int argc, const char** argv) parseConfigFiles(&data); parseArguments(&data, argc, argv); + if (instance.state.configDoc) + { + const char* error = NULL; + + if ( + (error = ffParseLogoJsonConfig()) || + (error = ffParseGeneralJsonConfig()) || + (error = ffParseDisplayJsonConfig()) || + (error = ffParseLibraryJsonConfig()) || + false + ) { + fputs(error, stderr); + exit(477); + } + } + if(data.structure.length > 0 || !instance.state.configDoc) { //If we don't have a custom structure, use the default one From 03442022ed5d8d9ed0147fb8d3c1e517ff9a4772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 14:33:17 +0800 Subject: [PATCH 270/493] Disk: fix `--disk-folders` printing duplicated paths --- src/modules/disk/disk.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index ca3e91ce7..fa5bd325b 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -97,10 +97,9 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) static void printMountpoint(FFDiskOptions* options, const FFlist* disks, const char* mountpoint) { - for(uint32_t i = disks->length; i > 0; i--) + FF_LIST_FOR_EACH(FFDisk, disk, *disks) { - FFDisk* disk = ffListGet(disks, i - 1); - if(strncmp(mountpoint, disk->mountpoint.chars, disk->mountpoint.length) == 0) + if(ffStrbufEqualS(&disk->mountpoint, mountpoint)) { printDisk(options, disk); return; From 7bd9e1e7500c16e085d929cc6a4dc207285a6193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 15:06:34 +0800 Subject: [PATCH 271/493] LocalIP: fix `--compact` --- src/modules/localip/localip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index a9c76da0d..ecd07a5de 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -84,6 +84,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) fputs(" - ", stdout); printIp(ip); } + putchar('\n'); } else { From 5e9f850fe15b41ff458f20a840b76ab8f6bf975d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 15:47:47 +0800 Subject: [PATCH 272/493] Title: fix typo `fdqn` -> `fqdn`; support standard module args --- doc/json_schema.json | 9 +++++++ src/modules/separator/separator.c | 2 +- src/modules/title/option.h | 3 ++- src/modules/title/title.c | 44 +++++++++++++++++++++---------- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index cfb5e3fe0..6b03607df 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -965,6 +965,15 @@ "type": "boolean", "title": "Set if the title should use fully qualified domain name", "default": false + }, + "key": { + "$ref": "#/$defs/key" + }, + "keyColor": { + "$ref": "#/$defs/keyColor" + }, + "format": { + "$ref": "#/$defs/format" } }, "additionalProperties": false diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 7a28f7bbe..79b53d27b 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -9,7 +9,7 @@ void ffPrintSeparator(FFSeparatorOptions* options) if (titleLength == 0) { // Title was not printed, should we support this case? - titleLength = instance.state.platform.userName.length + 1 + (instance.config.title.fdqn ? + titleLength = instance.state.platform.userName.length + 1 + (instance.config.title.fqdn ? instance.state.platform.domainName.length : instance.state.platform.hostName.length ); diff --git a/src/modules/title/option.h b/src/modules/title/option.h index 1faa59ea4..ac3902e09 100644 --- a/src/modules/title/option.h +++ b/src/modules/title/option.h @@ -7,6 +7,7 @@ typedef struct FFTitleOptions { const char* moduleName; + FFModuleArgs moduleArgs; - bool fdqn; + bool fqdn; } FFTitleOptions; diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 6faacaf67..b5ffa9349 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -4,6 +4,8 @@ #include "util/textModifier.h" #include "util/stringUtils.h" +#define FF_TITLE_NUM_FORMAT_ARGS 2 + static inline void printTitlePart(const FFstrbuf* content) { if(!instance.config.pipe) @@ -20,34 +22,45 @@ static inline void printTitlePart(const FFstrbuf* content) void ffPrintTitle(FFTitleOptions* options) { - ffLogoPrintLine(); - - printTitlePart(&instance.state.platform.userName); - putchar('@'); - FFstrbuf* host = options->fdqn ? + FFstrbuf* host = options->fqdn ? &instance.state.platform.domainName : &instance.state.platform.hostName; - printTitlePart(host); + if (options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_TITLE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + printTitlePart(&instance.state.platform.userName); + putchar('@'); + printTitlePart(host); + putchar('\n'); + } + else + { + ffPrintFormat(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_TITLE_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.userName}, + {FF_FORMAT_ARG_TYPE_STRBUF, host}, + }); + } instance.state.titleLength = instance.state.platform.userName.length + host->length + 1; - - putchar('\n'); } void ffInitTitleOptions(FFTitleOptions* options) { options->moduleName = FF_TITLE_MODULE_NAME; - options->fdqn = false; + ffOptionInitModuleArg(&options->moduleArgs); + options->fqdn = false; } bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value) { const char* subKey = ffOptionTestPrefix(key, FF_TITLE_MODULE_NAME); if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; - if (ffStrEqualsIgnCase(subKey, "fdqn")) + if (ffStrEqualsIgnCase(subKey, "fqdn")) { - options->fdqn = ffOptionParseBoolean(value); + options->fqdn = ffOptionParseBoolean(value); return true; } @@ -56,7 +69,7 @@ bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const void ffDestroyTitleOptions(FFTitleOptions* options) { - FF_UNUSED(options); + ffOptionDestroyModuleArg(&options->moduleArgs); } void ffParseTitleJsonObject(yyjson_val* module) @@ -74,9 +87,12 @@ void ffParseTitleJsonObject(yyjson_val* module) if(ffStrEqualsIgnCase(key, "type")) continue; - if (ffStrEqualsIgnCase(key, "fdqn")) + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + if (ffStrEqualsIgnCase(key, "fqdn")) { - options.fdqn = yyjson_get_bool(val); + options.fqdn = yyjson_get_bool(val); continue; } From 341b2ef62dc678746ab604645c00b9ce30d70e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 15:53:45 +0800 Subject: [PATCH 273/493] Presets: don't use module `Date` and `Time` --- presets/examples/4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presets/examples/4 b/presets/examples/4 index bd0ea06b5..f41e25a73 100644 --- a/presets/examples/4 +++ b/presets/examples/4 @@ -4,4 +4,4 @@ --logo arch_small --logo-padding-right 1 --separator "  " ---structure Date:Time:Break:Player:Media +--structure DateTime:Break:Player:Media From 0e5932fbc1e59c37d220b50be476e6d17c552c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Jul 2023 16:03:46 +0800 Subject: [PATCH 274/493] Presets: print more information --- presets/examples/2.jsonc | 117 +++++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 12 deletions(-) diff --git a/presets/examples/2.jsonc b/presets/examples/2.jsonc index d0e0814c6..4b89cff76 100644 --- a/presets/examples/2.jsonc +++ b/presets/examples/2.jsonc @@ -3,18 +3,19 @@ { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { - "type": "kitty", - "source": "/home/linus/Bilder/Gentoo.png", - "width": 28 - }, + // "logo": { + // "type": "iterm", + // "source": "/Users/carter/Desktop/apple1.png", + // "width": 28, + // "height": 12 + // }, "display": { "separator": "  " }, "modules": [ { "type": "custom", // HardwareStart - "format": "┌───────── \u001b[1mHardware Information\u001b[0m ─────────┐" // `\u001b` is `\033`, or `\e` + "format": "┌─────────── \u001b[1mHardware Information\u001b[0m ───────────┐" // `\u001b` is `\033`, or `\e` }, { "type": "host", @@ -28,17 +29,71 @@ "type": "gpu", "key": " ﬙" }, + { + "type": "disk", + "key": " " + }, + { + "type": "memory", + "key": " 󰑭" + }, + { + "type": "swap", + "key": " 󰓡" + }, + { + "type": "display", + "key": " 󰍹" + }, + { + "type": "brightness", + "key": " 󰃞" + }, + { + "type": "battery", + "key": " " + }, + { + "type": "poweradapter", + "key": " " + }, + { + "type": "bluetooth", + "key": " " + }, + { + "type": "sound", + "key": " " + }, + { + "type": "gamepad", + "key": " " + }, { "type": "custom", // SoftwareStart - "format": "├───────── \u001b[1mSoftware Information\u001b[0m ─────────┤" + "format": "├─────────── \u001b[1mSoftware Information\u001b[0m ───────────┤" + }, + { + "type": "title", + "key": " ", + "format": "{1}@{2}" }, { "type": "os", - "key": " " + "key": " " // Just get your distro's logo off nerdfonts.com }, { "type": "kernel", - "key": " " + "key": " ", + "format": "{1} {2}" + }, + { + "type": "lm", + "key": " 󰧨" + }, + { + "type": "de", + "key": " " }, { "type": "wm", @@ -56,17 +111,55 @@ "type": "terminalfont", "key": " " }, + { + "type": "theme", + "key": " 󰉼" + }, + { + "type": "icons", + "key": " 󰀻" + }, + { + "type": "wallpaper", + "key": " 󰸉" + }, { "type": "packages", - "key": " " + "key": " 󰏖" + }, + { + "type": "uptime", + "key": " 󰅐" + }, + { + "type": "media", + "key": " 󰝚" + }, + { + "type": "localip", + "key": " 󰩟", + "compact": true + }, + { + "type": "publicip", + "key": " 󰩠" + }, + { + "type": "wifi", + "key": " ", + "format": "{4}" // ssid + }, + { + "type": "locale", + "key": " " }, { "type": "custom", // InformationEnd - "format": "└────────────────────────────────────────┘" + "format": "└────────────────────────────────────────────┘" }, { "type": "colors", - "paddingLeft": 4, + "paddingLeft": 2, "symbol": "circle" } ] From dad5457700bf08f7a474189cb2bfda4cbae48d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 6 Jul 2023 09:06:35 +0800 Subject: [PATCH 275/493] Presets: more examples --- presets/examples/6.jsonc | 185 +++++++++++++++++++++++++++++++++++++++ presets/examples/7.jsonc | 141 +++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+) create mode 100644 presets/examples/6.jsonc create mode 100644 presets/examples/7.jsonc diff --git a/presets/examples/6.jsonc b/presets/examples/6.jsonc new file mode 100644 index 000000000..4a9c4c7eb --- /dev/null +++ b/presets/examples/6.jsonc @@ -0,0 +1,185 @@ +// Load with --load-config examples/2.jsonc +// Note that you must replace the image path to an existing image to display it. + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + // "logo": { + // "type": "iterm", + // "source": "/Users/carter/Desktop/apple1.png", + // "width": 28, + // "height": 12 + // }, + "display": { + "separator": " " + }, + "modules": [ + { + "type": "host", + "key": "╭─", + "keyColor": "green" + }, + { + "type": "cpu", + "key": "├─", + "keyColor": "green" + }, + { + "type": "gpu", + "key": "├─﬙", + "keyColor": "green" + }, + { + "type": "disk", + "key": "├─", + "keyColor": "green" + }, + { + "type": "memory", + "key": "├─󰑭", + "keyColor": "green" + }, + { + "type": "swap", + "key": "├─󰓡", + "keyColor": "green" + }, + { + "type": "display", + "key": "├─󰍹", + "keyColor": "green" + }, + { + "type": "brightness", + "key": "├─󰃞", + "keyColor": "green" + }, + { + "type": "battery", + "key": "├─", + "keyColor": "green" + }, + { + "type": "poweradapter", + "key": "├─", + "keyColor": "green" + }, + { + "type": "gamepad", + "key": "├─", + "keyColor": "green" + }, + { + "type": "bluetooth", + "key": "├─", + "keyColor": "green" + }, + { + "type": "sound", + "key": "╰─", + "keyColor": "green" + }, + "break", + + { + "type": "shell", + "key": "╭─", + "keyColor": "yellow" + }, + { + "type": "terminal", + "key": "├─", + "keyColor": "yellow" + }, + { + "type": "terminalfont", + "key": "├─", + "keyColor": "yellow" + }, + { + "type": "lm", + "key": "├─󰧨", + "keyColor": "yellow" + }, + { + "type": "de", + "key": "├─", + "keyColor": "yellow" + }, + { + "type": "wm", + "key": "├─", + "keyColor": "yellow" + }, + { + "type": "theme", + "key": "├─󰉼", + "keyColor": "yellow" + }, + { + "type": "icons", + "key": "├─󰀻", + "keyColor": "yellow" + }, + { + "type": "wallpaper", + "key": "╰─󰸉", + "keyColor": "yellow" + }, + + "break", + { + "type": "title", + "key": "╭─", + "format": "{1}@{2}", + "keyColor": "blue" + }, + { + "type": "os", + "key": "├─", // Just get your distro's logo off nerdfonts.com + "keyColor": "blue" + }, + { + "type": "kernel", + "key": "├─", + "format": "{1} {2}", + "keyColor": "blue" + }, + { + "type": "packages", + "key": "├─󰏖", + "keyColor": "blue" + }, + { + "type": "uptime", + "key": "├─󰅐", + "keyColor": "blue" + }, + { + "type": "media", + "key": "├─󰝚", + "keyColor": "blue" + }, + { + "type": "localip", + "key": "├─󰩟", + "compact": true, + "keyColor": "blue" + }, + { + "type": "publicip", + "key": "├─󰩠", + "keyColor": "blue" + }, + { + "type": "wifi", + "key": "├─", + "format": "{4}", // ssid + "keyColor": "blue" + }, + { + "type": "locale", + "key": "╰─", + "keyColor": "blue" + } + ] +} diff --git a/presets/examples/7.jsonc b/presets/examples/7.jsonc new file mode 100644 index 000000000..04f3c60b1 --- /dev/null +++ b/presets/examples/7.jsonc @@ -0,0 +1,141 @@ +// Load with --load-config examples/2.jsonc +// Note that you must replace the image path to an existing image to display it. + +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + // "logo": { + // "type": "iterm", + // "source": "/Users/carter/Desktop/apple1.png", + // "width": 28, + // "height": 12 + // }, + "display": { + "separator": " -> " + }, + "modules": [ + "title", + "separator", + { + "type": "os", + "key": " OS", + "keyColor": "blue", + "format": "{2}" + }, + { + "type": "os", + "key": "├", // Just get your distro's logo off nerdfonts.com + "keyColor": "blue", + "format": "{6}{?6} {?}{10} {8}" + }, + { + "type": "kernel", + "key": "├", + "format": "{1} {2}", + "keyColor": "blue" + }, + { + "type": "packages", + "key": "├󰏖", + "keyColor": "blue" + }, + { + "type": "shell", + "key": "└", + "keyColor": "yellow" + }, + "break", + + { + "type": "wm", + "key": " DE/WM", + "keyColor": "yellow" + }, + { + "type": "lm", + "key": "├󰧨", + "keyColor": "yellow" + }, + { + "type": "wmtheme", + "key": "├󰉼", + "keyColor": "yellow" + }, + { + "type": "icons", + "key": "├󰀻", + "keyColor": "yellow" + }, + { + "type": "terminal", + "key": "├", + "keyColor": "yellow" + }, + { + "type": "wallpaper", + "key": "└󰸉", + "keyColor": "yellow" + }, + + "break", + { + "type": "host", + "key": " PC", + "keyColor": "green" + }, + { + "type": "cpu", + "key": "├", + "keyColor": "green" + }, + { + "type": "gpu", + "key": "├﬙", + "keyColor": "green" + }, + { + "type": "disk", + "key": "├", + "keyColor": "green" + }, + { + "type": "memory", + "key": "├󰑭", + "keyColor": "green" + }, + { + "type": "swap", + "key": "├󰓡", + "keyColor": "green" + }, + { + "type": "uptime", + "key": "├󰅐", + "keyColor": "blue" + }, + { + "type": "display", + "key": "└󰍹", + "keyColor": "green" + }, + + "break", + { + "type": "media", + "key": "󰝚 SONG", + "keyColor": "blue" + }, + { + "type": "player", + "key": "├󰥠", + "keyColor": "blue" + }, + { + "type": "sound", + "key": "└", + "keyColor": "green" + }, + + "break", + "colors" + ] +} From 36950a95393a181ba897f6651aaf37d640d3ff85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 6 Jul 2023 15:43:53 +0800 Subject: [PATCH 276/493] Presets: update examples --- presets/examples/7.jsonc | 48 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/presets/examples/7.jsonc b/presets/examples/7.jsonc index 04f3c60b1..59048f7d2 100644 --- a/presets/examples/7.jsonc +++ b/presets/examples/7.jsonc @@ -3,12 +3,11 @@ { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - // "logo": { - // "type": "iterm", - // "source": "/Users/carter/Desktop/apple1.png", - // "width": 28, - // "height": 12 - // }, + "logo": { + "padding": { + "top": 2 + } + }, "display": { "separator": " -> " }, @@ -18,25 +17,24 @@ { "type": "os", "key": " OS", - "keyColor": "blue", + "keyColor": "yellow", "format": "{2}" }, { "type": "os", "key": "├", // Just get your distro's logo off nerdfonts.com - "keyColor": "blue", + "keyColor": "yellow", "format": "{6}{?6} {?}{10} {8}" }, { "type": "kernel", "key": "├", - "format": "{1} {2}", - "keyColor": "blue" + "keyColor": "yellow" }, { "type": "packages", "key": "├󰏖", - "keyColor": "blue" + "keyColor": "yellow" }, { "type": "shell", @@ -48,32 +46,32 @@ { "type": "wm", "key": " DE/WM", - "keyColor": "yellow" + "keyColor": "blue" }, { "type": "lm", "key": "├󰧨", - "keyColor": "yellow" + "keyColor": "blue" }, { "type": "wmtheme", "key": "├󰉼", - "keyColor": "yellow" + "keyColor": "blue" }, { "type": "icons", "key": "├󰀻", - "keyColor": "yellow" + "keyColor": "blue" }, { "type": "terminal", "key": "├", - "keyColor": "yellow" + "keyColor": "blue" }, { "type": "wallpaper", "key": "└󰸉", - "keyColor": "yellow" + "keyColor": "blue" }, "break", @@ -110,7 +108,7 @@ { "type": "uptime", "key": "├󰅐", - "keyColor": "blue" + "keyColor": "green" }, { "type": "display", @@ -120,19 +118,19 @@ "break", { - "type": "media", - "key": "󰝚 SONG", - "keyColor": "blue" + "type": "sound", + "key": " SOUND", + "keyColor": "cyan" }, { "type": "player", "key": "├󰥠", - "keyColor": "blue" + "keyColor": "cyan" }, { - "type": "sound", - "key": "└", - "keyColor": "green" + "type": "media", + "key": "└󰝚", + "keyColor": "cyan" }, "break", From 71ed353fde5c39b8ccd78881a965e80abe1f96e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 6 Jul 2023 15:49:41 +0800 Subject: [PATCH 277/493] Logo (Builtin): make Windows 11 small colorable --- src/logo/builtin.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index a86cdfdf1..b5a0985ff 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1539,15 +1539,15 @@ static const FFlogo* getLogoWindows11Small(void) FF_LOGO_INIT FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") FF_LOGO_LINES( - "$1lllllllll lllllllll\n" - "lllllllll lllllllll\n" - "lllllllll lllllllll\n" - "lllllllll lllllllll\n" + "$1lllllllll $2lllllllll\n" + "$1lllllllll $2lllllllll\n" + "$1lllllllll $2lllllllll\n" + "$1lllllllll $2lllllllll\n" "\n" - "lllllllll lllllllll\n" - "lllllllll lllllllll\n" - "lllllllll lllllllll\n" - "lllllllll lllllllll\n" + "$3lllllllll $4lllllllll\n" + "$3lllllllll $4lllllllll\n" + "$3lllllllll $4lllllllll\n" + "$3lllllllll $4lllllllll\n" ) FF_LOGO_COLORS( "34" //blue From e7db3cd7fe766198027ea77945034799d2bf1a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 6 Jul 2023 23:16:05 +0800 Subject: [PATCH 278/493] Logo: support builtin small logo Also improve performance of builtin logo finding Assume you are running macOS * default -> macos * `-l small` -> macos_small * `--logo-type small` -> macos_small * `-l macos` -> macos * `-l macos --logo-type small` -> macos_small * `-l macos_small` -> macos_small * `-l macos_small --logo-type small` -> error, because Logo `macos_small_small` doesn't exist --- README.md | 2 +- doc/json_schema.json | 1 + src/logo/builtin.c | 96 +++++++++++++++++++++++++++++++------------- src/logo/logo.c | 85 +++++++++++++++++++++++++-------------- src/logo/logo.h | 1 + src/logo/option.c | 10 ++++- src/logo/option.h | 1 + 7 files changed, 134 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 208279acd..11af03dae 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Currently, the performance difference is measurable, but too small to be recogni There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config `. They may also serve as a good example for format arguments. -Logos can be heavily customized too; see the [logo documentation](doc/logo.md) for more information. +Logos can be heavily customized too; see the [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for more information. ## Dependencies diff --git a/doc/json_schema.json b/doc/json_schema.json index 6b03607df..b12848e4f 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -45,6 +45,7 @@ "enum": [ "auto", "builtin", + "small", "file", "file-raw", "data", diff --git a/src/logo/builtin.c b/src/logo/builtin.c index b5a0985ff..f5e278944 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1,6 +1,8 @@ #include "logo.h" #define FF_LOGO_INIT static FFlogo logo; static bool init = false; if(init) return &logo; init = true; +// The names of small logo must end with `_small` or `-small` +#define FF_LOGO_INIT_SMALL FF_LOGO_INIT logo.small = true; #define FF_LOGO_NAMES(...) static const char* names[] = (const char*[]) { __VA_ARGS__, NULL }; logo.names = names; #define FF_LOGO_LINES(x) logo.data = x; #define FF_LOGO_COLORS(...) static const char* colors[] = (const char*[]) { __VA_ARGS__, NULL }; logo.builtinColors = colors; @@ -112,7 +114,7 @@ static const FFlogo* getLogoAlpine(void) static const FFlogo* getLogoAlpineSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("alpine_small", "alpine-linux-small") FF_LOGO_LINES( " /\\ /\\\n" @@ -165,7 +167,7 @@ static const FFlogo* getLogoAndroid(void) static const FFlogo* getLogoAndroidSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("android-small", "android_small") FF_LOGO_LINES( " ;, ,;\n" @@ -219,7 +221,7 @@ static const FFlogo* getLogoArch(void) static const FFlogo* getLogoArchSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("arch_small", "archlinux_small", "arch-linux-small") FF_LOGO_LINES( " /\\\n" @@ -274,7 +276,7 @@ static const FFlogo* getLogoArtix(void) static const FFlogo* getLogoArtixSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("artix_small", "artixlinux_small", "artix-linux-small") FF_LOGO_LINES( " /\\\n" @@ -437,7 +439,7 @@ static const FFlogo* getLogoCachyOS(void) static const FFlogo* getLogoCachyOSSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small") FF_LOGO_LINES( " /''''''''''''/\n" @@ -527,7 +529,7 @@ static const FFlogo* getLogoCentOS(void) static const FFlogo* getLogoCentOSSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small") FF_LOGO_LINES( " $2____$1^$4____\n" @@ -653,7 +655,7 @@ static const FFlogo* getLogoDebian(void) static const FFlogo* getLogoDebianSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("debian_small", "debian-linux-small") FF_LOGO_LINES( " _____\n" @@ -702,7 +704,7 @@ static const FFlogo* getLogoDevuan(void) static const FFlogo* getLogoDevuanSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("devuan_small", "devuan-linux-small") FF_LOGO_LINES( " ..:::.\n" @@ -853,7 +855,7 @@ static const FFlogo* getLogoFedora(void) static const FFlogo* getLogoFedoraSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("fedora_small", "fedora-linux-small") FF_LOGO_LINES( " ,'''''.\n" @@ -938,7 +940,7 @@ static const FFlogo* getLogoFreeBSD(void) static const FFlogo* getLogoFreeBSDSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("freebsd_small") FF_LOGO_LINES( "$1/\\,-'''''-,/\\\n" @@ -990,7 +992,7 @@ static const FFlogo* getLogoGaruda(void) static const FFlogo* getLogoGarudaSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("garuda_small", "garudalinux_small", "garuda-linux-small") FF_LOGO_LINES( " .----.\n" @@ -1042,7 +1044,7 @@ static const FFlogo* getLogoGentoo(void) static const FFlogo* getLogoGentooSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("gentoo_small", "gentoo-linux-small") FF_LOGO_LINES( " _-----_\n" @@ -1243,7 +1245,7 @@ static const FFlogo* getLogoMacOS(void) FF_LOGO_INIT FF_LOGO_NAMES("macos", "mac", "apple", "darwin", "osx") FF_LOGO_LINES( - " $1c.'\n" + " $1..'\n" " ,xNMM.\n" " .OMMMMo\n" " lMM\"\n" @@ -1275,7 +1277,7 @@ static const FFlogo* getLogoMacOS(void) static const FFlogo* getLogoMacOSSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("macos_small", "mac_small", "apple_small", "darwin_small", "osx_small") FF_LOGO_LINES( "$1 .:'\n" @@ -1298,10 +1300,45 @@ static const FFlogo* getLogoMacOSSmall(void) FF_LOGO_RETURN } -static const FFlogo* getLogoMacOSSmall2(void) +static const FFlogo* getLogoMacOS2(void) { FF_LOGO_INIT - FF_LOGO_NAMES("macos_small2", "mac_small2", "apple_small2", "darwin_small2", "osx_small2") + FF_LOGO_NAMES("macos2", "mac2", "apple2", "darwin2", "osx2") + FF_LOGO_LINES( + " $1..'\n" + " ,xN .\n" + " .O o\n" + " l \"\n" + " .;loddo:. .olloddol;.\n" + " cK NW 0:\n" + " $2.K Wd.\n" + " X X.\n" + "$3; :\n" + ": :\n" + ". X.\n" + " k Wd.\n" + " $4'X k\n" + " 'X K.\n" + " $5k d\n" + " ;K WXXW k.\n" + " \"cooc*\" \"*coo'\"" + ) + FF_LOGO_COLORS( + "32", //green + "33", //yellow + "31", //red + "35", //magenta + "34" //blue + ) + FF_LOGO_COLOR_KEYS("33"); //yellow + FF_LOGO_COLOR_TITLE("32"); //green + FF_LOGO_RETURN +} + +static const FFlogo* getLogoMacOS2Small(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("macos2_small", "mac2_small", "apple2_small", "darwin2_small", "osx2_small") FF_LOGO_LINES( "$1 .:'\n" " __ :'__\n" @@ -1353,7 +1390,7 @@ static const FFlogo* getLogoManjaro(void) static const FFlogo* getLogoManjaroSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("manjaro_small", "manjaro-linux-small") FF_LOGO_LINES( "||||||||| ||||\n" @@ -1408,7 +1445,7 @@ static const FFlogo* getLogoMint(void) static const FFlogo* getLogoMintSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("mint_small", "linuxmint_small", "mint-linux-small") FF_LOGO_LINES( " __________\n" @@ -1536,7 +1573,7 @@ static const FFlogo* getLogoWindows11(void) static const FFlogo* getLogoWindows11Small(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") FF_LOGO_LINES( "$1lllllllll $2lllllllll\n" @@ -1706,7 +1743,7 @@ static const FFlogo* getLogoNixOsOld(void) static const FFlogo* getLogoNixOsSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small") FF_LOGO_LINES( "$1 \\\\ \\\\ //\n" @@ -1791,7 +1828,7 @@ static const FFlogo* getLogoOpenSuse(void) static const FFlogo* getLogoOpenSuseSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("suse_small", "opensuse_small", "open_suse_small", "open-suse_small") FF_LOGO_LINES( " _______\n" @@ -1973,7 +2010,7 @@ static const FFlogo* getLogoParabola(void) static const FFlogo* getLogoParabolaSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("parabola_small", "parabola-gnulinux_small") FF_LOGO_LINES( " __ __ __ _\n" @@ -1993,7 +2030,7 @@ static const FFlogo* getLogoParabolaSmall(void) static const FFlogo* getLogoPopSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("pop_small", "popos_small", "pop_os_small", "pop-linux-small") FF_LOGO_LINES( "______\n" @@ -2052,7 +2089,7 @@ static const FFlogo* getLogoRaspbian(void) static const FFlogo* getLogoRaspbianSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small") FF_LOGO_LINES( " $2.~~. .~~.\n" @@ -2112,7 +2149,7 @@ static const FFlogo* getLogoReborn(void) static const FFlogo* getLogoRebornSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small") FF_LOGO_LINES( " _______________\n" @@ -2304,7 +2341,7 @@ static const FFlogo* getLogoSlackware(void) static const FFlogo* getLogoSlackwareSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small") FF_LOGO_LINES( " ________\n" @@ -2464,7 +2501,7 @@ static const FFlogo* getLogoUbuntuOld(void) static const FFlogo* getLogoUbuntuSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("ubuntu_small", "ubuntu-linux-small") FF_LOGO_LINES( " _\n" @@ -2550,7 +2587,7 @@ static const FFlogo* getLogoVoid(void) static const FFlogo* getLogoVoidSmall(void) { - FF_LOGO_INIT + FF_LOGO_INIT_SMALL FF_LOGO_NAMES("void_small", "void-linux-small") FF_LOGO_LINES( " _______\n" @@ -2647,7 +2684,8 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoLinux, getLogoMacOS, getLogoMacOSSmall, - getLogoMacOSSmall2, + getLogoMacOS2, + getLogoMacOS2Small, getLogoManjaro, getLogoManjaroSmall, getLogoMint, diff --git a/src/logo/logo.c b/src/logo/logo.c index c1e2b9f28..449901856 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -4,10 +4,18 @@ #include "detection/os/os.h" #include "detection/terminalshell/terminalshell.h" #include "util/textModifier.h" +#include "util/stringUtils.h" #include #include +typedef enum FFLogoSize +{ + FF_LOGO_SIZE_UNKNOWN, + FF_LOGO_SIZE_NORMAL, + FF_LOGO_SIZE_SMALL, +} FFLogoSize; + static void ffLogoPrintCharsRaw(const char* data, size_t length) { FFLogoOptions* options = &instance.config.logo; @@ -177,58 +185,71 @@ static void logoApplyColors(const FFlogo* logo) ffStrbufAppendS(&instance.config.colorTitle, logo->colorTitle); } -static bool logoHasName(const FFlogo* logo, const char* name) +static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) { - const char** logoName = logo->names; - - while(*logoName != NULL) + for(const char** logoName = logo->names; *logoName != NULL; ++logoName) { - if(strcasecmp(*logoName, name) == 0) + if(small) + { + uint32_t logoNameLength = (uint32_t) (strlen(*logoName) - strlen("_small")); + if(name->length == logoNameLength && strncasecmp(*logoName, name->chars, logoNameLength) == 0) return true; + } + if(ffStrbufIgnCaseEqualS(name, *logoName)) return true; - ++logoName; } return false; } -static const FFlogo* logoGetBuiltin(const char* name) +static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) { - GetLogoMethod* methods = ffLogoBuiltinGetAll(); + if (name->length == 0) + return NULL; - while(*methods != NULL) + for(GetLogoMethod* methods = ffLogoBuiltinGetAll(); *methods; ++methods) { const FFlogo* logo = (*methods)(); - if(logoHasName(logo, name)) - return logo; + switch (size) + { + case FF_LOGO_SIZE_NORMAL: + if(logo->small) continue; + break; + case FF_LOGO_SIZE_SMALL: + if(!logo->small) continue; + break; + default: + break; + } - ++methods; + if(logoHasName(logo, name, size == FF_LOGO_SIZE_SMALL)) + return logo; } return NULL; } -static const FFlogo* logoGetBuiltinDetected(void) +static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) { const FFOSResult* os = ffDetectOS(); - const FFlogo* logo = logoGetBuiltin(os->id.chars); + const FFlogo* logo = logoGetBuiltin(&os->id, size); if(logo != NULL) return logo; - logo = logoGetBuiltin(os->name.chars); + logo = logoGetBuiltin(&os->name, size); if(logo != NULL) return logo; - logo = logoGetBuiltin(os->prettyName.chars); + logo = logoGetBuiltin(&os->prettyName, size); if(logo != NULL) return logo; - logo = logoGetBuiltin(os->idLike.chars); + logo = logoGetBuiltin(&os->idLike, size); if(logo != NULL) return logo; - logo = logoGetBuiltin(instance.state.platform.systemName.chars); + logo = logoGetBuiltin(&instance.state.platform.systemName, size); if(logo != NULL) return logo; @@ -237,7 +258,7 @@ static const FFlogo* logoGetBuiltinDetected(void) static inline void logoApplyColorsDetected(void) { - logoApplyColors(logoGetBuiltinDetected()); + logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL)); } static void logoPrintStruct(const FFlogo* logo) @@ -263,15 +284,15 @@ static void logoPrintNone(void) instance.state.logoWidth = 0; } -static bool logoPrintBuiltinIfExists(const char* name) +static bool logoPrintBuiltinIfExists(const FFstrbuf* name, FFLogoSize size) { - if(strcasecmp(name, "none") == 0) + if(ffStrbufIgnCaseEqualS(name, "none")) { logoPrintNone(); return true; } - const FFlogo* logo = logoGetBuiltin(name); + const FFlogo* logo = logoGetBuiltin(name, size); if(logo == NULL) return false; @@ -280,12 +301,13 @@ static bool logoPrintBuiltinIfExists(const char* name) return true; } -static inline void logoPrintDetected(void) +static inline void logoPrintDetected(FFLogoSize size) { - logoPrintStruct(logoGetBuiltinDetected()); + logoPrintStruct(logoGetBuiltinDetected(size)); } -static bool logoPrintData(bool doColorReplacement) { +static bool logoPrintData(bool doColorReplacement) +{ FFLogoOptions* options = &instance.config.logo; if(options->source.length == 0) return false; @@ -360,7 +382,10 @@ static bool logoTryKnownType(void) } if(options->type == FF_LOGO_TYPE_BUILTIN) - return logoPrintBuiltinIfExists(options->source.chars); + return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_NORMAL); + + if(options->type == FF_LOGO_TYPE_SMALL) + return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_SMALL); if(options->type == FF_LOGO_TYPE_DATA) return logoPrintData(true); @@ -393,7 +418,7 @@ static bool logoTryKnownType(void) static void logoPrintKnownType(void) { if(!logoTryKnownType()) - logoPrintDetected(); + logoPrintDetected(FF_LOGO_SIZE_UNKNOWN); } void ffLogoPrint(void) @@ -419,7 +444,7 @@ void ffLogoPrint(void) //If the source is not set, we can directly print the detected logo. if(options->source.length == 0) { - logoPrintDetected(); + logoPrintDetected(options->type == FF_LOGO_TYPE_SMALL ? FF_LOGO_SIZE_SMALL : FF_LOGO_SIZE_NORMAL); return; } @@ -431,7 +456,7 @@ void ffLogoPrint(void) } //If source matches the name of a builtin logo, print it and return. - if(logoPrintBuiltinIfExists(options->source.chars)) + if(logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_UNKNOWN)) return; //Make sure the logo path is set correctly. @@ -454,7 +479,7 @@ void ffLogoPrint(void) if(logoPrintFileIfExists(true, false)) return; - logoPrintDetected(); + logoPrintDetected(FF_LOGO_SIZE_UNKNOWN); } void ffLogoPrintLine(void) diff --git a/src/logo/logo.h b/src/logo/logo.h index 4c4d42c3f..6bbfa7cff 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -12,6 +12,7 @@ typedef struct FFlogo const char** builtinColors; //Null terminated const char* colorKeys; const char* colorTitle; + bool small; } FFlogo; typedef const FFlogo*(*GetLogoMethod)(); diff --git a/src/logo/option.c b/src/logo/option.c index a277616a8..86433f90f 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -35,8 +35,6 @@ bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const ch if (subKey[0] == '\0') { logoType: - ffOptionParseString(key, value, &options->source); - //this is usally wanted when using the none logo if(strcasecmp(value, "none") == 0) { @@ -45,12 +43,19 @@ logoType: options->paddingLeft = 0; options->type = FF_LOGO_TYPE_NONE; } + else if(strcasecmp(value, "small") == 0) + { + options->type = FF_LOGO_TYPE_SMALL; + } + else + ffOptionParseString(key, value, &options->source); } else if(strcasecmp(subKey, "type") == 0) { options->type = (FFLogoType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { { "auto", FF_LOGO_TYPE_AUTO }, { "builtin", FF_LOGO_TYPE_BUILTIN }, + { "small", FF_LOGO_TYPE_SMALL }, { "file", FF_LOGO_TYPE_FILE }, { "file-raw", FF_LOGO_TYPE_FILE_RAW }, { "data", FF_LOGO_TYPE_DATA }, @@ -231,6 +236,7 @@ const char* ffParseLogoJsonConfig(void) const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { { "auto", FF_LOGO_TYPE_AUTO }, { "builtin", FF_LOGO_TYPE_BUILTIN }, + { "small", FF_LOGO_TYPE_SMALL }, { "file", FF_LOGO_TYPE_FILE }, { "file-raw", FF_LOGO_TYPE_FILE_RAW }, { "data", FF_LOGO_TYPE_DATA }, diff --git a/src/logo/option.h b/src/logo/option.h index 09f7822d1..9039b4b57 100644 --- a/src/logo/option.h +++ b/src/logo/option.h @@ -8,6 +8,7 @@ typedef enum FFLogoType { FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo FF_LOGO_TYPE_BUILTIN, //builtin ascii art + FF_LOGO_TYPE_SMALL, //builtin ascii art, small version FF_LOGO_TYPE_FILE, //text file, printed with color code replacement FF_LOGO_TYPE_FILE_RAW, //text file, printed as is FF_LOGO_TYPE_DATA, //text data, printed with color code replacement From b9f192682ca3caea6bb3110a778ecbb8b7196b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 6 Jul 2023 23:26:45 +0800 Subject: [PATCH 279/493] Doc: update changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce67506c..7c622cc65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,17 @@ Changes: * Remove `--display-detect-name`. Display name is always detected, and will be printed if multiple displays are detected * Deprecate `--set` and `--set-keyless`; they may be removed in future releases. Use JSON config with Custom module instead * Remove the special handling of Command module (it can be set once in the triditional `config.conf`). Use JSON config with Command module instead +* Change `--wm-theme-*` to `--wmtheme-*`. Affect `key` and `format` +* Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module * Support `--colors-symbol` and `--colors-padding-left` -* Add LM (Login Manager) module +* Add LM (Login Manager) module. Currently requires systemd installed (thus Linux only) * Add `--wmi-timeout` option (Windows) +* Add `--logo-type small` to search for small logos # 1.12.2 From 53569d5a66ae450e00f3a0593c339fae1ee895b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 7 Jul 2023 09:40:04 +0800 Subject: [PATCH 280/493] Terminal: support Cockpit version detection --- src/detection/terminalshell/terminalshell.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 96f63bbbf..95779576f 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -214,6 +214,16 @@ FF_MAYBE_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrb return version->length > 0; } +FF_MAYBE_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* version) +{ + if(!getExeVersionRaw(exe, version)) return false; + + //Version: 295\n... + ffStrbufSubstrBeforeFirstC(version, '\n'); + ffStrbufSubstrAfterFirstC(version, ' '); + return version->length > 0; +} + #ifdef _WIN32 static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) @@ -278,6 +288,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "mate-terminal")) return getTerminalVersionMateTerminal(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "cockpit-bridge")) + return getTerminalVersionCockpit(exe, version); + #endif #ifdef _WIN32 From 09d843d47f5a977dd4e47ef8c594609c34cba9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 09:30:13 +0800 Subject: [PATCH 281/493] CMake: don't install global config file No one use it. Note we just don't install the default config file with `make install`; `/etc/fastfetch/config.conf` is still looked at runtime. Fix #491 --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b93e61332..9d06a6e17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -845,12 +845,6 @@ install( DESTINATION "${CMAKE_INSTALL_BINDIR}" ) -install( - FILES "${CMAKE_SOURCE_DIR}/src/data/config_system.txt" - DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}" - RENAME "config.conf" -) - install( FILES "${CMAKE_SOURCE_DIR}/completions/bash" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions" From 11cd79542564b0eac349267a533e6014b766b144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 09:16:13 +0800 Subject: [PATCH 282/493] LM (Linux): detection LightDM version --- src/detection/lm/lm_linux.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index b698a2ae4..f20c6bd90 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -93,6 +93,22 @@ static const char* getXfwmVersion(FFstrbuf* version) return NULL; } +static const char* getLightdmVersion(FFstrbuf* version) +{ + const char* error = = ffProcessAppendStdOut(version, (char* const[]) { + "lightdm", + "--version", + NULL + }); + if (error) + return error; + + // lightdm 1.30.0 + ffStrbufSubstrAfterFirstC(version, ' '); + + return NULL; +} + const char* ffDetectLM(FFLMResult* result) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); @@ -129,6 +145,8 @@ const char* ffDetectLM(FFLMResult* result) getSddmVersion(&result->version); else if (ffStrbufStartsWithS(&result->service, "xfwm")) getXfwmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "lightdm")) + getLightdmVersion(&result->version); // Correct char cases if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND)) From 713a62b383ab5128209535c758f21426c2943858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 09:17:25 +0800 Subject: [PATCH 283/493] Logo: fix segfault with `fastfetch -l` --- src/logo/option.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/logo/option.c b/src/logo/option.c index 86433f90f..425dd056f 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -35,7 +35,12 @@ bool ffParseLogoCommandOptions(FFLogoOptions* options, const char* key, const ch if (subKey[0] == '\0') { logoType: - //this is usally wanted when using the none logo + if(value == NULL) + { + fprintf(stderr, "Error: usage: %s \n", key); + exit(477); + } + //this is usually wanted when disabling logo if(strcasecmp(value, "none") == 0) { options->paddingTop = 0; From 55c516a14b003d29edf0cfbb73701401ebcefb0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 10:06:04 +0800 Subject: [PATCH 284/493] DisplayServer: prepare for DDC/CI --- src/detection/displayserver/displayserver.c | 4 ++- src/detection/displayserver/displayserver.h | 4 ++- .../displayserver/displayserver_apple.c | 3 +- .../displayserver/displayserver_windows.c | 29 ++++++++++++------- .../displayserver/linux/displayserver_linux.c | 3 +- src/detection/displayserver/linux/wayland.c | 3 +- src/detection/displayserver/linux/xcb.c | 15 ++++++---- src/detection/displayserver/linux/xlib.c | 12 +++++--- 8 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index 538ff7d89..0b0db7833 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -11,7 +11,8 @@ bool ffdsAppendDisplay( uint32_t rotation, FFstrbuf* name, FFDisplayType type, - bool primary) + bool primary, + uint64_t id) { if(width == 0 || height == 0) return false; @@ -26,6 +27,7 @@ bool ffdsAppendDisplay( ffStrbufInitMove(&display->name, name); display->type = type; display->primary = primary; + display->id = id; return true; } diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index d45f43070..b4ab5283b 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -58,6 +58,7 @@ typedef struct FFDisplayResult FFDisplayType type; uint32_t rotation; bool primary; + uint64_t id; // platform dependent } FFDisplayResult; typedef struct FFDisplayServerResult @@ -83,6 +84,7 @@ bool ffdsAppendDisplay( uint32_t rotation, FFstrbuf* name, FFDisplayType type, - bool primary); + bool primary, + uint64_t id); #endif diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 0a7ddde5a..d004647d4 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -63,7 +63,8 @@ static void detectDisplays(FFDisplayServerResult* ds) (uint32_t)CGDisplayRotation(screen), &name, CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL, - screen == primary + screen == primary, + (uint64_t)screen ); CGDisplayModeRelease(mode); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 0a91eedb1..a37c506b1 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -6,6 +6,12 @@ #include #include +typedef struct FFMonitorInfo +{ + HMONITOR handle; + MONITORINFOEXW info; +} FFMonitorInfo; + static CALLBACK BOOL MonitorEnumProc( HMONITOR hMonitor, FF_MAYBE_UNUSED HDC hdc, @@ -14,14 +20,16 @@ static CALLBACK BOOL MonitorEnumProc( ) { FFlist* monitors = (FFlist*) lParam; - MONITORINFOEXW* newMonitor = ffListAdd(monitors); - newMonitor->cbSize = sizeof(*newMonitor); - return GetMonitorInfoW(hMonitor, (MONITORINFO*) newMonitor); + FFMonitorInfo* newMonitor = ffListAdd(monitors); + newMonitor->handle = hMonitor; + newMonitor->info.cbSize = sizeof(newMonitor->info); + + return GetMonitorInfoW(hMonitor, (MONITORINFO*) &newMonitor->info); } static void detectDisplays(FFDisplayServerResult* ds) { - FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(MONITORINFOEXW)); + FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(FFMonitorInfo)); EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) &monitors); DISPLAYCONFIG_PATH_INFO paths[128]; @@ -50,12 +58,12 @@ static void detectDisplays(FFDisplayServerResult* ds) }, }; - MONITORINFOEXW* monitorInfo = NULL; + FFMonitorInfo* monitorInfo = NULL; if (DisplayConfigGetDeviceInfo(&sourceName.header) == ERROR_SUCCESS) { - FF_LIST_FOR_EACH(MONITORINFOEXW, item, monitors) + FF_LIST_FOR_EACH(FFMonitorInfo, item, monitors) { - if (wcsncmp(item->szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0) + if (wcsncmp(item->info.szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0) { monitorInfo = item; break; @@ -117,15 +125,16 @@ static void detectDisplays(FFDisplayServerResult* ds) width, height, path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator, - (uint32_t) (monitorInfo->rcMonitor.right - monitorInfo->rcMonitor.left), - (uint32_t) (monitorInfo->rcMonitor.bottom - monitorInfo->rcMonitor.top), + (uint32_t) (monitorInfo->info.rcMonitor.right - monitorInfo->info.rcMonitor.left), + (uint32_t) (monitorInfo->info.rcMonitor.bottom - monitorInfo->info.rcMonitor.top), rotation, &name, path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL, - !!(monitorInfo->dwFlags & MONITORINFOF_PRIMARY) + !!(monitorInfo->info.dwFlags & MONITORINFOF_PRIMARY), + (uint64_t)(uintptr_t) monitorInfo->handle ); } } diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 65f1075ba..506f519b1 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -53,7 +53,8 @@ static void parseDRM(FFDisplayServerResult* result) 0, &name, FF_DISPLAY_TYPE_UNKNOWN, - false + false, + 0 ); } diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 0f2ec77c6..814129e8a 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -187,7 +187,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist rotation, &display.name, display.type, - false + false, + 0 ); ffThreadMutexUnlock(&mutex); diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 47c5ec851..0858690ed 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -128,7 +128,8 @@ void ffdsConnectXcb(FFDisplayServerResult* result) 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, - false + false, + 0 ); ffxcb_screen_next(&iterator); } @@ -198,7 +199,8 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo rotation, name, FF_DISPLAY_TYPE_UNKNOWN, - primary + primary, + 0 ); } @@ -255,7 +257,8 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb rotation, name, FF_DISPLAY_TYPE_UNKNOWN, - primary + primary, + 0 ); free(crtcInfoReply); @@ -315,7 +318,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* 0, &name, FF_DISPLAY_TYPE_UNKNOWN, - !!monitor->primary + !!monitor->primary, + 0 ); } @@ -379,7 +383,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, - false + false, + 0 ); } diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 288763ee6..7bccf5faa 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -86,7 +86,8 @@ void ffdsConnectXlib(FFDisplayServerResult* result) 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, - false + false, + 0 ); } @@ -184,7 +185,8 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary) rotation, NULL, FF_DISPLAY_TYPE_UNKNOWN, - primary + primary, + 0 ); data->ffXRRFreeCrtcInfo(crtcInfo); @@ -224,7 +226,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, - !!monitorInfo->primary + !!monitorInfo->primary, + 0 ); } @@ -282,7 +285,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, - false + false, + 0 ); } From faf6d139d1b7b7ec8969d8429749cfa1b96b3e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 10:28:39 +0800 Subject: [PATCH 285/493] Brightness (Windows): detect brightness of external monitors with DDC/CI --- CMakeLists.txt | 1 + .../brightness/brightness_windows.cpp | 54 ++++++++++++++++--- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d06a6e17..dc95b0fcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -755,6 +755,7 @@ elseif(WIN32) PRIVATE "setupapi" PRIVATE "hid" PRIVATE "wtsapi32" + PRIVATE "dxva2" ) elseif(BSD) target_link_libraries(libfastfetch diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index 0f86ba49e..a085c71c5 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -1,12 +1,15 @@ extern "C" { #include "brightness.h" +#include "detection/displayserver/displayserver.h" } #include "util/windows/wmi.hpp" #include "util/windows/unicode.hpp" -extern "C" -const char* ffDetectBrightness(FFlist* result) +#include +#include + +static const char* detectWithWmi(FFlist* result) { FFWmiQuery query(L"SELECT CurrentBrightness, InstanceName FROM WmiMonitorBrightness WHERE Active = true", nullptr, FFWmiNamespace::WMI); if(!query) @@ -16,17 +19,52 @@ const char* ffDetectBrightness(FFlist* result) { if(FFWmiVariant vtValue = record.get(L"CurrentBrightness")) { - FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); - display->value = vtValue.get(); + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = vtValue.get(); - ffStrbufInit(&display->name); + ffStrbufInit(&brightness->name); if (FFWmiVariant vtName = record.get(L"InstanceName")) { - ffStrbufSetWSV(&display->name, vtName.get()); - ffStrbufSubstrAfterFirstC(&display->name, '\\'); - ffStrbufSubstrBeforeFirstC(&display->name, '\\'); + ffStrbufSetWSV(&brightness->name, vtName.get()); + ffStrbufSubstrAfterFirstC(&brightness->name, '\\'); + ffStrbufSubstrBeforeFirstC(&brightness->name, '\\'); } } } return NULL; } + +static char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result) +{ + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + { + PHYSICAL_MONITOR physicalMonitor; + if (GetPhysicalMonitorsFromHMONITOR((HMONITOR)(uintptr_t) display->id, 1, &physicalMonitor)) + { + DWORD min = 0, curr = 0, max = 0; + if (GetMonitorBrightness(physicalMonitor.hPhysicalMonitor, &min, &curr, &max)) + { + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + + if (display->name.length) + ffStrbufInitCopy(&brightness->name, &display->name); + else + ffStrbufInitWS(&brightness->name, physicalMonitor.szPhysicalMonitorDescription); + + brightness->value = (float) (curr - min) * 100.f / (float) (max - min); + } + } + } + return NULL; +} + +extern "C" +const char* ffDetectBrightness(FFlist* result) +{ + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + + detectWithWmi(result); + if (instance.config.allowSlowOperations && result->length < displayServer->displays.length) + detectWithDdcci(displayServer, result); + return NULL; +} From 30afe7e86b897d1c855547e378b0c727aece8ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 8 Jul 2023 23:56:44 +0800 Subject: [PATCH 286/493] Brightness (macOS): detect brightness of external monitors with DDC/CI --- src/detection/brightness/brightness_apple.c | 95 ++++++++++++++------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index b318e0a6a..d9c8454f0 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -1,50 +1,85 @@ #include "brightness.h" +#include "detection/displayserver/displayserver.h" #include "util/apple/cf_helpers.h" #include extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float *brightness) __attribute__((weak_import)); -extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); + +// DDC/CI +typedef CFTypeRef IOAVServiceRef; +extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator); +extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service); +extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2); +extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize); +extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize); + +static void getNameFromEdid(uint8_t edid[128], FFstrbuf* name) +{ + // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c + for (uint32_t i = 0x36; i < 0x7E; i += 0x12) + { // read through descriptor blocks... + if (edid[i] == 0x00) + { // not a timing descriptor + if (edid[i+3] == 0xfc) + { // Model Name tag + for (uint32_t j = 0; j < 13; j++) + { + if (edid[i + 5 + j] == 0x0a) + return; + ffStrbufAppendC(name, (char) edid[i + 5 + j]); + } + } + } + } +} const char* ffDetectBrightness(FFlist* result) { if(DisplayServicesGetBrightness == NULL) return "DisplayServices function DisplayServicesGetBrightness is not available"; - CGDirectDisplayID screens[128]; - uint32_t screenCount; - if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess) - return "CGGetOnlineDisplayList() failed"; + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); - for(uint32_t i = 0; i < screenCount; i++) + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) { - CGDirectDisplayID screen = screens[i]; - float brightness; - if(DisplayServicesGetBrightness(screen, &brightness) != kCGErrorSuccess) - continue; - - FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); - display->value = brightness * 100; - ffStrbufInit(&display->name); - - if(CoreDisplay_DisplayCreateInfoDictionary) + float value; + if(DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) { - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); - if(displayInfo) - { - CFDictionaryRef productNames; - if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - { - if(!ffCfDictGetString(productNames, CFSTR("en_US"), &display->name)) - continue; - } - } + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = value * 100; + ffStrbufInitCopy(&brightness->name, &display->name); + continue; } + } - if(CGDisplayIsBuiltin(screen)) - ffStrbufAppendS(&display->name, "built-in"); - else - ffStrbufAppendF(&display->name, "external-%u", (unsigned) screen); + if (!instance.config.allowSlowOperations) + return NULL; + + // https://github.com/waydabber/m1ddc + // This only works for Apple Silicon and USB-C adapter connection ( but not HTMI ) + FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreate(kCFAllocatorDefault); + uint8_t i2cData[12] = { 0x82, 0x01, 0x00 }; + i2cData[3] = 0x6e ^ i2cData[0] ^ i2cData[1] ^ i2cData[2] ^ i2cData[3]; + + for (uint32_t i = 0; i < 3; ++i) + { + IOAVServiceWriteI2C(service, 0x37, 0x51, i2cData, 4); + usleep(10000); + } + + memset(i2cData, 0, sizeof(i2cData)); + if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cData, sizeof(i2cData)) == KERN_SUCCESS) + { + uint8_t current = i2cData[9], max = i2cData[7]; + + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = (float) current * 100.f / max; + ffStrbufInit(&brightness->name); + + uint8_t edid[128] = {}; + if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, sizeof(edid)) == KERN_SUCCESS) + getNameFromEdid(edid, &brightness->name); } return NULL; From f1667357f5eb9b27e724c0c329db3c05d6f914c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 00:36:29 +0800 Subject: [PATCH 287/493] LM (Linux): fix compiling --- src/detection/lm/lm_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index f20c6bd90..c85fc5bf9 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -60,7 +60,7 @@ static const char* getSddmVersion(FFstrbuf* version) } ffStrbufSubstrBefore(version, ffStrbufNextIndexC(version, index, '\n')); - ffStrbufSubstrAfter(version, index + strlen(".TH ")); + ffStrbufSubstrAfter(version, index + (uint32_t) strlen(".TH ")); // "SDDM" 1 "May 2014" "sddm 0.20.0" "sddm" ffStrbufSubstrBeforeLastC(version, ' '); @@ -95,7 +95,7 @@ static const char* getXfwmVersion(FFstrbuf* version) static const char* getLightdmVersion(FFstrbuf* version) { - const char* error = = ffProcessAppendStdOut(version, (char* const[]) { + const char* error = ffProcessAppendStdOut(version, (char* const[]) { "lightdm", "--version", NULL From 300d06ffcd398988c923512e98c7219e9e4a9c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 16:56:12 +0800 Subject: [PATCH 288/493] Fastfetch: don't hide cursor in DEBUG mode --- src/common/init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/init.c b/src/common/init.c index 061d70344..d684fae1a 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -49,8 +49,15 @@ static void defaultConfig(void) instance.config.recache = false; instance.config.allowSlowOperations = false; instance.config.pipe = !isatty(STDOUT_FILENO); + + #ifdef NDEBUG instance.config.disableLinewrap = !instance.config.pipe; instance.config.hideCursor = !instance.config.pipe; + #else + instance.config.disableLinewrap = false; + instance.config.hideCursor = false; + #endif + instance.config.escapeBedrock = true; instance.config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; instance.config.multithreading = true; From d0ce6aabb6e90e4f70efeadb94f93b8a0d6a3a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 17:22:04 +0800 Subject: [PATCH 289/493] Brightness (Linux): detect brightness of external monitors with DDC/CI --- .github/workflows/ci.yml | 4 +- CHANGELOG.md | 1 + CMakeLists.txt | 5 + README.md | 1 + completions/bash | 2 + doc/json_schema.json | 4 + src/common/init.c | 5 + src/common/jsonconfig.c | 2 + src/data/config_user.txt | 2 + src/data/help.txt | 1 + src/detection/brightness/brightness_linux.c | 128 ++++++++++++++++++-- src/fastfetch.c | 2 + src/fastfetch.h | 1 + 13 files changed, 146 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 904dff2a8..c352081cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev + run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libddcutil-dev - name: configure project env: @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libddcutil-dev - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c622cc65..3270a4c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Features: * Add LM (Login Manager) module. Currently requires systemd installed (thus Linux only) * Add `--wmi-timeout` option (Windows) * Add `--logo-type small` to search for small logos +* Support detecting brightness of external displays with DDC/CI (guard behind `--allow-slow-operations`) (Brightness) # 1.12.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index dc95b0fcc..dd8b7415f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) +cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) option(BUILD_TESTS "Build tests" OFF) # Also create test executables @@ -715,6 +716,10 @@ ff_lib_enable(PULSE "libpulse" "Pulse" ) +ff_lib_enable(DDCUTIL + "ddcutil" + "Ddcutil" +) if(ENABLE_THREADS) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS) diff --git a/README.md b/README.md index 11af03dae..71d14b750 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ The following libraries are used if present at runtime: * [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE. * [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection. * [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection. +* [`libddcutil`](https://github.com/rockowitz/ddcutil): Used for brightness detection of external displays ### macOS diff --git a/completions/bash b/completions/bash index c340753cd..a8db1c600 100644 --- a/completions/bash +++ b/completions/bash @@ -383,6 +383,8 @@ __fastfetch_completion() "--lib-osmesa" "--lib-opencl" "--lib-pulse" + "--lib-ddcutil" + "--lib-nm" "--battery-dir" ) diff --git a/doc/json_schema.json b/doc/json_schema.json index b12848e4f..ce264db47 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -406,6 +406,10 @@ "nm": { "title": "NetworkManager. Used for Wifi detection (Linux)", "type": "string" + }, + "ddcutil": { + "title": "Used for brightness detection of external displays (Linux)", + "type": "string" } }, "additionalProperties": false diff --git a/src/common/init.c b/src/common/init.c index d684fae1a..c17188bd4 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -139,6 +139,7 @@ static void defaultConfig(void) ffStrbufInit(&instance.config.libfreetype); ffStrbufInit(&instance.config.libPulse); ffStrbufInit(&instance.config.libnm); + ffStrbufInit(&instance.config.libDdcutil); instance.config.percentType = 1; } @@ -344,6 +345,7 @@ static void destroyConfig(void) ffStrbufDestroy(&instance.config.libfreetype); ffStrbufDestroy(&instance.config.libPulse); ffStrbufDestroy(&instance.config.libnm); + ffStrbufDestroy(&instance.config.libDdcutil); } static void destroyState(void) @@ -437,6 +439,9 @@ void ffListFeatures(void) #ifdef FF_HAVE_LIBNM "libnm\n" #endif + #ifdef FF_HAVE_DDCUTIL + "libddcutil\n" + #endif "" , stdout); } diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index af56b6c57..f67766a7c 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -463,6 +463,8 @@ const char* ffParseLibraryJsonConfig(void) ffStrbufSetS(&config->libPulse, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "nm")) ffStrbufSetS(&config->libnm, yyjson_get_str(val)); + else if (ffStrEqualsIgnCase(key, "ddcutil")) + ffStrbufSetS(&config->libDdcutil, yyjson_get_str(val)); else return "Unknown library property"; } diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 29823779e..b424a4585 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -458,3 +458,5 @@ #--lib-opencl /usr/lib/libOpenCL.so #--lib-freetype /data/data/com.termux/files/usr/lib #--lib-pulse /usr/lib/libpulse.so +#--lib-ddcutil /usr/lib/libddcutil.so +#--lib-nm /usr/lib/libnm.so diff --git a/src/data/help.txt b/src/data/help.txt index 137a09597..0f60e7b7a 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -99,6 +99,7 @@ Library options: Set the path of a library to load --lib-opencl --lib-pulse --lib-freetype + --lib-ddcutil Module specific options: --title-fqdn : Set if the title should use fully qualified domain name. Default is false diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index fc4afd556..41a47aac8 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -6,7 +6,7 @@ #include #include -const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) +static const char* detectWithBacklight(FFlist* result) { //https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-backlight const char* backlightDirPath = "/sys/class/backlight/"; @@ -38,21 +38,21 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) ffStrbufAppendS(&backlightDir, "/max_brightness"); if(ffReadFileBuffer(backlightDir.chars, &buffer)) { - FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); ffStrbufSubstrBeforeLastC(&backlightDir, '/'); ffStrbufAppendS(&backlightDir, "/device"); - ffStrbufInitA(&display->name, PATH_MAX + 1); - if(realpath(backlightDir.chars, display->name.chars)) + ffStrbufInitA(&brightness->name, PATH_MAX + 1); + if(realpath(backlightDir.chars, brightness->name.chars)) { - ffStrbufRecalculateLength(&display->name); - ffStrbufSubstrAfterLastC(&display->name, '/'); - if(ffStrbufStartsWithS(&display->name, "card") && isdigit(display->name.chars[4])) - ffStrbufSubstrAfterFirstC(&display->name, '-'); + ffStrbufRecalculateLength(&brightness->name); + ffStrbufSubstrAfterLastC(&brightness->name, '/'); + if(ffStrbufStartsWithS(&brightness->name, "card") && isdigit(brightness->name.chars[4])) + ffStrbufSubstrAfterFirstC(&brightness->name, '-'); } else - ffStrbufInitS(&display->name, entry->d_name); + ffStrbufInitS(&brightness->name, entry->d_name); double maxBrightness = ffStrbufToDouble(&buffer); - display->value = (float) (actualBrightness * 100 / maxBrightness); + brightness->value = (float) (actualBrightness * 100 / maxBrightness); } } ffStrbufSubstrBefore(&backlightDir, backlightDirLength); @@ -62,3 +62,111 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) return NULL; } + +#ifdef FF_HAVE_DDCUTIL +#include "detection/displayserver/displayserver.h" +#include "common/library.h" +#include "util/mallocHelper.h" + +#include + +static bool findDrmByEdid(const uint8_t srcEdidData[128], FFstrbuf* result) +{ + const char* drmDirPath = "/sys/class/drm/"; + + DIR* dirp = opendir(drmDirPath); + if(dirp == NULL) + return false; + + FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64); + ffStrbufAppendS(&drmDir, drmDirPath); + + uint32_t drmDirLength = drmDir.length; + + struct dirent* entry; + while((entry = readdir(dirp)) != NULL) + { + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + continue; + + ffStrbufAppendS(&drmDir, entry->d_name); + ffStrbufAppendS(&drmDir, "/edid"); + + uint8_t edidData[128]; + if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData)) + { + ffStrbufSubstrBefore(&drmDir, drmDirLength); + continue; + } + if (memcmp(srcEdidData, edidData, sizeof(edidData)) == 0) + { + ffStrbufAppendS(result, entry->d_name); + closedir(dirp); + return true; + } + } + return false; +} + +static const char* detectWithDdcci(FFlist* result) +{ + FF_LIBRARY_LOAD(libddcutil, &instance.config.libDdcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_any_vcp_value_using_explicit_type) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display) + + FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL; + if (__builtin_expect(ffddca_get_display_info_list2(false, &infoList) < 0, 0)) + return "ddca_get_display_info_list2(false, &infoList) failed"; + + if (infoList->ct == 0) + return "No DDC/CI compatible displays found"; + + for (int index = 0; index < infoList->ct; ++index) + { + const DDCA_Display_Info* display = &infoList->info[index]; + + DDCA_Display_Handle handle; + if (ffddca_open_display2(display->dref, false, &handle) >= 0) + { + DDCA_Any_Vcp_Value* vcpValue = NULL; + if (ffddca_get_any_vcp_value_using_explicit_type(handle, 0x10 /*brightness*/, DDCA_NON_TABLE_VCP_VALUE, &vcpValue) >= 0) + { + assert(vcpValue->value_type == DDCA_NON_TABLE_VCP_VALUE); + int current = VALREC_CUR_VAL(vcpValue), max = VALREC_MAX_VAL(vcpValue); + ffddca_free_any_vcp_value(vcpValue); + + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = (float) current * 100.f / (float) max; + ffStrbufInit(&brightness->name); + if (findDrmByEdid(display->edid_bytes, &brightness->name)) + { + if (ffStrbufStartsWithS(&brightness->name, "card")) + ffStrbufSubstrAfterFirstC(&brightness->name, '-'); + } + } + ffddca_close_display(handle); + } + } + + return NULL; +} +#endif + +const char* ffDetectBrightness(FFlist* result) +{ + detectWithBacklight(result); + + #ifdef FF_HAVE_DDCUTIL + if (instance.config.allowSlowOperations) + { + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + if (result->length < displayServer->displays.length) + detectWithDdcci(result); + } + #endif + + return NULL; +} diff --git a/src/fastfetch.c b/src/fastfetch.c index 23143c318..c6850f7d4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1028,6 +1028,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) ffOptionParseString(key, value, &instance.config.libPulse); else if(ffStrEqualsIgnCase(subkey, "-nm")) ffOptionParseString(key, value, &instance.config.libnm); + else if(ffStrEqualsIgnCase(subkey, "-ddcutil")) + ffOptionParseString(key, value, &instance.config.libDdcutil); else goto error; } diff --git a/src/fastfetch.h b/src/fastfetch.h index 7db8ec8d1..f59506877 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -132,6 +132,7 @@ typedef struct FFconfig FFstrbuf libfreetype; FFstrbuf libPulse; FFstrbuf libnm; + FFstrbuf libDdcutil; uint32_t percentType; From da6dafe49a8fbab2a211384bc0efabdba4a2630a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 17:36:36 +0800 Subject: [PATCH 290/493] CI (Linux): ddcutil is not available on Ubuntu 20.04; disable it --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c352081cc..904dff2a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libddcutil-dev + run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: configure project env: @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v3 - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libddcutil-dev + run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev - name: Initialize CodeQL uses: github/codeql-action/init@v2 From 98079f583c948cdda7c742b1d3cd60d2ea5db886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 19:32:29 +0800 Subject: [PATCH 291/493] Brightness (macOS): fix crashing when no external display connected --- src/detection/brightness/brightness_apple.c | 44 ++++++++++++--------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index d9c8454f0..e961bac03 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -53,33 +53,41 @@ const char* ffDetectBrightness(FFlist* result) } } - if (!instance.config.allowSlowOperations) + if (!instance.config.allowSlowOperations || displayServer->displays.length <= result->length) return NULL; // https://github.com/waydabber/m1ddc // This only works for Apple Silicon and USB-C adapter connection ( but not HTMI ) FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreate(kCFAllocatorDefault); - uint8_t i2cData[12] = { 0x82, 0x01, 0x00 }; - i2cData[3] = 0x6e ^ i2cData[0] ^ i2cData[1] ^ i2cData[2] ^ i2cData[3]; - - for (uint32_t i = 0; i < 3; ++i) + if (service) { - IOAVServiceWriteI2C(service, 0x37, 0x51, i2cData, 4); - usleep(10000); - } + uint8_t i2cData[12] = { 0x82, 0x01, 0x00 }; + i2cData[3] = 0x6e ^ i2cData[0] ^ i2cData[1] ^ i2cData[2] ^ i2cData[3]; - memset(i2cData, 0, sizeof(i2cData)); - if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cData, sizeof(i2cData)) == KERN_SUCCESS) - { - uint8_t current = i2cData[9], max = i2cData[7]; + for (uint32_t i = 0; i < 3; ++i) + { + IOAVServiceWriteI2C(service, 0x37, 0x51, i2cData, 4); + usleep(10000); + } - FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); - brightness->value = (float) current * 100.f / max; - ffStrbufInit(&brightness->name); + memset(i2cData, 0, sizeof(i2cData)); + if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cData, sizeof(i2cData)) == KERN_SUCCESS) + { + if (i2cData[2] != 0x02 || i2cData[3] != 0x00) + return NULL; - uint8_t edid[128] = {}; - if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, sizeof(edid)) == KERN_SUCCESS) - getNameFromEdid(edid, &brightness->name); + uint32_t mh = i2cData[6], ml = i2cData[7], sh = i2cData[8], sl = i2cData[9]; + uint32_t current = (mh << 8u) + ml; + uint32_t max = (sh << 8u) + sl; + + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = (float) current * 100.f / max; + ffStrbufInit(&brightness->name); + + uint8_t edid[128] = {}; + if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, sizeof(edid)) == KERN_SUCCESS) + getNameFromEdid(edid, &brightness->name); + } } return NULL; From cad89fccd10ca6d82d92e751341016c36eb678ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 22:15:03 +0800 Subject: [PATCH 292/493] Terminal: detect xterm terminal version --- src/detection/terminalshell/terminalshell.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 95779576f..ddfd85390 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -224,6 +224,20 @@ FF_MAYBE_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* v return version->length > 0; } +FF_MAYBE_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]){ + exe->chars, + "-v", + NULL + })) return false; + + //xterm(273) + ffStrbufTrimRight(version, ')'); + ffStrbufSubstrAfterFirstC(version, '('); + return version->length > 0; +} + #ifdef _WIN32 static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) @@ -291,6 +305,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "cockpit-bridge")) return getTerminalVersionCockpit(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "xterm")) + return getTerminalVersionXterm(exe, version); + #endif #ifdef _WIN32 From e99b45a24b8506d31be9b2484d5e59cfd671df44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Jul 2023 22:29:54 +0800 Subject: [PATCH 293/493] TerminalFont (Linux): support xterm --- .../terminalfont/terminalfont_linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index fabca6902..d95f94376 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -208,6 +208,23 @@ static void detectQTerminal(FFTerminalFontResult* terminalFont) ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } +static void detectXterm(FFTerminalFontResult* terminalFont) +{ + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); + + ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) { + {"xterm*faceName:", &fontName}, + {"xterm*faceSize:", &fontSize}, + }); + + if (fontName.length == 0) + ffStrbufAppendS(&fontName, "fixed"); + if (fontSize.length == 0) + ffStrbufAppendS(&fontSize, "8.0"); + ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); +} + void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "konsole")) @@ -228,4 +245,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FF detectFootTerminal(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "qterminal")) detectQTerminal(terminalFont); + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "xterm")) + detectXterm(terminalFont); } From d5f0ccae88f80d9289bd45dae61cf36b416b0844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 09:36:33 +0800 Subject: [PATCH 294/493] LM (Linux): try fixing LightDM version detection --- src/common/processing.h | 1 + src/common/processing_linux.c | 42 +++++++++++++++++ src/common/processing_windows.c | 80 +++++++++++++++++++++++++++++---- src/detection/lm/lm_linux.c | 2 +- 4 files changed, 115 insertions(+), 10 deletions(-) diff --git a/src/common/processing.h b/src/common/processing.h index 51164b0e9..08d8c64bf 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -6,5 +6,6 @@ #include "util/FFstrbuf.h" const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]); +const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]); #endif diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index b9bf20c1b..082891131 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -47,3 +47,45 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) return NULL; } + +const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) +{ + int pipes[2]; + + if(pipe(pipes) == -1) + return "pipe() failed"; + + pid_t childPid = fork(); + if(childPid == -1) + return "fork() failed"; + + //Child + if(childPid == 0) + { + dup2(pipes[1], STDERR_FILENO); + close(pipes[0]); + close(pipes[1]); + close(STDOUT_FILENO); + execvp(argv[0], argv); + exit(901); + } + + //Parent + close(pipes[1]); + + int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; + int status = -1; + if(waitpid(childPid, &status, 0) < 0) + return "waitpid(childPid, &status, 0) failed"; + + if (!WIFEXITED(status)) + return "WIFEXITED(status) == false"; + + if(WEXITSTATUS(status) == 901) + return "WEXITSTATUS(status) == 901 ( execvp failed )"; + + if(!ffAppendFDBuffer(childPipeFd, buffer)) + return "ffAppendFDBuffer(childPipeFd, buffer) failed"; + + return NULL; +} diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index 580a29146..a7de09e8e 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -11,18 +11,18 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) .bInheritHandle = TRUE, }; - HANDLE hChildStdoutRead, hChildStdoutWrite; - if (!CreatePipe(&hChildStdoutRead, &hChildStdoutWrite, &saAttr, 0)) + HANDLE hChildPipeRead, hChildPipeWrite; + if (!CreatePipe(&hChildPipeRead, &hChildPipeWrite, &saAttr, 0)) return "CreatePipe() failed"; - if (!SetHandleInformation(hChildStdoutRead, HANDLE_FLAG_INHERIT, 0)) - return "SetHandleInformation(hChildStdoutRead) failed"; + if (!SetHandleInformation(hChildPipeRead, HANDLE_FLAG_INHERIT, 0)) + return "SetHandleInformation(hChildPipeRead) failed"; PROCESS_INFORMATION piProcInfo = {0}; STARTUPINFOA siStartInfo = { .cb = sizeof(siStartInfo), .dwFlags = STARTF_USESTDHANDLES, - .hStdOutput = hChildStdoutWrite, + .hStdOutput = hChildPipeWrite, }; BOOL success; @@ -49,18 +49,80 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) ); } - CloseHandle(hChildStdoutWrite); + CloseHandle(hChildPipeWrite); if(!success) { - CloseHandle(hChildStdoutRead); + CloseHandle(hChildPipeRead); return "CreateProcessA() failed"; } char str[1024]; DWORD nRead; - while(ReadFile(hChildStdoutRead, str, sizeof(str), &nRead, NULL) && nRead > 0) + while(ReadFile(hChildPipeRead, str, sizeof(str), &nRead, NULL) && nRead > 0) ffStrbufAppendNS(buffer, nRead, str); - CloseHandle(hChildStdoutRead); + CloseHandle(hChildPipeRead); + return NULL; +} + +const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) +{ + SECURITY_ATTRIBUTES saAttr = { + .nLength = sizeof(SECURITY_ATTRIBUTES), + .lpSecurityDescriptor = NULL, + .bInheritHandle = TRUE, + }; + + HANDLE hChildPipeRead, hChildPipeWrite; + if (!CreatePipe(&hChildPipeRead, &hChildPipeWrite, &saAttr, 0)) + return "CreatePipe() failed"; + + if (!SetHandleInformation(hChildPipeRead, HANDLE_FLAG_INHERIT, 0)) + return "SetHandleInformation(hChildPipeRead) failed"; + + PROCESS_INFORMATION piProcInfo = {0}; + STARTUPINFOA siStartInfo = { + .cb = sizeof(siStartInfo), + .dwFlags = STARTF_USESTDHANDLES, + .hStdError = hChildPipeWrite, + }; + + BOOL success; + + { + FF_STRBUF_AUTO_DESTROY cmdline = ffStrbufCreateF("\"%s\"", argv[0]); + for(char* const* parg = &argv[1]; *parg; ++parg) + { + ffStrbufAppendC(&cmdline, ' '); + ffStrbufAppendS(&cmdline, *parg); + } + + success = CreateProcessA( + NULL, // application name + cmdline.chars, // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are inherited + 0, // creation flags + NULL, // use parent's environment + NULL, // use parent's current directory + &siStartInfo, // STARTUPINFO pointer + &piProcInfo // receives PROCESS_INFORMATION + ); + } + + CloseHandle(hChildPipeWrite); + if(!success) + { + CloseHandle(hChildPipeRead); + return "CreateProcessA() failed"; + } + + char str[1024]; + DWORD nRead; + while(ReadFile(hChildPipeRead, str, sizeof(str), &nRead, NULL) && nRead > 0) + ffStrbufAppendNS(buffer, nRead, str); + + CloseHandle(hChildPipeRead); return NULL; } diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index c85fc5bf9..0ce9cd8b0 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -95,7 +95,7 @@ static const char* getXfwmVersion(FFstrbuf* version) static const char* getLightdmVersion(FFstrbuf* version) { - const char* error = ffProcessAppendStdOut(version, (char* const[]) { + const char* error = ffProcessAppendStdErr(version, (char* const[]) { "lightdm", "--version", NULL From 856d732e13bd25e59f38b6173a878324dbb2e308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 15:25:45 +0800 Subject: [PATCH 295/493] Global: add option `--size-ndigits` and `--size-max-prefix` --- CHANGELOG.md | 1 + doc/json_schema.json | 10 ++++++++++ src/common/init.c | 2 ++ src/common/jsonconfig.c | 4 ++++ src/common/parsing.c | 18 ++++++++---------- src/data/config_user.txt | 12 ++++++++++++ src/data/help.txt | 2 ++ src/fastfetch.c | 4 ++++ src/fastfetch.h | 2 ++ 9 files changed, 45 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3270a4c3b..b11b10f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Features: * Add `--wmi-timeout` option (Windows) * Add `--logo-type small` to search for small logos * Support detecting brightness of external displays with DDC/CI (guard behind `--allow-slow-operations`) (Brightness) +* Add option `--size-ndigits` and `--size-max-prefix` (#494) # 1.12.2 diff --git a/doc/json_schema.json b/doc/json_schema.json index ce264db47..01f05602d 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -296,6 +296,16 @@ "jedec" ] }, + "sizeNdigits": { + "type": "integer", + "title": "Set the number of digits to keep after the decimal point when formatting sizes", + "default": 2 + }, + "sizeMaxPrefix": { + "type": "integer", + "title": "Set the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc.", + "default": 255 + }, "percentType": { "type": "number", "title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", diff --git a/src/common/init.c b/src/common/init.c index c17188bd4..53426ad2f 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -60,6 +60,8 @@ static void defaultConfig(void) instance.config.escapeBedrock = true; instance.config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; + instance.config.sizeNdigits = 2; + instance.config.sizeMaxPrefix = UINT8_MAX; instance.config.multithreading = true; instance.config.stat = false; instance.config.noBuffer = false; diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index f67766a7c..4b6d09546 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -386,6 +386,10 @@ const char* ffParseDisplayJsonConfig(void) if (error) return error; config->binaryPrefixType = (FFBinaryPrefixType) value; } + else if (ffStrEqualsIgnCase(key, "sizeNdigits")) + config->sizeNdigits = (uint8_t) yyjson_get_uint(val); + else if (ffStrEqualsIgnCase(key, "sizeMaxPrefix")) + config->sizeMaxPrefix = (uint8_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "percentType")) config->percentType = (uint32_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "noBuffer")) diff --git a/src/common/parsing.c b/src/common/parsing.c index 4bd8c19be..8fd5da367 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -60,12 +60,12 @@ void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty) ffStrbufAppendF(pretty, ".%u", version->patch); } -static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, uint8_t prefixesLength, const char** prefixes) +static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, const char** prefixes) { - long double size = (long double) bytes; + double size = (double) bytes; uint8_t counter = 0; - while(size >= base && counter < prefixesLength - 1) + while(size >= base && counter < instance.config.sizeMaxPrefix && prefixes[counter + 1]) { size /= base; counter++; @@ -73,22 +73,20 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, uint8_t p if(counter == 0) ffStrbufAppendF(result, "%"PRIu64" %s", bytes, prefixes[0]); - else if(counter < 3 || (counter == 3 && size < 100.0)) - ffStrbufAppendF(result, "%.2Lf %s", size, prefixes[counter]); else - ffStrbufAppendF(result, "%.0Lf %s", size, prefixes[counter]); + ffStrbufAppendF(result, "%.*f %s", instance.config.sizeNdigits, size, prefixes[counter]); } void ffParseSize(uint64_t bytes, FFBinaryPrefixType binaryPrefix, FFstrbuf* result) { if(binaryPrefix == FF_BINARY_PREFIX_TYPE_IEC) - parseSize(result, bytes, 1024, 5, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB"}); + parseSize(result, bytes, 1024, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL}); else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_SI) - parseSize(result, bytes, 1000, 5, (const char*[]) {"B", "kB", "MB", "GB", "TB"}); + parseSize(result, bytes, 1000, (const char*[]) {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL}); else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_JEDEC) - parseSize(result, bytes, 1024, 5, (const char*[]) {"B", "KB", "MB", "GB", "TB"}); + parseSize(result, bytes, 1024, (const char*[]) {"B", "KB", "MB", "GB", "TB", NULL}); else - parseSize(result, bytes, 1024, 1, (const char*[]) {"B"}); + parseSize(result, bytes, 1024, (const char*[]) {"B", NULL}); } void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index b424a4585..2128c51a2 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -152,6 +152,18 @@ # Default is IEC. #--binary-prefix IEC +# Size number of digits option: +# Sets the number of digits to keep after the decimal point when formatting sizes. +# Must be an possitive integer. +# Default is 2. +#--size-ndigits 2 + +# Size max prefix option: +# Sets the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc. +# Must be an possitive integer. +# Default is 255 (unlimited). +#--size-max-prefix 255 + # Disable output buffer option: # Sets if the stdout application buffer should be disabled. # Must be true or false. diff --git a/src/data/help.txt b/src/data/help.txt index 0f60e7b7a..fdc21004a 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -65,6 +65,8 @@ Display options: --binary-prefix : Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --no-buffer : Set if the stdout application buffer should be disabled. Default is false + --size-ndigits : Set the number of digits to keep after the decimal point when formatting sizes + --size-max-prefix : Set the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc. General module options: ---format : Set the format string to use for each specific module. diff --git a/src/fastfetch.c b/src/fastfetch.c index c6850f7d4..94453774b 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -915,6 +915,10 @@ static void parseOption(FFdata* data, const char* key, const char* value) {} }); } + else if(ffStrEqualsIgnCase(key, "--size-ndigits")) + instance.config.sizeNdigits = (uint8_t) ffOptionParseUInt32(key, value); + else if(ffStrEqualsIgnCase(key, "--size-max-prefix")) + instance.config.sizeMaxPrefix = (uint8_t) ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--percent-type")) instance.config.percentType = ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--no-buffer")) diff --git a/src/fastfetch.h b/src/fastfetch.h index f59506877..5c455cd70 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -44,6 +44,8 @@ typedef struct FFconfig bool hideCursor; bool escapeBedrock; FFBinaryPrefixType binaryPrefixType; + uint8_t sizeNdigits; + uint8_t sizeMaxPrefix; bool pipe; //disables logo and all escape sequences bool multithreading; bool stat; From e611ce57339fc2c371abfb57c901f55f5ab36291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 10:16:53 +0800 Subject: [PATCH 296/493] Processing (Linux): don't hang on `waitpid(2)` --- src/common/processing_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 082891131..36f263ef3 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -75,7 +75,7 @@ const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; int status = -1; - if(waitpid(childPid, &status, 0) < 0) + if(waitpid(childPid, &status, WNOHANG) < 0) return "waitpid(childPid, &status, 0) failed"; if (!WIFEXITED(status)) From 9719c17d19c97e7a9c86db6dbec4411deb0d17d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 16:13:10 +0800 Subject: [PATCH 297/493] LM (Linux): detect sshd version --- src/detection/lm/lm_linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 0ce9cd8b0..93137bcd6 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -24,6 +24,23 @@ static const char* getGdmVersion(FFstrbuf* version) return NULL; } +static const char* getSshdVersion(FFstrbuf* version) +{ + const char* error = ffProcessAppendStdErr(version, (char* const[]) { + "sshd", + "-qv", + NULL + }); + if (error) + return error; + + // unknown option -- v + // OpenSSH_9.0p1, OpenSSL 3.0.9 30 May 2023... + ffStrbufSubstrBeforeFirstC(version, ','); + ffStrbufSubstrAfterFirstC(version, '_'); + return NULL; +} + #ifdef FF_HAVE_ZLIB #include "common/library.h" #include @@ -147,6 +164,8 @@ const char* ffDetectLM(FFLMResult* result) getXfwmVersion(&result->version); else if (ffStrbufStartsWithS(&result->service, "lightdm")) getLightdmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "sshd")) + getSshdVersion(&result->version); // Correct char cases if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND)) From ad9103c7672de0b68e99137a266e06292d31806e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 16:14:04 +0800 Subject: [PATCH 298/493] Processing (Linux): support timeout --- src/common/processing_linux.c | 58 ++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 36f263ef3..6681bc681 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -1,10 +1,60 @@ #include "fastfetch.h" #include "common/processing.h" #include "common/io/io.h" +#include "common/time.h" #include #include #include +#include +#include + +#ifdef __linux__ + #include + #include + #include +#endif + +#define FF_WAIT_TIMEOUT 1000 + +int waitpid_timeout(pid_t pid, int* status) +{ + if (FF_WAIT_TIMEOUT <= 0) + return waitpid(pid, status, 0); + + #ifdef __linux__ + + FF_AUTO_CLOSE_FD int pidfd = (int) syscall(SYS_pidfd_open, pid, 0); + if (pidfd >= 0) + { + int res = poll(&(struct pollfd) { .events = POLLIN, .fd = pidfd }, 1, FF_WAIT_TIMEOUT); + if (res > 0) + return (int) waitpid(pid, status, WNOHANG); + else if (res == 0) + { + kill(pid, SIGTERM); + return -ETIME; + } + return -1; + } + + #endif + + uint64_t start = ffTimeGetTick(); + while (true) + { + int res = (int) waitpid(pid, status, WNOHANG); + if (res != 0) + return res; + if (ffTimeGetTick() - start < FF_WAIT_TIMEOUT) + ffTimeSleep(FF_WAIT_TIMEOUT / 10); + else + { + kill(pid, SIGTERM); + return -ETIME; + } + } +} const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) { @@ -33,8 +83,8 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; int status = -1; - if(waitpid(childPid, &status, 0) < 0) - return "waitpid(childPid, &status, 0) failed"; + if(waitpid_timeout(childPid, &status) < 0) + return "waitpid(childPid, &status) failed"; if (!WIFEXITED(status)) return "WIFEXITED(status) == false"; @@ -75,8 +125,8 @@ const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; int status = -1; - if(waitpid(childPid, &status, WNOHANG) < 0) - return "waitpid(childPid, &status, 0) failed"; + if(waitpid_timeout(childPid, &status) < 0) + return "waitpid(childPid, &status) failed"; if (!WIFEXITED(status)) return "WIFEXITED(status) == false"; From 7bd0780f1a1fbe4c75c9360bea272a20ab1d2d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 17:30:08 +0800 Subject: [PATCH 299/493] Fastfetch: make `--size-max-prefix` accept enum values. --- doc/json_schema.json | 7 ++++--- src/common/jsonconfig.c | 18 +++++++++++++++++- src/data/config_user.txt | 8 ++++---- src/data/help.txt | 2 +- src/fastfetch.c | 15 ++++++++++++++- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 01f05602d..6391b2b79 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -302,9 +302,10 @@ "default": 2 }, "sizeMaxPrefix": { - "type": "integer", - "title": "Set the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc.", - "default": 255 + "type": "string", + "title": "Set the largest binary prefix to use when formatting sizes", + "enum": ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], + "default": "YB" }, "percentType": { "type": "number", diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 4b6d09546..3fa6fe37f 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -389,7 +389,23 @@ const char* ffParseDisplayJsonConfig(void) else if (ffStrEqualsIgnCase(key, "sizeNdigits")) config->sizeNdigits = (uint8_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "sizeMaxPrefix")) - config->sizeMaxPrefix = (uint8_t) yyjson_get_uint(val); + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "B", 0 }, + { "kB", 1 }, + { "MB", 2 }, + { "GB", 3 }, + { "TB", 4 }, + { "PB", 5 }, + { "EB", 6 }, + { "ZB", 7 }, + { "YB", 8 }, + {} + }); + if (error) return error; + config->sizeMaxPrefix = (uint8_t) value; + } else if (ffStrEqualsIgnCase(key, "percentType")) config->percentType = (uint32_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "noBuffer")) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 2128c51a2..e9a481727 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -159,10 +159,10 @@ #--size-ndigits 2 # Size max prefix option: -# Sets the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc. -# Must be an possitive integer. -# Default is 255 (unlimited). -#--size-max-prefix 255 +# Sets the largest binary prefix to use when formatting sizes. +# Must be one of B, kB, MB, GB, TB, PB, EB, ZB, YB +# Default is YB. +#--size-max-prefix YB # Disable output buffer option: # Sets if the stdout application buffer should be disabled. diff --git a/src/data/help.txt b/src/data/help.txt index fdc21004a..78af50b05 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -66,7 +66,7 @@ Display options: --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --no-buffer : Set if the stdout application buffer should be disabled. Default is false --size-ndigits : Set the number of digits to keep after the decimal point when formatting sizes - --size-max-prefix : Set the largest binary prefix to use when formatting sizes. 0 is B; 1 is KB; 2 is MB; etc. + --size-max-prefix : Set the largest binary prefix to use when formatting sizes. Default is YB General module options: ---format : Set the format string to use for each specific module. diff --git a/src/fastfetch.c b/src/fastfetch.c index 94453774b..c83718fa9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -918,7 +918,20 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffStrEqualsIgnCase(key, "--size-ndigits")) instance.config.sizeNdigits = (uint8_t) ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--size-max-prefix")) - instance.config.sizeMaxPrefix = (uint8_t) ffOptionParseUInt32(key, value); + { + instance.config.sizeMaxPrefix = (uint8_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "B", 0 }, + { "kB", 1 }, + { "MB", 2 }, + { "GB", 3 }, + { "TB", 4 }, + { "PB", 5 }, + { "EB", 6 }, + { "ZB", 7 }, + { "YB", 8 }, + {} + }); + } else if(ffStrEqualsIgnCase(key, "--percent-type")) instance.config.percentType = ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--no-buffer")) From 301e6153e1748c8b5e3e03cb19ea9e0052dcd26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 18:02:40 +0800 Subject: [PATCH 300/493] WM/DE (Linux): revert 2486e68fe32a932f2ff83653ff292759733e9f0a because it seems to cause too many issues Ref: #495 #489 #481#480 --- src/detection/displayserver/linux/wmde.c | 49 +++++++++++++----------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index abb39fc91..b563bc83e 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -60,47 +60,52 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) if(!ffStrSet(name)) return; - if(strcasestr(name, "kwin") != NULL) - ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_KWIN); + if( + strcasecmp(name, "kwin_wayland") == 0 || + strcasecmp(name, "kwin_wayland_wrapper") == 0 || + strcasecmp(name, "kwin_x11") == 0 || + strcasecmp(name, "kwin_x11_wrapper") == 0 || + strcasecmp(name, "kwin") == 0 + ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_KWIN); else if( strcasecmp(name, "gnome-shell") == 0 || strcasecmp(name, "gnome shell") == 0 || strcasecmp(name, "gnome-session-binary") == 0 || - strcasestr(name, "mutter") != NULL - ) - ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUTTER); + strcasecmp(name, "Mutter") == 0 + ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUTTER); else if( strcasecmp(name, "cinnamon-session") == 0 || - strcasestr(name, "muffin") != NULL - ) - ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUFFIN); - else if(strcasestr(name, "sway") != NULL) + strcasecmp(name, "Muffin") == 0 || + strcasecmp(name, "Mutter (Muffin)") == 0 + ) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MUFFIN); + else if(strcasecmp(name, "sway") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_SWAY); - else if(strcasestr(name, "weston") != NULL) + else if(strcasecmp(name, "weston") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WESTON); - else if(strcasestr(name, "wayfire") != NULL) + else if(strcasecmp(name, "wayfire") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WAYFIRE); - else if(strcasestr(name, "openbox") != NULL) + else if(strcasecmp(name, "openbox") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_OPENBOX); - else if(strcasestr(name, "xfwm4") != NULL) + else if(strcasecmp(name, "xfwm4") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XFWM4); - else if(strcasestr(name, "marco") != NULL) + else if(strcasecmp(name, "Marco") == 0 || + strcasecmp(name, "Metacity (Macro)") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MARCO); - else if(strcasestr(name, "xmonad") != NULL) + else if(strcasecmp(name, "xmonad") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XMONAD); - else if(strcasestr(name, "wslg") != NULL) + else if(strcasecmp(name, "WSLg") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_WSLG); - else if(strcasestr(name, "dwm") != NULL) + else if(strcasecmp(name, "dwm") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_DWM); - else if(strcasestr(name, "bspwm") != NULL) + else if(strcasecmp(name, "bspwm") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_BSPWM); - else if(strcasestr(name, "tinywm") != NULL) + else if(strcasecmp(name, "tinywm") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_TINYWM); - else if(strcasestr(name, "qtile") != NULL) + else if(strcasecmp(name, "qtile") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_QTILE); - else if(strcasestr(name, "herbstluftwm") != NULL) + else if(strcasecmp(name, "herbstluftwm") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_HERBSTLUFTWM); - else if(strcasestr(name, "icewm") != NULL) + else if(strcasecmp(name, "icewm") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_ICEWM); } From c1b2ebc66e978bed218c48a19cff9f21002ada7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 18:04:21 +0800 Subject: [PATCH 301/493] CI: fix compiling errors --- src/common/processing_linux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 6681bc681..1cd1ce3bd 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -11,8 +11,7 @@ #ifdef __linux__ #include - #include - #include + #include #endif #define FF_WAIT_TIMEOUT 1000 @@ -33,7 +32,7 @@ int waitpid_timeout(pid_t pid, int* status) else if (res == 0) { kill(pid, SIGTERM); - return -ETIME; + return -62; // -ETIME } return -1; } @@ -51,7 +50,7 @@ int waitpid_timeout(pid_t pid, int* status) else { kill(pid, SIGTERM); - return -ETIME; + return -62; // -ETIME } } } From 9c9ba2f1a17792938f1a83eabebc441908888a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 18:10:59 +0800 Subject: [PATCH 302/493] CI (Linux): fix build on musl --- src/common/processing_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 1cd1ce3bd..105f725bd 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -21,7 +21,7 @@ int waitpid_timeout(pid_t pid, int* status) if (FF_WAIT_TIMEOUT <= 0) return waitpid(pid, status, 0); - #ifdef __linux__ + #if defined(__linux__) && defined(SYS_pidfd_open) // musl don't define SYS_pidfd_open FF_AUTO_CLOSE_FD int pidfd = (int) syscall(SYS_pidfd_open, pid, 0); if (pidfd >= 0) From d53b584ba281fb86a5f94e7be2ee51ad0bde6757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 21:02:13 +0800 Subject: [PATCH 303/493] Processing (Windows): support timeout --- src/common/processing.h | 15 ++++++- src/common/processing_linux.c | 50 ++------------------- src/common/processing_windows.c | 77 ++++++--------------------------- 3 files changed, 29 insertions(+), 113 deletions(-) diff --git a/src/common/processing.h b/src/common/processing.h index 08d8c64bf..37dfceba3 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -5,7 +5,18 @@ #include "util/FFstrbuf.h" -const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]); -const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]); +#define FF_WAIT_TIMEOUT 1000 + +const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr); + +static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) +{ + return ffProcessAppendOutput(buffer, argv, false); +} + +static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) +{ + return ffProcessAppendOutput(buffer, argv, true); +} #endif diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 105f725bd..45311b2b1 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -14,8 +14,6 @@ #include #endif -#define FF_WAIT_TIMEOUT 1000 - int waitpid_timeout(pid_t pid, int* status) { if (FF_WAIT_TIMEOUT <= 0) @@ -55,7 +53,7 @@ int waitpid_timeout(pid_t pid, int* status) } } -const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) +const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { int pipes[2]; @@ -69,52 +67,10 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) //Child if(childPid == 0) { - dup2(pipes[1], STDOUT_FILENO); + dup2(pipes[1], useStdErr ? STDERR_FILENO : STDOUT_FILENO); close(pipes[0]); close(pipes[1]); - close(STDERR_FILENO); - execvp(argv[0], argv); - exit(901); - } - - //Parent - close(pipes[1]); - - int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; - int status = -1; - if(waitpid_timeout(childPid, &status) < 0) - return "waitpid(childPid, &status) failed"; - - if (!WIFEXITED(status)) - return "WIFEXITED(status) == false"; - - if(WEXITSTATUS(status) == 901) - return "WEXITSTATUS(status) == 901 ( execvp failed )"; - - if(!ffAppendFDBuffer(childPipeFd, buffer)) - return "ffAppendFDBuffer(childPipeFd, buffer) failed"; - - return NULL; -} - -const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) -{ - int pipes[2]; - - if(pipe(pipes) == -1) - return "pipe() failed"; - - pid_t childPid = fork(); - if(childPid == -1) - return "fork() failed"; - - //Child - if(childPid == 0) - { - dup2(pipes[1], STDERR_FILENO); - close(pipes[0]); - close(pipes[1]); - close(STDOUT_FILENO); + close(useStdErr ? STDOUT_FILENO : STDERR_FILENO); execvp(argv[0], argv); exit(901); } diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index a7de09e8e..7070d31c7 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -1,9 +1,10 @@ #include "fastfetch.h" #include "common/processing.h" +#include "common/io/io.h" #include -const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) +const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { SECURITY_ATTRIBUTES saAttr = { .nLength = sizeof(SECURITY_ATTRIBUTES), @@ -11,7 +12,8 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) .bInheritHandle = TRUE, }; - HANDLE hChildPipeRead, hChildPipeWrite; + FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = NULL; + HANDLE hChildPipeWrite = NULL; if (!CreatePipe(&hChildPipeRead, &hChildPipeWrite, &saAttr, 0)) return "CreatePipe() failed"; @@ -22,8 +24,11 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) STARTUPINFOA siStartInfo = { .cb = sizeof(siStartInfo), .dwFlags = STARTF_USESTDHANDLES, - .hStdOutput = hChildPipeWrite, }; + if (useStdErr) + siStartInfo.hStdError = hChildPipeWrite; + else + siStartInfo.hStdOutput = hChildPipeWrite; BOOL success; @@ -51,71 +56,16 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) CloseHandle(hChildPipeWrite); if(!success) - { - CloseHandle(hChildPipeRead); return "CreateProcessA() failed"; - } - - char str[1024]; - DWORD nRead; - while(ReadFile(hChildPipeRead, str, sizeof(str), &nRead, NULL) && nRead > 0) - ffStrbufAppendNS(buffer, nRead, str); - - CloseHandle(hChildPipeRead); - return NULL; -} - -const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) -{ - SECURITY_ATTRIBUTES saAttr = { - .nLength = sizeof(SECURITY_ATTRIBUTES), - .lpSecurityDescriptor = NULL, - .bInheritHandle = TRUE, - }; - - HANDLE hChildPipeRead, hChildPipeWrite; - if (!CreatePipe(&hChildPipeRead, &hChildPipeWrite, &saAttr, 0)) - return "CreatePipe() failed"; - - if (!SetHandleInformation(hChildPipeRead, HANDLE_FLAG_INHERIT, 0)) - return "SetHandleInformation(hChildPipeRead) failed"; - - PROCESS_INFORMATION piProcInfo = {0}; - STARTUPINFOA siStartInfo = { - .cb = sizeof(siStartInfo), - .dwFlags = STARTF_USESTDHANDLES, - .hStdError = hChildPipeWrite, - }; - - BOOL success; + if (FF_WAIT_TIMEOUT > 0) { - FF_STRBUF_AUTO_DESTROY cmdline = ffStrbufCreateF("\"%s\"", argv[0]); - for(char* const* parg = &argv[1]; *parg; ++parg) + DWORD ret = WaitForSingleObjectEx(piProcInfo.hProcess, FF_WAIT_TIMEOUT, TRUE); + if (ret == WAIT_TIMEOUT) { - ffStrbufAppendC(&cmdline, ' '); - ffStrbufAppendS(&cmdline, *parg); + TerminateProcess(piProcInfo.hProcess, 1); + return "Waiting process timeout"; } - - success = CreateProcessA( - NULL, // application name - cmdline.chars, // command line - NULL, // process security attributes - NULL, // primary thread security attributes - TRUE, // handles are inherited - 0, // creation flags - NULL, // use parent's environment - NULL, // use parent's current directory - &siStartInfo, // STARTUPINFO pointer - &piProcInfo // receives PROCESS_INFORMATION - ); - } - - CloseHandle(hChildPipeWrite); - if(!success) - { - CloseHandle(hChildPipeRead); - return "CreateProcessA() failed"; } char str[1024]; @@ -123,6 +73,5 @@ const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) while(ReadFile(hChildPipeRead, str, sizeof(str), &nRead, NULL) && nRead > 0) ffStrbufAppendNS(buffer, nRead, str); - CloseHandle(hChildPipeRead); return NULL; } From 7dae59ee928442039e8944fc962a532efa70789f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 22:12:07 +0800 Subject: [PATCH 304/493] Processing: add `--processing-timeout` --- CHANGELOG.md | 1 + src/common/init.c | 1 + src/common/jsonconfig.c | 2 ++ src/common/processing.h | 2 -- src/common/processing_linux.c | 10 ++++++---- src/common/processing_windows.c | 4 ++-- src/data/config_user.txt | 6 ++++++ src/data/help.txt | 2 ++ src/fastfetch.c | 2 ++ src/fastfetch.h | 1 + 10 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b11b10f56..b827262db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Features: * Add `--logo-type small` to search for small logos * Support detecting brightness of external displays with DDC/CI (guard behind `--allow-slow-operations`) (Brightness) * Add option `--size-ndigits` and `--size-max-prefix` (#494) +* Add option `--processing-timeout` to the timeout when waiting for child processes. # 1.12.2 diff --git a/src/common/init.c b/src/common/init.c index 53426ad2f..e71509292 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -37,6 +37,7 @@ static void defaultConfig(void) ffStrbufInit(&instance.config.colorKeys); ffStrbufInit(&instance.config.colorTitle); ffStrbufInitS(&instance.config.keyValueSeparator, ": "); + instance.config.processingTimeout = 1000; #if defined(__linux__) || defined(__FreeBSD__) ffStrbufInit(&instance.config.playerName); diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 3fa6fe37f..690254202 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -309,6 +309,8 @@ const char* ffParseGeneralJsonConfig(void) config->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "pipe")) config->pipe = yyjson_get_bool(val); + else if (ffStrEqualsIgnCase(key, "processingTimeout")) + config->processingTimeout = (int32_t) yyjson_get_int(val); #if defined(__linux__) || defined(__FreeBSD__) else if (ffStrEqualsIgnCase(key, "playerName")) diff --git a/src/common/processing.h b/src/common/processing.h index 37dfceba3..9f02e799d 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -5,8 +5,6 @@ #include "util/FFstrbuf.h" -#define FF_WAIT_TIMEOUT 1000 - const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr); static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 45311b2b1..9a468d83c 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -16,15 +16,17 @@ int waitpid_timeout(pid_t pid, int* status) { - if (FF_WAIT_TIMEOUT <= 0) + if (instance.config.processingTimeout <= 0) return waitpid(pid, status, 0); + uint32_t timeout = (uint32_t) instance.config.processingTimeout; + #if defined(__linux__) && defined(SYS_pidfd_open) // musl don't define SYS_pidfd_open FF_AUTO_CLOSE_FD int pidfd = (int) syscall(SYS_pidfd_open, pid, 0); if (pidfd >= 0) { - int res = poll(&(struct pollfd) { .events = POLLIN, .fd = pidfd }, 1, FF_WAIT_TIMEOUT); + int res = poll(&(struct pollfd) { .events = POLLIN, .fd = pidfd }, 1, (int) timeout); if (res > 0) return (int) waitpid(pid, status, WNOHANG); else if (res == 0) @@ -43,8 +45,8 @@ int waitpid_timeout(pid_t pid, int* status) int res = (int) waitpid(pid, status, WNOHANG); if (res != 0) return res; - if (ffTimeGetTick() - start < FF_WAIT_TIMEOUT) - ffTimeSleep(FF_WAIT_TIMEOUT / 10); + if (ffTimeGetTick() - start < timeout) + ffTimeSleep(timeout / 10); else { kill(pid, SIGTERM); diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index 7070d31c7..8a9885abc 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -58,9 +58,9 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use if(!success) return "CreateProcessA() failed"; - if (FF_WAIT_TIMEOUT > 0) + if (instance.config.processingTimeout > 0) { - DWORD ret = WaitForSingleObjectEx(piProcInfo.hProcess, FF_WAIT_TIMEOUT, TRUE); + DWORD ret = WaitForSingleObjectEx(piProcInfo.hProcess, (DWORD) instance.config.processingTimeout, TRUE); if (ret == WAIT_TIMEOUT) { TerminateProcess(piProcInfo.hProcess, 1); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index e9a481727..d5eccdc8e 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -58,6 +58,12 @@ # Default is true. #--hide-cursor true +# Processing timeout option: +# Sets the timeout (ms) when waiting for child processes +# Must be an integer. +# Default is 1000 +#--processing-timeout 1000 + # WMI timeout option: # Sets the timeout (ms) for WMI queries. Windows only # Must be an integer. diff --git a/src/data/help.txt b/src/data/help.txt index 78af50b05..fae9abc0a 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -24,6 +24,8 @@ General options: --allow-slow-operations : Allow operations that are usually very slow for more detailed output --escape-bedrock : On Bedrock Linux, whether to escape the bedrock jail --pipe : Disable logo and all escape sequences + --wmi-timeout : Set the timeout (ms) for WMI queries. Windows only. Default is 5000 + --processing-timeout : Set the timeout (ms) when waiting for child processes. Default is 1000 Logo options: -l,--logo : Set the logo; if default, the name of a builtin logo or a path to a file diff --git a/src/fastfetch.c b/src/fastfetch.c index c83718fa9..fe55857fc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -859,6 +859,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) instance.config.pipe = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--load-user-config")) data->loadUserConfig = ffOptionParseBoolean(value); + else if(ffStrEqualsIgnCase(key, "--processing-timeout")) + instance.config.processingTimeout = ffOptionParseInt32(key, value); #if defined(__linux__) || defined(__FreeBSD__) else if(ffStrEqualsIgnCase(key, "--player-name")) diff --git a/src/fastfetch.h b/src/fastfetch.h index 5c455cd70..90d6aa47c 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -50,6 +50,7 @@ typedef struct FFconfig bool multithreading; bool stat; bool noBuffer; + int32_t processingTimeout; // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) From ced234782911a1e8b4368a9cc5adc42a56c9a3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Jul 2023 11:10:10 +0800 Subject: [PATCH 305/493] Processing (Linux): fix potential hang when reading large buffer `write` in child process blocks when the pipe is full. However because we are `waitpid`ing, we don't read the pipe, so that the pipe is never free. Therefore `write` in child process blocks forever and `waitpid` hangs. Fix #493 --- src/common/processing_linux.c | 78 ++++++++++------------------------- 1 file changed, 21 insertions(+), 57 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 9a468d83c..6f7dadb5e 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -5,55 +5,8 @@ #include #include -#include -#include #include - -#ifdef __linux__ - #include - #include -#endif - -int waitpid_timeout(pid_t pid, int* status) -{ - if (instance.config.processingTimeout <= 0) - return waitpid(pid, status, 0); - - uint32_t timeout = (uint32_t) instance.config.processingTimeout; - - #if defined(__linux__) && defined(SYS_pidfd_open) // musl don't define SYS_pidfd_open - - FF_AUTO_CLOSE_FD int pidfd = (int) syscall(SYS_pidfd_open, pid, 0); - if (pidfd >= 0) - { - int res = poll(&(struct pollfd) { .events = POLLIN, .fd = pidfd }, 1, (int) timeout); - if (res > 0) - return (int) waitpid(pid, status, WNOHANG); - else if (res == 0) - { - kill(pid, SIGTERM); - return -62; // -ETIME - } - return -1; - } - - #endif - - uint64_t start = ffTimeGetTick(); - while (true) - { - int res = (int) waitpid(pid, status, WNOHANG); - if (res != 0) - return res; - if (ffTimeGetTick() - start < timeout) - ffTimeSleep(timeout / 10); - else - { - kill(pid, SIGTERM); - return -62; // -ETIME - } - } -} +#include const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { @@ -81,16 +34,27 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use close(pipes[1]); int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; - int status = -1; - if(waitpid_timeout(childPid, &status) < 0) - return "waitpid(childPid, &status) failed"; - - if (!WIFEXITED(status)) - return "WIFEXITED(status) == false"; - - if(WEXITSTATUS(status) == 901) - return "WEXITSTATUS(status) == 901 ( execvp failed )"; + if (instance.config.processingTimeout >= 0) + { + struct pollfd pollfd = { childPipeFd, POLLIN, 0 }; + if (poll(&pollfd, 1, (int) instance.config.processingTimeout) == 0) + { + kill(childPid, SIGTERM); + return "poll(&pollfd, 1, (int) instance.config.processingTimeout) timeout"; + } + else if (pollfd.revents & POLLERR) + { + kill(childPid, SIGTERM); + return "poll(&pollfd, 1, (int) instance.config.processingTimeout) error"; + } + else if (pollfd.revents & POLLHUP) + { + return "Child process closed its end (nothing to read)"; + } + } + // Note that we only know we have something to read here + // However the child process may still block later if(!ffAppendFDBuffer(childPipeFd, buffer)) return "ffAppendFDBuffer(childPipeFd, buffer) failed"; From 992fd6e5ad9b29e1c1f65a997b2988c62329f1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Jul 2023 16:00:58 +0800 Subject: [PATCH 306/493] Processing (Windows): properly implement timed reading --- src/common/processing_windows.c | 91 +++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index 8a9885abc..10ca7adbf 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -4,35 +4,55 @@ #include +enum { FF_PIPE_BUFSIZ = 4096 }; + const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { - SECURITY_ATTRIBUTES saAttr = { - .nLength = sizeof(SECURITY_ATTRIBUTES), - .lpSecurityDescriptor = NULL, - .bInheritHandle = TRUE, - }; + int timeout = instance.config.processingTimeout; - FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = NULL; - HANDLE hChildPipeWrite = NULL; - if (!CreatePipe(&hChildPipeRead, &hChildPipeWrite, &saAttr, 0)) - return "CreatePipe() failed"; + FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = CreateNamedPipeW( + L"\\\\.\\pipe\\LOCAL\\", + PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE | (timeout < 0 ? 0 : FILE_FLAG_OVERLAPPED), + 0, + 1, + FF_PIPE_BUFSIZ, + FF_PIPE_BUFSIZ, + 0, + NULL + ); + if (hChildPipeRead == INVALID_HANDLE_VALUE) + return "CreateNamedPipeW(L\"\\\\.\\pipe\\LOCAL\\\") failed"; - if (!SetHandleInformation(hChildPipeRead, HANDLE_FLAG_INHERIT, 0)) - return "SetHandleInformation(hChildPipeRead) failed"; + HANDLE hChildPipeWrite = CreateFileW( + L"\\\\.\\pipe\\LOCAL\\", + GENERIC_WRITE, + 0, + &(SECURITY_ATTRIBUTES){ + .nLength = sizeof(SECURITY_ATTRIBUTES), + .lpSecurityDescriptor = NULL, + .bInheritHandle = TRUE, + }, + OPEN_EXISTING, + 0, + NULL + ); + if (hChildPipeWrite == INVALID_HANDLE_VALUE) + return "CreateFileW(L\"\\\\.\\pipe\\LOCAL\\\") failed"; PROCESS_INFORMATION piProcInfo = {0}; - STARTUPINFOA siStartInfo = { - .cb = sizeof(siStartInfo), - .dwFlags = STARTF_USESTDHANDLES, - }; - if (useStdErr) - siStartInfo.hStdError = hChildPipeWrite; - else - siStartInfo.hStdOutput = hChildPipeWrite; BOOL success; { + STARTUPINFOA siStartInfo = { + .cb = sizeof(siStartInfo), + .dwFlags = STARTF_USESTDHANDLES, + }; + if (useStdErr) + siStartInfo.hStdError = hChildPipeWrite; + else + siStartInfo.hStdOutput = hChildPipeWrite; + FF_STRBUF_AUTO_DESTROY cmdline = ffStrbufCreateF("\"%s\"", argv[0]); for(char* const* parg = &argv[1]; *parg; ++parg) { @@ -58,20 +78,35 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use if(!success) return "CreateProcessA() failed"; - if (instance.config.processingTimeout > 0) + char str[FF_PIPE_BUFSIZ]; + DWORD nRead = 0; + OVERLAPPED overlapped = {}; + // ReadFile always completes synchronously if the pipe is not created with FILE_FLAG_OVERLAPPED + if (!ReadFile(hChildPipeRead, str, sizeof(str), &nRead, &overlapped)) { - DWORD ret = WaitForSingleObjectEx(piProcInfo.hProcess, (DWORD) instance.config.processingTimeout, TRUE); - if (ret == WAIT_TIMEOUT) + if (!GetOverlappedResultEx(hChildPipeRead, &overlapped, &nRead, (DWORD) timeout, TRUE)) { + if (GetLastError() == ERROR_BROKEN_PIPE) + return "Child process closed its end (nothing to read)"; + CancelIo(hChildPipeRead); TerminateProcess(piProcInfo.hProcess, 1); - return "Waiting process timeout"; + return "GetOverlappedResultEx(hChildPipeRead) failed or timeout"; + } + } + while (nRead > 0) + { + ffStrbufAppendNS(buffer, nRead, str); + if (!ReadFile(hChildPipeRead, str, sizeof(str), &nRead, &overlapped)) + { + if (!GetOverlappedResult(hChildPipeRead, &overlapped, &nRead, TRUE)) + { + if (GetLastError() == ERROR_BROKEN_PIPE) + return NULL; + CancelIo(hChildPipeRead); + return "GetOverlappedResult(hChildPipeRead) failed"; + } } } - char str[1024]; - DWORD nRead; - while(ReadFile(hChildPipeRead, str, sizeof(str), &nRead, NULL) && nRead > 0) - ffStrbufAppendNS(buffer, nRead, str); - return NULL; } From 11adefd8393a03857ff731228f94ebc3b6e96aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Jul 2023 19:45:16 +0800 Subject: [PATCH 307/493] Processing (Windows): fix hanging when executing cygwin processes --- src/common/processing_linux.c | 2 +- src/common/processing_windows.c | 39 ++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 6f7dadb5e..9a97b359f 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -49,7 +49,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use } else if (pollfd.revents & POLLHUP) { - return "Child process closed its end (nothing to read)"; + return NULL; } } diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index 10ca7adbf..ea304606b 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -82,31 +82,34 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use DWORD nRead = 0; OVERLAPPED overlapped = {}; // ReadFile always completes synchronously if the pipe is not created with FILE_FLAG_OVERLAPPED - if (!ReadFile(hChildPipeRead, str, sizeof(str), &nRead, &overlapped)) + do { - if (!GetOverlappedResultEx(hChildPipeRead, &overlapped, &nRead, (DWORD) timeout, TRUE)) - { - if (GetLastError() == ERROR_BROKEN_PIPE) - return "Child process closed its end (nothing to read)"; - CancelIo(hChildPipeRead); - TerminateProcess(piProcInfo.hProcess, 1); - return "GetOverlappedResultEx(hChildPipeRead) failed or timeout"; - } - } - while (nRead > 0) - { - ffStrbufAppendNS(buffer, nRead, str); if (!ReadFile(hChildPipeRead, str, sizeof(str), &nRead, &overlapped)) { - if (!GetOverlappedResult(hChildPipeRead, &overlapped, &nRead, TRUE)) + switch (GetLastError()) { - if (GetLastError() == ERROR_BROKEN_PIPE) - return NULL; + case ERROR_IO_PENDING: + if (!GetOverlappedResultEx(hChildPipeRead, &overlapped, &nRead, (DWORD) timeout, TRUE)) + { + if (GetLastError() == ERROR_BROKEN_PIPE) + return NULL; + CancelIo(hChildPipeRead); + TerminateProcess(piProcInfo.hProcess, 1); + return "GetOverlappedResultEx(hChildPipeRead) failed or timeout"; + } + break; + + case ERROR_BROKEN_PIPE: + return NULL; + + default: CancelIo(hChildPipeRead); - return "GetOverlappedResult(hChildPipeRead) failed"; + TerminateProcess(piProcInfo.hProcess, 1); + return "ReadFile(hChildPipeRead) failed"; } } - } + ffStrbufAppendNS(buffer, nRead, str); + } while (nRead > 0); return NULL; } From dfefb802d064e50d5af2d7708b4cc38f0540918f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Jul 2023 20:28:59 +0800 Subject: [PATCH 308/493] Processing (Linux): always poll before read --- src/common/processing_linux.c | 63 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 9a97b359f..43c19dae9 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -7,6 +7,10 @@ #include #include #include +#include +#include + +enum { FF_PIPE_BUFSIZ = 4096 }; const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { @@ -34,29 +38,44 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use close(pipes[1]); int FF_AUTO_CLOSE_FD childPipeFd = pipes[0]; - if (instance.config.processingTimeout >= 0) - { - struct pollfd pollfd = { childPipeFd, POLLIN, 0 }; - if (poll(&pollfd, 1, (int) instance.config.processingTimeout) == 0) - { - kill(childPid, SIGTERM); - return "poll(&pollfd, 1, (int) instance.config.processingTimeout) timeout"; - } - else if (pollfd.revents & POLLERR) - { - kill(childPid, SIGTERM); - return "poll(&pollfd, 1, (int) instance.config.processingTimeout) error"; - } - else if (pollfd.revents & POLLHUP) - { - return NULL; - } - } - // Note that we only know we have something to read here - // However the child process may still block later - if(!ffAppendFDBuffer(childPipeFd, buffer)) - return "ffAppendFDBuffer(childPipeFd, buffer) failed"; + int timeout = instance.config.processingTimeout; + if (timeout >= 0) + fcntl(childPipeFd, F_SETFL, fcntl(childPipeFd, F_GETFL) | O_NONBLOCK); + + do + { + if (timeout >= 0) + { + struct pollfd pollfd = { childPipeFd, POLLIN, 0 }; + if (poll(&pollfd, 1, timeout) == 0) + { + kill(childPid, SIGTERM); + return "poll(&pollfd, 1, timeout) timeout"; + } + else if (pollfd.revents & POLLERR) + { + kill(childPid, SIGTERM); + return "poll(&pollfd, 1, timeout) error"; + } + else if (pollfd.revents & POLLHUP) + { + return NULL; + } + } + + char str[FF_PIPE_BUFSIZ]; + while (true) + { + ssize_t nRead = read(childPipeFd, str, FF_PIPE_BUFSIZ); + if (nRead > 0) + ffStrbufAppendNS(buffer, (uint32_t) nRead, str); + else if (nRead == 0) + return NULL; + else if (nRead < 0) + break; + } + } while (errno == EAGAIN); return NULL; } From 63fbaa146cabb827817c62efc114d1afbceb7ffb Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Wed, 12 Jul 2023 11:38:56 +0200 Subject: [PATCH 309/493] CPU: properly detect CPU on POWER Excerpt for a thread from /proc/cpuinfo: processor : 0 cpu : POWER9, altivec supported clock : 3800.000000MHz revision : 2.2 (pvr 004e 1202) Without this patch, the following is printed for a CPU: CPU: CPU (64) @ 3.8 GHz With it, there is: CPU: POWER9, altivec supported (64) @ 3.8 GHz --- src/detection/cpu/cpu_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 00c332a26..1fd61ce37 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -29,7 +29,8 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, ffParsePropLine(line, "cpu MHz :", cpuMHz) || ffParsePropLine(line, "isa :", cpuIsa) || ffParsePropLine(line, "uarch :", cpuUarch) || - (cpu->name.length == 0 && ffParsePropLine(line, "Hardware :", &cpu->name)) //For Android devices + (cpu->name.length == 0 && ffParsePropLine(line, "Hardware :", &cpu->name)) || //For Android devices + (cpu->name.length == 0 && ffParsePropLine(line, "cpu :", &cpu->name)) //For POWER ); } From ad627e0e0a3147b7c200ee98a8cf01080ebf9f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Jul 2023 09:53:31 +0800 Subject: [PATCH 310/493] GPU (Linux): disable GPU memory size detection with libpci by default Ref: #495, #497 --- CMakeLists.txt | 5 +++++ src/detection/gpu/gpu_linux.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8b7415f..4450e6b28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) +cmake_dependent_option(ENABLE_PCI_MEMORY "Enable detecting GPU memory size with libpci" OFF "LINUX OR BSD" OFF) option(BUILD_TESTS "Build tests" OFF) # Also create test executables option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds @@ -728,6 +729,10 @@ if(ENABLE_THREADS) endif() endif() +if(ENABLE_PCI_MEMORY) + target_compile_definitions(libfastfetch PRIVATE FF_USE_PCI_MEMORY) +endif() + if(APPLE) target_link_libraries(libfastfetch PRIVATE "-framework Cocoa" diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index a567b1285..d59127e10 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -147,7 +147,7 @@ FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, struct pci_dev* devi } } -static bool pciDetectMemory(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device) +FF_MAYBE_UNUSED static bool pciDetectMemory(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* device) { gpu->dedicated.used = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; @@ -180,7 +180,7 @@ static bool pciDetectMemory(FFGPUResult* gpu, const PCIData* pci, struct pci_dev return true; } -static void pciDetectType(FFGPUResult* gpu) +FF_MAYBE_UNUSED static void pciDetectType(FFGPUResult* gpu) { //There is no straightforward way to detect the type of a GPU. //The approach taken here is to look at the memory sizes of the device. @@ -224,11 +224,16 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInit(&gpu->driver); pciDetectDriverName(gpu, pci, device); - pciDetectMemory(gpu, pci, device); - pciDetectType(gpu); + #if FF_USE_PCI_MEMORY + // Libpci reports at least 2 false results (#495, #497) + pciDetectMemory(gpu, pci, device); + pciDetectType(gpu); + #else + gpu->dedicated.used = gpu->shared.used = gpu->dedicated.total = gpu->shared.total = FF_GPU_VMEM_SIZE_UNSET; + gpu->type = FF_GPU_TYPE_UNKNOWN; + #endif gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; - gpu->temperature = FF_GPU_TEMP_UNSET; #ifdef __linux__ From 67d3910fd311ab24a0a745ec0c9c705c5d05fc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Jul 2023 11:19:23 +0800 Subject: [PATCH 311/493] LM (Linux): fix LightDM version detection --- src/detection/lm/lm_linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 93137bcd6..6b96db254 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -122,6 +122,7 @@ static const char* getLightdmVersion(FFstrbuf* version) // lightdm 1.30.0 ffStrbufSubstrAfterFirstC(version, ' '); + ffStrbufTrimRight(version, '\n'); return NULL; } From c9735984e993161c74f755bcabfd33ad4689a6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Jul 2023 07:32:31 +0000 Subject: [PATCH 312/493] DE (Linux): revert bc7d84fea2053883f734c5cc40a50b176cd67fa1 Ref: #495 --- src/detection/displayserver/linux/wmde.c | 62 +++++++++++++++++------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index b563bc83e..60473a6f8 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -289,24 +289,52 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) { if(!ffStrSet(name)) return; - else if(strcasestr(name, "plasma") != NULL || strcasecmp(name, "KDE") == 0) - getKDE(result); - else if(strcasestr(name, "budgie") != NULL) - getBudgie(result); + else if( - strcasecmp(name, "polkit-gnome") != 0 && - strcasecmp(name, "gnome-keyring") != 0 && - strcasestr(name, "gnome") != NULL - ) - getGnome(result); - else if(strcasestr(name, "cinnamon") != NULL) - getCinnamon(result); - else if(strcasestr(name, "xfce") != NULL) - getXFCE4(result); - else if(strcasestr(name, "mate") != NULL) - getMate(result); - else if(strcasestr(name, "lxqt") != NULL) - getLXQt(result); + strcasecmp(name, "KDE") == 0 || + strcasecmp(name, "plasma") == 0 || + strcasecmp(name, "plasmashell") == 0 || + strcasecmp(name, "plasmawayland") == 0 + ) getKDE(result); + + else if( + strcasecmp(name, "Gnome") == 0 || + strcasecmp(name, "ubuntu:GNOME") == 0 || + strcasecmp(name, "ubuntu") == 0 || + strcasecmp(name, "gnome-shell") == 0 + ) getGnome(result); + + else if( + strcasecmp(name, "X-Cinnamon") == 0 || + strcasecmp(name, "Cinnamon") == 0 + ) getCinnamon(result); + + else if( + strcasecmp(name, "XFCE") == 0 || + strcasecmp(name, "X-XFCE") == 0 || + strcasecmp(name, "XFCE4") == 0 || + strcasecmp(name, "X-XFCE4") == 0 || + strcasecmp(name, "xfce4-session") == 0 + ) getXFCE4(result); + + else if( + strcasecmp(name, "MATE") == 0 || + strcasecmp(name, "X-MATE") == 0 || + strcasecmp(name, "mate-session") == 0 + ) getMate(result); + + else if( + strcasecmp(name, "LXQt") == 0 || + strcasecmp(name, "X-LXQT") == 0 || + strcasecmp(name, "lxqt-session") == 0 + ) getLXQt(result); + + else if( + strcasecmp(name, "Budgie") == 0 || + strcasecmp(name, "X-Budgie") == 0 || + strcasecmp(name, "budgie-desktop") == 0 || + strcasecmp(name, "Budgie:GNOME") == 0 + ) getBudgie(result); } static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) From da4ec98f47a41ff1addbc6f0cf1e92279fcd27ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Jul 2023 07:46:40 +0000 Subject: [PATCH 313/493] Wifi (Linux): fix false errors when built without libnm support --- src/detection/wifi/wifi_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 23534f3b9..0186179e2 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -323,7 +323,7 @@ const char* ffDetectWifi(FFlist* result) #endif #ifdef FF_DETECT_WIFI_WITH_IOCTLS - detectWifiWithIoctls(result); + return detectWifiWithIoctls(result); #endif return "linux/wireless.h not found during compilation"; From d3d121a965b4a4f3af40fa3030741af85d1f75ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Jul 2023 11:16:05 +0800 Subject: [PATCH 314/493] Brightness (Linux): use display model name as a fallback if we fail to match the display with edid --- src/detection/brightness/brightness_linux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 41a47aac8..f8867a3c0 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -146,6 +146,10 @@ static const char* detectWithDdcci(FFlist* result) if (ffStrbufStartsWithS(&brightness->name, "card")) ffStrbufSubstrAfterFirstC(&brightness->name, '-'); } + else + { + ffStrbufAppendS(&brightness->name, display->model_name); + } } ffddca_close_display(handle); } From 872b108e52d1cf740c524da27dfba21689d3fe89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Jul 2023 11:19:16 +0800 Subject: [PATCH 315/493] DisplayServer (Linux): fix heap-buffer-overflow reading --- src/detection/displayserver/linux/xcb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 0858690ed..e27e5a174 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -17,6 +17,7 @@ typedef struct XcbPropertyData FF_LIBRARY_SYMBOL(xcb_get_property_value_length) FF_LIBRARY_SYMBOL(xcb_get_atom_name) FF_LIBRARY_SYMBOL(xcb_get_atom_name_name) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_name_length) FF_LIBRARY_SYMBOL(xcb_get_atom_name_reply) } XcbPropertyData; @@ -30,6 +31,7 @@ static bool xcbInitPropertyData(void* libraryHandle, XcbPropertyData* propertyDa FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_value_length, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_name, false) + FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_name_length, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_reply, false) return true; @@ -293,11 +295,10 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* data->propData.ffxcb_get_atom_name(data->connection, monitor->name), NULL ); - char* buf = data->propData.ffxcb_get_atom_name_name(nameReply); - FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(buf); - // name.chars = buf; - // name.allocated = (uint32_t) strlen(buf); - // name.length = name.allocated; + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateNS( + (uint32_t) data->propData.ffxcb_get_atom_name_name_length(nameReply), + data->propData.ffxcb_get_atom_name_name(nameReply) + ); bool foundOutput = false; From 87ebdef8df4323303702d1594199d5744c4d4db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 00:33:18 +0800 Subject: [PATCH 316/493] Processing (Linux): don't leave zombie processes --- src/common/processing_linux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 43c19dae9..d44eebb27 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -9,9 +9,17 @@ #include #include #include +#include enum { FF_PIPE_BUFSIZ = 4096 }; +static inline void waitpid_wrapper(pid_t* pid) +{ + // remove zombie processes + if (*pid > 0) + waitpid(*pid, NULL, 0); +} + const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr) { int pipes[2]; @@ -19,7 +27,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use if(pipe(pipes) == -1) return "pipe() failed"; - pid_t childPid = fork(); + __attribute__((__cleanup__(waitpid_wrapper))) pid_t childPid = fork(); if(childPid == -1) return "fork() failed"; From 55e0f8e5dd2ee5d1737c20e885a58a7abd1dd165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 08:22:45 +0800 Subject: [PATCH 317/493] Linux (Bluetooth): silence warnings --- src/detection/bluetooth/bluetooth_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index 3938cafbd..79f61d5fb 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -193,7 +193,7 @@ static const char* detectBluetooth(FFlist* devices) #endif -const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothDevice */) +const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothDevice */) { #ifdef FF_HAVE_DBUS return detectBluetooth(devices); From a9466654b21b67e01f2d44bb7af2658a8d23f708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 08:25:57 +0800 Subject: [PATCH 318/493] Processing (macOS): fix compiling --- src/common/processing_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index d44eebb27..9f5f0ca01 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include enum { FF_PIPE_BUFSIZ = 4096 }; From 426aae1ab64704ecf914d8bb141a36fbf7f77f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 11:24:12 +0800 Subject: [PATCH 319/493] PublicIP: print location --- CHANGELOG.md | 1 + src/modules/publicip/publicip.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b827262db..de07fc129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Features: * Support detecting brightness of external displays with DDC/CI (guard behind `--allow-slow-operations`) (Brightness) * Add option `--size-ndigits` and `--size-max-prefix` (#494) * Add option `--processing-timeout` to the timeout when waiting for child processes. +* Public IP module prints the IP location if `--publicip-url` is not set # 1.12.2 diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index 3b30e5b66..24d65ea3c 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -10,10 +10,17 @@ static FFNetworkingState state; static int status = -1; +static inline void wrapYyjsonFree(yyjson_doc** doc) +{ + assert(doc); + if (*doc) + yyjson_doc_free(*doc); +} + void ffPreparePublicIp(FFPublicIpOptions* options) { if (options->url.length == 0) - status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/ip", NULL); + status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/json", NULL); else { FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&options->url); @@ -56,6 +63,22 @@ void ffPrintPublicIp(FFPublicIpOptions* options) if (options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + + if (options->url.length == 0) + { + yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(result.chars, result.length, 0, NULL, NULL); + if (doc) + { + yyjson_val* root = yyjson_doc_get_root(doc); + printf("%s (%s, %s)\n", + yyjson_get_str(yyjson_obj_get(root, "ip")), + yyjson_get_str(yyjson_obj_get(root, "city")), + yyjson_get_str(yyjson_obj_get(root, "country")) + ); + return; + } + } + ffStrbufPutTo(&result, stdout); } else From f6101a6629410f37e2ccc5bd1926d72cb3a95711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 11:31:14 +0800 Subject: [PATCH 320/493] Doc: update changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de07fc129..20a6fbf7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,13 @@ Features: * Support detecting brightness of external displays with DDC/CI (guard behind `--allow-slow-operations`) (Brightness) * Add option `--size-ndigits` and `--size-max-prefix` (#494) * Add option `--processing-timeout` to the timeout when waiting for child processes. -* Public IP module prints the IP location if `--publicip-url` is not set +* Public IP module prints the IP location if `--publicip-url` is not set (PublicIP) + +Bugfixes: +* Fix possible hanging (TerminalFont, #493) +* Fix heap-buffer-overflow reading (DisplayServer, Linux) +* Fix false errors when built without libnm support (Wifi, Linux) +* Properly detect CPU on POWER (CPU, Linux) # 1.12.2 From 1ddecf4cdbe8d3dcc323a0ee4d6c635230fc485f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 13:25:19 +0800 Subject: [PATCH 321/493] Brightness (Linux): work around #499 --- src/detection/brightness/brightness_linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index f8867a3c0..8f3e0f4c9 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -116,6 +116,7 @@ static const char* detectWithDdcci(FFlist* result) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_any_vcp_value_using_explicit_type) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display) + libddcutil = NULL; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330 FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL; if (__builtin_expect(ffddca_get_display_info_list2(false, &infoList) < 0, 0)) From 64ea1af99124913687125849c6a11bafaa102aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Jul 2023 15:46:19 +0800 Subject: [PATCH 322/493] Processing: always trim trailing new lines --- src/common/processing.h | 8 ++++++-- src/detection/terminalshell/terminalshell.c | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/processing.h b/src/common/processing.h index 9f02e799d..8b38337c0 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -9,12 +9,16 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) { - return ffProcessAppendOutput(buffer, argv, false); + const char* error = ffProcessAppendOutput(buffer, argv, false); + if (!error) ffStrbufTrimRight(buffer, '\n'); + return error; } static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) { - return ffProcessAppendOutput(buffer, argv, true); + const char* error = ffProcessAppendOutput(buffer, argv, true); + if (!error) ffStrbufTrimRight(buffer, '\n'); + return error; } #endif diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index ddfd85390..ad540e666 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -83,7 +83,6 @@ static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) return false; //fish, version 3.6.0 - ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); return true; } @@ -101,7 +100,6 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) if(!getExeVersionRaw(exe, version)) return false; - ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); return true; } @@ -118,7 +116,6 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) NULL })) return false; - ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); return true; } From ddc55d70a7a847e00314670c8098dbbca3b8763e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 13:12:50 +0800 Subject: [PATCH 323/493] Terminal (Linux): don't assume conhost in WSL --- src/detection/terminalshell/terminalshell_linux.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 770df3c09..a6777f570 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -208,6 +208,11 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) getenv("WT_SESSION") != NULL || getenv("WT_PROFILE_ID") != NULL )) term = "Windows Terminal"; + + //ConEmu + if(!ffStrSet(term) && ( + getenv("ConEmuPID") != NULL + )) term = "ConEmu"; #endif //Alacritty @@ -237,15 +242,6 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) if(!ffStrSet(term)) term = getenv("TERM_PROGRAM"); - #ifdef __linux__ - if(!ffStrSet(term)) - { - //We are in WSL but not in Windows Terminal - if(getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) - term = "conhost"; - } - #endif - //Normal Terminal if(!ffStrSet(term)) term = getenv("TERM"); From e4b3d7e6cfb3af754d13068adf84455919450614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 14:22:39 +0800 Subject: [PATCH 324/493] Terminal (Windows): don't detect Windows Terminal as conhost --- .../terminalshell/terminalshell_windows.c | 47 ++----------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index bf3915d65..d7a42e0c5 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -78,45 +78,6 @@ static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrb return true; } -static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* result, uint32_t ppid) -{ - ULONG size = 0; - if(NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) - return false; - - size += sizeof(SystemProcessInformation) * 5; //What if new processes are created during two syscalls? - - SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PROCESS_INFORMATION*)malloc(size); - if(!pstart) - return false; - - if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessInformation, pstart, size, NULL))) - return false; - - uint32_t currentProcessId = (uint32_t) GetCurrentProcessId(); - - for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset)) - { - if ((uint32_t)(uintptr_t) ptr->InheritedFromUniqueProcessId != ppid) - continue; - - uint32_t pid = (uint32_t)(uintptr_t) ptr->UniqueProcessId; - if (pid == currentProcessId) - continue; - - if(!getProcessInfo(pid, NULL, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName)) - return false; - - result->terminalPid = pid; - ffStrbufSet(&result->terminalPrettyName, &result->terminalProcessName); - if(ffStrbufEndsWithIgnCaseS(&result->terminalPrettyName, ".exe")) - ffStrbufSubstrBefore(&result->terminalPrettyName, result->terminalPrettyName.length - 4); - - return true; - } - return false; -} - bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) @@ -232,14 +193,14 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "sihost") || ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "explorer") ) { + // A CUI program created by Windows Explorer will spawn a conhost as its child. + // However the conhost process is just a placeholder; + // The true terminal can be Windows Terminal or others. ffStrbufClear(&result->terminalProcessName); ffStrbufClear(&result->terminalPrettyName); ffStrbufClear(&result->terminalExe); result->terminalExeName = ""; - - // Maybe terminal process is created by shell - if(!getTerminalInfoByEnumeratingChildProcesses(result, result->shellPid)) - return 0; + return 0; } else result->terminalPid = pid; From 7705237f10d51061879722aa2d16731be9d34385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 18:26:04 +0800 Subject: [PATCH 325/493] Terminal (Windows): better terminal detection when running shell directly in Windows Explorer --- .../terminalshell/terminalshell_windows.c | 170 ++++++++++---- src/util/windows/registry.c | 219 ++++++++++-------- src/util/windows/registry.h | 1 + 3 files changed, 244 insertions(+), 146 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index d7a42e0c5..165c14520 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -1,7 +1,10 @@ #include "terminalshell.h" +#include "common/io/io.h" #include "common/processing.h" #include "common/thread.h" #include "util/mallocHelper.h" +#include "util/windows/registry.h" +#include "util/windows/unicode.h" #include #include @@ -161,6 +164,118 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) return ppid; } +static bool getTerminalFromEnv(FFTerminalShellResult* result) +{ + if( + result->terminalProcessName.length > 0 && + ffStrbufIgnCaseCompS(&result->terminalProcessName, "explorer") != 0 + ) return false; + + const char* term = getenv("ConEmuPID"); + + if(term) + { + //ConEmu + uint32_t pid = (uint32_t) strtoul(term, NULL, 10); + result->terminalPid = pid; + getProcessInfo(pid, NULL, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName); + return true; + } + + //SSH + if(getenv("SSH_CONNECTION") != NULL) + term = getenv("SSH_TTY"); + + //Windows Terminal + if(!term && ( + getenv("WT_SESSION") != NULL || + getenv("WT_PROFILE_ID") != NULL + )) term = "Windows Terminal"; + + //Alacritty + if(!term && ( + getenv("ALACRITTY_SOCKET") != NULL || + getenv("ALACRITTY_LOG") != NULL || + getenv("ALACRITTY_WINDOW_ID") != NULL + )) term = "Alacritty"; + + if(!term) + term = getenv("TERM_PROGRAM"); + + //Normal Terminal + if(!term) + term = getenv("TERM"); + + if(term) + { + ffStrbufSetS(&result->terminalProcessName, term); + ffStrbufSetS(&result->terminalPrettyName, term); + ffStrbufSetS(&result->terminalExe, term); + result->terminalExeName = ""; + return true; + } + + return false; +} + +static bool detectDefaultTerminal(FFTerminalShellResult* result) +{ + wchar_t regPath[128] = L"SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\"; + wchar_t* uuid = regPath + strlen("SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\"); + DWORD bufSize = 80; + if (RegGetValueW(HKEY_CURRENT_USER, L"Console\\%%Startup", L"DelegationTerminal", RRF_RT_REG_SZ, NULL, uuid, &bufSize) == ERROR_SUCCESS) + { + if(wcscmp(uuid, L"{00000000-0000-0000-0000-000000000000}") == 0) + { + // Let Windows deside + return false; + } + if(wcscmp(uuid, L"{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}") == 0) + { + goto conhost; + } + + FF_HKEY_AUTO_DESTROY hKey = NULL; + if(ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regPath, &hKey, NULL)) + { + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); + if(ffRegGetSubKey(hKey, 0, &path, NULL)) + { + if (ffStrbufStartsWithS(&path, "Microsoft.WindowsTerminal")) + { + ffStrbufSetS(&result->terminalProcessName, "WindowsTerminal.exe"); + ffStrbufSetS(&result->terminalPrettyName, "WindowsTerminal"); + ffStrbufSetF(&result->terminalExe, "%s\\WindowsApps\\%s\\WindowsTerminal.exe", getenv("ProgramFiles"), path.chars); + if(ffPathExists(result->terminalExe.chars, FF_PATHTYPE_FILE)) + { + result->terminalExeName = result->terminalExe.chars + ffStrbufLastIndexC(&result->terminalExe, '\\') + 1; + } + else + { + ffStrbufDestroy(&result->terminalExe); + ffStrbufInitMove(&result->terminalExe, &path); + result->terminalExeName = ""; + } + return true; + } + } + } + } + +conhost: + ffStrbufSetF(&result->terminalExe, "%s\\System32\\conhost.exe", getenv("SystemRoot")); + if(ffPathExists(result->terminalExe.chars, FF_PATHTYPE_FILE)) + { + ffStrbufSetS(&result->terminalProcessName, "conhost.exe"); + ffStrbufSetS(&result->terminalPrettyName, "conhost"); + result->terminalExeName = result->terminalExe.chars + ffStrbufLastIndexC(&result->terminalExe, '\\') + 1; + return true; + } + + ffStrbufClear(&result->terminalExe); + return false; +} + static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) { uint32_t ppid; @@ -196,11 +311,14 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) // A CUI program created by Windows Explorer will spawn a conhost as its child. // However the conhost process is just a placeholder; // The true terminal can be Windows Terminal or others. - ffStrbufClear(&result->terminalProcessName); - ffStrbufClear(&result->terminalPrettyName); - ffStrbufClear(&result->terminalExe); - result->terminalExeName = ""; - return 0; + if (!getTerminalFromEnv(result) && !detectDefaultTerminal(result)) + { + ffStrbufClear(&result->terminalProcessName); + ffStrbufClear(&result->terminalPrettyName); + ffStrbufClear(&result->terminalExe); + result->terminalExeName = ""; + return 0; + } } else result->terminalPid = pid; @@ -224,48 +342,6 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) return ppid; } -static void getTerminalFromEnv(FFTerminalShellResult* result) -{ - if( - result->terminalProcessName.length > 0 && - ffStrbufIgnCaseCompS(&result->terminalProcessName, "explorer") != 0 - ) return; - - const char* term = NULL; - - //SSH - if(getenv("SSH_CONNECTION") != NULL) - term = getenv("SSH_TTY"); - - //Windows Terminal - if(!term && ( - getenv("WT_SESSION") != NULL || - getenv("WT_PROFILE_ID") != NULL - )) term = "Windows Terminal"; - - //Alacritty - if(!term && ( - getenv("ALACRITTY_SOCKET") != NULL || - getenv("ALACRITTY_LOG") != NULL || - getenv("ALACRITTY_WINDOW_ID") != NULL - )) term = "Alacritty"; - - if(!term) - term = getenv("TERM_PROGRAM"); - - //Normal Terminal - if(!term) - term = getenv("TERM"); - - if(term) - { - ffStrbufSetS(&result->terminalProcessName, term); - ffStrbufSetS(&result->terminalPrettyName, term); - ffStrbufSetS(&result->terminalExe, term); - result->terminalExeName = ""; - } -} - bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version); const FFTerminalShellResult* ffDetectTerminalShell(void) diff --git a/src/util/windows/registry.c b/src/util/windows/registry.c index 0a80781d3..d4dbffa93 100644 --- a/src/util/windows/registry.c +++ b/src/util/windows/registry.c @@ -1,99 +1,120 @@ -#include "registry.h" -#include "unicode.h" -#include "util/mallocHelper.h" - -static const char* hKey2Str(HKEY hKey) -{ - #define HKEY_CASE(compareKey) if(hKey == compareKey) return #compareKey; - HKEY_CASE(HKEY_CLASSES_ROOT) - HKEY_CASE(HKEY_CURRENT_USER) - HKEY_CASE(HKEY_LOCAL_MACHINE) - HKEY_CASE(HKEY_USERS) - HKEY_CASE(HKEY_PERFORMANCE_DATA) - HKEY_CASE(HKEY_PERFORMANCE_TEXT) - HKEY_CASE(HKEY_PERFORMANCE_NLSTEXT) - HKEY_CASE(HKEY_CURRENT_CONFIG) - HKEY_CASE(HKEY_DYN_DATA) - HKEY_CASE(HKEY_CURRENT_USER_LOCAL_SETTINGS) - #undef HKEY_CASE - - return "UNKNOWN"; -} - -bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrbuf* error) -{ - if(RegOpenKeyExW(hKey, subKeyW, 0, KEY_READ, result) != ERROR_SUCCESS) - { - if(error) - { - FF_STRBUF_AUTO_DESTROY subKeyA = ffStrbufCreateWS(subKeyW); - ffStrbufAppendF(error, "RegOpenKeyExW(%s\\%s) failed", hKey2Str(hKey), subKeyA.chars); - } - return false; - } - return true; -} - -bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error) -{ - DWORD bufSize; //with tailing '\0' - if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_SZ, NULL, NULL, &bufSize) != ERROR_SUCCESS) - { - if(error) - { - if(!valueNameW) - valueNameW = L"(default)"; - FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); - ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_SZ) failed", valueNameA.chars); - } - return false; - } - wchar_t* FF_AUTO_FREE resultW = (wchar_t*)malloc(bufSize); - if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_SZ, NULL, resultW, &bufSize) != ERROR_SUCCESS) - { - if(error) - { - if(!valueNameW) - valueNameW = L"(default)"; - FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); - ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_REG_SZ) failed", valueNameA.chars); - } - return false; - } - ffStrbufSetWS(result, resultW); - return true; -} - -bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error) -{ - DWORD bufSize = sizeof(*result); - if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_DWORD, NULL, result, &bufSize) != ERROR_SUCCESS) - { - if(error) - { - if(!valueNameW) - valueNameW = L"(default)"; - FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); - ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_DWORD) failed", valueNameA.chars); - } - return false; - } - return true; -} - -bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error) -{ - DWORD bufSize = sizeof(*result); - if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_QWORD, NULL, result, &bufSize) != ERROR_SUCCESS) - { - if(error) - { - if(!valueNameW) - valueNameW = L"(default)"; - FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); - ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_QWORD) failed", valueNameA.chars); - } - return false; - } - return true; -} +#include "registry.h" +#include "unicode.h" +#include "util/mallocHelper.h" + +static const char* hKey2Str(HKEY hKey) +{ + #define HKEY_CASE(compareKey) if(hKey == compareKey) return #compareKey; + HKEY_CASE(HKEY_CLASSES_ROOT) + HKEY_CASE(HKEY_CURRENT_USER) + HKEY_CASE(HKEY_LOCAL_MACHINE) + HKEY_CASE(HKEY_USERS) + HKEY_CASE(HKEY_PERFORMANCE_DATA) + HKEY_CASE(HKEY_PERFORMANCE_TEXT) + HKEY_CASE(HKEY_PERFORMANCE_NLSTEXT) + HKEY_CASE(HKEY_CURRENT_CONFIG) + HKEY_CASE(HKEY_DYN_DATA) + HKEY_CASE(HKEY_CURRENT_USER_LOCAL_SETTINGS) + #undef HKEY_CASE + + return "UNKNOWN"; +} + +bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrbuf* error) +{ + if(RegOpenKeyExW(hKey, subKeyW, 0, KEY_READ, result) != ERROR_SUCCESS) + { + if(error) + { + FF_STRBUF_AUTO_DESTROY subKeyA = ffStrbufCreateWS(subKeyW); + ffStrbufAppendF(error, "RegOpenKeyExW(%s\\%s) failed", hKey2Str(hKey), subKeyA.chars); + } + return false; + } + return true; +} + +bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error) +{ + DWORD bufSize; //with tailing '\0' + if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_SZ, NULL, NULL, &bufSize) != ERROR_SUCCESS) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_SZ) failed", valueNameA.chars); + } + return false; + } + wchar_t* FF_AUTO_FREE resultW = (wchar_t*)malloc(bufSize); + if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_SZ, NULL, resultW, &bufSize) != ERROR_SUCCESS) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_REG_SZ) failed", valueNameA.chars); + } + return false; + } + ffStrbufSetWS(result, resultW); + return true; +} + +bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error) +{ + DWORD bufSize = sizeof(*result); + if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_DWORD, NULL, result, &bufSize) != ERROR_SUCCESS) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_DWORD) failed", valueNameA.chars); + } + return false; + } + return true; +} + +bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error) +{ + DWORD bufSize = sizeof(*result); + if(RegGetValueW(hKey, NULL, valueNameW, RRF_RT_QWORD, NULL, result, &bufSize) != ERROR_SUCCESS) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, result, RRF_RT_QWORD) failed", valueNameA.chars); + } + return false; + } + return true; +} + +bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error) +{ + DWORD bufSize = 0; + if(RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, &bufSize, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) + { + if (error) + ffStrbufAppendS(error, "RegQueryInfoKeyW(hKey) failed"); + return false; + } + ++bufSize; + wchar_t* FF_AUTO_FREE resultW = (wchar_t*) malloc(bufSize * sizeof(*resultW)); + if(RegEnumKeyExW(hKey, index, resultW, &bufSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) + { + if (error) + ffStrbufAppendF(error, "RegEnumKeyExW(hKey, %u) failed", (unsigned) index); + return false; + } + ffStrbufSetWS(result, resultW); + return true; +} diff --git a/src/util/windows/registry.h b/src/util/windows/registry.h index 44fd5c430..222b468a7 100644 --- a/src/util/windows/registry.h +++ b/src/util/windows/registry.h @@ -19,5 +19,6 @@ bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrb bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error); bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error); bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error); +bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error); #endif From a77553409b578b0a7d75d311aab1136b4f36e3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 18:57:33 +0800 Subject: [PATCH 326/493] Processing (Windows): try fixing Win7 compatiblity --- src/common/processing_windows.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index ea304606b..6355a3a1f 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -78,9 +78,13 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use if(!success) return "CreateProcessA() failed"; + FF_AUTO_CLOSE_FD HANDLE hProcess = piProcInfo.hProcess; + FF_MAYBE_UNUSED FF_AUTO_CLOSE_FD HANDLE hThread = piProcInfo.hThread; + char str[FF_PIPE_BUFSIZ]; DWORD nRead = 0; - OVERLAPPED overlapped = {}; + FF_AUTO_CLOSE_FD HANDLE hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + OVERLAPPED overlapped = { .hEvent = hEvent }; // ReadFile always completes synchronously if the pipe is not created with FILE_FLAG_OVERLAPPED do { @@ -89,13 +93,21 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use switch (GetLastError()) { case ERROR_IO_PENDING: - if (!GetOverlappedResultEx(hChildPipeRead, &overlapped, &nRead, (DWORD) timeout, TRUE)) + if (!timeout || WaitForSingleObject(hEvent, (DWORD) timeout) != WAIT_OBJECT_0) + { + CancelIo(hChildPipeRead); + TerminateProcess(hProcess, 1); + return "WaitForSingleObject(hEvent) failed or timeout"; + } + + if (!GetOverlappedResult(hChildPipeRead, &overlapped, &nRead, FALSE)) { if (GetLastError() == ERROR_BROKEN_PIPE) return NULL; + CancelIo(hChildPipeRead); - TerminateProcess(piProcInfo.hProcess, 1); - return "GetOverlappedResultEx(hChildPipeRead) failed or timeout"; + TerminateProcess(hProcess, 1); + return "GetOverlappedResult(hChildPipeRead) failed"; } break; @@ -104,7 +116,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use default: CancelIo(hChildPipeRead); - TerminateProcess(piProcInfo.hProcess, 1); + TerminateProcess(hProcess, 1); return "ReadFile(hChildPipeRead) failed"; } } From 6f0b4c0ce61e3885aaa40e40e5f2412402bf3404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 19:22:20 +0800 Subject: [PATCH 327/493] Cursor (Windows): fix Win7 compatibility --- src/detection/cursor/cursor_windows.c | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/detection/cursor/cursor_windows.c b/src/detection/cursor/cursor_windows.c index 6cb8f8985..d992ff83c 100644 --- a/src/detection/cursor/cursor_windows.c +++ b/src/detection/cursor/cursor_windows.c @@ -1,17 +1,17 @@ -#include "cursor.h" - -#include "util/windows/registry.h" - -void ffDetectCursor(FFCursorResult* result) -{ - FF_HKEY_AUTO_DESTROY hKey; - if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error)) - { - if (!ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error)) - return; - - uint32_t cursorBaseSize; - ffRegReadUint(hKey, L"CursorBaseSize", &cursorBaseSize, &result->error); - ffStrbufAppendF(&result->size, "%u", (unsigned) cursorBaseSize); - } -} +#include "cursor.h" + +#include "util/windows/registry.h" + +void ffDetectCursor(FFCursorResult* result) +{ + FF_HKEY_AUTO_DESTROY hKey; + if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error)) + { + if (!ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error)) + return; + + uint32_t cursorBaseSize; + if (ffRegReadUint(hKey, L"CursorBaseSize", &cursorBaseSize, NULL)) + ffStrbufAppendF(&result->size, "%u", (unsigned) cursorBaseSize); + } +} From c1d5a3eb1c7b8b3926ff89fb19fc53cbe2fa06b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 19:47:17 +0800 Subject: [PATCH 328/493] Terminal (Windows): unified handling of ConEmu --- .../terminalfont/terminalfont_windows.c | 2 +- src/detection/terminalshell/terminalshell.c | 2 +- .../terminalshell/terminalshell_windows.c | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index 704efa5d5..e461986dd 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -91,6 +91,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FF detectMintty(terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "conhost.exe") == 0) detectConhost(terminalFont); - else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "ConEmuC")) + else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "ConEmu")) detectConEmu(terminalFont); } diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index ad540e666..b5261f7a7 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -312,7 +312,7 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "WindowsTerminal.exe")) return getTerminalVersionWindowsTerminal(exe, version); - if(ffStrbufStartsWithIgnCaseS(processName, "ConEmuC")) + if(ffStrbufStartsWithIgnCaseS(processName, "ConEmu")) return getTerminalVersionConEmu(exe, version); #endif diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 165c14520..15c2da12f 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -107,7 +107,7 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufIgnCaseEqualS(&result->shellPrettyName, "fastfetch") || //scoop warps the real binaries with a "shim" exe ffStrbufIgnCaseEqualS(&result->shellPrettyName, "flashfetch") || ffStrbufContainIgnCaseS(&result->shellPrettyName, "debug") || - ffStrbufStartsWithIgnCaseS(&result->shellPrettyName, "ConEmuC") // https://github.com/fastfetch-cli/fastfetch/issues/488#issuecomment-1619982014 + ffStrbufStartsWithIgnCaseS(&result->shellPrettyName, "ConEmu") // https://github.com/fastfetch-cli/fastfetch/issues/488#issuecomment-1619982014 ) { ffStrbufClear(&result->shellProcessName); ffStrbufClear(&result->shellPrettyName); @@ -178,8 +178,17 @@ static bool getTerminalFromEnv(FFTerminalShellResult* result) //ConEmu uint32_t pid = (uint32_t) strtoul(term, NULL, 10); result->terminalPid = pid; - getProcessInfo(pid, NULL, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName); - return true; + if(getProcessInfo(pid, NULL, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName)) + { + ffStrbufSet(&result->terminalPrettyName, &result->terminalProcessName); + if(ffStrbufEndsWithIgnCaseS(&result->terminalPrettyName, ".exe")) + ffStrbufSubstrBefore(&result->terminalPrettyName, result->terminalPrettyName.length - 4); + return true; + } + else + { + term = "ConEmu"; + } } //SSH @@ -295,7 +304,8 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "fish") || ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "nu") || ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "powershell") || - ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "powershell_ise") + ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "powershell_ise") || + ffStrbufStartsWithIgnCaseS(&result->terminalPrettyName, "ConEmuC") // wrapper process of ConEmu ) { //We are nested shell ffStrbufClear(&result->terminalProcessName); @@ -334,8 +344,6 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufSetS(&result->terminalPrettyName, "Visual Studio Code"); else if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "explorer")) ffStrbufSetS(&result->terminalPrettyName, "Windows Explorer"); - else if(ffStrbufStartsWithIgnCaseS(&result->terminalPrettyName, "ConEmuC")) - ffStrbufSetS(&result->terminalPrettyName, "ConEmu"); else if(ffStrbufEqualS(&result->terminalPrettyName, "wezterm-gui")) ffStrbufInitS(&result->terminalPrettyName, "WezTerm"); From eea70020c30029fd8fccc63a431ad75c7462fa8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 20:39:28 +0800 Subject: [PATCH 329/493] Terminal (macOS): fix compatibility with Fig --- src/detection/terminalshell/terminalshell_linux.c | 6 ++++++ src/util/stringUtils.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index a6777f570..91852519e 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -172,6 +172,12 @@ static void getTerminalShell(FFTerminalShellResult* result, pid_t pid) return; } + #ifdef __APPLE__ + // https://github.com/fastfetch-cli/fastfetch/discussions/501 + if (ffStrEndsWith(name, " (figterm)")) + getProcessNameAndPpid(ppid, name, &ppid); + #endif + result->terminalPid = (uint32_t) pid; ffStrbufSetS(&result->terminalProcessName, name); getProcessInformation(pid, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName); diff --git a/src/util/stringUtils.h b/src/util/stringUtils.h index 2283b0aec..80894ad26 100644 --- a/src/util/stringUtils.h +++ b/src/util/stringUtils.h @@ -25,6 +25,15 @@ static inline bool ffStrStartsWith(const char* str, const char* compareTo) return strncmp(str, compareTo, strlen(compareTo)) == 0; } +static inline bool ffStrEndsWith(const char* str, const char* compareTo) +{ + size_t strLength = strlen(str); + size_t compareToLength = strlen(compareTo); + if (strLength < compareToLength) + return false; + return memcmp(str + strLength - compareToLength, compareTo, compareToLength) == 0; +} + static inline bool ffStrEquals(const char* str, const char* compareTo) { return strcmp(str, compareTo) == 0; From c79120b99cd68b6ed438979e2d53360bc4a61576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 20:55:22 +0800 Subject: [PATCH 330/493] TerminalFont (macOS): detect non-ascii font of iTerm --- src/detection/terminalfont/terminalfont.h | 1 + src/detection/terminalfont/terminalfont_apple.m | 8 ++++++++ src/modules/terminalfont/terminalfont.c | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.h b/src/detection/terminalfont/terminalfont.h index 9b15dede4..936cdeb4f 100644 --- a/src/detection/terminalfont/terminalfont.h +++ b/src/detection/terminalfont/terminalfont.h @@ -10,6 +10,7 @@ typedef struct FFTerminalFontResult { FFstrbuf error; FFfont font; + FFfont fallback; } FFTerminalFontResult; bool ffDetectTerminalFont(FFTerminalFontResult* result); diff --git a/src/detection/terminalfont/terminalfont_apple.m b/src/detection/terminalfont/terminalfont_apple.m index c89b4135f..871462109 100644 --- a/src/detection/terminalfont/terminalfont_apple.m +++ b/src/detection/terminalfont/terminalfont_apple.m @@ -38,6 +38,14 @@ static void detectIterm2(FFTerminalFontResult* terminalFont) return; } ffFontInitWithSpace(&terminalFont->font, normalFont.UTF8String); + + NSNumber* useNonAsciiFont = [bookmark valueForKey:@"Use Non-ASCII Font"]; + if(useNonAsciiFont.boolValue) + { + NSString* nonAsciiFont = [bookmark valueForKey:@"Non Ascii Font"]; + if (nonAsciiFont) + ffFontInitWithSpace(&terminalFont->fallback, nonAsciiFont.UTF8String); + } return; } diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 6e03ed45c..9e9b683d8 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -11,6 +11,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) { FFTerminalFontResult terminalFont; ffFontInit(&terminalFont.font); + ffFontInit(&terminalFont.fallback); ffStrbufInit(&terminalFont.error); if(!ffDetectTerminalFont(&terminalFont)) @@ -22,7 +23,13 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - ffStrbufPutTo(&terminalFont.font.pretty, stdout); + ffStrbufWriteTo(&terminalFont.font.pretty, stdout); + if(terminalFont.fallback.pretty.length) + { + fputs(" / ", stdout); + ffStrbufWriteTo(&terminalFont.fallback.pretty, stdout); + } + putchar('\n'); } else { @@ -37,6 +44,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) ffStrbufDestroy(&terminalFont.error); ffFontDestroy(&terminalFont.font); + ffFontDestroy(&terminalFont.fallback); } void ffInitTerminalFontOptions(FFTerminalFontOptions* options) From 80007233fa315c590aa9189639052bff3ce71194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 22:39:21 +0800 Subject: [PATCH 331/493] Disk (Linux): fix #479 --- src/detection/disk/disk_linux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 2859fa374..6cca83dab 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -19,6 +19,10 @@ static bool isPhysicalDevice(FFstrbuf* device) { #ifndef __ANDROID__ //On Android, `/dev` is not accessable, so that the following checks always fail + //https://askubuntu.com/a/1289123 + if(ffStrbufEqualS(device, "/cow")) + return true; + //DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem. if(ffStrbufEqualS(device, "drvfs")) return true; From a5c838e4a0149800605cb946413fbc55a02d73e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Jul 2023 23:00:39 +0800 Subject: [PATCH 332/493] Disk: print mount points as links --- src/modules/disk/disk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index fa5bd325b..de983f3ed 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -15,7 +15,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) if(options->moduleArgs.key.length == 0) { - ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars); + if(instance.config.pipe) + ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars); + else + ffStrbufAppendF(&key, "%s (\e]8;;file://%s\e\\%s\e]8;;\e\\)", FF_DISK_MODULE_NAME, disk->mountpoint.chars, disk->mountpoint.chars); } else { From 44faa3aa8405ab1b6c53ad5a615252d860bc6232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 10:41:53 +0800 Subject: [PATCH 333/493] LocalIP (Linux): test default route --- src/detection/localip/localip.h | 1 + src/detection/localip/localip_linux.c | 27 +++++++++++++++++++++++++ src/detection/localip/localip_windows.c | 1 + src/modules/localip/localip.c | 9 ++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index 4c9a91539..8d0fe84bf 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -11,6 +11,7 @@ typedef struct FFLocalIpResult FFstrbuf ipv4; FFstrbuf ipv6; FFstrbuf mac; + bool defaultRoute; } FFLocalIpResult; const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results); diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 8ee01f7af..17fa2651b 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -1,4 +1,5 @@ #include "localip.h" +#include "common/io/io.h" #include #include @@ -6,6 +7,7 @@ #include #include #include +#include #if defined(__FreeBSD__) || defined(__APPLE__) #include @@ -13,6 +15,23 @@ #include #endif +static bool getDefaultRoute(char iface[16 /*IF_NAMESIZE*/ + 1]) +{ + FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); + // skip first line + flockfile(netRoute); + while (fgetc_unlocked(netRoute) != '\n'); + funlockfile(netRoute); + unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, + + while (fscanf(netRoute, "%16s%llx%*[^\n]", iface, &destination) == 2) + { + if (destination == 0) + return true; + } + return false; +} + static void addNewIp(FFlist* list, const char* name, const char* addr, int type) { FFLocalIpResult* ip = NULL; @@ -30,6 +49,7 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type) ffStrbufInit(&ip->ipv4); ffStrbufInit(&ip->ipv6); ffStrbufInit(&ip->mac); + ip->defaultRoute = false; } switch (type) @@ -111,5 +131,12 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) } if (ifAddrStruct) freeifaddrs(ifAddrStruct); + + char iface[16 /*IF_NAMESIZE*/ + 1]; + if (getDefaultRoute(iface)) + { + FF_LIST_FOR_EACH(FFLocalIpResult, ip, *results) + ip->defaultRoute = ffStrbufEqualS(&ip->name, iface); + } return NULL; } diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index d1295afb0..0f7c8b805 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -17,6 +17,7 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type ffStrbufInit(&ip->ipv4); ffStrbufInit(&ip->ipv6); ffStrbufInit(&ip->mac); + ip->defaultRoute = false; } else { diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index ecd07a5de..1ae61b4cc 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -31,7 +31,7 @@ static void formatKey(const FFLocalIpOptions* options, const FFLocalIpResult* ip } } -static void printIp(FFLocalIpResult* ip) +static void printIp(FFLocalIpResult* ip, bool markDefaultRoute) { bool flag = false; if (ip->ipv4.length) @@ -52,6 +52,8 @@ static void printIp(FFLocalIpResult* ip) else ffStrbufWriteTo(&ip->mac, stdout); } + if (markDefaultRoute && flag && ip->defaultRoute) + fputs(" *", stdout); } void ffPrintLocalIp(FFLocalIpOptions* options) @@ -82,7 +84,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) { if ((void*) ip != (void*) results.data) fputs(" - ", stdout); - printIp(ip); + printIp(ip, false); } putchar('\n'); } @@ -96,7 +98,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - printIp(ip); + printIp(ip, results.length > 1); putchar('\n'); } else @@ -106,6 +108,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, + {FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute}, }); } } From 68f71c542120fcfa0ddefd52828208fd74d0c683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 15:02:32 +0800 Subject: [PATCH 334/493] LocalIP (macOS): detect default route --- src/detection/localip/localip_linux.c | 96 ++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 17fa2651b..ce2bd1e59 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -11,11 +11,14 @@ #if defined(__FreeBSD__) || defined(__APPLE__) #include +#include +#include #else #include #endif -static bool getDefaultRoute(char iface[16 /*IF_NAMESIZE*/ + 1]) +#ifdef __linux__ +static bool getDefaultRoute(char iface[IF_NAMESIZE + 1]) { FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); // skip first line @@ -24,6 +27,7 @@ static bool getDefaultRoute(char iface[16 /*IF_NAMESIZE*/ + 1]) funlockfile(netRoute); unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, + static_assert(IF_NAMESIZE >= 16, "IF_NAMESIZE is too small"); while (fscanf(netRoute, "%16s%llx%*[^\n]", iface, &destination) == 2) { if (destination == 0) @@ -31,6 +35,96 @@ static bool getDefaultRoute(char iface[16 /*IF_NAMESIZE*/ + 1]) } return false; } +#elif defined(__FreeBSD__) || defined(__APPLE__) + +#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n)) + +#if defined(__APPLE__) +# define ROUNDUP(a) ROUNDUP2((a), sizeof(int)) +#elif defined(__NetBSD__) +# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t)) +#elif defined(__FreeBSD__) +# define ROUNDUP(a) ROUNDUP2((a), sizeof(int)) +#elif defined(__OpenBSD__) +# define ROUNDUP(a) ROUNDUP2((a), sizeof(int)) +#else +# error unknown platform +#endif + +static struct sockaddr * +get_rt_address(struct rt_msghdr *rtm, int desired) +{ + struct sockaddr *sa = (struct sockaddr *)(rtm + 1); + + for (int i = 0; i < RTAX_MAX; i++) + { + if (rtm->rtm_addrs & (1 << i)) + { + if ((1 <sa_len) + (char *)sa); + } + } + return NULL; +} + +static bool getDefaultRoute(char iface[IF_NAMESIZE + 1]) +{ + //https://github.com/hashPirate/copenheimer-masscan-fork/blob/36f1ed9f7b751a7dccd5ed27874e2e703db7d481/src/rawsock-getif.c#L104 + + FF_AUTO_CLOSE_FD int pfRoute = socket(PF_ROUTE, SOCK_RAW, AF_INET); + if (pfRoute < 0) + return false; + + { + struct timeval timeout = {1, 0}; + setsockopt(pfRoute, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); + setsockopt(pfRoute, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); + } + + int pid = getpid(); + + struct { + struct rt_msghdr hdr; + struct sockaddr_in dst; + uint8_t data[512]; + } rtmsg = { + .hdr = { + .rtm_type = RTM_GET, + .rtm_flags = RTF_UP | RTF_GATEWAY, + .rtm_version = RTM_VERSION, + .rtm_addrs = RTA_DST | RTA_IFP, + .rtm_msglen = sizeof(rtmsg.hdr) + sizeof(rtmsg.dst), + .rtm_pid = pid, + .rtm_seq = 1, + }, + .dst = { + .sin_family = AF_INET, + .sin_len = sizeof(rtmsg.dst), + }, + }; + + if (write(pfRoute, &rtmsg, rtmsg.hdr.rtm_msglen) != rtmsg.hdr.rtm_msglen) + return false; + + while (read(pfRoute, &rtmsg, sizeof(rtmsg)) > 0) + { + if (rtmsg.hdr.rtm_seq == 1 && rtmsg.hdr.rtm_pid == pid) + { + struct sockaddr_dl* sdl = (struct sockaddr_dl *)get_rt_address(&rtmsg.hdr, RTA_IFP); + if (sdl) + { + assert(sdl->sdl_nlen <= IF_NAMESIZE); + memcpy(iface, sdl->sdl_data, sdl->sdl_nlen); + iface[sdl->sdl_nlen] = 0; + return true; + } + return false; + } + } + return false; +} +#endif static void addNewIp(FFlist* list, const char* name, const char* addr, int type) { From 1e57c4c0887d78531d0b0d6272d056d8815a1773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 16:15:41 +0800 Subject: [PATCH 335/493] LocalIP (Windows): detect default route --- src/detection/localip/localip.h | 4 +++ src/detection/localip/localip_windows.c | 38 ++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index 8d0fe84bf..6fea95a79 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -12,6 +12,10 @@ typedef struct FFLocalIpResult FFstrbuf ipv6; FFstrbuf mac; bool defaultRoute; + + #ifdef _WIN32 + uint32_t ifIndex; + #endif } FFLocalIpResult; const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results); diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index 0f7c8b805..c986120ba 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -6,7 +6,34 @@ #include "util/windows/unicode.h" #include "localip.h" -static void addNewIp(FFlist* list, const char* name, const char* value, int type, bool newIp) +static void setDefaultRoute(FFlist* ips) +{ + ULONG size = 0; + if (GetIpForwardTable(NULL, &size, TRUE) != ERROR_INSUFFICIENT_BUFFER) + return; + + FF_AUTO_FREE MIB_IPFORWARDTABLE* pIpForwardTable = (MIB_IPFORWARDTABLE*) malloc(size); + if (GetIpForwardTable(pIpForwardTable, &size, TRUE) != ERROR_SUCCESS) + return; + + for (uint32_t i = 0; i < pIpForwardTable->dwNumEntries; ++i) + { + MIB_IPFORWARDROW* ipForwardRow = &pIpForwardTable->table[i]; + if (ipForwardRow->dwForwardDest == 0 && ipForwardRow->dwForwardMask == 0) + { + FF_LIST_FOR_EACH(FFLocalIpResult, ip, *ips) + { + if (ip->ifIndex == ipForwardRow->dwForwardIfIndex) + { + ip->defaultRoute = true; + break; + } + } + } + } +} + +static void addNewIp(FFlist* list, const char* name, const char* value, int type, bool newIp, uint32_t ifIndex) { FFLocalIpResult* ip = NULL; @@ -18,6 +45,7 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type ffStrbufInit(&ip->ipv6); ffStrbufInit(&ip->mac); ip->defaultRoute = false; + ip->ifIndex = ifIndex; } else { @@ -88,7 +116,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) uint8_t* ptr = adapter->PhysicalAddress; snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); - addNewIp(results, name, addressBuffer, -1, newIp); + addNewIp(results, name, addressBuffer, -1, newIp, adapter->IfIndex); newIp = false; } @@ -99,7 +127,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr; char addressBuffer[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN); - addNewIp(results, name, addressBuffer, AF_INET, newIp); + addNewIp(results, name, addressBuffer, AF_INET, newIp, adapter->IfIndex); newIp = false; } else if (ifa->Address.lpSockaddr->sa_family == AF_INET6) @@ -107,11 +135,13 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr; char addressBuffer[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN); - addNewIp(results, name, addressBuffer, AF_INET6, newIp); + addNewIp(results, name, addressBuffer, AF_INET6, newIp, adapter->IfIndex); newIp = false; } } } + setDefaultRoute(results); + return NULL; } From f34d51b911782304173ad4252caab9d810f6e7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 18:32:13 +0800 Subject: [PATCH 336/493] LocalIP: add option `--localip-default-route-only` --- CHANGELOG.md | 1 + doc/json_schema.json | 5 +++++ src/data/help.txt | 1 + src/modules/localip/localip.c | 27 +++++++++++++++++++++++++-- src/modules/localip/option.h | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a6fbf7f..930f7a4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Features: * Add option `--size-ndigits` and `--size-max-prefix` (#494) * Add option `--processing-timeout` to the timeout when waiting for child processes. * Public IP module prints the IP location if `--publicip-url` is not set (PublicIP) +* Add option `--localip-default-route-only` (LocalIP) Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/doc/json_schema.json b/doc/json_schema.json index 6391b2b79..025437c64 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -859,6 +859,11 @@ "title": "Show IPs with given name prefix only", "type": "string" }, + "showDefaultRouteOnly": { + "title": "Show ips that are used for default routing only", + "type": "boolean", + "default": false + }, "key": { "$ref": "#/$defs/key" }, diff --git a/src/data/help.txt b/src/data/help.txt index fae9abc0a..f7985f03e 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -131,6 +131,7 @@ Module specific options: --localip-show-mac : Show mac addresses in local ip module. Default is false --localip-show-loop : Show loop back addresses (127.0.0.1) in local ip module. Default is false --localip-name-prefix : Show IPs with given name prefix only. Default is empty + --localip-default-route-only : Show ips that are used for default routing only. Default is false --localip-compact : Show all IPs in one line. Default is false --publicip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0) --publicip-url: The URL of public IP detection server to be used. diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 1ae61b4cc..d3aeb3cba 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -80,10 +80,17 @@ void ffPrintLocalIp(FFLocalIpOptions* options) { ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + bool flag = false; + FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { - if ((void*) ip != (void*) results.data) + if (options->defaultRouteOnly && !ip->defaultRoute) + continue; + + if (flag) fputs(" - ", stdout); + else + flag = true; printIp(ip, false); } putchar('\n'); @@ -94,11 +101,14 @@ void ffPrintLocalIp(FFLocalIpOptions* options) FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { + if (options->defaultRouteOnly && !ip->defaultRoute) + continue; + formatKey(options, ip, &key); if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - printIp(ip, results.length > 1); + printIp(ip, !options->defaultRouteOnly); putchar('\n'); } else @@ -130,6 +140,7 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options) options->showType = FF_LOCALIP_TYPE_IPV4_BIT; ffStrbufInit(&options->namePrefix); + options->defaultRouteOnly = false; } bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value) @@ -190,6 +201,12 @@ bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, co return true; } + if (ffStrEqualsIgnCase(subKey, "default-route-only")) + { + options->defaultRouteOnly = ffOptionParseBoolean(value); + return true; + } + return false; } @@ -268,6 +285,12 @@ void ffParseLocalIpJsonObject(yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "defaultRouteOnly")) + { + options.defaultRouteOnly = yyjson_get_bool(val); + continue; + } + ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } diff --git a/src/modules/localip/option.h b/src/modules/localip/option.h index 65dcfc60d..8d58b8235 100644 --- a/src/modules/localip/option.h +++ b/src/modules/localip/option.h @@ -22,4 +22,5 @@ typedef struct FFLocalIpOptions FFLocalIpType showType; FFstrbuf namePrefix; + bool defaultRouteOnly; } FFLocalIpOptions; From 59dc2f82e3642e8de7c3f01a1f713ba405d7333a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 23:03:56 +0800 Subject: [PATCH 337/493] LocalIP (Linux): fix build on Android --- src/detection/localip/localip_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index ce2bd1e59..f1814f77f 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -23,7 +23,7 @@ static bool getDefaultRoute(char iface[IF_NAMESIZE + 1]) FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); // skip first line flockfile(netRoute); - while (fgetc_unlocked(netRoute) != '\n'); + while (getc_unlocked(netRoute) != '\n'); funlockfile(netRoute); unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, From 1dc0ee183c8f871d98809dfb8ea6a078915d9ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 23:40:59 +0800 Subject: [PATCH 338/493] LocalIP (Android): fix crashing --- src/detection/localip/localip_linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index f1814f77f..f93ee6f9d 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -17,10 +17,12 @@ #include #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__ANDROID__) static bool getDefaultRoute(char iface[IF_NAMESIZE + 1]) { FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); + if (!netRoute) return false; + // skip first line flockfile(netRoute); while (getc_unlocked(netRoute) != '\n'); From f1ebcd7c31e9aad8605bcb585bb30ec79c4cbcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Jul 2023 21:09:37 +0800 Subject: [PATCH 339/493] Logo: add `kitty-direct` protocol --- CHANGELOG.md | 5 +++++ doc/json_schema.json | 1 + src/logo/image/image.c | 16 +++++++--------- src/logo/option.c | 7 +++++++ src/logo/option.h | 1 + 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 930f7a4fb..756fcf836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,11 @@ Bugfixes: * Fix false errors when built without libnm support (Wifi, Linux) * Properly detect CPU on POWER (CPU, Linux) +Logo: +* Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: + 1. Although konsole was said to support `kitty` image protocol, it doesn't support `kitty-direct` + 2. wezterm support more image formats other than `.png` (tested with `.jpg` and `.webp`) + # 1.12.2 Features: diff --git a/doc/json_schema.json b/doc/json_schema.json index 025437c64..9e4238b81 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -52,6 +52,7 @@ "data-raw", "sixel", "kitty", + "kitty-direct", "iterm", "chafa", "raw", diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 79dad505b..c2379bbb0 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -68,9 +68,14 @@ static bool printImageIterm(void) static bool printImageKittyDirect(void) { + if (!instance.config.logo.width || !instance.config.logo.height) + { + fputs("Logo: `kitty-direct` protocol only works when both `--logo-width` and `--logo-height` being specified\n", stderr); + return false; + } ffPrintCharTimes(' ', instance.config.logo.paddingLeft); ffPrintCharTimes('\n', instance.config.logo.paddingTop); - FFstrbuf base64 = base64Encode(&instance.config.logo.source); + FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&instance.config.logo.source); printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D", (unsigned) instance.config.logo.width, (unsigned) instance.config.logo.height, @@ -80,8 +85,6 @@ static bool printImageKittyDirect(void) instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; - ffStrbufDestroy(&base64); - return true; } @@ -741,12 +744,7 @@ bool ffLogoPrintImageIfExists(FFLogoType type, bool printError) if(type == FF_LOGO_TYPE_IMAGE_ITERM) return printImageIterm(); - if( - type == FF_LOGO_TYPE_IMAGE_KITTY && - ffStrbufEndsWithIgnCaseS(&instance.config.logo.source, ".png") && - instance.config.logo.width && - instance.config.logo.height - ) + if(type == FF_LOGO_TYPE_IMAGE_KITTY_DIRECT) return printImageKittyDirect(); #if !defined(FF_HAVE_CHAFA) diff --git a/src/logo/option.c b/src/logo/option.c index 425dd056f..a3b59b806 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -67,6 +67,7 @@ logoType: { "data-raw", FF_LOGO_TYPE_DATA_RAW }, { "sixel", FF_LOGO_TYPE_IMAGE_SIXEL }, { "kitty", FF_LOGO_TYPE_IMAGE_KITTY }, + { "kitty-direct", FF_LOGO_TYPE_IMAGE_KITTY_DIRECT }, { "iterm", FF_LOGO_TYPE_IMAGE_ITERM }, { "chafa", FF_LOGO_TYPE_IMAGE_CHAFA }, { "raw", FF_LOGO_TYPE_IMAGE_RAW }, @@ -155,6 +156,11 @@ logoType: ffOptionParseString(key, value, &options->source); options->type = FF_LOGO_TYPE_IMAGE_KITTY; } + else if(strcasecmp(key, "--kitty-direct") == 0) + { + ffOptionParseString(key, value, &options->source); + options->type = FF_LOGO_TYPE_IMAGE_KITTY_DIRECT; + } else if(strcasecmp(key, "--iterm") == 0) { ffOptionParseString(key, value, &options->source); @@ -248,6 +254,7 @@ const char* ffParseLogoJsonConfig(void) { "data-raw", FF_LOGO_TYPE_DATA_RAW }, { "sixel", FF_LOGO_TYPE_IMAGE_SIXEL }, { "kitty", FF_LOGO_TYPE_IMAGE_KITTY }, + { "kitty-direct", FF_LOGO_TYPE_IMAGE_KITTY_DIRECT }, { "iterm", FF_LOGO_TYPE_IMAGE_ITERM }, { "chafa", FF_LOGO_TYPE_IMAGE_CHAFA }, { "raw", FF_LOGO_TYPE_IMAGE_RAW }, diff --git a/src/logo/option.h b/src/logo/option.h index 9039b4b57..d31ca53f4 100644 --- a/src/logo/option.h +++ b/src/logo/option.h @@ -15,6 +15,7 @@ typedef enum FFLogoType FF_LOGO_TYPE_DATA_RAW, //text data, printed as is FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes. FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol + FF_LOGO_TYPE_IMAGE_KITTY_DIRECT, //image file, tell the terminal emulator to read image data from the specified file (Supported by kitty and wezterm) FF_LOGO_TYPE_IMAGE_ITERM, //image file, printed as iterm graphics protocol FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa FF_LOGO_TYPE_IMAGE_RAW, //image file, printed as raw binary string From e48a7aa92f2d1010bea0b1048301b680cff7a05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 13:57:26 +0800 Subject: [PATCH 340/493] LocalIP (Android): tidy --- src/detection/localip/localip_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index f93ee6f9d..e70234735 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -17,7 +17,7 @@ #include #endif -#if defined(__linux__) || defined(__ANDROID__) +#if defined(__linux__) static bool getDefaultRoute(char iface[IF_NAMESIZE + 1]) { FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); From 7d91e7b7b423ed5be7f694db73f19de12d845290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 13:59:40 +0800 Subject: [PATCH 341/493] Display (Android): support detection in adb --- CMakeLists.txt | 2 +- .../displayserver/displayserver_android.c | 79 +++++++++++++++++++ src/modules/display/display.c | 5 -- 3 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 src/detection/displayserver/displayserver_android.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4450e6b28..542040f06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,7 +395,7 @@ elseif(ANDROID) src/detection/cursor/cursor_nosupport.c src/detection/cpuusage/cpuusage_linux.c src/detection/disk/disk_linux.c - src/detection/displayserver/displayserver_nosupport.c + src/detection/displayserver/displayserver_android.c src/detection/font/font_nosupport.c src/detection/gpu/gpu_nosupport.c src/detection/host/host_android.c diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c new file mode 100644 index 000000000..24d874b4c --- /dev/null +++ b/src/detection/displayserver/displayserver_android.c @@ -0,0 +1,79 @@ +#include "displayserver.h" + +#include "common/processing.h" + +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) +{ + ffStrbufInit(&ds->wmProcessName); + ffStrbufInit(&ds->wmPrettyName); + ffStrbufInit(&ds->wmProtocolName); + ffStrbufInit(&ds->deProcessName); + ffStrbufInit(&ds->dePrettyName); + ffStrbufInit(&ds->deVersion); + ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); + + FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); + if (ffProcessAppendStdOut(&buf, (char* []) { + "/system/bin/dumpsys", + "display", + NULL, + }) != NULL || buf.length == 0) + return; // Only works in `adb shell`, or when rooted + + uint32_t index = 0; + while ((index = ffStrbufNextIndexS(&buf, index, "DisplayDeviceInfo")) < buf.length) + { + index += strlen("DisplayDeviceInfo"); + uint32_t nextIndex = ffStrbufNextIndexC(&buf, index, '\n'); + buf.chars[nextIndex] = '\0'; + const char* info = buf.chars + index; + + // {"Builtin display": uniqueId="local:4630947134992368259", 1440 x 3200, modeId 2, defaultModeId 1, supportedModes [{id=1, width=1440, height=3200, fps=60.000004, alternativeRefreshRates=[24.000002, 30.000002, 40.0, 120.00001, 120.00001, 120.00001, 120.00001, 120.00001]}, + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateA(64); + unsigned width = 0, height = 0, modeId = 0; + double refreshRate = 0; + // {"Builtin display": uniqueId="local:4630947134992368259", 1440 x 3200, modeId 2 + int res = sscanf(info, "{\"%63[^\"]\":%*s%u x %u, modeId%u", name.chars, &width, &height, &modeId); + if (res >= 3) + { + if (res == 4) + { + ++info; // skip first '{' + while ((info = strchr(info, '{'))) + { + ++info; + + unsigned id; + double fps; + // id=1, width=1440, height=3200, fps=60.000004, + if (sscanf(info, "id=%u, %*s%*s fps=%lf", &id, &fps) >= 2) + { + if (id == modeId) + { + refreshRate = fps; + break; + } + } + else + break; + } + } + + ffStrbufRecalculateLength(&name); + ffdsAppendDisplay(ds, + (uint32_t)width, + (uint32_t)height, + refreshRate, + 0, + 0, + 0, + &name, + FF_DISPLAY_TYPE_UNKNOWN, + false, + 0 + ); + } + + index = nextIndex + 1; + } +} diff --git a/src/modules/display/display.c b/src/modules/display/display.c index abf233316..848936f61 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -8,11 +8,6 @@ void ffPrintDisplay(FFDisplayOptions* options) { - #ifdef __ANDROID__ - ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Display detection is not supported on Android"); - return; - #endif - const FFDisplayServerResult* dsResult = ffConnectDisplayServer(); if(dsResult->displays.length == 0) From 8ef2bb788f12d4d882a9502a3a7cc1d33788e0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 14:17:33 +0800 Subject: [PATCH 342/493] Battery (Android): use yyjson to parse JSON string --- src/detection/battery/battery_android.c | 40 +++++++++++-------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index d163f0894..aeb9b74d1 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -7,6 +7,13 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "BatteryStatus" +static inline void wrapYyjsonFree(yyjson_doc** doc) +{ + assert(doc); + if (*doc) + yyjson_doc_free(*doc); +} + const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -18,8 +25,13 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) })) return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; - if(buffer.chars[0] != '{') - return "`" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` prints invalid result (not a JSON object)"; + yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + if (!doc) + return "Failed to parse battery info"; + + yyjson_val* root = yyjson_doc_get_root(doc); + if (!yyjson_is_obj(root)) + return "Battery info result is not a JSON object"; BatteryResult* battery = ffListAdd(results); battery->temperature = FF_BATTERY_TEMP_UNSET; @@ -28,28 +40,10 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) ffStrbufInit(&battery->status); ffStrbufInit(&battery->technology); - if(ffParsePropLines(buffer.chars, "\"percentage\": ", &battery->status)) - { - battery->capacity = ffStrbufToDouble(&battery->status); - ffStrbufClear(&battery->status); - } - + battery->capacity = yyjson_get_num(yyjson_obj_get(root, "percentage")); + ffStrbufAppendS(&battery->status, yyjson_get_str(yyjson_obj_get(root, "status"))); if(options->temp) - { - if(ffParsePropLines(buffer.chars, "\"temperature\": ", &battery->status)) - { - ffStrbufTrimRight(&battery->status, ','); - ffStrbufTrim(&battery->status, '"'); - battery->temperature = ffStrbufToDouble(&battery->status); - ffStrbufClear(&battery->status); - } - } - - if(ffParsePropLines(buffer.chars, "\"status\": ", &battery->status)) - { - ffStrbufTrimRight(&battery->status, ','); - ffStrbufTrim(&battery->status, '"'); - } + battery->temperature = yyjson_get_num(yyjson_obj_get(root, "temperature")); return NULL; } From 396cec80333d2e408cb53f95b02a7fb9a5e54caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 14:57:41 +0800 Subject: [PATCH 343/493] Wifi (Android): use yyjson to parse JSON string --- src/detection/wifi/wifi_android.c | 57 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/detection/wifi/wifi_android.c b/src/detection/wifi/wifi_android.c index b04796d6e..e34f45365 100644 --- a/src/detection/wifi/wifi_android.c +++ b/src/detection/wifi/wifi_android.c @@ -6,6 +6,13 @@ #define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api" #define FF_TERMUX_API_PARAM "WifiConnectionInfo" +static inline void wrapYyjsonFree(yyjson_doc** doc) +{ + assert(doc); + if (*doc) + yyjson_doc_free(*doc); +} + const char* ffDetectWifi(FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -17,8 +24,13 @@ const char* ffDetectWifi(FFlist* result) })) return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; - if(buffer.chars[0] != '{') - return "`" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` prints invalid result (not a JSON object)"; + yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + if (!doc) + return "Failed to parse wifi connection info"; + + yyjson_val* root = yyjson_doc_get_root(doc); + if (!yyjson_is_obj(root)) + return "Wifi info result is not a JSON object"; FFWifiResult* item = (FFWifiResult*)ffListAdd(result); ffStrbufInit(&item->inf.description); @@ -32,37 +44,22 @@ const char* ffDetectWifi(FFlist* result) item->conn.rxRate = 0.0/0.0; item->conn.txRate = 0.0/0.0; - if(!ffParsePropLines(buffer.chars, "\"supplicant_state\": ", &item->inf.status)) + ffStrbufAppendS(&item->inf.status, yyjson_get_str(yyjson_obj_get(root, "supplicant_state"))); + if(!item->inf.status.length) + { ffStrbufAppendS(&item->inf.status, "Unknown"); - - { - ffStrbufTrimRight(&item->inf.status, ','); - ffStrbufTrim(&item->inf.status, '"'); - if(!ffStrbufEqualS(&item->inf.status, "COMPLETED")) - return NULL; + return NULL; } - if(ffParsePropLines(buffer.chars, "\"rssi\": ", &item->inf.description)) - { - double rssi = ffStrbufToDouble(&item->inf.description); - item->conn.signalQuality = rssi >= -50 ? 100 : rssi <= -100 ? 0 : (rssi + 100) * 2; - ffStrbufClear(&item->inf.description); - } - - if(ffParsePropLines(buffer.chars, "\"network_id\": ", &item->inf.description)) - ffStrbufTrimRight(&item->inf.description, ','); - - if(ffParsePropLines(buffer.chars, "\"bssid\": ", &item->conn.macAddress)) - { - ffStrbufTrimRight(&item->conn.macAddress, ','); - ffStrbufTrim(&item->conn.macAddress, '"'); - } - - if(ffParsePropLines(buffer.chars, "\"ssid\": ", &item->conn.ssid)) - { - ffStrbufTrimRight(&item->conn.ssid, ','); - ffStrbufTrim(&item->conn.ssid, '"'); - } + if(!ffStrbufEqualS(&item->inf.status, "COMPLETED")) + return NULL; + + double rssi = yyjson_get_num(yyjson_obj_get(root, "rssi")); + item->conn.signalQuality = rssi >= -50 ? 100 : rssi <= -100 ? 0 : (rssi + 100) * 2; + + ffStrbufAppendS(&item->inf.description, yyjson_get_str(yyjson_obj_get(root, "ip"))); + ffStrbufAppendS(&item->conn.macAddress, yyjson_get_str(yyjson_obj_get(root, "bssid"))); + ffStrbufAppendS(&item->conn.ssid, yyjson_get_str(yyjson_obj_get(root, "ssid"))); return NULL; } From 3c5c2d2ca83201b81d02785a54cec35f7e257e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 15:30:45 +0800 Subject: [PATCH 344/493] Battery (Android): support detection with `dumpsys` --- src/detection/battery/battery_android.c | 81 ++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index aeb9b74d1..b05cce111 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -14,7 +14,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) yyjson_doc_free(*doc); } -const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) +static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -47,3 +47,82 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) return NULL; } + +static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) +{ + FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); + if (ffProcessAppendStdOut(&buf, (char* []) { + "/system/bin/dumpsys", + "battery", + NULL, + }) != NULL || buf.length == 0) + return "Executing `/system/bin/dumpsys battery` failed"; // Only works in `adb shell`, or when rooted + + if (!ffStrbufStartsWithS(&buf, "Current Battery Service state:\n")) + return "Invalid `/system/bin/dumpsys battery` result"; + + const char* start = buf.chars + strlen("Current Battery Service state:\n"); + + FF_STRBUF_AUTO_DESTROY temp = ffStrbufCreate(); + if (!ffParsePropLines(start, "present: ", &temp) || !ffStrbufEqualS(&temp, "true")) + return NULL; + ffStrbufClear(&temp); + + BatteryResult* battery = ffListAdd(results); + battery->temperature = FF_BATTERY_TEMP_UNSET; + ffStrbufInit(&battery->manufacturer); + ffStrbufInit(&battery->modelName); + ffStrbufInit(&battery->status); + ffStrbufInit(&battery->technology); + + if (ffParsePropLines(start, "AC powered: ", &temp) && ffStrbufEqualS(&temp, "true")) + ffStrbufAppendS(&battery->status, "AC powered"); + ffStrbufClear(&temp); + + if (ffParsePropLines(start, "USB powered: ", &temp) && ffStrbufEqualS(&temp, "true")) + { + if (battery->status.length) ffStrbufAppendS(&battery->status, ", "); + ffStrbufAppendS(&battery->status, "USB powered"); + } + ffStrbufClear(&temp); + + if (ffParsePropLines(start, "Wireless powered: ", &temp) && ffStrbufEqualS(&temp, "true")) + { + if (battery->status.length) ffStrbufAppendS(&battery->status, ", "); + ffStrbufAppendS(&battery->status, "Wireless powered"); + } + ffStrbufClear(&temp); + + { + double level = 0, scale = 0; + if (ffParsePropLines(start, "level: ", &temp)) + level = ffStrbufToDouble(&temp); + ffStrbufClear(&temp); + + if (ffParsePropLines(start, "scale: ", &temp)) + scale = ffStrbufToDouble(&temp); + ffStrbufClear(&temp); + + if (level > 0 && scale > 0) + battery->capacity = level * 100 / scale; + } + + if(options->temp) + { + if (ffParsePropLines(start, "temperature: ", &temp)) + battery->temperature = ffStrbufToDouble(&temp); + ffStrbufClear(&temp); + } + + ffParsePropLines(start, "technology: ", &battery->technology); + + return NULL; +} + +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) +{ + const char* error = parseTermuxApi(options, results); + if (error && parseDumpsys(options, results) == NULL) + return NULL; + return error; +} From e25eed5896b447ca850dda6acb4d77471d330230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 10:55:13 +0800 Subject: [PATCH 345/493] Weather: add option `--weather-location` --- CHANGELOG.md | 1 + doc/json_schema.json | 4 ++++ src/data/config_user.txt | 5 +++++ src/modules/weather/option.h | 1 + src/modules/weather/weather.c | 18 +++++++++++++++++- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 756fcf836..3e7648dc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Features: * Add option `--processing-timeout` to the timeout when waiting for child processes. * Public IP module prints the IP location if `--publicip-url` is not set (PublicIP) * Add option `--localip-default-route-only` (LocalIP) +* Add option `--weather-location` (Weather) Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/doc/json_schema.json b/doc/json_schema.json index 9e4238b81..46a8cac71 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -1006,6 +1006,10 @@ "type": { "const": "weather" }, + "location": { + "title": "The location to display", + "type": "string" + }, "timeout": { "title": "Time in milliseconds to wait for the weather server to respond", "type": "integer", diff --git a/src/data/config_user.txt b/src/data/config_user.txt index d5eccdc8e..3b62ac180 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -206,6 +206,11 @@ # Default is 0 (disabled). #--publicip-timeout 0 +# Weather location option: +# Sets location to be used. It must be URI encoded. +# Default is empty (guessing by public IP) +#--weather-location "Location" + # Weather output format option: # Sets the weather format to be used. It must be URI encoded. # See: https://github.com/chubin/wttr.in#one-line-output diff --git a/src/modules/weather/option.h b/src/modules/weather/option.h index d481fb6b7..6f82f5388 100644 --- a/src/modules/weather/option.h +++ b/src/modules/weather/option.h @@ -9,6 +9,7 @@ typedef struct FFWeatherOptions const char* moduleName; FFModuleArgs moduleArgs; + FFstrbuf location; FFstrbuf outputFormat; uint32_t timeout; } FFWeatherOptions; diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 84f34ee82..cbf5cb524 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -11,7 +11,10 @@ static int status = -1; void ffPrepareWeather(FFWeatherOptions* options) { - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/?format="); + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/"); + if (options->location.length) + ffStrbufAppend(&path, &options->location); + ffStrbufAppendS(&path, "?format="); ffStrbufAppend(&path, &options->outputFormat); status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); } @@ -55,6 +58,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options) options->moduleName = FF_WEATHER_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); + ffStrbufInit(&options->location); ffStrbufInitS(&options->outputFormat, "%t+-+%C+(%l)"); options->timeout = 0; } @@ -66,6 +70,12 @@ bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, co if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; + if (ffStrEqualsIgnCase(subKey, "location")) + { + ffOptionParseString(key, value, &options->location); + return true; + } + if (ffStrEqualsIgnCase(subKey, "output-format")) { ffOptionParseString(key, value, &options->outputFormat); @@ -106,6 +116,12 @@ void ffParseWeatherJsonObject(yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; + if (ffStrEqualsIgnCase(key, "location")) + { + ffStrbufSetS(&options.location, yyjson_get_str(val)); + continue; + } + if (ffStrEqualsIgnCase(key, "outputFormat")) { ffStrbufSetS(&options.outputFormat, yyjson_get_str(val)); From e55da74c5c80fa4b17992d3e618e99b6f45e051c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 10:57:15 +0800 Subject: [PATCH 346/493] Doc: update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e7648dc5..2d11708a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,12 +26,14 @@ Features: * Public IP module prints the IP location if `--publicip-url` is not set (PublicIP) * Add option `--localip-default-route-only` (LocalIP) * Add option `--weather-location` (Weather) +* Support iTerm non-ascii font detection (Terminal, macOS) Bugfixes: * Fix possible hanging (TerminalFont, #493) * Fix heap-buffer-overflow reading (DisplayServer, Linux) * Fix false errors when built without libnm support (Wifi, Linux) * Properly detect CPU on POWER (CPU, Linux) +* Fix compatibility with Fig (Terminal, macOS) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: From 9de7a78f43c61fbe3a1b2d258ab97bdcdcacde24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Jul 2023 10:58:33 +0800 Subject: [PATCH 347/493] JsonConfig: don't disable `--show-errors` when setting `--stat false` --- src/common/jsonconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 690254202..08fbb999b 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -302,8 +302,8 @@ const char* ffParseGeneralJsonConfig(void) config->multithreading = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "stat")) { - config->stat = yyjson_get_bool(val); - config->showErrors= config->stat; + if ((config->stat = yyjson_get_bool(val))) + config->showErrors = true; } else if (ffStrEqualsIgnCase(key, "escapeBedrock")) config->escapeBedrock = yyjson_get_bool(val); From a0cfbe74c4209cb1317dbc02cd1472b81547e0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 10:19:40 +0800 Subject: [PATCH 348/493] CMake: print message before fetching yyjson --- CMakeLists.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 542040f06..7b9890db7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,16 +37,21 @@ endif() include(CheckIncludeFile) include(FetchContent) -FetchContent_Declare( - yyjson - GIT_REPOSITORY https://github.com/ibireme/yyjson - GIT_TAG 0.7.0 -) -FetchContent_GetProperties(yyjson) -if(NOT yyjson_POPULATED) - FetchContent_Populate(yyjson) - add_subdirectory(${yyjson_SOURCE_DIR} ${yyjson_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() +function(ff_fetch_dep package repo tag) + FetchContent_Declare( + "${package}" + GIT_REPOSITORY "${repo}" + GIT_TAG "${tag}" + ) + FetchContent_GetProperties("${package}") + if(NOT ${package}_POPULATED) + message("-- Fetching dependency ${package}@${tag} from ${repo}") + FetchContent_Populate(${package}) + add_subdirectory(${${package}_SOURCE_DIR} ${${package}_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() +endfunction() + +ff_fetch_dep(yyjson "https://github.com/ibireme/yyjson" "0.7.0") ##################### # Configure options # From d3ff245e1b3ae75ca0e026c8e013e816fdaf98d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 10:30:32 +0800 Subject: [PATCH 349/493] Logo (Builtin): add linux_small --- src/logo/builtin.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index f5e278944..4efbc5d4f 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1240,6 +1240,29 @@ static const FFlogo* getLogoLinux(void) FF_LOGO_RETURN } +static const FFlogo* getLogoLinuxSmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("linux_small", "linux-generic_small") + FF_LOGO_LINES( + " $1___\n" + " ($2.. $1\\\n" + " ($3<> $1|\n" + " /$2/ \\ $1\\\n" + " ( $2| | $1/|\n" + "$3_$1/\\ $2__)$1/$3_$1)\n" + "$3\\/$1-____$3\\/\n" + ) + FF_LOGO_COLORS( + "30", //black + "37", //white + "33" //yellow + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoMacOS(void) { FF_LOGO_INIT @@ -2682,6 +2705,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoKubuntu, getLogoLangitKetujuh, getLogoLinux, + getLogoLinuxSmall, getLogoMacOS, getLogoMacOSSmall, getLogoMacOS2, From 00a5f1bf3f30e2d5ea7e81dd77b23fbadfdf9514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 11:14:30 +0800 Subject: [PATCH 350/493] Title: fix option `--title-fqdn` doesn't work --- CHANGELOG.md | 1 + src/fastfetch.c | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d11708a4..76d94c2fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Bugfixes: * Fix false errors when built without libnm support (Wifi, Linux) * Properly detect CPU on POWER (CPU, Linux) * Fix compatibility with Fig (Terminal, macOS) +* Fix option `--title-fqdn` doesn't work (Title) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: diff --git a/src/fastfetch.c b/src/fastfetch.c index fe55857fc..25a7a448e 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -962,6 +962,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseWifiCommandOptions(&instance.config.wifi, key, value)) {} else if(ffParseWMCommandOptions(&instance.config.wm, key, value)) {} else if(ffParseWMThemeCommandOptions(&instance.config.wmTheme, key, value)) {} + else if(ffParseTitleCommandOptions(&instance.config.title, key, value)) {} else if(ffParseThemeCommandOptions(&instance.config.theme, key, value)) {} else if(ffParseIconsCommandOptions(&instance.config.icons, key, value)) {} else if(ffParseWallpaperCommandOptions(&instance.config.wallpaper, key, value)) {} From e9ec7d3597c0e6f9de53b390aff29a6da4fa735e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 11:21:12 +0800 Subject: [PATCH 351/493] Title: add option `--title-color-user`, `--title-color-at` and `--title-color-host` --- CHANGELOG.md | 1 + doc/json_schema.json | 17 ++++++++++++ src/data/config_user.txt | 15 +++++++++++ src/data/help.txt | 3 +++ src/modules/title/option.h | 3 +++ src/modules/title/title.c | 54 +++++++++++++++++++++++++++++++++++--- 6 files changed, 89 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76d94c2fd..99c95c7e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Features: * Add option `--localip-default-route-only` (LocalIP) * Add option `--weather-location` (Weather) * Support iTerm non-ascii font detection (Terminal, macOS) +* Add option `--title-color-user`, `--title-color-at` and `--title-color-host` (Title) Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/doc/json_schema.json b/doc/json_schema.json index 46a8cac71..f97dbdcf3 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -988,6 +988,23 @@ "title": "Set if the title should use fully qualified domain name", "default": false }, + "color": { + "title": "Set colors of the different part of title", + "properties": { + "user": { + "title": "Set color of the user name (left part)", + "$ref": "#/$defs/colors" + }, + "at": { + "title": "Set color of the @ symbol (middle part)", + "$ref": "#/$defs/colors" + }, + "host": { + "title": "Set color of the host name (right part)", + "$ref": "#/$defs/colors" + } + } + }, "key": { "$ref": "#/$defs/key" }, diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 3b62ac180..e7ea439e0 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -182,6 +182,21 @@ # Default is false. #--title-fqdn false +# Title user color option: +# Sets color of the user name (left part). +# Default is empty (use color of `--color-title`). +#--title-color-user + +# Title at color option: +# Sets color of the @ symbol (middle part). +# Default is empty (use color of `--color-title`). +#--title-color-at + +# Title host color option: +# Sets color of the host name (right part). +# Default is empty (use color of `--color-title`). +#--title-color-host + # Separator option: # Sets the string placed between a key and its value. # Can be any string. diff --git a/src/data/help.txt b/src/data/help.txt index f7985f03e..0870ec5d4 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -107,6 +107,9 @@ Library options: Set the path of a library to load Module specific options: --title-fqdn : Set if the title should use fully qualified domain name. Default is false + --title-color-user : Set color of the user name (left part). Default is empty (use color of `--color-title`). + --title-color-at : Set color of the @ symbol (middle part). Default is empty (use color of `--color-title`) + --title-color-host : Set color of the host name (right part). Default is empty (use color of `--color-title`) --separator-string : Set the string printed by the separator module --os-file : Set the path to the file containing OS information --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) diff --git a/src/modules/title/option.h b/src/modules/title/option.h index ac3902e09..b44aef8ed 100644 --- a/src/modules/title/option.h +++ b/src/modules/title/option.h @@ -10,4 +10,7 @@ typedef struct FFTitleOptions FFModuleArgs moduleArgs; bool fqdn; + FFstrbuf colorUser; + FFstrbuf colorAt; + FFstrbuf colorHost; } FFTitleOptions; diff --git a/src/modules/title/title.c b/src/modules/title/title.c index b5ffa9349..3c29acb11 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -6,12 +6,12 @@ #define FF_TITLE_NUM_FORMAT_ARGS 2 -static inline void printTitlePart(const FFstrbuf* content) +static inline void printTitlePart(const FFstrbuf* content, const FFstrbuf* color) { if(!instance.config.pipe) { fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - ffPrintColor(&instance.config.colorTitle); + ffPrintColor(color->length > 0 ? color : &instance.config.colorTitle); } ffStrbufWriteTo(content, stdout); @@ -29,9 +29,14 @@ void ffPrintTitle(FFTitleOptions* options) if (options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_TITLE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); - printTitlePart(&instance.state.platform.userName); + + printTitlePart(&instance.state.platform.userName, &options->colorUser); + + if (!instance.config.pipe && options->colorAt.length > 0) + ffPrintColor(&options->colorAt); putchar('@'); - printTitlePart(host); + + printTitlePart(host, &options->colorHost); putchar('\n'); } else @@ -49,6 +54,9 @@ void ffInitTitleOptions(FFTitleOptions* options) options->moduleName = FF_TITLE_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); options->fqdn = false; + ffStrbufInit(&options->colorUser); + ffStrbufInit(&options->colorAt); + ffStrbufInit(&options->colorHost); } bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value) @@ -64,12 +72,33 @@ bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const return true; } + if (ffStrEqualsIgnCase(subKey, "color-user")) + { + ffOptionParseColor(value, &options->colorUser); + return true; + } + + if (ffStrEqualsIgnCase(subKey, "color-at")) + { + ffOptionParseColor(value, &options->colorAt); + return true; + } + + if (ffStrEqualsIgnCase(subKey, "color-host")) + { + ffOptionParseColor(value, &options->colorHost); + return true; + } + return false; } void ffDestroyTitleOptions(FFTitleOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); + ffStrbufDestroy(&options->colorUser); + ffStrbufDestroy(&options->colorAt); + ffStrbufDestroy(&options->colorHost); } void ffParseTitleJsonObject(yyjson_val* module) @@ -96,6 +125,23 @@ void ffParseTitleJsonObject(yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "color")) + { + if (!yyjson_is_obj(val)) + continue; + + yyjson_val* color = yyjson_obj_get(val, "user"); + if (color) + ffOptionParseColor(yyjson_get_str(color), &options.colorUser); + color = yyjson_obj_get(val, "at"); + if (color) + ffOptionParseColor(yyjson_get_str(color), &options.colorAt); + color = yyjson_obj_get(val, "host"); + if (color) + ffOptionParseColor(yyjson_get_str(color), &options.colorHost); + continue; + } + ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } From d13e72b815a1b5b7bda4cfd159fbd09716e3bbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 16:10:13 +0800 Subject: [PATCH 352/493] Processing: always trim white spaces --- src/common/processing.h | 16 ++++++++++++---- src/detection/terminalshell/terminalshell.c | 8 +------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/common/processing.h b/src/common/processing.h index 8b38337c0..380c2a36e 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -9,15 +9,23 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) { - const char* error = ffProcessAppendOutput(buffer, argv, false); - if (!error) ffStrbufTrimRight(buffer, '\n'); + const char* error = ffProcessAppendOutput(buffer, argv, false); + if (!error) + { + ffStrbufTrimRight(buffer, '\n'); + ffStrbufTrimRight(buffer, ' '); + } return error; } static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[]) { - const char* error = ffProcessAppendOutput(buffer, argv, true); - if (!error) ffStrbufTrimRight(buffer, '\n'); + const char* error = ffProcessAppendOutput(buffer, argv, true); + if (!error) + { + ffStrbufTrimRight(buffer, '\n'); + ffStrbufTrimRight(buffer, ' '); + } return error; } diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index b5261f7a7..cfaede137 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -41,17 +41,11 @@ static bool getFileVersion(const char* exePath, FFstrbuf* version) static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) { - bool ok = ffProcessAppendStdOut(version, (char* const[]) { + return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) == NULL; - if (ok) - { - ffStrbufTrim(version, '\n'); - ffStrbufTrim(version, ' '); - } - return ok; } static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) From 493824113b2bdb6b46f2ab740ed4a37d604025e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Jul 2023 16:11:02 +0800 Subject: [PATCH 353/493] Shell: support ksh version detection --- src/detection/terminalshell/terminalshell.c | 34 +++++++++++++++++++ .../terminalshell/terminalshell_linux.c | 2 ++ 2 files changed, 36 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index cfaede137..86c7f2e67 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -98,6 +98,36 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) return true; } +static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdErr(version, (char* const[]) { + exe->chars, + "--version", + NULL + }) != NULL) + return false; + + // version sh (AT&T Research) 93u+ 2012-08-01 + ffStrbufSubstrAfterLastC(version, ')'); + ffStrbufTrim(version, ' '); + return true; +} + +static bool getShellVersionOksh(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]) { + exe->chars, + "-c", + "echo $OKSH_VERSION", + NULL + }) != NULL) + return false; + + //oksh 7.3 + ffStrbufSubstrAfterFirstC(version, ' '); + return true; +} + #ifdef _WIN32 static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) { @@ -129,6 +159,10 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return getExeVersionGeneral(exe, version); //tcsh 6.24.07 (Astron) 2022-12-21 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec if(strcasecmp(exeName, "nu") == 0) return getExeVersionRaw(exe, version); //0.73.0 + if(strcasecmp(exeName, "ksh") == 0) + return getShellVersionKsh(exe, version); + if(strcasecmp(exeName, "oksh") == 0) + return getShellVersionOksh(exe, version); if(strcasecmp(exeName, "python") == 0 && getenv("XONSH_VERSION")) { ffStrbufSetS(version, getenv("XONSH_VERSION")); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 91852519e..5d578fff3 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -152,6 +152,8 @@ static void getTerminalShell(FFTerminalShellResult* result, pid_t pid) strcasecmp(name, "bash") == 0 || strcasecmp(name, "zsh") == 0 || strcasecmp(name, "ksh") == 0 || + strcasecmp(name, "mksh") == 0 || + strcasecmp(name, "oksh") == 0 || strcasecmp(name, "csh") == 0 || strcasecmp(name, "tcsh") == 0 || strcasecmp(name, "fish") == 0 || From d33ef3173da4c683a94ba7f609f1a90acfceeb40 Mon Sep 17 00:00:00 2001 From: Tom Briden Date: Thu, 20 Jul 2023 16:14:54 +0100 Subject: [PATCH 354/493] Add Exherbo logo --- README.md | 2 +- src/logo/builtin.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71d14b750..809c3007e 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Zorin +AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Zorin ``` ##### Package managers diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4efbc5d4f..fcd755e63 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -819,6 +819,44 @@ static const FFlogo* getLogoEnso(void) FF_LOGO_RETURN } +static const FFlogo* getLogoExherbo(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("exherbo", "exherbo-linux") + FF_LOGO_LINES( + "$2 ,\n" + "OXo.\n" + "NXdX0: .cok0KXNNXXK0ko:.\n" + "KX '0XdKMMK;.xMMMk, .0MMMMMXx; ...\n" + "'NO..xWkMMx kMMM cMMMMMX,NMWOxOXd.\n" + " cNMk NK .oXM. OMMMMO. 0MMNo kW.\n" + " lMc o: ., .oKNk; ;NMMWlxW'\n" + " ;Mc .. .,,' .0M$1g;$2WMN'dWMMMMMMO\n" + " XX ,WMMMMW. cM$1cfli$2WMKlo. .kMk\n" + ".Mo .WM$1GD$2MW. XM$1WO0$2MMk oMl\n" + ",M: ,XMMWx::,''oOK0x; NM.\n" + "'Ml ,kNKOxxxxxkkO0XXKOd:. oMk\n" + " NK .0Nxc$3:::::::::::::::$2fkKNk, .MW\n" + " ,Mo .NXc$3::$2qXWXb$3::::::::::$2oo$3::$2lNK. .MW\n" + " ;Wo oMd$3:::$2oNMNP$3::::::::$2oWMMMx$3:$2c0M; lMO\n" + " 'NO;W0c$3:::::::::::::::$2dMMMMO$3::$2lMk .WM'\n" + " xWONXdc$3::::::::::::::$2oOOo$3::$2lXN. ,WMd\n" + " 'KWWNXXK0Okxxo,$3:::::::$2,lkKNo xMMO\n" + " :XMNxl,';:lodxkOO000Oxc. .oWMMo\n" + " 'dXMMXkl;,. .,o0MMNo'\n" + " ':d0XWMMMMWNNNNMMMNOl'\n" + " ':okKXWNKkl'\n" + ) + FF_LOGO_COLORS( + "34", //blue + "37", //white + "31" //red + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("34"); //blue + FF_LOGO_RETURN +} + static const FFlogo* getLogoFedora(void) { FF_LOGO_INIT @@ -2690,6 +2728,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoDeepin, getLogoEndeavour, getLogoEnso, + getLogoExherbo, getLogoFedora, getLogoFedoraSmall, getLogoFedoraOld, From 250d3c349e1df799d9bed20cf88804f36603121d Mon Sep 17 00:00:00 2001 From: Tom Briden Date: Thu, 20 Jul 2023 16:43:29 +0100 Subject: [PATCH 355/493] Add paludis (exherbo) package count --- README.md | 2 +- presets/verbose | 2 +- src/detection/packages/packages.h | 1 + src/detection/packages/packages_linux.c | 1 + src/fastfetch.c | 5 +++-- src/modules/packages/packages.c | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 809c3007e..36a8c7462 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CR ##### Package managers ``` -apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, pkg, pkgtool, rpm, scoop, Snap, xbps +apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, paludis, pkg, pkgtool, rpm, scoop, Snap, xbps ``` ##### WM themes diff --git a/presets/verbose b/presets/verbose index 833cfd4d9..3ed020f19 100644 --- a/presets/verbose +++ b/presets/verbose @@ -3,7 +3,7 @@ --kernel-format Sysname: {}; Release: {}; Version: {} --uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {} --processes-format Count: {} ---packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}; pkgtool: {} +--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}; pkgtool: {}; paludis {} --shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {} --display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {} --de-format Process name: {}; Pretty name: {}; Version: {} diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index 59b1d1ef6..77f8e6812 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -20,6 +20,7 @@ typedef struct FFPackagesResult uint32_t nixSystem; uint32_t nixUser; uint32_t pacman; + uint32_t paludis; uint32_t pkg; uint32_t pkgtool; uint32_t port; diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 1c12ad14d..7dd4061b4 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -276,6 +276,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts) packageCounts->xbps += getXBPS(baseDir, "/var/db/xbps"); packageCounts->brewCask += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Caskroom", DT_DIR); packageCounts->brew += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Cellar", DT_DIR); + packageCounts->paludis += countFilesRecursive(baseDir, "/var/db/paludis/repositories", "environment.bz2"); } static void getPackageCountsRegular(FFstrbuf* baseDir, FFPackagesResult* packageCounts) diff --git a/src/fastfetch.c b/src/fastfetch.c index 25a7a448e..9c41dc3c7 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -141,7 +141,7 @@ static inline void printCommandHelp(const char* command) } else if(ffStrEqualsIgnCase(command, "packages-format")) { - constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco), {22} (pkgtool)", 22, + constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis)", 23, "Number of all packages", "Number of pacman packages", "Pacman branch on manjaro", @@ -163,7 +163,8 @@ static inline void printCommandHelp(const char* command) "Number of macports packages", "Number of scoop packages", "Number of choco packages", - "Number of pkgtool packages" + "Number of pkgtool packages", + "Number of paludis packages" ); } else if(ffStrEqualsIgnCase(command, "shell-format")) diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 0866cfb05..0fa86f31c 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -62,6 +62,7 @@ void ffPrintPackages(FFPackagesOptions* options) FF_PRINT_PACKAGE(scoop) FF_PRINT_PACKAGE(choco) FF_PRINT_PACKAGE(pkgtool) + FF_PRINT_PACKAGE(paludis) putchar('\n'); } From 76f3090e2a56ffbae08396c63c2ea4fde91170b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Jul 2023 09:46:38 +0800 Subject: [PATCH 356/493] Doc: update JSON schema --- doc/json_schema.json | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index f97dbdcf3..6139dd549 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -19,12 +19,14 @@ } }, "type": "object", - "title": "JSON config file for fastfetch. Usually be `~/.config/fastfetch.jsonc`", + "title": "JSON config", + "description": "JSON config file for fastfetch. Usually be `~/.config/fastfetch.jsonc`", "properties": { "$schema": { "type": "string", - "title": "JSON schema URL", - "format": "uri" + "title": "JSON schema URL, for JSON validation and IDE intelligence", + "format": "uri", + "default": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json" }, "logo": { "oneOf": [ @@ -104,7 +106,8 @@ "title": "Color 9", "$ref": "#/$defs/colors" } - } + }, + "additionalProperties": false }, "width": { "type": "integer", @@ -135,7 +138,8 @@ "title": "Set the right padding of the logo", "minimum": 0 } - } + }, + "additionalProperties": false }, "printRemaining": { "type": "boolean", @@ -191,7 +195,8 @@ "DIFFUSION" ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -284,7 +289,8 @@ "title": "Set the color of the title", "$ref": "#/$defs/colors" } - } + }, + "additionalProperties": false } ] }, @@ -512,6 +518,7 @@ "additionalProperties": false }, { + "title": "No additional properties", "properties": { "type": { "enum": [ @@ -1050,7 +1057,8 @@ }, "additionalProperties": false } - ] + ], + "additionalProperties": false } ] } From 48a22db9693a20b62ed229a79e5a91648a24bc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Jul 2023 10:04:38 +0800 Subject: [PATCH 357/493] Doc: update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99c95c7e3..8eca06e84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # 2.0.0 -This release introduces a new configuration file format: JSON config +This release introduces a new configuration file format: JSON config. Please refer to Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. @@ -28,6 +28,7 @@ Features: * Add option `--weather-location` (Weather) * Support iTerm non-ascii font detection (Terminal, macOS) * Add option `--title-color-user`, `--title-color-at` and `--title-color-host` (Title) +* Add Exherbo logo and package manager count (Packages, Linux, #503) Bugfixes: * Fix possible hanging (TerminalFont, #493) From 1feb3915a0123f02ebdeef9b1e63795ef41eaa03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Jul 2023 15:30:39 +0800 Subject: [PATCH 358/493] Brightness (macOS): fix detecting with ddc/ci --- src/detection/brightness/brightness_apple.c | 121 ++++++++++++++------ 1 file changed, 83 insertions(+), 38 deletions(-) diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index e961bac03..2b31d45e8 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -8,11 +8,31 @@ extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float *bright // DDC/CI typedef CFTypeRef IOAVServiceRef; -extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator); -extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service); -extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2); -extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize); -extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize); +extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import)); +extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import)); +extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import)); +extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import)); +extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import)); + +// Works for internal display +static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) +{ + if(DisplayServicesGetBrightness == NULL) + return "DisplayServices function DisplayServicesGetBrightness is not available"; + + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + { + float value; + if(DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) + { + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = value * 100; + ffStrbufInitCopy(&brightness->name, &display->name); + } + } + + return NULL; +} static void getNameFromEdid(uint8_t edid[128], FFstrbuf* name) { @@ -34,51 +54,65 @@ static void getNameFromEdid(uint8_t edid[128], FFstrbuf* name) } } -const char* ffDetectBrightness(FFlist* result) +// https://github.com/waydabber/m1ddc +// Works for Apple Silicon and USB-C adapter connection ( but not HTMI ) +static const char* detectWithDdcci(FFlist* result) { - if(DisplayServicesGetBrightness == NULL) - return "DisplayServices function DisplayServicesGetBrightness is not available"; + if (!IOAVServiceCreate || !IOAVServiceReadI2C) + return "IOAVService is not available"; - const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + CFMutableDictionaryRef matchDict = IOServiceMatching("DCPAVServiceProxy"); + if (matchDict == NULL) + return "IOServiceMatching(\"DCPAVServiceProxy\") failed"; - FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + io_iterator_t iterator; + if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess) + return "IOServiceGetMatchingServices() failed"; + + FF_STRBUF_AUTO_DESTROY location = ffStrbufCreate(); + + io_registry_entry_t registryEntry; + while((registryEntry = IOIteratorNext(iterator)) != 0) { - float value; - if(DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) + CFMutableDictionaryRef properties; + if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { - FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); - brightness->value = value * 100; - ffStrbufInitCopy(&brightness->name, &display->name); + IOObjectRelease(registryEntry); continue; } - } - if (!instance.config.allowSlowOperations || displayServer->displays.length <= result->length) - return NULL; - - // https://github.com/waydabber/m1ddc - // This only works for Apple Silicon and USB-C adapter connection ( but not HTMI ) - FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreate(kCFAllocatorDefault); - if (service) - { - uint8_t i2cData[12] = { 0x82, 0x01, 0x00 }; - i2cData[3] = 0x6e ^ i2cData[0] ^ i2cData[1] ^ i2cData[2] ^ i2cData[3]; - - for (uint32_t i = 0; i < 3; ++i) + ffStrbufClear(&location); + if(ffCfDictGetString(properties, CFSTR("Location"), &location) || ffStrbufEqualS(&location, "Embedded")) { - IOAVServiceWriteI2C(service, 0x37, 0x51, i2cData, 4); - usleep(10000); + // Builtin display should be handled by DisplayServices + IOObjectRelease(registryEntry); + continue; } - memset(i2cData, 0, sizeof(i2cData)); - if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cData, sizeof(i2cData)) == KERN_SUCCESS) - { - if (i2cData[2] != 0x02 || i2cData[3] != 0x00) - return NULL; + FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreateWithService(kCFAllocatorDefault, (io_service_t) registryEntry); + IOObjectRelease(registryEntry); - uint32_t mh = i2cData[6], ml = i2cData[7], sh = i2cData[8], sl = i2cData[9]; - uint32_t current = (mh << 8u) + ml; - uint32_t max = (sh << 8u) + sl; + if (!service) continue; + + { + uint8_t i2cIn[4] = { 0x82, 0x01, 0x10 /* luminance */ }; + i2cIn[3] = 0x6e ^ i2cIn[0] ^ i2cIn[1] ^ i2cIn[2]; + + for (uint32_t i = 0; i < 2; ++i) + { + IOAVServiceWriteI2C(service, 0x37, 0x51, i2cIn, sizeof(i2cIn)); + usleep(10000); + } + } + + uint8_t i2cOut[12] = {}; + if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cOut, sizeof(i2cOut)) == KERN_SUCCESS) + { + if (i2cOut[2] != 0x02 || i2cOut[3] != 0x00) + continue; + + uint32_t current = ((uint32_t) i2cOut[8] << 8u) + (uint32_t) i2cOut[9]; + uint32_t max = ((uint32_t) i2cOut[6] << 8u) + (uint32_t) i2cOut[7]; FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); brightness->value = (float) current * 100.f / max; @@ -92,3 +126,14 @@ const char* ffDetectBrightness(FFlist* result) return NULL; } + +const char* ffDetectBrightness(FFlist* result) +{ + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + detectWithDisplayServices(displayServer, result); + + if (instance.config.allowSlowOperations && displayServer->displays.length > result->length) + detectWithDdcci(result); + + return NULL; +} From 9af5c36e169aba662baaeb3342ea5bec5e3e3885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Jul 2023 16:41:53 +0800 Subject: [PATCH 359/493] Doc: update JSON schema --- doc/json_schema.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 6139dd549..f9521c4cb 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -1010,7 +1010,8 @@ "title": "Set color of the host name (right part)", "$ref": "#/$defs/colors" } - } + }, + "additionalProperties": false }, "key": { "$ref": "#/$defs/key" @@ -1057,8 +1058,7 @@ }, "additionalProperties": false } - ], - "additionalProperties": false + ] } ] } From 30791e14bd46701045c5e282db0cbd73ef70a7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 21 Jul 2023 16:42:10 +0800 Subject: [PATCH 360/493] Presets: add a new example --- presets/examples/8.jsonc | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 presets/examples/8.jsonc diff --git a/presets/examples/8.jsonc b/presets/examples/8.jsonc new file mode 100644 index 000000000..7fe01dd7f --- /dev/null +++ b/presets/examples/8.jsonc @@ -0,0 +1,51 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "small" + }, + "display": { + "separator": " ", + "color": { + "keys": "magenta" + }, + "sizeNdigits": 0, + "sizeMaxPrefix": "MB", + "percentType": 9 + }, + "modules": [ + { + "type": "title", + "color": { + "user": "green", + "at": "red", + "host": "blue" + } + }, + { + "type": "os", + "key": "", + "format": "{2} {8}" + }, + { + "type": "kernel", + "key": "" + }, + { + "type": "memory", + "key": "" + }, + { + "type": "packages", + "key": "" + }, + { + "type": "uptime", + "key": "" + }, + { + "type": "custom", + "key": "", + "format": "\u001b[31m███\u001b[32m███\u001b[33m███\u001b[34m███\u001b[35m███\u001b[36m███" + } + ] +} From 4202e618dbc018c79362e69c415558fa53ba0ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 23 Jul 2023 13:15:22 +0800 Subject: [PATCH 361/493] Brightness: improve performance --- src/detection/brightness/brightness_apple.c | 14 +++++++++++++- src/detection/brightness/brightness_windows.cpp | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 2b31d45e8..c584fc4a4 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -127,10 +127,22 @@ static const char* detectWithDdcci(FFlist* result) return NULL; } +static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) +{ + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + { + if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) + return true; + } + return false; +} + const char* ffDetectBrightness(FFlist* result) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); - detectWithDisplayServices(displayServer, result); + + if (hasBuiltinDisplay(displayServer)) + detectWithDisplayServices(displayServer, result); if (instance.config.allowSlowOperations && displayServer->displays.length > result->length) detectWithDdcci(result); diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index a085c71c5..dcde38502 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -58,12 +58,24 @@ static char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* return NULL; } +static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) +{ + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + { + if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) + return true; + } + return false; +} + extern "C" const char* ffDetectBrightness(FFlist* result) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); - detectWithWmi(result); + if (hasBuiltinDisplay(displayServer)) + detectWithWmi(result); + if (instance.config.allowSlowOperations && result->length < displayServer->displays.length) detectWithDdcci(displayServer, result); return NULL; From 5220144ad8cdfec37c5388bbf4016e823d3abc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 23 Jul 2023 19:30:51 +0800 Subject: [PATCH 362/493] DE: fix detection for ghostbsd --- src/detection/displayserver/linux/wmde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 60473a6f8..f1bcea4ee 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -89,7 +89,7 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) else if(strcasecmp(name, "xfwm4") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XFWM4); else if(strcasecmp(name, "Marco") == 0 || - strcasecmp(name, "Metacity (Macro)") == 0) + strcasecmp(name, "Metacity (Marco)") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_MARCO); else if(strcasecmp(name, "xmonad") == 0) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_XMONAD); From e8d075907f1407ebbd4080b0aedaa14f7091cde5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 23 Jul 2023 19:32:44 +0800 Subject: [PATCH 363/493] CMake: show progress when fetching deps --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b9890db7..48dc065cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ function(ff_fetch_dep package repo tag) "${package}" GIT_REPOSITORY "${repo}" GIT_TAG "${tag}" + GIT_PROGRESS TRUE ) FetchContent_GetProperties("${package}") if(NOT ${package}_POPULATED) From 2aa637ecc85b1aa1819a33957fa4996f5c7df743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 24 Jul 2023 21:30:41 +0800 Subject: [PATCH 364/493] Processing (Linux): don't return on POLLHUP In case child process finishs too fast --- src/common/processing_linux.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 9f5f0ca01..815ed1fc8 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -66,10 +66,6 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use kill(childPid, SIGTERM); return "poll(&pollfd, 1, timeout) error"; } - else if (pollfd.revents & POLLHUP) - { - return NULL; - } } char str[FF_PIPE_BUFSIZ]; From fc6acd1e3f604302830247a5e02cdb1499c83474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 24 Jul 2023 21:58:37 +0800 Subject: [PATCH 365/493] Logo: fix `--logo-padding-top` for `kitty-direct` --- src/logo/image/image.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index c2379bbb0..06939d6fd 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -73,13 +73,14 @@ static bool printImageKittyDirect(void) fputs("Logo: `kitty-direct` protocol only works when both `--logo-width` and `--logo-height` being specified\n", stderr); return false; } - ffPrintCharTimes(' ', instance.config.logo.paddingLeft); ffPrintCharTimes('\n', instance.config.logo.paddingTop); + ffPrintCharTimes(' ', instance.config.logo.paddingLeft); FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&instance.config.logo.source); - printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D", + printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D\033[%uA", (unsigned) instance.config.logo.width, (unsigned) instance.config.logo.height, - base64.chars + base64.chars, + (unsigned) instance.config.logo.paddingTop ); instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; From 62cfd27ac0e01907a473a941cecb169522e1696a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 24 Jul 2023 22:56:40 +0800 Subject: [PATCH 366/493] Logo: fix WezTerm compatibility with `kitty-direct` --- src/logo/image/image.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 06939d6fd..a8eacc518 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -75,17 +75,17 @@ static bool printImageKittyDirect(void) } ffPrintCharTimes('\n', instance.config.logo.paddingTop); ffPrintCharTimes(' ', instance.config.logo.paddingLeft); + FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&instance.config.logo.source); - printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D\033[%uA", + instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; + instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; + printf("\033_Ga=T,f=100,t=f,c=%u,r=%u;%s\033\\\033[9999999D\033[%uA", (unsigned) instance.config.logo.width, (unsigned) instance.config.logo.height, base64.chars, - (unsigned) instance.config.logo.paddingTop + (unsigned) instance.state.logoHeight ); - instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; - instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; - return true; } From e685a00a4b4c6c0b14d41f0ba712f324e5505ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Jul 2023 14:53:57 +0800 Subject: [PATCH 367/493] FFstrbuf: remove ffStrbufRemoveStringsV; rename ffStrbufRemoveStringsA to ffStrbufRemoveStrings --- src/detection/cpu/cpu.c | 2 +- src/detection/gpu/gpu_linux.c | 2 +- .../terminalshell/terminalshell_linux.c | 2 +- src/detection/wmtheme/wmtheme_linux.c | 2 +- src/modules/media/media.c | 2 +- src/util/FFstrbuf.c | 16 +--------------- src/util/FFstrbuf.h | 4 +--- tests/strbuf.c | 2 +- 8 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 4fc6d34bc..b95a354ad 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -14,7 +14,7 @@ const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu) " 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core", " with Radeon Graphics" }; - ffStrbufRemoveStringsA(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it return NULL; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index d59127e10..749072f46 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -80,7 +80,7 @@ static void drmDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* " (TM)", "(TM)", " Graphics Adapter", " Graphics", " Series", " Edition" }; - ffStrbufRemoveStringsA(&gpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&gpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); } static void pciDetectDeviceName(FFGPUResult* gpu, PCIData* pci, struct pci_dev* device) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 5d578fff3..eede327c5 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -299,7 +299,7 @@ static void getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* NULL }); ffStrbufSubstrBeforeFirstC(version, '('); - ffStrbufRemoveStrings(version, 2, "-release", "release"); + ffStrbufRemoveStrings(version, 2, (const char*[]) { "-release", "release" }); } bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index ba1e172a1..92eac7cfb 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -164,7 +164,7 @@ static bool detectOpenbox(const FFstrbuf* dePrettyName, FFstrbuf* themeOrError) if(strstr(line, "") != 0) { ffStrbufAppendS(themeOrError, line); - ffStrbufRemoveStrings(themeOrError, 2, "", ""); + ffStrbufRemoveStrings(themeOrError, 2, (const char*[]) { "", "" }); ffStrbufTrimRight(themeOrError, '\n'); ffStrbufTrim(themeOrError, ' '); break; diff --git a/src/modules/media/media.c b/src/modules/media/media.c index e60b04698..f28852e8c 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -63,7 +63,7 @@ void ffPrintMedia(FFMediaOptions* options) "[Lyric Video]", "[Official Lyric Video]", "[Lyrics]", "| Lyric Video", "| Official Lyric Video", "| Lyrics", }; - ffStrbufRemoveStringsA(&songPretty, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); + ffStrbufRemoveStrings(&songPretty, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings); ffStrbufTrimRight(&songPretty, ' '); if(songPretty.length == 0) diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index c05a7fa36..305c28dbb 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -269,26 +269,12 @@ void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str) ffStrbufRemoveSubstr(strbuf, i, i + stringLength); } -void ffStrbufRemoveStringsA(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]) +void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]) { for(uint32_t i = 0; i < numStrings; i++) ffStrbufRemoveS(strbuf, strings[i]); } -void ffStrbufRemoveStringsV(FFstrbuf* strbuf, uint32_t numStrings, va_list arguments) -{ - for(uint32_t i = 0; i < numStrings; i++) - ffStrbufRemoveS(strbuf, va_arg(arguments, const char*)); -} - -void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...) -{ - va_list argp; - va_start(argp, numStrings); - ffStrbufRemoveStringsV(strbuf, numStrings, argp); - va_end(argp); -} - uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { assert(start <= strbuf->length); diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index c47719679..e8d723f9d 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -59,9 +59,7 @@ void ffStrbufTrim(FFstrbuf* strbuf, char c); void ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex); void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str); -void ffStrbufRemoveStringsA(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]); -void ffStrbufRemoveStringsV(FFstrbuf* strbuf, uint32_t numStrings, va_list arguments); -void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, ...); +void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]); FF_C_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c); FF_C_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str); diff --git a/tests/strbuf.c b/tests/strbuf.c index 3df30af23..027cf2415 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -129,7 +129,7 @@ int main(void) //removeStrings - ffStrbufRemoveStrings(&strbuf, 3, "23", "45", "9"); + ffStrbufRemoveStrings(&strbuf, 3, (const char*[]) { "23", "45", "9" }); VERIFY(strbuf.length == 2); VERIFY(strcmp(strbuf.chars, "16") == 0); From 309d1d213065a405a3aaa96e923536a99dc05177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Jul 2023 16:01:38 +0800 Subject: [PATCH 368/493] FFstrbuf: add ffStrbufCreateStatic --- src/fastfetch.h | 5 +-- src/util/FFstrbuf.c | 78 +++++++++++++++++--------------- src/util/FFstrbuf.h | 84 +++++++++++++++++++++++++++++------ src/util/unused.h | 10 +++++ tests/strbuf.c | 105 +++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 228 insertions(+), 54 deletions(-) create mode 100644 src/util/unused.h diff --git a/src/fastfetch.h b/src/fastfetch.h index 90d6aa47c..645bc20d0 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -12,10 +12,7 @@ #include "util/FFstrbuf.h" #include "util/FFlist.h" #include "util/platform/FFPlatform.h" - -static inline void ffUnused(int dummy, ...) { (void) dummy; } -#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__); -#define FF_MAYBE_UNUSED __attribute__ ((__unused__)) +#include "util/unused.h" #include "modules/options.h" #include "logo/option.h" diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index 305c28dbb..d714622a4 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -16,12 +16,6 @@ void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate) ffStrbufClear(strbuf); } -void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src) -{ - ffStrbufInitA(strbuf, src->allocated); - ffStrbufAppend(strbuf, src); -} - void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) { assert(format != NULL); @@ -33,18 +27,9 @@ void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments) strbuf->length = (uint32_t)len; } -uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) -{ - assert(strbuf != NULL); - if(strbuf->allocated == 0) - return 0; - - return strbuf->allocated - strbuf->length - 1; // - 1 for the null byte -} - void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free) { - if(ffStrbufGetFree(strbuf) >= free) + if(ffStrbufGetFree(strbuf) >= free && !(strbuf->allocated == 0 && strbuf->length > 0)) return; uint32_t allocate = strbuf->allocated; @@ -56,8 +41,12 @@ void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free) if(strbuf->allocated == 0) { - strbuf->chars = malloc(sizeof(*strbuf->chars) * allocate); - strbuf->chars[0] = '\0'; + char* newbuf = malloc(sizeof(*strbuf->chars) * allocate); + if(strbuf->length == 0) + *newbuf = '\0'; + else + memcpy(newbuf, strbuf->chars, strbuf->length + 1); + strbuf->chars = newbuf; } else strbuf->chars = realloc(strbuf->chars, sizeof(*strbuf->chars) * allocate); @@ -213,7 +202,7 @@ void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value) void ffStrbufTrimLeft(FFstrbuf* strbuf, char c) { - if(strbuf->length == 0) //`allocated == 0` implies `length == 0` + if(strbuf->length == 0) return; uint32_t index = 0; @@ -223,6 +212,14 @@ void ffStrbufTrimLeft(FFstrbuf* strbuf, char c) if(index == 0) return; + if(strbuf->allocated == 0) + { + //static string + strbuf->length -= index; + strbuf->chars += index; + return; + } + memmove(strbuf->chars, strbuf->chars + index, strbuf->length - index); strbuf->length -= index; strbuf->chars[strbuf->length] = '\0'; @@ -236,13 +233,14 @@ void ffStrbufTrimRight(FFstrbuf* strbuf, char c) while(ffStrbufEndsWithC(strbuf, c)) --strbuf->length; - strbuf->chars[strbuf->length] = '\0'; -} + if(strbuf->allocated == 0) + { + //static string + ffStrbufInitNS(strbuf, strbuf->length, strbuf->chars); + return; + } -void ffStrbufTrim(FFstrbuf* strbuf, char c) -{ - ffStrbufTrimRight(strbuf, c); - ffStrbufTrimLeft(strbuf, c); + strbuf->chars[strbuf->length] = '\0'; } void ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex) @@ -256,6 +254,7 @@ void ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endInd return; } + ffStrbufEnsureFree(strbuf, 0); memmove(strbuf->chars + startIndex, strbuf->chars + endIndex, strbuf->length - endIndex); strbuf->length -= (endIndex - startIndex); strbuf->chars[strbuf->length] = '\0'; @@ -306,6 +305,10 @@ uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace) { + if (strbuf->length == 0) + return; + + ffStrbufEnsureFree(strbuf, 0); for (char *current_pos = strchr(strbuf->chars, find); current_pos; current_pos = strchr(current_pos + 1, find)) *current_pos = replace; } @@ -315,20 +318,17 @@ void ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index) if(strbuf->length <= index) return; + if(strbuf->allocated == 0) + { + //static string + ffStrbufInitNS(strbuf, strbuf->length, strbuf->chars); + return; + } + strbuf->length = index; strbuf->chars[strbuf->length] = '\0'; } -void ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, char c) -{ - ffStrbufSubstrBefore(strbuf, ffStrbufFirstIndexC(strbuf, c)); -} - -void ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) -{ - ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c)); -} - void ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index) { if(index >= strbuf->length) @@ -337,6 +337,14 @@ void ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index) return; } + if(strbuf->allocated == 0) + { + //static string + strbuf->length -= index; + strbuf->chars += index; + return; + } + memmove(strbuf->chars, strbuf->chars + index + 1, strbuf->length - index - 1); strbuf->length -= (index + 1); strbuf->chars[strbuf->length] = '\0'; diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index e8d723f9d..d87cad305 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -30,15 +30,13 @@ typedef struct FFstrbuf static inline void ffStrbufInit(FFstrbuf* strbuf); void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate); -void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src); void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments); void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free); -FF_C_NODISCARD uint32_t ffStrbufGetFree(const FFstrbuf* strbuf); - void ffStrbufClear(FFstrbuf* strbuf); +static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value); void ffStrbufAppendC(FFstrbuf* strbuf, char c); void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value); void ffStrbufAppendNSExludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude); @@ -55,7 +53,6 @@ void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufTrimLeft(FFstrbuf* strbuf, char c); void ffStrbufTrimRight(FFstrbuf* strbuf, char c); -void ffStrbufTrim(FFstrbuf* strbuf, char c); void ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex); void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str); @@ -69,8 +66,6 @@ FF_C_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace); void ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index); -void ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, char c); -void ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c); void ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index); void ffStrbufSubstrAfterFirstC(FFstrbuf* strbuf, char c); void ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str); @@ -95,6 +90,12 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) return strbuf; } +static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src) +{ + ffStrbufInitA(strbuf, src->allocated); + ffStrbufAppend(strbuf, src); +} + FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) { FFstrbuf strbuf; @@ -152,6 +153,32 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) return strbuf; } +static inline void ffStrbufDestroy(FFstrbuf* strbuf) +{ + extern char* CHAR_NULL_PTR; + + if(strbuf->allocated == 0) + { + strbuf->length = 0; + strbuf->chars = CHAR_NULL_PTR; + return; + } + + //Avoid free-after-use. These 3 assignments are cheap so don't remove them + strbuf->allocated = strbuf->length = 0; + free(strbuf->chars); + strbuf->chars = CHAR_NULL_PTR; +} + +FF_C_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) +{ + assert(strbuf != NULL); + if(strbuf->allocated == 0) + return 0; + + return strbuf->allocated - strbuf->length - 1; // - 1 for the null byte +} + static inline void ffStrbufRecalculateLength(FFstrbuf* strbuf) { strbuf->length = (uint32_t) strlen(strbuf->chars); @@ -187,6 +214,30 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate() return strbuf; } +static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) +{ + ffStrbufInit(strbuf); + strbuf->allocated = 0; + strbuf->length = (uint32_t) strlen(str); + strbuf->chars = (char*) str; +} + +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) +{ + FFstrbuf strbuf; + ffStrbufInitStatic(&strbuf, str); + return strbuf; +} + +static inline void ffStrbufSetStatic(FFstrbuf* strbuf, const char* value) +{ + if(strbuf->allocated > 0) + ffStrbufDestroy(strbuf); + + if(value != NULL) + ffStrbufInitStatic(strbuf, value); +} + static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* str) { ffStrbufInit(strbuf); @@ -322,6 +373,16 @@ static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c); } +static inline void ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, char c) +{ + ffStrbufSubstrBefore(strbuf, ffStrbufFirstIndexC(strbuf, c)); +} + +static inline void ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) +{ + ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c)); +} + static inline FF_C_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) { return strbuf->chars[0] == c; @@ -403,15 +464,10 @@ static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars); } -static inline void ffStrbufDestroy(FFstrbuf* strbuf) +static inline void ffStrbufTrim(FFstrbuf* strbuf, char c) { - if(strbuf->allocated == 0) return; - - extern char* CHAR_NULL_PTR; - //Avoid free-after-use. These 3 assignments are cheap so don't remove them - strbuf->allocated = strbuf->length = 0; - free(strbuf->chars); - strbuf->chars = CHAR_NULL_PTR; + ffStrbufTrimRight(strbuf, c); + ffStrbufTrimLeft(strbuf, c); } #define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy))) diff --git a/src/util/unused.h b/src/util/unused.h new file mode 100644 index 000000000..fbc0e93e3 --- /dev/null +++ b/src/util/unused.h @@ -0,0 +1,10 @@ +#pragma once + +#ifndef FASTFETCH_INCLUDED_UNUSED +#define FASTFETCH_INCLUDED_UNUSED + +static inline void ffUnused(int dummy, ...) { (void) dummy; } +#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__); +#define FF_MAYBE_UNUSED __attribute__ ((__unused__)) + +#endif diff --git a/tests/strbuf.c b/tests/strbuf.c index 027cf2415..d35c93e2f 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -214,13 +214,116 @@ int main(void) ffStrbufReplaceAllC(&strbuf, '1', '-'); VERIFY(ffStrbufEqualS(&strbuf, "-234567890-234567890-234567890-")); + //trim + ffStrbufTrim(&strbuf, '-'); + VERIFY(ffStrbufEqualS(&strbuf, "234567890-234567890-234567890")); + ffStrbufDestroy(&strbuf); + //ffStrbufCreateS { FF_STRBUF_AUTO_DESTROY testCreate = ffStrbufCreateS("TEST"); VERIFY(ffStrbufEqualS(&testCreate, "TEST")); } + //ffStrbufCreateStatic + ffStrbufInitStatic(&strbuf, "TEST"); + VERIFY(ffStrbufEqualS(&strbuf, "TEST")); + VERIFY(strbuf.length == 4); + VERIFY(strbuf.allocated == 0); + + ffStrbufDestroy(&strbuf); + VERIFY(strbuf.length == 0); + VERIFY(strbuf.allocated == 0); + + //ffStrbufCreateStatic / Allocate + ffStrbufInitStatic(&strbuf, "TEST"); + ffStrbufEnsureFree(&strbuf, 0); + VERIFY(ffStrbufEqualS(&strbuf, "TEST")); + VERIFY(strbuf.length == 4); + VERIFY(strbuf.allocated > 0); + + //ffStrbufCreateStatic / Append + ffStrbufInitStatic(&strbuf, "TEST"); + ffStrbufAppendS(&strbuf, "_TEST"); + VERIFY(ffStrbufEqualS(&strbuf, "TEST_TEST")); + VERIFY(strbuf.length == 9); + VERIFY(strbuf.allocated >= 10); + ffStrbufDestroy(&strbuf); + VERIFY(strbuf.length == 0); + VERIFY(strbuf.allocated == 0); + + //ffStrbufCreateStatic / Clear + ffStrbufInitStatic(&strbuf, "TEST"); + ffStrbufClear(&strbuf); + VERIFY(strbuf.length == 0); + VERIFY(strbuf.allocated == 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Set + ffStrbufInitStatic(&strbuf, "TEST"); // static + ffStrbufSetStatic(&strbuf, "test"); + VERIFY(ffStrbufEqualS(&strbuf, "test")); + VERIFY(strbuf.length == 4); + VERIFY(strbuf.allocated == 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Set + ffStrbufInitS(&strbuf, "TEST"); // allocated + ffStrbufSetStatic(&strbuf, "test"); + VERIFY(ffStrbufEqualS(&strbuf, "test")); + VERIFY(strbuf.length == 4); + VERIFY(strbuf.allocated == 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / TrimL + ffStrbufInitStatic(&strbuf, "_TEST_"); + ffStrbufTrimLeft(&strbuf, '_'); + VERIFY(ffStrbufEqualS(&strbuf, "TEST_")); + VERIFY(strbuf.length == 5); + VERIFY(strbuf.allocated == 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / TrimR + ffStrbufInitStatic(&strbuf, "_TEST_"); + ffStrbufTrimRight(&strbuf, '_'); + VERIFY(ffStrbufEqualS(&strbuf, "_TEST")); + VERIFY(strbuf.length == 5); + VERIFY(strbuf.allocated > 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Substr + ffStrbufInitStatic(&strbuf, "__TEST__"); + ffStrbufRemoveSubstr(&strbuf, 0, 6); + VERIFY(ffStrbufEqualS(&strbuf, "__")); + VERIFY(strbuf.length == 2); + VERIFY(strbuf.allocated > 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Substr + ffStrbufInitStatic(&strbuf, "__TEST__"); + ffStrbufRemoveSubstr(&strbuf, 2, 8); + VERIFY(ffStrbufEqualS(&strbuf, "__")); + VERIFY(strbuf.length == 2); + VERIFY(strbuf.allocated > 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Substr + ffStrbufInitStatic(&strbuf, "__TEST__"); + ffStrbufRemoveSubstr(&strbuf, 2, 6); + VERIFY(ffStrbufEqualS(&strbuf, "____")); + VERIFY(strbuf.length == 4); + VERIFY(strbuf.allocated > 0); + ffStrbufDestroy(&strbuf); + + //ffStrbufCreateStatic / Substr + ffStrbufInitStatic(&strbuf, "__TEST__"); + ffStrbufReplaceAllC(&strbuf, '_', '-'); + VERIFY(ffStrbufEqualS(&strbuf, "--TEST--")); + VERIFY(strbuf.length == 8); + VERIFY(strbuf.allocated > 0); + ffStrbufDestroy(&strbuf); + //Success - puts("\033[32mAll tests passed!"FASTFETCH_TEXT_MODIFIER_RESET); + puts("\033[32mAll tests passed!" FASTFETCH_TEXT_MODIFIER_RESET); } From 841be619bae218a3881ff9a796d5b8ec4784af98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 25 Jul 2023 16:09:09 +0800 Subject: [PATCH 369/493] Global: use ffStrbufInitStatic --- src/common/init.c | 2 +- .../displayserver/displayserver_apple.c | 7 +++---- .../displayserver/displayserver_windows.c | 14 +++++++------- src/detection/os/os_android.c | 6 +++--- .../terminalshell/terminalshell_linux.c | 16 ++++++++-------- .../terminalshell/terminalshell_windows.c | 10 +++++----- src/logo/option.c | 2 +- src/modules/weather/weather.c | 2 +- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/common/init.c b/src/common/init.c index e71509292..ba8c173a2 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -36,7 +36,7 @@ static void defaultConfig(void) ffStrbufInit(&instance.config.colorKeys); ffStrbufInit(&instance.config.colorTitle); - ffStrbufInitS(&instance.config.keyValueSeparator, ": "); + ffStrbufInitStatic(&instance.config.keyValueSeparator, ": "); instance.config.processingTimeout = 1000; #if defined(__linux__) || defined(__FreeBSD__) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index d004647d4..60feb6efe 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -103,8 +103,8 @@ static void detectWMPlugin(FFstrbuf* name) void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { - ffStrbufInitS(&ds->wmProcessName, "WindowServer"); - ffStrbufInitS(&ds->wmPrettyName, "Quartz Compositor"); + ffStrbufInitStatic(&ds->wmProcessName, "WindowServer"); + ffStrbufInitStatic(&ds->wmPrettyName, "Quartz Compositor"); ffStrbufInit(&ds->wmProtocolName); if(instance.config.allowSlowOperations) @@ -117,9 +117,8 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) } ffStrbufInit(&ds->deProcessName); - ffStrbufInit(&ds->dePrettyName); + ffStrbufInitStatic(&ds->dePrettyName, "Aqua"); ffStrbufInit(&ds->deVersion); - ffStrbufAppendS(&ds->dePrettyName, "Aqua"); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); detectDisplays(ds); diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index a37c506b1..b4945436b 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -145,13 +145,13 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) BOOL enabled; if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE) { - ffStrbufInitS(&ds->wmProcessName, "dwm.exe"); - ffStrbufInitS(&ds->wmPrettyName, "Desktop Window Manager"); + ffStrbufInitStatic(&ds->wmProcessName, "dwm.exe"); + ffStrbufInitStatic(&ds->wmPrettyName, "Desktop Window Manager"); } else { - ffStrbufInitS(&ds->wmProcessName, "internal"); - ffStrbufInitS(&ds->wmPrettyName, "internal"); + ffStrbufInitStatic(&ds->wmProcessName, "explorer.exe"); + ffStrbufInitStatic(&ds->wmPrettyName, "Windows Explorer"); } ffStrbufInit(&ds->wmProtocolName); ffStrbufInit(&ds->deProcessName); @@ -169,13 +169,13 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufEqualS(&os->version, "2022") || ffStrbufEqualS(&os->version, "2019") || ffStrbufEqualS(&os->version, "2016") - ) ffStrbufSetS(&ds->dePrettyName, "Fluent"); + ) ffStrbufSetStatic(&ds->dePrettyName, "Fluent"); else if( ffStrbufEqualS(&os->version, "8") || ffStrbufEqualS(&os->version, "8.1") || ffStrbufEqualS(&os->version, "2012 R2") || ffStrbufEqualS(&os->version, "2012") - ) ffStrbufSetS(&ds->dePrettyName, "Metro"); + ) ffStrbufSetStatic(&ds->dePrettyName, "Metro"); else - ffStrbufSetS(&ds->dePrettyName, "Aero"); + ffStrbufSetStatic(&ds->dePrettyName, "Aero"); } diff --git a/src/detection/os/os_android.c b/src/detection/os/os_android.c index 18b491283..1877aadfb 100644 --- a/src/detection/os/os_android.c +++ b/src/detection/os/os_android.c @@ -3,11 +3,11 @@ void ffDetectOSImpl(FFOSResult* os) { - ffStrbufInitS(&os->name, "Android"); + ffStrbufInitStatic(&os->name, "Android"); - ffStrbufInitS(&os->prettyName, "Android"); + ffStrbufInitStatic(&os->prettyName, "Android"); - ffStrbufInitS(&os->id, "android"); + ffStrbufInitStatic(&os->id, "android"); ffStrbufInit(&os->version); ffSettingsGetAndroidProperty("ro.build.version.release", &os->version); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index eede327c5..88d6519a4 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -363,11 +363,11 @@ const FFTerminalShellResult* ffDetectTerminalShell() ffStrbufSet(&result.userShellVersion, &result.shellVersion); if(ffStrbufEqualS(&result.shellProcessName, "pwsh")) - ffStrbufInitS(&result.shellPrettyName, "PowerShell"); + ffStrbufInitStatic(&result.shellPrettyName, "PowerShell"); else if(ffStrbufEqualS(&result.shellProcessName, "nu")) - ffStrbufInitS(&result.shellPrettyName, "nushell"); + ffStrbufInitStatic(&result.shellPrettyName, "nushell"); else if(ffStrbufIgnCaseEqualS(&result.shellProcessName, "python") && getenv("XONSH_VERSION")) - ffStrbufInitS(&result.shellPrettyName, "xonsh"); + ffStrbufInitStatic(&result.shellPrettyName, "xonsh"); else { // https://github.com/fastfetch-cli/fastfetch/discussions/280#discussioncomment-3831734 @@ -376,21 +376,21 @@ const FFTerminalShellResult* ffDetectTerminalShell() if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) - ffStrbufInitS(&result.terminalPrettyName, "WezTerm"); + ffStrbufInitStatic(&result.terminalPrettyName, "WezTerm"); #if defined(__linux__) || defined(__FreeBSD__) else if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-")) - ffStrbufInitS(&result.terminalPrettyName, "gnome-terminal"); + ffStrbufInitStatic(&result.terminalPrettyName, "gnome-terminal"); #elif defined(__APPLE__) else if(ffStrbufEqualS(&result.terminalProcessName, "iTerm.app") || ffStrbufStartsWithS(&result.terminalProcessName, "iTermServer-")) - ffStrbufInitS(&result.terminalPrettyName, "iTerm"); + ffStrbufInitStatic(&result.terminalPrettyName, "iTerm"); else if(ffStrbufEqualS(&result.terminalProcessName, "Apple_Terminal")) - ffStrbufInitS(&result.terminalPrettyName, "Apple Terminal"); + ffStrbufInitStatic(&result.terminalPrettyName, "Apple Terminal"); else if(ffStrbufEqualS(&result.terminalProcessName, "WarpTerminal")) - ffStrbufInitS(&result.terminalPrettyName, "Warp"); + ffStrbufInitStatic(&result.terminalPrettyName, "Warp"); #endif diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 15c2da12f..aa38e0075 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -334,18 +334,18 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) result->terminalPid = pid; if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "WindowsTerminal")) - ffStrbufSetS(&result->terminalPrettyName, ffStrbufContainIgnCaseS(&result->terminalExe, ".WindowsTerminalPreview_") + ffStrbufSetStatic(&result->terminalPrettyName, ffStrbufContainIgnCaseS(&result->terminalExe, ".WindowsTerminalPreview_") ? "Windows Terminal Preview" : "Windows Terminal" ); else if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "conhost")) - ffStrbufSetS(&result->terminalPrettyName, "Console Window Host"); + ffStrbufSetStatic(&result->terminalPrettyName, "Console Window Host"); else if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "Code")) - ffStrbufSetS(&result->terminalPrettyName, "Visual Studio Code"); + ffStrbufSetStatic(&result->terminalPrettyName, "Visual Studio Code"); else if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "explorer")) - ffStrbufSetS(&result->terminalPrettyName, "Windows Explorer"); + ffStrbufSetStatic(&result->terminalPrettyName, "Windows Explorer"); else if(ffStrbufEqualS(&result->terminalPrettyName, "wezterm-gui")) - ffStrbufInitS(&result->terminalPrettyName, "WezTerm"); + ffStrbufSetStatic(&result->terminalPrettyName, "WezTerm"); return ppid; } diff --git a/src/logo/option.c b/src/logo/option.c index a3b59b806..96e9caed0 100644 --- a/src/logo/option.c +++ b/src/logo/option.c @@ -18,7 +18,7 @@ void ffInitLogoOptions(FFLogoOptions* options) options->preserveAspectRadio = false; options->chafaFgOnly = false; - ffStrbufInitS(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default + ffStrbufInitStatic(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default options->chafaCanvasMode = UINT32_MAX; options->chafaColorSpace = UINT32_MAX; options->chafaDitherMode = UINT32_MAX; diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index cbf5cb524..b80875108 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -59,7 +59,7 @@ void ffInitWeatherOptions(FFWeatherOptions* options) ffOptionInitModuleArg(&options->moduleArgs); ffStrbufInit(&options->location); - ffStrbufInitS(&options->outputFormat, "%t+-+%C+(%l)"); + ffStrbufInitStatic(&options->outputFormat, "%t+-+%C+(%l)"); options->timeout = 0; } From 2f0d0a5a020c3a876d1e0766a9fcd2e965127fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 26 Jul 2023 09:18:46 +0800 Subject: [PATCH 370/493] CMake: build universal binaries for macOS --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 904dff2a8..fcc466ccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,7 @@ jobs: languages: c - name: configure project - run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . + run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' . - name: build project run: cmake --build . --target package From 8cbeb709f918bed57ddb6c99484a7cbb55ec4336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 26 Jul 2023 10:27:40 +0800 Subject: [PATCH 371/493] TerminalSize: add new module --- CHANGELOG.md | 1 + CMakeLists.txt | 6 ++ README.md | 2 +- doc/json_schema.json | 2 + presets/all | 2 +- presets/all.jsonc | 1 + src/common/io/io.h | 6 +- src/common/io/io_unix.c | 19 ++-- src/common/io/io_windows.c | 57 ++++++++++++ src/common/jsonconfig.c | 1 + src/detection/terminalsize/terminalsize.h | 18 ++++ .../terminalsize/terminalsize_linux.c | 26 ++++++ .../terminalsize/terminalsize_windows.c | 41 +++++++++ src/fastfetch.c | 3 + src/fastfetch.h | 1 + src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/terminalsize/option.h | 11 +++ src/modules/terminalsize/terminalsize.c | 86 +++++++++++++++++++ src/modules/terminalsize/terminalsize.h | 11 +++ 20 files changed, 279 insertions(+), 17 deletions(-) create mode 100644 src/detection/terminalsize/terminalsize.h create mode 100644 src/detection/terminalsize/terminalsize_linux.c create mode 100644 src/detection/terminalsize/terminalsize_windows.c create mode 100644 src/modules/terminalsize/option.h create mode 100644 src/modules/terminalsize/terminalsize.c create mode 100644 src/modules/terminalsize/terminalsize.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eca06e84..707a35f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Features: * Support iTerm non-ascii font detection (Terminal, macOS) * Add option `--title-color-user`, `--title-color-at` and `--title-color-host` (Title) * Add Exherbo logo and package manager count (Packages, Linux, #503) +* Add module `Terminal Size` which prints the number of terminal width and height in charactors and pixels Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48dc065cb..702019783 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,6 +319,7 @@ set(LIBFASTFETCH_SRC src/modules/media/media.c src/modules/terminal/terminal.c src/modules/terminalfont/terminalfont.c + src/modules/terminalsize/terminalsize.c src/modules/theme/theme.c src/modules/title/title.c src/modules/uptime/uptime.c @@ -378,6 +379,7 @@ if(LINUX) src/detection/temps/temps_linux.c src/detection/terminalfont/terminalfont_linux.c src/detection/terminalshell/terminalshell_linux.c + src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_linux.c src/detection/uptime/uptime_linux.c src/detection/users/users_linux.c @@ -421,6 +423,7 @@ elseif(ANDROID) src/detection/temps/temps_linux.c src/detection/terminalfont/terminalfont_android.c src/detection/terminalshell/terminalshell_linux.c + src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_nosupport.c src/detection/uptime/uptime_linux.c src/detection/users/users_linux.c @@ -472,6 +475,7 @@ elseif(BSD) src/detection/temps/temps_bsd.c src/detection/terminalfont/terminalfont_linux.c src/detection/terminalshell/terminalshell_linux.c + src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_linux.c src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c @@ -517,6 +521,7 @@ elseif(APPLE) src/detection/temps/temps_apple.c src/detection/terminalfont/terminalfont_apple.m src/detection/terminalshell/terminalshell_linux.c + src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_nosupport.c src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c @@ -561,6 +566,7 @@ elseif(WIN32) src/detection/swap/swap_windows.c src/detection/terminalfont/terminalfont_windows.c src/detection/terminalshell/terminalshell_windows.c + src/detection/terminalsize/terminalsize_windows.c src/detection/temps/temps_windows.cpp src/detection/theme/theme_nosupport.c src/detection/uptime/uptime_windows.c diff --git a/README.md b/README.md index 36a8c7462..4cd69b8ca 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ All categories not listed here should work without needing a specific implementa ##### Available Modules ``` -Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme +Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme ``` ##### Builtin logos diff --git a/doc/json_schema.json b/doc/json_schema.json index f9521c4cb..1d5aa740f 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -482,6 +482,7 @@ "swap", "terminal", "terminalfont", + "terminalsize", "title", "theme", "uptime", @@ -549,6 +550,7 @@ "swap", "terminal", "terminalfont", + "terminalsize", "theme", "uptime", "users", diff --git a/presets/all b/presets/all index b669e6643..506ee7a65 100644 --- a/presets/all +++ b/presets/all @@ -1 +1 @@ ---structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors +--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors diff --git a/presets/all.jsonc b/presets/all.jsonc index b25c8baa8..3659006d0 100644 --- a/presets/all.jsonc +++ b/presets/all.jsonc @@ -26,6 +26,7 @@ "wallpaper", "terminal", "terminalfont", + "terminalsize", "cpu", "cpuusage", "gpu", diff --git a/src/common/io/io.h b/src/common/io/io.h index e28a9b3c0..cfe730550 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -83,10 +83,8 @@ typedef enum FFPathType bool ffPathExists(const char* path, FFPathType pathType); -#ifndef _WIN32 - FF_C_SCANF(2, 3) - void ffGetTerminalResponse(const char* request, const char* format, ...); -#endif +FF_C_SCANF(2, 3) +const char* ffGetTerminalResponse(const char* request, const char* format, ...); // Not thread safe! bool ffSuppressIO(bool suppress); diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 54e561190..7680cab81 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -107,30 +107,25 @@ bool ffPathExists(const char* path, FFPathType type) return false; } -void ffGetTerminalResponse(const char* request, const char* format, ...) +const char* ffGetTerminalResponse(const char* request, const char* format, ...) { struct termios oldTerm, newTerm; if(tcgetattr(STDIN_FILENO, &oldTerm) == -1) - return; + return "tcgetattr(STDIN_FILENO, &oldTerm) failed"; newTerm = oldTerm; newTerm.c_lflag &= (tcflag_t) ~(ICANON | ECHO); if(tcsetattr(STDIN_FILENO, TCSANOW, &newTerm) == -1) - return; + return "tcsetattr(STDIN_FILENO, TCSANOW, &newTerm)"; fputs(request, stdout); fflush(stdout); - struct pollfd pfd; - pfd.fd = STDIN_FILENO; - pfd.events = POLLIN; - pfd.revents = 0; - //Give the terminal 35ms to respond - if(poll(&pfd, 1, 35) <= 0) + if(poll(&(struct pollfd) { .fd = STDIN_FILENO, .events = POLLIN }, 1, 35) <= 0) { tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm); - return; + return "poll() timeout or failed"; } char buffer[512]; @@ -139,7 +134,7 @@ void ffGetTerminalResponse(const char* request, const char* format, ...) tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm); if(readed <= 0) - return; + return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed"; buffer[readed] = '\0'; @@ -147,6 +142,8 @@ void ffGetTerminalResponse(const char* request, const char* format, ...) va_start(args, format); vsscanf(buffer, format, args); va_end(args); + + return NULL; } bool ffSuppressIO(bool suppress) diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index f1f40a2b0..bf19540a2 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -1,6 +1,8 @@ #include "io.h" #include "util/stringUtils.h" +#include + static void createSubfolders(const char* fileName) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); @@ -144,3 +146,58 @@ void ffListFilesRecursively(const char* path) ffStrbufEnsureEndsWithC(&folder, '/'); listFilesRecursively(&folder, 0, NULL); } + +const char* ffGetTerminalResponse(const char* request, const char* format, ...) +{ + HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); + DWORD prev_mode; + GetConsoleMode(hInput, &prev_mode); + SetConsoleMode(hInput, 0); + + FlushConsoleInputBuffer(hInput); + + DWORD bytes = 0; + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), request, (DWORD) strlen(request), &bytes, NULL); + + while (true) + { + if (WaitForSingleObjectEx(hInput, 35, TRUE) != WAIT_OBJECT_0) + { + SetConsoleMode(hInput, prev_mode); + return "WaitForSingleObject() failed or timeout"; + } + + // Ignore all unexpected input events + INPUT_RECORD record; + DWORD len = 0; + if (!PeekConsoleInputW(hInput, &record, 1, &len)) + break; + + if ( + record.EventType == KEY_EVENT && + record.Event.KeyEvent.uChar.UnicodeChar != L'\r' && + record.Event.KeyEvent.uChar.UnicodeChar != L'\n' + ) + break; + else + ReadConsoleInputW(hInput, &record, 1, &len); + } + + char buffer[512]; + bytes = 0; + ReadFile(hInput, buffer, sizeof(buffer) - 1, &bytes, NULL); + + SetConsoleMode(hInput, prev_mode); + + if(bytes <= 0) + return "ReadFile() failed"; + + buffer[bytes] = '\0'; + + va_list args; + va_start(args, format); + vsscanf(buffer, format, args); + va_end(args); + + return NULL; +} diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 08fbb999b..5fd490657 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -188,6 +188,7 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) return tryModule(type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) || tryModule(type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) || + tryModule(type, module, FF_TERMINALSIZE_MODULE_NAME, ffParseTerminalSizeJsonObject) || tryModule(type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) || tryModule(type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) || false; diff --git a/src/detection/terminalsize/terminalsize.h b/src/detection/terminalsize/terminalsize.h new file mode 100644 index 000000000..b1b51ebe5 --- /dev/null +++ b/src/detection/terminalsize/terminalsize.h @@ -0,0 +1,18 @@ +#pragma once + +#ifndef FF_INCLUDED_detection_terminalsize_terminalsize +#define FF_INCLUDED_detection_terminalsize_terminalsize + +#include "fastfetch.h" + +typedef struct FFTerminalSizeResult +{ + uint16_t rows; + uint16_t columns; + uint16_t width; + uint16_t height; +} FFTerminalSizeResult; + +bool ffDetectTerminalSize(FFTerminalSizeResult* result); + +#endif diff --git a/src/detection/terminalsize/terminalsize_linux.c b/src/detection/terminalsize/terminalsize_linux.c new file mode 100644 index 000000000..68a75cbb2 --- /dev/null +++ b/src/detection/terminalsize/terminalsize_linux.c @@ -0,0 +1,26 @@ +#include "terminalsize.h" +#include "common/io/io.h" + +#include +#include + +bool ffDetectTerminalSize(FFTerminalSizeResult* result) +{ + struct winsize winsize = {}; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize); + + if (winsize.ws_row == 0 || winsize.ws_col == 0) + ffGetTerminalResponse("\033[18t", "\033[8;%hu;%hut", &winsize.ws_row, &winsize.ws_col); + + if (winsize.ws_ypixel == 0 || winsize.ws_xpixel == 0) + ffGetTerminalResponse("\033[14t", "\033[4;%hu;%hut", &winsize.ws_ypixel, &winsize.ws_xpixel); + + if (winsize.ws_row == 0 && winsize.ws_col == 0) + return false; + + result->rows = winsize.ws_row; + result->columns = winsize.ws_col; + result->width = winsize.ws_xpixel; + result->height = winsize.ws_ypixel; + return true; +} diff --git a/src/detection/terminalsize/terminalsize_windows.c b/src/detection/terminalsize/terminalsize_windows.c new file mode 100644 index 000000000..a0b554517 --- /dev/null +++ b/src/detection/terminalsize/terminalsize_windows.c @@ -0,0 +1,41 @@ +#include "terminalsize.h" +#include "common/io/io.h" + +#include + +bool ffDetectTerminalSize(FFTerminalSizeResult* result) +{ + { + CONSOLE_SCREEN_BUFFER_INFO csbi; + if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) + { + result->columns = (uint16_t) (csbi.srWindow.Right - csbi.srWindow.Left + 1); + result->rows = (uint16_t) (csbi.srWindow.Bottom - csbi.srWindow.Top + 1); + } + else + { + ffGetTerminalResponse("\033[18t", "\033[8;%hu;%hut", &result->rows, &result->columns); + } + } + + if (result->columns == 0 && result->rows == 0) + return false; + + { + CONSOLE_FONT_INFO cfi; + if(GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi)) // Only works for ConHost + { + result->width = result->columns * (uint16_t) cfi.dwFontSize.X; + result->height = result->rows * (uint16_t) cfi.dwFontSize.Y; + } + else + { + // Pending https://github.com/microsoft/terminal/issues/8581 + // if (result->width == 0 && result->height == 0) + // ffGetTerminalResponse("\033[14t", "\033[4;%hu;%hut", &result->height, &result->width); + return false; + } + } + + return result->columns > 0 && result->rows > 0; +} diff --git a/src/fastfetch.c b/src/fastfetch.c index 9c41dc3c7..f201c7849 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -971,6 +971,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseCursorCommandOptions(&instance.config.cursor, key, value)) {} else if(ffParseTerminalCommandOptions(&instance.config.terminal, key, value)) {} else if(ffParseTerminalFontCommandOptions(&instance.config.terminalFont, key, value)) {} + else if(ffParseTerminalSizeCommandOptions(&instance.config.terminalSize, key, value)) {} else if(ffParseCPUCommandOptions(&instance.config.cpu, key, value)) {} else if(ffParseCPUUsageCommandOptions(&instance.config.cpuUsage, key, value)) {} else if(ffParseGPUCommandOptions(&instance.config.gpu, key, value)) {} @@ -1182,6 +1183,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues) ffPrintTerminal(&instance.config.terminal); else if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME)) ffPrintTerminalFont(&instance.config.terminalFont); + else if(ffStrEqualsIgnCase(line, FF_TERMINALSIZE_MODULE_NAME)) + ffPrintTerminalSize(&instance.config.terminalSize); else if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME)) ffPrintCPU(&instance.config.cpu); else if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index 645bc20d0..85256e0ed 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -82,6 +82,7 @@ typedef struct FFconfig FFCursorOptions cursor; FFTerminalOptions terminal; FFTerminalFontOptions terminalFont; + FFTerminalSizeOptions terminalSize; FFCPUOptions cpu; FFCPUUsageOptions cpuUsage; FFCustomOptions custom; diff --git a/src/modules/modules.h b/src/modules/modules.h index 6959ab815..f2a6f6799 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -44,6 +44,7 @@ #include "modules/swap/swap.h" #include "modules/terminal/terminal.h" #include "modules/terminalfont/terminalfont.h" +#include "modules/terminalsize/terminalsize.h" #include "modules/theme/theme.h" #include "modules/title/title.h" #include "modules/uptime/uptime.h" diff --git a/src/modules/options.h b/src/modules/options.h index 2fdc65c3e..7d9c0668d 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -43,6 +43,7 @@ #include "modules/swap/option.h" #include "modules/terminal/option.h" #include "modules/terminalfont/option.h" +#include "modules/terminalsize/option.h" #include "modules/theme/option.h" #include "modules/title/option.h" #include "modules/uptime/option.h" diff --git a/src/modules/terminalsize/option.h b/src/modules/terminalsize/option.h new file mode 100644 index 000000000..16f482466 --- /dev/null +++ b/src/modules/terminalsize/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFTerminalSizeOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFTerminalSizeOptions; diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c new file mode 100644 index 000000000..e33966eb5 --- /dev/null +++ b/src/modules/terminalsize/terminalsize.c @@ -0,0 +1,86 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/terminalsize/terminalsize.h" +#include "modules/terminalsize/terminalsize.h" +#include "util/stringUtils.h" + +#define FF_TERMINALSIZE_DISPLAY_NAME "Terminal Size" +#define FF_TERMINALSIZE_NUM_FORMAT_ARGS 4 + +void ffPrintTerminalSize(FFTerminalSizeOptions* options) +{ + FFTerminalSizeResult result = {}; + + if(!ffDetectTerminalSize(&result)) + { + ffPrintError(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect terminal size"); + } + else + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + printf("%u columns x %u rows", result.columns, result.rows); + + if (result.width != 0 && result.height != 0) + printf(" (%upx x %upx)", result.width, result.height); + + putchar('\n'); + } + else + { + ffPrintFormat(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALSIZE_NUM_FORMAT_ARGS, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT16, &result.rows}, + {FF_FORMAT_ARG_TYPE_UINT16, &result.columns}, + {FF_FORMAT_ARG_TYPE_UINT16, &result.width}, + {FF_FORMAT_ARG_TYPE_UINT16, &result.height} + }); + } + } +} + +void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options) +{ + options->moduleName = FF_TERMINALSIZE_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseTerminalSizeCommandOptions(FFTerminalSizeOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_TERMINALSIZE_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyTerminalSizeOptions(FFTerminalSizeOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParseTerminalSizeJsonObject(yyjson_val* module) +{ + FFTerminalSizeOptions __attribute__((__cleanup__(ffDestroyTerminalSizeOptions))) options; + ffInitTerminalSizeOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(FF_TERMINALSIZE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintTerminalSize(&options); +} diff --git a/src/modules/terminalsize/terminalsize.h b/src/modules/terminalsize/terminalsize.h new file mode 100644 index 000000000..0b1b37d32 --- /dev/null +++ b/src/modules/terminalsize/terminalsize.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_TERMINALSIZE_MODULE_NAME "TerminalSize" + +void ffPrintTerminalSize(FFTerminalSizeOptions* options); +void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options); +bool ffParseTerminalSizeCommandOptions(FFTerminalSizeOptions* options, const char* key, const char* value); +void ffDestroyTerminalSizeOptions(FFTerminalSizeOptions* options); +void ffParseTerminalSizeJsonObject(yyjson_val* module); From de3cb1f8553e03ca06bb42d1a52fbd6ce11989c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 26 Jul 2023 21:44:01 +0800 Subject: [PATCH 372/493] Logo: fix `kitty-direct` --- src/logo/image/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index a8eacc518..f50b73423 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -79,7 +79,7 @@ static bool printImageKittyDirect(void) FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&instance.config.logo.source); instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight; instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height; - printf("\033_Ga=T,f=100,t=f,c=%u,r=%u;%s\033\\\033[9999999D\033[%uA", + printf("\033_Ga=T,f=100,t=f,c=%u,r=%u;%s\033\\\033[9999999D\n\033[%uA", (unsigned) instance.config.logo.width, (unsigned) instance.config.logo.height, base64.chars, From c9741d166283b08ec7adc8be4adff2cefec16b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 15:17:54 +0800 Subject: [PATCH 373/493] Parsing: simplify code --- src/common/parsing.c | 25 ++++++++++++++++--------- src/common/parsing.h | 2 +- src/modules/disk/disk.c | 4 ++-- src/modules/gpu/gpu.c | 4 ++-- src/modules/memory/memory.c | 4 ++-- src/modules/swap/swap.c | 4 ++-- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/common/parsing.c b/src/common/parsing.c index 8fd5da367..9df1d1046 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -77,16 +77,23 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, const cha ffStrbufAppendF(result, "%.*f %s", instance.config.sizeNdigits, size, prefixes[counter]); } -void ffParseSize(uint64_t bytes, FFBinaryPrefixType binaryPrefix, FFstrbuf* result) +void ffParseSize(uint64_t bytes, FFstrbuf* result) { - if(binaryPrefix == FF_BINARY_PREFIX_TYPE_IEC) - parseSize(result, bytes, 1024, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL}); - else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_SI) - parseSize(result, bytes, 1000, (const char*[]) {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL}); - else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_JEDEC) - parseSize(result, bytes, 1024, (const char*[]) {"B", "KB", "MB", "GB", "TB", NULL}); - else - parseSize(result, bytes, 1024, (const char*[]) {"B", NULL}); + switch (instance.config.binaryPrefixType) + { + case FF_BINARY_PREFIX_TYPE_IEC: + parseSize(result, bytes, 1024, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL}); + break; + case FF_BINARY_PREFIX_TYPE_SI: + parseSize(result, bytes, 1000, (const char*[]) {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL}); + break; + case FF_BINARY_PREFIX_TYPE_JEDEC: + parseSize(result, bytes, 1024, (const char*[]) {"B", "KB", "MB", "GB", "TB", NULL}); + break; + default: + parseSize(result, bytes, 1024, (const char*[]) {"B", NULL}); + break; + } } void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4) diff --git a/src/common/parsing.h b/src/common/parsing.h index 4f8a29c04..41ac3858e 100644 --- a/src/common/parsing.h +++ b/src/common/parsing.h @@ -22,6 +22,6 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty); int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2); -void ffParseSize(uint64_t bytes, FFBinaryPrefixType binaryPrefix, FFstrbuf* result); +void ffParseSize(uint64_t bytes, FFstrbuf* result); #endif diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index de983f3ed..be61a902c 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -28,10 +28,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(disk->bytesUsed, instance.config.binaryPrefixType, &usedPretty); + ffParseSize(disk->bytesUsed, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(disk->bytesTotal, instance.config.binaryPrefixType, &totalPretty); + ffParseSize(disk->bytesTotal, &totalPretty); uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0; diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index d7ec2d246..b0f03b45c 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -47,10 +47,10 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) { - ffParseSize(gpu->dedicated.used, instance.config.binaryPrefixType, &output); + ffParseSize(gpu->dedicated.used, &output); ffStrbufAppendS(&output, " / "); } - ffParseSize(gpu->dedicated.total, instance.config.binaryPrefixType, &output); + ffParseSize(gpu->dedicated.total, &output); if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) { ffStrbufAppendS(&output, ", "); diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 6663d9bc4..8bd1e7e8f 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -20,10 +20,10 @@ void ffPrintMemory(FFMemoryOptions* options) } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty); + ffParseSize(storage.bytesUsed, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty); + ffParseSize(storage.bytesTotal, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 ? 0 diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 99ce0455e..5f13b286e 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -20,10 +20,10 @@ void ffPrintSwap(FFSwapOptions* options) } FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); - ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty); + ffParseSize(storage.bytesUsed, &usedPretty); FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate(); - ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty); + ffParseSize(storage.bytesTotal, &totalPretty); uint8_t percentage = storage.bytesTotal == 0 ? 0 From af2c6a832e9eb6263616ad998184b28aa7ff1d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 15:58:49 +0800 Subject: [PATCH 374/493] Fastfetch: add new option `--temperature-unit` --- doc/json_schema.json | 6 ++++++ src/common/init.c | 1 + src/common/jsonconfig.c | 15 +++++++++++++++ src/common/parsing.c | 16 ++++++++++++++++ src/common/parsing.h | 1 + src/data/help.txt | 1 + src/fastfetch.c | 12 ++++++++++++ src/fastfetch.h | 8 ++++++++ src/modules/battery/battery.c | 3 ++- src/modules/cpu/cpu.c | 22 ++++++++++++++-------- src/modules/gpu/gpu.c | 6 +++++- 11 files changed, 81 insertions(+), 10 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 1d5aa740f..a4eed6218 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -314,6 +314,12 @@ "enum": ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], "default": "YB" }, + "temperatureUnit": { + "type": "string", + "title": "Set the unit of the temperature", + "enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"], + "default": "C" + }, "percentType": { "type": "number", "title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number", diff --git a/src/common/init.c b/src/common/init.c index ba8c173a2..1b5659f46 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -63,6 +63,7 @@ static void defaultConfig(void) instance.config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC; instance.config.sizeNdigits = 2; instance.config.sizeMaxPrefix = UINT8_MAX; + instance.config.temperatureUnit = FF_TEMPERATURE_UNIT_CELSIUS; instance.config.multithreading = true; instance.config.stat = false; instance.config.noBuffer = false; diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 5fd490657..0b327ca4f 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -409,6 +409,21 @@ const char* ffParseDisplayJsonConfig(void) if (error) return error; config->sizeMaxPrefix = (uint8_t) value; } + else if (ffStrEqualsIgnCase(key, "temperatureUnit")) + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "CELSIUS", FF_TEMPERATURE_UNIT_CELSIUS }, + { "C", FF_TEMPERATURE_UNIT_CELSIUS }, + { "FAHRENHEIT", FF_TEMPERATURE_UNIT_FAHRENHEIT }, + { "F", FF_TEMPERATURE_UNIT_FAHRENHEIT }, + { "KELVIN", FF_TEMPERATURE_UNIT_KELVIN }, + { "K", FF_TEMPERATURE_UNIT_KELVIN }, + {}, + }); + if (error) return error; + config->temperatureUnit = (FFTemperatureUnit) value; + } else if (ffStrEqualsIgnCase(key, "percentType")) config->percentType = (uint32_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "noBuffer")) diff --git a/src/common/parsing.c b/src/common/parsing.c index 9df1d1046..55a2780fe 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -96,6 +96,22 @@ void ffParseSize(uint64_t bytes, FFstrbuf* result) } } +void ffParseTemperature(double celsius, FFstrbuf* buffer) +{ + switch (instance.config.temperatureUnit) + { + case FF_TEMPERATURE_UNIT_CELSIUS: + ffStrbufAppendF(buffer, "%.1f°C", celsius); + break; + case FF_TEMPERATURE_UNIT_FAHRENHEIT: + ffStrbufAppendF(buffer, "%.1f°F", celsius * 1.8 + 32); + break; + case FF_TEMPERATURE_UNIT_KELVIN: + ffStrbufAppendF(buffer, "%.1f K", celsius + 273.15); + break; + } +} + void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4) { if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0) diff --git a/src/common/parsing.h b/src/common/parsing.h index 41ac3858e..deb555c01 100644 --- a/src/common/parsing.h +++ b/src/common/parsing.h @@ -23,5 +23,6 @@ void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty); int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2); void ffParseSize(uint64_t bytes, FFstrbuf* result); +void ffParseTemperature(double celsius, FFstrbuf* buffer); #endif diff --git a/src/data/help.txt b/src/data/help.txt index 0870ec5d4..097fc518d 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -69,6 +69,7 @@ Display options: --no-buffer : Set if the stdout application buffer should be disabled. Default is false --size-ndigits : Set the number of digits to keep after the decimal point when formatting sizes --size-max-prefix : Set the largest binary prefix to use when formatting sizes. Default is YB + --temperature-unit : Set the unit of the temperature. Must be one of C, F and K. Default is C General module options: ---format : Set the format string to use for each specific module. diff --git a/src/fastfetch.c b/src/fastfetch.c index f201c7849..50ad5c3d8 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -935,6 +935,18 @@ static void parseOption(FFdata* data, const char* key, const char* value) {} }); } + else if(ffStrEqualsIgnCase(key, "--temperature-unit")) + { + instance.config.temperatureUnit = (FFTemperatureUnit) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "CELSIUS", FF_TEMPERATURE_UNIT_CELSIUS }, + { "C", FF_TEMPERATURE_UNIT_CELSIUS }, + { "FAHRENHEIT", FF_TEMPERATURE_UNIT_FAHRENHEIT }, + { "F", FF_TEMPERATURE_UNIT_FAHRENHEIT }, + { "KELVIN", FF_TEMPERATURE_UNIT_KELVIN }, + { "K", FF_TEMPERATURE_UNIT_KELVIN }, + {}, + }); + } else if(ffStrEqualsIgnCase(key, "--percent-type")) instance.config.percentType = ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(key, "--no-buffer")) diff --git a/src/fastfetch.h b/src/fastfetch.h index 85256e0ed..90cc4e9aa 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -24,6 +24,13 @@ typedef enum FFBinaryPrefixType FF_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 kB, 1024 K = 1 MB, ... } FFBinaryPrefixType; +typedef enum FFTemperatureUnit +{ + FF_TEMPERATURE_UNIT_CELSIUS, + FF_TEMPERATURE_UNIT_FAHRENHEIT, + FF_TEMPERATURE_UNIT_KELVIN, +} FFTemperatureUnit; + typedef struct FFconfig { FFLogoOptions logo; @@ -43,6 +50,7 @@ typedef struct FFconfig FFBinaryPrefixType binaryPrefixType; uint8_t sizeNdigits; uint8_t sizeMaxPrefix; + FFTemperatureUnit temperatureUnit; bool pipe; //disables logo and all escape sequences bool multithreading; bool stat; diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 297d30d50..5f5a93329 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -1,6 +1,7 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "common/bar.h" +#include "common/parsing.h" #include "detection/battery/battery.h" #include "modules/battery/battery.h" #include "util/stringUtils.h" @@ -54,7 +55,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8 if(str.length > 0) ffStrbufAppendS(&str, " - "); - ffStrbufAppendF(&str, "%.1f°C", result->temperature); + ffParseTemperature(result->temperature, &str); } ffStrbufPutTo(&str, stdout); diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index f4b41be5c..14d751685 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -1,5 +1,6 @@ #include "common/printing.h" #include "common/jsonconfig.h" +#include "common/parsing.h" #include "detection/cpu/cpu.h" #include "modules/cpu/cpu.h" #include "util/stringUtils.h" @@ -31,26 +32,31 @@ void ffPrintCPU(FFCPUOptions* options) { ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); + if(cpu.name.length > 0) - ffStrbufWriteTo(&cpu.name, stdout); + ffStrbufAppend(&str, &cpu.name); else if(cpu.vendor.length > 0) { - ffStrbufWriteTo(&cpu.vendor, stdout); - fputs(" CPU", stdout); + ffStrbufAppend(&str, &cpu.vendor); + ffStrbufAppendS(&str, " CPU"); } else - fputs("CPU", stdout); + ffStrbufAppendS(&str, "Unknown"); if(cpu.coresOnline > 1) - printf(" (%u)", cpu.coresOnline); + ffStrbufAppendF(&str, " (%u)", cpu.coresOnline); if(cpu.frequencyMax > 0.0) - printf(" @ %.9g GHz", cpu.frequencyMax); + ffStrbufAppendF(&str, " @ %.9g GHz", cpu.frequencyMax); if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET - printf(" - %.1f°C", cpu.temperature); + { + ffStrbufAppendS(&str, " - "); + ffParseTemperature(cpu.temperature, &str); + } - putchar('\n'); + ffStrbufPutTo(&str, stdout); } else { diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index b0f03b45c..84a379f29 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -2,6 +2,7 @@ #include "common/parsing.h" #include "common/printing.h" #include "common/jsonconfig.h" +#include "common/parsing.h" #include "detection/host/host.h" #include "detection/gpu/gpu.h" #include "modules/gpu/gpu.h" @@ -39,7 +40,10 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu ffStrbufAppendF(&output, " (%d)", gpu->coreCount); if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET - ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature); + { + ffStrbufAppendS(&output, " - "); + ffParseTemperature(gpu->temperature, &output); + } if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0) { From 5fcf5b7f64ac3a2698eb1dcf95ba24349070127a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 16:16:09 +0800 Subject: [PATCH 375/493] CPU (Linux): tidy --- src/detection/cpu/cpu_linux.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 1fd61ce37..99ce8d5b9 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -2,6 +2,7 @@ #include "common/io/io.h" #include "common/properties.h" #include "detection/temps/temps_linux.h" +#include "util/mallocHelper.h" #include #include @@ -9,11 +10,11 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch) { - FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); + FF_AUTO_CLOSE_FILE FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); if(cpuinfo == NULL) return "fopen(\"/proc/cpuinfo\", \"r\") failed"; - char* line = NULL; + FF_AUTO_FREE char* line = NULL; size_t len = 0; while(getline(&line, &len, cpuinfo) != -1) @@ -34,11 +35,6 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, ); } - if(line != NULL) - free(line); - - fclose(cpuinfo); - return NULL; } From 92b1d74d124426e99c241cd7ddc6be004942afe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 19:35:55 +0800 Subject: [PATCH 376/493] CPU (Android): better CPU name detection at least for Xiaomi --- src/detection/cpu/cpu_linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 99ce8d5b9..bdffc755f 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -8,6 +8,21 @@ #include #include +#ifdef __ANDROID__ +#include "common/settings.h" + +static void detectAndroid(FFCPUResult* cpu) +{ + if (cpu->name.length == 0) + ffSettingsGetAndroidProperty("ro.soc.model", &cpu->name); + if (cpu->vendor.length == 0) + { + if (!ffSettingsGetAndroidProperty("ro.soc.manufacturer", &cpu->vendor)) + ffSettingsGetAndroidProperty("ro.product.product.manufacturer", &cpu->vendor); + } +} +#endif + static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch) { FF_AUTO_CLOSE_FILE FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); @@ -144,5 +159,9 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) ffStrbufAppend(&cpu->name, &cpuIsa); } + #ifdef __ANDROID__ + detectAndroid(cpu); + #endif + return NULL; } From 7147029c96ab43fe3b6c04411dcb287ac0541e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 19:47:26 +0800 Subject: [PATCH 377/493] Board (Android): add support --- CMakeLists.txt | 2 +- src/detection/board/board_android.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/detection/board/board_android.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 702019783..f54c012bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -396,7 +396,7 @@ elseif(ANDROID) src/detection/battery/battery_android.c src/detection/bios/bios_nosupport.c src/detection/bluetooth/bluetooth_nosupport.c - src/detection/board/board_nosupport.c + src/detection/board/board_android.c src/detection/brightness/brightness_nosupport.c src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_linux.c diff --git a/src/detection/board/board_android.c b/src/detection/board/board_android.c new file mode 100644 index 000000000..64e917e6a --- /dev/null +++ b/src/detection/board/board_android.c @@ -0,0 +1,9 @@ +#include "board.h" +#include "common/settings.h" + +const char* ffDetectBoard(FFBoardResult* board) +{ + if (!ffSettingsGetAndroidProperty("ro.product.board", &board->name)) + ffSettingsGetAndroidProperty("ro.board.platform", &board->name); + return NULL; +} From be93714fd363e501e8242a79028ea97859494fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 20:45:08 +0800 Subject: [PATCH 378/493] Display (Android): add support for Xiaomi devices --- .../displayserver/displayserver_android.c | 56 +++++++++++++++---- .../displayserver/displayserver_nosupport.c | 12 ---- 2 files changed, 46 insertions(+), 22 deletions(-) delete mode 100644 src/detection/displayserver/displayserver_nosupport.c diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c index 24d874b4c..af57a0628 100644 --- a/src/detection/displayserver/displayserver_android.c +++ b/src/detection/displayserver/displayserver_android.c @@ -1,17 +1,10 @@ #include "displayserver.h" +#include "common/settings.h" #include "common/processing.h" -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) +static void detectWithDumpsys(FFDisplayServerResult* ds) { - ffStrbufInit(&ds->wmProcessName); - ffStrbufInit(&ds->wmPrettyName); - ffStrbufInit(&ds->wmProtocolName); - ffStrbufInit(&ds->deProcessName); - ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); - ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); - FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); if (ffProcessAppendStdOut(&buf, (char* []) { "/system/bin/dumpsys", @@ -73,7 +66,50 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) 0 ); } - + index = nextIndex + 1; } } + +static bool detectWithGetprop(FFDisplayServerResult* ds) +{ + // Only for MiUI + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + ; + if (ffSettingsGetAndroidProperty("persist.sys.miui_resolution", &buffer) && + ffStrbufContainC(&buffer, ',')) + { + // 1440,3200,560 => width,height,ppi + uint32_t width = ffStrbufToUInt16(&buffer, 0); + ffStrbufSubstrAfterFirstC(&buffer, ','); + uint32_t height = ffStrbufToUInt16(&buffer, 0); + return ffdsAppendDisplay(ds, + width, + height, + 0, + 0, + 0, + 0, + 0, + FF_DISPLAY_TYPE_BUILTIN, + false, + 0 + ); + } + + return false; +} + +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) +{ + ffStrbufInitStatic(&ds->wmProcessName, "WindowManager"); + ffStrbufInitStatic(&ds->wmPrettyName, "Window Manager"); + ffStrbufInit(&ds->wmProtocolName); + ffStrbufInit(&ds->deProcessName); + ffStrbufInit(&ds->dePrettyName); + ffStrbufInit(&ds->deVersion); + ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); + + if (!detectWithGetprop(ds)) + detectWithDumpsys(ds); +} diff --git a/src/detection/displayserver/displayserver_nosupport.c b/src/detection/displayserver/displayserver_nosupport.c deleted file mode 100644 index 20e121e65..000000000 --- a/src/detection/displayserver/displayserver_nosupport.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "displayserver.h" - -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) -{ - ffStrbufInit(&ds->wmProcessName); - ffStrbufInit(&ds->wmPrettyName); - ffStrbufInit(&ds->wmProtocolName); - ffStrbufInit(&ds->deProcessName); - ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); - ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); -} From 7abf91aa7f9b7522fca72e78561976c1bb283e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 19:23:27 +0800 Subject: [PATCH 379/493] Host (Android): better host detection --- src/detection/host/host_android.c | 31 +++++++++++++++++++++++-------- src/util/FFstrbuf.h | 7 +++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/detection/host/host_android.c b/src/detection/host/host_android.c index 53e18d1ea..4b7c095a9 100644 --- a/src/detection/host/host_android.c +++ b/src/detection/host/host_android.c @@ -4,19 +4,34 @@ const char* ffDetectHost(FFHostResult* host) { + // http://newandroidbook.com/ddb/ ffSettingsGetAndroidProperty("ro.product.device", &host->productFamily); - ffSettingsGetAndroidProperty("ro.product.brand", &host->productName); - if(host->productName.length > 0) - { - host->productName.chars[0] = (char) toupper(host->productName.chars[0]); - ffStrbufAppendC(&host->productName, ' '); - } + ffSettingsGetAndroidProperty("ro.product.marketname", &host->productName) + || ffSettingsGetAndroidProperty("ro.vendor.product.display", &host->productName) + || ffSettingsGetAndroidProperty("ro.config.devicename", &host->productName) + || ffSettingsGetAndroidProperty("ro.config.marketing_name", &host->productName) + || ffSettingsGetAndroidProperty("ro.product.vendor.model", &host->productName) + || ffSettingsGetAndroidProperty("ro.product.oppo_model", &host->productName) + || ffSettingsGetAndroidProperty("ro.oppo.market.name", &host->productName) + || ffSettingsGetAndroidProperty("ro.product.brand", &host->productName); - ffSettingsGetAndroidProperty("ro.product.model", &host->productName); - ffStrbufTrimRight(&host->productName, ' '); + if (ffSettingsGetAndroidProperty("ro.product.model", &host->productVersion)) + { + if (ffStrbufStartsWithIgnCase(&host->productVersion, &host->productName)) + { + ffStrbufSubstrAfter(&host->productVersion, host->productName.length); + ffStrbufTrimLeft(&host->productVersion, ' '); + } + } ffSettingsGetAndroidProperty("ro.product.manufacturer", &host->sysVendor); + if(host->sysVendor.length && !ffStrbufStartsWithIgnCase(&host->productName, &host->sysVendor)) + { + ffStrbufPrependS(&host->productName, " "); + ffStrbufPrepend(&host->productName, &host->sysVendor); + } + return NULL; } diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index d87cad305..fa8e66234 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -272,6 +272,13 @@ static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* _ ffStrbufAppendNS(strbuf, value->length, value->chars); } +static inline void ffStrbufPrepend(FFstrbuf* strbuf, FFstrbuf* value) +{ + if(value == NULL) + return; + ffStrbufPrependNS(strbuf, value->length, value->chars); +} + static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) { if(value == NULL) From a2b00cbf9e9c63c865c711b6c873c63b9a4e89a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 22:50:19 +0800 Subject: [PATCH 380/493] Bios (Android): add support --- CMakeLists.txt | 2 +- src/detection/bios/bios_android.c | 13 +++++++++++++ src/detection/bios/bios_nosupport.c | 6 ------ 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 src/detection/bios/bios_android.c delete mode 100644 src/detection/bios/bios_nosupport.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f54c012bc..4335df20a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -394,7 +394,7 @@ elseif(ANDROID) src/common/networking_linux.c src/common/processing_linux.c src/detection/battery/battery_android.c - src/detection/bios/bios_nosupport.c + src/detection/bios/bios_android.c src/detection/bluetooth/bluetooth_nosupport.c src/detection/board/board_android.c src/detection/brightness/brightness_nosupport.c diff --git a/src/detection/bios/bios_android.c b/src/detection/bios/bios_android.c new file mode 100644 index 000000000..737df08de --- /dev/null +++ b/src/detection/bios/bios_android.c @@ -0,0 +1,13 @@ +#include "bios.h" +#include "common/settings.h" + +const char* ffDetectBios(FFBiosResult* bios) +{ + if (!ffSettingsGetAndroidProperty("ro.bootloader", &bios->version)) + ffSettingsGetAndroidProperty("ro.boot.bootloader", &bios->version); + + if (ffStrbufIgnCaseEqualS(&bios->version, "unknown")) + ffStrbufClear(&bios->version); + + return NULL; +} diff --git a/src/detection/bios/bios_nosupport.c b/src/detection/bios/bios_nosupport.c deleted file mode 100644 index ac544fd3e..000000000 --- a/src/detection/bios/bios_nosupport.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "bios.h" - -const char* ffDetectBios(FF_MAYBE_UNUSED FFBiosResult* bios) -{ - return "Not supported on this platform"; -} From 340f2b23748a997faa7ab4ee39fe63e054f84d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Jul 2023 23:09:10 +0800 Subject: [PATCH 381/493] Doc: update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 707a35f87..6c68debfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ Features: * Add option `--title-color-user`, `--title-color-at` and `--title-color-host` (Title) * Add Exherbo logo and package manager count (Packages, Linux, #503) * Add module `Terminal Size` which prints the number of terminal width and height in charactors and pixels +* Add new option `--temperature-unit` +* Better CPU and Host detection for Android (Android) Bugfixes: * Fix possible hanging (TerminalFont, #493) From 124a49098e6154f6c3cc7f3f48a3b8542e81365e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 28 Jul 2023 14:12:48 +0800 Subject: [PATCH 382/493] Logo: add Windows 95; refactor code From https://github.com/dylanaraps/neofetch/pull/2346/files --- CHANGELOG.md | 1 + CMakeLists.txt | 31 ++++++++++++++++--- README.md | 2 +- src/fastfetch.c | 1 + src/fastfetch_config.h.in | 11 ++----- src/fastfetch_datatext.h.in | 15 ++++++++++ src/logo/ascii/Windows95.txt | 18 +++++++++++ src/logo/builtin.c | 58 ++++++++++++++++++++++++------------ src/logo/builtin.h.in | 8 +++++ 9 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 src/fastfetch_datatext.h.in create mode 100644 src/logo/ascii/Windows95.txt create mode 100644 src/logo/builtin.h.in diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c68debfe..e8d0f4905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: 1. Although konsole was said to support `kitty` image protocol, it doesn't support `kitty-direct` 2. wezterm support more image formats other than `.png` (tested with `.jpg` and `.webp`) +* Add `Windows 95` # 1.12.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4335df20a..9906c36b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,11 +233,34 @@ fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR) fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT) fastfetch_load_text(src/data/help_config.txt DATATEXT_HELP_CONFIG) -###################### -# Configure config.h # -###################### +configure_file(src/fastfetch_config.h.in fastfetch_config.h @ONLY) +configure_file(src/fastfetch_datatext.h.in fastfetch_datatext.h @ONLY) -configure_file(src/fastfetch_config.h.in fastfetch_config.h) +#################### +# Ascii image data # +#################### + +function(fastfetch_load_raw_text FILENAME OUTVAR) + file(READ "${FILENAME}" TEMP) + string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline + string(JSON TEMP SET "{}" "${TEMP}" "0") # Encode raw strings using JSON_SET + string(REGEX REPLACE "^\\{[ \t\r\n]*" "" TEMP "${TEMP}") # Remove JSON braces + string(REGEX REPLACE "[ \t\r\n]*:[ \t\r\n]*0[ \t\r\n]*\\}$" "" TEMP "${TEMP}") # Remove trailing ` : 0 }` + if(NOT "${TEMP}" MATCHES "^\"[^\n]*\"") + message(FATAL_ERROR "Internal error: unexpected output: '${TEMP}'") + endif() + set(${OUTVAR} "${TEMP}" PARENT_SCOPE) +endfunction(fastfetch_load_raw_text) + +file(GLOB LOGO_FILES "src/logo/ascii/*.txt") +foreach(file ${LOGO_FILES}) + fastfetch_load_raw_text("${file}" content) + get_filename_component(file "${file}" NAME_WLE) + string(TOUPPER "${file}" file) + string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" DATATEXT_LOGO_${file} "${content}") +endforeach() + +configure_file(src/logo/builtin.h.in src_logo_builtin.h @ONLY) ####################### # libfastfetch target # diff --git a/README.md b/README.md index 4cd69b8ca..ff1e4b8d3 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Zorin +AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/fastfetch.c b/src/fastfetch.c index 50ad5c3d8..f7fa7f3d4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -6,6 +6,7 @@ #include "common/jsonconfig.h" #include "util/stringUtils.h" #include "logo/logo.h" +#include "fastfetch_datatext.h" #include #include diff --git a/src/fastfetch_config.h.in b/src/fastfetch_config.h.in index 0fcf3f2d1..f91397389 100644 --- a/src/fastfetch_config.h.in +++ b/src/fastfetch_config.h.in @@ -1,3 +1,5 @@ +#pragma once + #ifndef FASTFETCH_INDLUDED_fastfetch_config_h_in #define FASTFETCH_INDLUDED_fastfetch_config_h_in @@ -19,13 +21,4 @@ #define FASTFETCH_TARGET_DIR_INSTALL_SYSCONF "@CMAKE_INSTALL_SYSCONFDIR@" -#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@" -#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" -#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set -#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@" -#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@" -#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@" -#define FASTFETCH_DATATEXT_HELP_FORMAT "@DATATEXT_HELP_FORMAT@" -#define FASTFETCH_DATATEXT_HELP_CONFIG "@DATATEXT_HELP_CONFIG@" - #endif // FASTFETCH_INDLUDED_fastfetch_config_h_in diff --git a/src/fastfetch_datatext.h.in b/src/fastfetch_datatext.h.in new file mode 100644 index 000000000..dd5418f3a --- /dev/null +++ b/src/fastfetch_datatext.h.in @@ -0,0 +1,15 @@ +#pragma once + +#ifndef FASTFETCH_INDLUDED_fastfetch_datatext_h_in +#define FASTFETCH_INDLUDED_fastfetch_datatext_h_in + +#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@" +#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" +#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set +#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@" +#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@" +#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@" +#define FASTFETCH_DATATEXT_HELP_FORMAT "@DATATEXT_HELP_FORMAT@" +#define FASTFETCH_DATATEXT_HELP_CONFIG "@DATATEXT_HELP_CONFIG@" + +#endif diff --git a/src/logo/ascii/Windows95.txt b/src/logo/ascii/Windows95.txt new file mode 100644 index 000000000..77d20ea01 --- /dev/null +++ b/src/logo/ascii/Windows95.txt @@ -0,0 +1,18 @@ +${c6} ___ + .--=+++++=-:. +. _ *%@@@@@@@@@@@@@@* + *:+:.__ :+* @@@ @"${c5}_*&%${c6}@@${c4}%&&&*${c6}"@@@ + "+.-#+ +%* " _ ${c5}++&&&%${c6}@@${c4}%&&&&&#${c6}@@ +${c5}" , ${c6}%@@ ${c5}&&&&&%${c6}@@${c4}%&&&&&#${c6}@@ +${c5} * oo *# ${c6}" _ ${c5}&&&&&%${c6}@@${c4}%&&&&&#${c6}@@ +${c5}" , ${c6}%@@ ${c5}&&&&"${c6}@@@@#*${c4}"&&&${c6}@@ +.${c5} * oo *# ${c6}" _ %@@@@@@@@@@@@@@@@ + *:+:.__ :=* %@@ @"${c1}**&%${c6}@@${c3}%&&&*${c6}"@@@ + "+.-#+ +%* " _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ +${c1}" , ${c6}%@@ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ +${c1} * oo *# ${c6}" _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ +${c1}" , ${c6}%@@ ${c1}&&*"${c6}%@@@@@@${c3}"*%&${c6}@@ +.${c1} * oo *# ${c6}" _ @@@@@@@@@@@@@@@@@ + *:+:.__ :+# @@@ @%#=+""""""+==%#@ + "+.-#+ +%* %+" " ":@ + " " diff --git a/src/logo/builtin.c b/src/logo/builtin.c index fcd755e63..a12e1acba 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1,4 +1,5 @@ #include "logo.h" +#include "src_logo_builtin.h" // Generated with `src/logo/builtin.h` #define FF_LOGO_INIT static FFlogo logo; static bool init = false; if(init) return &logo; init = true; // The names of small logo must end with `_small` or `-small` @@ -335,25 +336,25 @@ static const FFlogo* getLogoBSD(void) FF_LOGO_INIT FF_LOGO_NAMES("bsd") FF_LOGO_LINES( -"$1 , ,\n" -" /( )`\n" -" \\ \\___ / |\n" -" /- _ `-/ '\n" -" ($2/\\/ \\ $1\\ /\\\n" -" $2/ / | ` $1\\\n" -" $3O O $2) $1/ |\n" -" $2`-^--'$1`< '\n" -" (_.) _ ) /\n" -" `.___/` /\n" -" `-----' /\n" -"$4<----. __ / __ \\\n" -"$4<----|====$1O)))$4==$1) \\) /$4====|\n" -"<----' $1`--' `.__,' \\\n" -" | |\n" -" \\ / /\\\n" -" $5______$1( (_ / \\______/\n" -" $5,' ,-----' |\n" -" `--{__________)\n" + "$1 , ,\n" + " /( )`\n" + " \\ \\___ / |\n" + " /- _ `-/ '\n" + " ($2/\\/ \\ $1\\ /\\\n" + " $2/ / | ` $1\\\n" + " $3O O $2) $1/ |\n" + " $2`-^--'$1`< '\n" + " (_.) _ ) /\n" + " `.___/` /\n" + " `-----' /\n" + "$4<----. __ / __ \\\n" + "$4<----|====$1O)))$4==$1) \\) /$4====|\n" + "<----' $1`--' `.__,' \\\n" + " | |\n" + " \\ / /\\\n" + " $5______$1( (_ / \\______/\n" + " $5,' ,-----' |\n" + " `--{__________)\n" ) FF_LOGO_COLORS( "31", @@ -1724,6 +1725,24 @@ static const FFlogo* getLogoWindows(void) FF_LOGO_RETURN } +static const FFlogo* getLogoWindows95(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Windows 9x", "Windows 95") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS95) + FF_LOGO_COLORS( + "36", //cyan + "34", //blue + "33", //yellow + "32", //green + "31", + "30" + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("34"); //blue + FF_LOGO_RETURN +} + static const FFlogo* getLogoNixOS(void) { FF_LOGO_INIT @@ -2759,6 +2778,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoWindows11Small, getLogoWindows8, getLogoWindows, + getLogoWindows95, getLogoNixOS, getLogoNixOsOld, getLogoNixOsSmall, diff --git a/src/logo/builtin.h.in b/src/logo/builtin.h.in new file mode 100644 index 000000000..4695313c0 --- /dev/null +++ b/src/logo/builtin.h.in @@ -0,0 +1,8 @@ +#pragma once + +#ifndef FASTFETCH_INDLUDED_logo_builtin_h_in +#define FASTFETCH_INDLUDED_logo_builtin_h_in + +#define FASTFETCH_DATATEXT_LOGO_WINDOWS95 @DATATEXT_LOGO_WINDOWS95@ + +#endif From 5291d1a190cf1783995eecd4d2c3e834b0bdb874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 28 Jul 2023 16:50:15 +0800 Subject: [PATCH 383/493] Logo: add more ASCII logos --- src/logo/ascii/AIX.txt | 20 ++ src/logo/ascii/Asahi.txt | 18 ++ src/logo/ascii/GNU.txt | 18 ++ src/logo/ascii/Gnome.txt | 21 ++ src/logo/ascii/Haiku.txt | 12 + src/logo/ascii/Haiku_Small.txt | 8 + src/logo/ascii/LMDE.txt | 17 ++ src/logo/ascii/Mandriva.txt | 15 + src/logo/ascii/Minix.txt | 17 ++ src/logo/ascii/NetBSD.txt | 17 ++ src/logo/ascii/NomadBSD.txt | 13 + src/logo/ascii/OpenBSD.txt | 23 ++ src/logo/ascii/OpenBSD_Small.txt | 7 + src/logo/ascii/OpenKylin.txt | 18 ++ src/logo/ascii/OpenWrt.txt | 9 + src/logo/ascii/OpensuseTumbleweed2.txt | 13 + src/logo/ascii/Oracle.txt | 11 + src/logo/ascii/Solaris.txt | 8 + src/logo/ascii/Solaris_Small.txt | 5 + src/logo/ascii/UOS.txt | 20 ++ src/logo/ascii/Ubuntu2_Small.txt | 11 + src/logo/ascii/UbuntuKylin.txt | 20 ++ src/logo/ascii/UbuntuMate.txt | 20 ++ src/logo/builtin.c | 395 +++++++++++++++++++++++-- src/logo/builtin.h.in | 23 ++ 25 files changed, 730 insertions(+), 29 deletions(-) create mode 100644 src/logo/ascii/AIX.txt create mode 100644 src/logo/ascii/Asahi.txt create mode 100644 src/logo/ascii/GNU.txt create mode 100644 src/logo/ascii/Gnome.txt create mode 100644 src/logo/ascii/Haiku.txt create mode 100644 src/logo/ascii/Haiku_Small.txt create mode 100644 src/logo/ascii/LMDE.txt create mode 100644 src/logo/ascii/Mandriva.txt create mode 100644 src/logo/ascii/Minix.txt create mode 100644 src/logo/ascii/NetBSD.txt create mode 100644 src/logo/ascii/NomadBSD.txt create mode 100644 src/logo/ascii/OpenBSD.txt create mode 100644 src/logo/ascii/OpenBSD_Small.txt create mode 100644 src/logo/ascii/OpenKylin.txt create mode 100644 src/logo/ascii/OpenWrt.txt create mode 100644 src/logo/ascii/OpensuseTumbleweed2.txt create mode 100644 src/logo/ascii/Oracle.txt create mode 100644 src/logo/ascii/Solaris.txt create mode 100644 src/logo/ascii/Solaris_Small.txt create mode 100644 src/logo/ascii/UOS.txt create mode 100644 src/logo/ascii/Ubuntu2_Small.txt create mode 100644 src/logo/ascii/UbuntuKylin.txt create mode 100644 src/logo/ascii/UbuntuMate.txt diff --git a/src/logo/ascii/AIX.txt b/src/logo/ascii/AIX.txt new file mode 100644 index 000000000..2f2483701 --- /dev/null +++ b/src/logo/ascii/AIX.txt @@ -0,0 +1,20 @@ + `:+ssssossossss+-` + .oys///oyhddddhyo///sy+. + /yo:+hNNNNNNNNNNNNNNNNh+:oy/ + :h/:yNNNNNNNNNNNNNNNNNNNNNNy-+h: + `ys.yNNNNNNNNNNNNNNNNNNNNNNNNNNy.ys + `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oh + h+-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.oy +/d`mNNNNNNN/::mNNNd::m+:/dNNNo::dNNNd`m: +h//NNNNNNN: . .NNNh mNo od. -dNNNNN:+y +N.sNNNNNN+ -N/ -NNh mNNd. sNNNNNNNo-m +N.sNNNNNs +oo /Nh mNNs` ` /mNNNNNNo-m +h//NNNNh ossss` +h md- .hm/ `sNNNNN:+y +:d`mNNN+/yNNNNNd//y//h//oNNNNy//sNNNd`m- + yo-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNm.ss + `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oy + sy.yNNNNNNNNNNNNNNNNNNNNNNNNNNs.yo + :h+-yNNNNNNNNNNNNNNNNNNNNNNs-oh- + :ys:/yNNNNNNNNNNNNNNNmy/:sy: + .+ys///osyhhhhys+///sy+. + -/osssossossso/- diff --git a/src/logo/ascii/Asahi.txt b/src/logo/ascii/Asahi.txt new file mode 100644 index 000000000..fef162fd0 --- /dev/null +++ b/src/logo/ascii/Asahi.txt @@ -0,0 +1,18 @@ +${c1} ## ${c2}** + ${c1}*####${c2}****. + ${c1}###${c2}, + ${c3}...,${c1}/#${c3},,,.. + ${c3}/*,,,,,,,,${c1}*${c3},........${c4},, + ${c3},((((((//*,,,,,,,,${c4},...... + ${c3}((((((((((((((${c5}%..${c4}.......... + ${c3},(((((((((((((((${c5}@@(${c4}............ + ${c3}(((((((((((((((((${c5}@@@@/${c4}............ + ${c3},((((((((((((((((((${c5}@@@@@&*${c4}........... + ${c3}((((((((((((((((((((${c5}@@@@@@@&${c4},........... +${c3}(((((((((((((((((((((${c5}@@@${c6}&%&${c5}@@@%${c4},.......... + ${c3}/(((((((((((((((((((${c5}@@@${c6}&%%&${c5}@@@@(${c4}........ + ${c3},((((((((((((((((${c5}@@@${c6}&&${c5}@@&/&@@@/${c4}.. + ${c3}/((((((((((((${c5}@@@@@@/${c4}.../&& + ${c3}.(((((((((${c5}@@@@(${c4}.... + ${c3}/(((((${c5}@@#${c4}... + ${c3}.((${c4}&, diff --git a/src/logo/ascii/GNU.txt b/src/logo/ascii/GNU.txt new file mode 100644 index 000000000..4d1af8d58 --- /dev/null +++ b/src/logo/ascii/GNU.txt @@ -0,0 +1,18 @@ + _-`````-, ,- '- . + .' .- - | | - -. `. + /.' / `. \ +:/ : _... ..._ `` : +:: : /._ .`:'_.._\. || : +:: `._ ./ ,` : \ . _.'' . +`:. / | -. \-. \\_ / + \:._ _/ .' .@) \@) ` `\ ,.' + _/,--' .- .\,-.`--`. + ,'/'' (( \ ` ) + /'/' \ `-' ( + '/'' `._,-----' + ''/' .,---' + ''/' ;: + ''/'' ''/ + ''/''/'' + '/'/' + `; diff --git a/src/logo/ascii/Gnome.txt b/src/logo/ascii/Gnome.txt new file mode 100644 index 000000000..822cf2aec --- /dev/null +++ b/src/logo/ascii/Gnome.txt @@ -0,0 +1,21 @@ + ,@@@@@@@@, + @@@@@@ @@@@@@@@@@@@ + ,@@. @@@@@@@ *@@@@@@@@@@@@ + @@@@@% @@@@@@( @@@@@@@@@@@& + @@@@@@ @@@@* @@@@@@@@@# +@@@@* @@@@, *@@@@@% +@@@@@. + @@@@# @@@@@@@@@@@@@@@@ + ,@@@@@@@@@@@@@@@@@@@@@@@, + ,@@@@@@@@@@@@@@@@@@@@@@@@@@& + .@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@( + @@@@@@@@@@@@@@@@@@@@% + @@@@@@@@@@@@@@@@ + @@@@@@@@@@@@* @@@@@@@@/ + &@@@@@@@@@@ @@@@@@@@@* + @@@@@@@@@@@, @@@@@@@@@* + ,@@@@@@@@@@@@@@@@@@@@& + &@@@@@@@@@@@@@@ + ... diff --git a/src/logo/ascii/Haiku.txt b/src/logo/ascii/Haiku.txt new file mode 100644 index 000000000..ce164058f --- /dev/null +++ b/src/logo/ascii/Haiku.txt @@ -0,0 +1,12 @@ +${c3} MMMM MMMM + MMMM MMMM + MMMM MMMM + MMMM MMMM + MMMM${c4} .ciO| /YMMMMM*" +${c3} MMMM${c4} .cOMMMMM|/MMMMM/` + , ,iMM|/MMMMMMMMMMMMMMM* + `*.__,-cMMMMMMMMMMMMMMMMM/`${c3}.MMM + MM${c4}MMMMMMM/`:MMM/ ${c3}MMMM + MMMM MMMM + MMMM MMMM + """" """" diff --git a/src/logo/ascii/Haiku_Small.txt b/src/logo/ascii/Haiku_Small.txt new file mode 100644 index 000000000..5c6b30a41 --- /dev/null +++ b/src/logo/ascii/Haiku_Small.txt @@ -0,0 +1,8 @@ + ,^, + / \\ +*--_ ; ; _--* +\\ '" "' / + '. .' +.-'" "'-. + '-.__. .__.-' + |_| diff --git a/src/logo/ascii/LMDE.txt b/src/logo/ascii/LMDE.txt new file mode 100644 index 000000000..4fcad0636 --- /dev/null +++ b/src/logo/ascii/LMDE.txt @@ -0,0 +1,17 @@ +${c2} `.-::---.. +${c1} .:++++ooooosssoo:. + .+o++::. `.:oos+. +${c1} :oo:.` -+oo${c2}: +${c1} ${c2}`${c1}+o/` .${c2}::::::${c1}-. .++-${c2}` +${c1}${c2}`${c1}/s/ .yyyyyyyyyyo: +o-${c2}` +${c1}${c2}`${c1}so .ss ohyo` :s-${c2}: +${c1}${c2}`${c1}s/ .ss h m myy/ /s`${c2}` +${c1}`s: `oo s m Myy+-o:` +`oo :+sdoohyoydyso/. + :o. .:////////++: +${c1} `/++ ${c2}-:::::- +${c1} ${c2}`${c1}++- +${c1} ${c2}`${c1}/+- +${c1} ${c2}.${c1}+/. +${c1} ${c2}.${c1}:+-. + `--.`` diff --git a/src/logo/ascii/Mandriva.txt b/src/logo/ascii/Mandriva.txt new file mode 100644 index 000000000..ef3e84390 --- /dev/null +++ b/src/logo/ascii/Mandriva.txt @@ -0,0 +1,15 @@ +${c2} `` + `-. +${c1} ` ${c2}.--- +${c1} -/ ${c2}-::--` +${c1} `++ ${c2}`----...```-:::::. +${c1} `os. ${c2}.::::::::::::::-``` ` ` +${c1} +s+ ${c2}.::::::::::::::::---...--` +${c1}-ss: ${c2}`-::::::::::::::::-.``.`` +${c1}/ss- ${c2}.::::::::::::-.`` ` +${c1}+ss: ${c2}.::::::::::::- +${c1}/sso ${c2}.::::::-::::::- +${c1}.sss/ ${c2}-:::-.` .::::: +${c1} /sss+. ${c2}..`${c1} `--` ${c2}.::: +${c1} -ossso+/:://+/-` ${c2}.:` +${c1} -/+ooo+/-. ${c2}` diff --git a/src/logo/ascii/Minix.txt b/src/logo/ascii/Minix.txt new file mode 100644 index 000000000..a0ff143ca --- /dev/null +++ b/src/logo/ascii/Minix.txt @@ -0,0 +1,17 @@ +${c2} -sdhyo+:-` -/syymm: + sdyooymmNNy. `` .smNmmdysNd + odyoso+syNNmysoyhhdhsoomNmm+/osdm/ + :hhy+-/syNNmddhddddddmNMNo:sdNd: + `smNNdNmmNmddddddddddmmmmmmmy` + `ohhhhdddddmmNNdmddNmNNmdddddmdh- + odNNNmdyo/:/-/hNddNy-`..-+ydNNNmd: + `+mNho:` smmd/ sNNh :dmms` -+ymmo. +-od/ -m${c1}mm${c2}mo -NN+ +m${c1}mm${c2}m- yms: ++sms -.` :so: .NN+ :os/ .-`mNh: +.-hyh+:////- -sNNd:` .--://ohNs- + `:hNNNNNNNMMd/sNMmhsdMMh/ymmNNNmmNNy/ + -+sNNNNMMNNNsmNMo: :NNmymNNNNMMMms: + //oydNMMMMydMMNysNMMmsMMMMMNyo/` + ../-yNMMy--/::/-.sMMmos+.` + -+oyhNsooo+omy/``` + `::ohdmds-` diff --git a/src/logo/ascii/NetBSD.txt b/src/logo/ascii/NetBSD.txt new file mode 100644 index 000000000..6048ee3a3 --- /dev/null +++ b/src/logo/ascii/NetBSD.txt @@ -0,0 +1,17 @@ +${c1} `-/oshdmNMNdhyo+:-` +${c2}y${c1}/s+:-`` `.-:+oydNMMMMNhs/-`` +${c2}-m+${c1}NMMMMMMMMMMMMMMMMMMMNdhmNMMMmdhs+/-` + ${c2}-m+${c1}NMMMMMMMMMMMMMMMMMMMMmy+:` + ${c2}-N/${c1}dMMMMMMMMMMMMMMMds:` + ${c2}-N/${c1}hMMMMMMMMMmho:` + ${c2}-N/${c1}-:/++/:.` +${c2} :M+ + :Mo + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms diff --git a/src/logo/ascii/NomadBSD.txt b/src/logo/ascii/NomadBSD.txt new file mode 100644 index 000000000..867666efa --- /dev/null +++ b/src/logo/ascii/NomadBSD.txt @@ -0,0 +1,13 @@ + _======__ + (===============\\ + (===================\\ + _ _---__ + (= ====- + (= ====== + (== ====== + (== ====== + (==\\ \\=-_ _=/ /====/ + (==\\ \\========/ /====/ /====-_ + (==\\ \\=====/ /==/ /===-- +/================/ /===- +\\===========/ diff --git a/src/logo/ascii/OpenBSD.txt b/src/logo/ascii/OpenBSD.txt new file mode 100644 index 000000000..f758fbd82 --- /dev/null +++ b/src/logo/ascii/OpenBSD.txt @@ -0,0 +1,23 @@ +${c3} _ + (_) +${c1} | . +${c1} . |L /| . ${c3} _ +${c1} _ . |\ _| \--+._/| . ${c3}(_) +${c1} / ||\| Y J ) / |/| ./ + J |)'( | ` F`.'/ ${c3} _ +${c1} -<| F __ .-< ${c3}(_) +${c1} | / .-'${c3}. ${c1}`. /${c3}-. ${c1}L___ + J \\ < ${c3}\ ${c1} | | ${c5}O${c3}\\${c1}|.-' ${c3} _ +${c1} _J \\ .- \\${c3}/ ${c5}O ${c3}| ${c1}| \\ |${c1}F ${c3}(_) +${c1} '-F -<_. \\ .-' `-' L__ +__J _ _. >-' ${c1})${c4}._. ${c1}|-' +${c1} `-|.' /_. ${c4}\_| ${c1} F + /.- . _.< + /' /.' .' `\\ + /L /' |/ _.-'-\\ + /'J ___.---'\| + |\ .--' V | `. ` + |/`. `-. `._) + / .-.\\ + \\ ( `\\ + `.\\ diff --git a/src/logo/ascii/OpenBSD_Small.txt b/src/logo/ascii/OpenBSD_Small.txt new file mode 100644 index 000000000..bb6e646ac --- /dev/null +++ b/src/logo/ascii/OpenBSD_Small.txt @@ -0,0 +1,7 @@ +${c1} _____ + \\- -/ + \\_/ \\ + | ${c2}O O${c1} | + |_ < ) 3 ) + / \\ / + /-_____-\\ diff --git a/src/logo/ascii/OpenKylin.txt b/src/logo/ascii/OpenKylin.txt new file mode 100644 index 000000000..f1af1f1c3 --- /dev/null +++ b/src/logo/ascii/OpenKylin.txt @@ -0,0 +1,18 @@ + + /KKK] + KKKKKKK` ]KKKK\ + KKKKK/ /KKKKKKKKK\ + KKKK/ ,KKKKKKKKKKKK^ + ,]KKK =KKK` /KKKKKKOOOOOO` +,KKKKKK =KK /` [\OOOOOOO\ + \KKKKK =K ,OOOOOOO` + ,KKKKK =^ \OOOOOO + ,KKKK ^ OOOOOO^ + *KKK^ =OOOOO^ + OOKK^ OOOOOO^ + \OOOK\ /OOOOOO` + OOOOOO] ,OOOOOOO^ + ,OOOOOOOO\] ,[OOOOOOOOO/ + \OOOOOOOOOOOOOOOOOOOOO` + [OOOOOOOOOOOOOOOO/` + ,[OOOOOOOOO] diff --git a/src/logo/ascii/OpenWrt.txt b/src/logo/ascii/OpenWrt.txt new file mode 100644 index 000000000..0ba1d9a12 --- /dev/null +++ b/src/logo/ascii/OpenWrt.txt @@ -0,0 +1,9 @@ + _______ +| |.-----.-----.-----. +| - || _ | -__| | +|_______|| __|_____|__|__| + |__| + ________ __ +| | | |.----.| |_ +| | | || _|| _| +|________||__| |____| diff --git a/src/logo/ascii/OpensuseTumbleweed2.txt b/src/logo/ascii/OpensuseTumbleweed2.txt new file mode 100644 index 000000000..fbdcb2bcf --- /dev/null +++ b/src/logo/ascii/OpensuseTumbleweed2.txt @@ -0,0 +1,13 @@ + ...... + .,cdxxxoc,. .:kKMMMNWMMMNk:. + cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. + ;WMK;' 'lKMMNM, :NMK' 'OMW; + cMW; WMMMN ,XMK' oMM. +.MMc ''^*~l. xMN: KM0 +'MM. .NMO oMM +.MM, .kMMl xMN + KM0 .kMM0' .dl>~,. .WMd + 'XM0. ,OMMK' OMMM7' .XMK + *WMO:. .;xNMMk' NNNMKl. .xWMx + ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' + ''''' ':dOOXXKOxl' diff --git a/src/logo/ascii/Oracle.txt b/src/logo/ascii/Oracle.txt new file mode 100644 index 000000000..076847ec8 --- /dev/null +++ b/src/logo/ascii/Oracle.txt @@ -0,0 +1,11 @@ + `-/+++++++++++++++++/-.` + `/syyyyyyyyyyyyyyyyyyyyyyys/. + :yyyyo/-...............-/oyyyy/ + /yyys- .oyyy+ +.yyyy` `syyy- +:yyyo /yyy/ +.yyyy` `syyy- + /yyys. .oyyyo + /yyyyo:-...............-:oyyyy/` + `/syyyyyyyyyyyyyyyyyyyyyyys+. + `.:/+ooooooooooooooo+/:.` diff --git a/src/logo/ascii/Solaris.txt b/src/logo/ascii/Solaris.txt new file mode 100644 index 000000000..cd78b5d13 --- /dev/null +++ b/src/logo/ascii/Solaris.txt @@ -0,0 +1,8 @@ + `- ` + `-- `+- .: + .+: `++: -/+- . + `.::` -++/``:::`./+/ `.-/. + `++/-`.` ` /++:` + `` ./:` .: `..`.- +``./+/:- -+++:- + -/+` :. diff --git a/src/logo/ascii/Solaris_Small.txt b/src/logo/ascii/Solaris_Small.txt new file mode 100644 index 000000000..148d7537a --- /dev/null +++ b/src/logo/ascii/Solaris_Small.txt @@ -0,0 +1,5 @@ + . .; . + . :; :: ;: . + .;. .. .. .;. +.. .. .. .. + .;, ,;. diff --git a/src/logo/ascii/UOS.txt b/src/logo/ascii/UOS.txt new file mode 100644 index 000000000..e5d229db1 --- /dev/null +++ b/src/logo/ascii/UOS.txt @@ -0,0 +1,20 @@ + ....... + .............. + ...................... + ............................. +uuuuuu uuuuuu ooooooooooo ssssssssss +u::::u u::::u oo:::::::::::oo ss::::::::::s +u::::u u::::u o:::::::::::::::oss:::::::::::::s +u::::u u::::u o:::::ooooo:::::os::::::ssss:::::s +u::::u u::::u o::::o o::::o s:::::s ssssss +u::::u u::::u o::::o o::::o s::::::s +u::::u u::::u o::::o o::::o s::::::s +u:::::uuuu:::::u o::::o o::::ossssss s:::::s +u:::::::::::::::uuo:::::ooooo:::::os:::::ssss::::::s +u:::::::::::::::uo:::::::::::::::os::::::::::::::s +uu::::::::uu:::u oo:::::::::::oo s:::::::::::ss + uuuuuuuu uuuu ooooooooooo sssssssssss + ............................. + ..................... + ............. + ...... diff --git a/src/logo/ascii/Ubuntu2_Small.txt b/src/logo/ascii/Ubuntu2_Small.txt new file mode 100644 index 000000000..0a3146659 --- /dev/null +++ b/src/logo/ascii/Ubuntu2_Small.txt @@ -0,0 +1,11 @@ + ..;,; .,;,. + .,lool: .ooooo, + ;oo;: .coool. + .... ''' ,l; +:oooo, 'oo. +looooc :oo' + '::' ,oo: + ,., .... co, + lo:;. :oooo; . + ':ooo; cooooc + ''' '''' diff --git a/src/logo/ascii/UbuntuKylin.txt b/src/logo/ascii/UbuntuKylin.txt new file mode 100644 index 000000000..c1ace067d --- /dev/null +++ b/src/logo/ascii/UbuntuKylin.txt @@ -0,0 +1,20 @@ +${c1} .__=liiiiiii=__, + ._=liiliii|i|i|iiilii=_. + _=iiiii|ii|i|ii|i|inwwwzii=, + .=liiii|ii|ii|wwww|i${c2}3QWWWW${c1}ziii=, + =lii|i|ii|i|${c2}QQQWWWWWm]QWWQD${c1}||iiii= + =lii|iiivw${c2}Qm${c1}>3${c2}WWWWWQWQQwwQw${c1}cii|i|ii= + =lii|ii|n${c2}QWWWQ${c1}|)i${c2}|i${c1}%i|]${c2}TQWWWWm${c1}|ii|i|i= +.li|i|i|m${c2}WWWQV${c1}|ii${c2}wmD${c1}|iiii|${c2}TWWWWm${c1}|i|iiii, +=iii${c2}www|$WQWk${c1}|i${c2}aWWWD${c1}|i|i|ii]${c2}QQWQk${c1}|ii|i|= +iii${c2}QWWWQz$WW${c1}|i${c2}jQQWQm${c1}w|ii${c2}wW${c1}k|${c2}TTTTY${c1}i|i|iii +iiI${c2}QWQWWtyQQ${c1}|i|${c2}$WWWWWQWk${c1}||i|i|ii||i|ii|i +<|i|${c2}TTT|mQQWz${c1}|i${c2}3D${c1}]C|${c2}nD$W${c1}|ii${c2}vWWWWk${c1}||ii|i> +-|ii|i|i${c2}WWWQw${c1}|${c2}Tt${c1}|i3${c2}T${c1}|${c2}T${c1}|i|${c2}nQWQWDk${c1}|ii|ii` + <|i|iii|${c2}VWQWWQ${c1}|i|i|||ii${c2}wmWWQWD${c1}||ii|ii+ + <|ii|i|i]${c2}$W@${c1}tv${c2}QQQWQQQWWTTHT${c1}1|iii|i|> + <|i|ii|ii||v${c2}QWWWQWWW@vmWWWm${c1}|i|i|i> + -<|i|ii|ii|i|${c2}TTTTTT${c1}|]${c2}QQWWWC${c1}|ii>` + -<|i|ii|i|ii|i|i|ii3${c2}TTT${c1}t|i>` + ~<|ii|ii|iiiii|i|||i>~ + -~~<|ii|i||i>~~` diff --git a/src/logo/ascii/UbuntuMate.txt b/src/logo/ascii/UbuntuMate.txt new file mode 100644 index 000000000..5711b8439 --- /dev/null +++ b/src/logo/ascii/UbuntuMate.txt @@ -0,0 +1,20 @@ +${c1} .:/+oossssoo+/:.` + `:+ssssssssssssssssss+:` + -+sssssssssssssss${c2}y${c1}ssssssss+- + .osssssssssssss${c2}yy${c1}ss${c2}mMmh${c1}ssssssso. + /sssssssss${c2}ydmNNNmmd${c1}s${c2}mMMMMNdy${c1}sssss/ + `+ssssssss${c2}hNNdy${c1}sssssss${c2}mMMMMNdy${c1}ssssss+` + +sssssss${c2}yNNh${c1}ss${c2}hmNNNNm${c1}s${c2}mMmh${c1}s${c2}ydy${c1}sssssss+ +-sssss${c2}y${c1}ss${c2}Nm${c1}ss${c2}hNNh${c1}ssssss${c2}y${c1}s${c2}hh${c1}ss${c2}mMy${c1}sssssss- ++ssss${c2}yMNdy${c1}ss${c2}hMd${c1}ssssssssss${c2}hMd${c1}ss${c2}NN${c1}sssssss+ +sssss${c2}yMMMMMmh${c1}sssssssssssss${c2}NM${c1}ss${c2}dMy${c1}sssssss +sssss${c2}yMMMMMmhy${c1}ssssssssssss${c2}NM${c1}ss${c2}dMy${c1}sssssss ++ssss${c2}yMNdy${c1}ss${c2}hMd${c1}ssssssssss${c2}hMd${c1}ss${c2}NN${c1}sssssss+ +-sssss${c2}y${c1}ss${c2}Nm${c1}ss${c2}hNNh${c1}ssssssss${c2}dh${c1}ss${c2}mMy${c1}sssssss- + +sssssss${c2}yNNh${c1}ss${c2}hmNNNNm${c1}s${c2}mNmh${c1}s${c2}ymy${c1}sssssss+ + +ssssssss${c2}hNNdy${c1}sssssss${c2}mMMMMmhy${c1}ssssss+ + /sssssssss${c2}ydmNNNNmd${c1}s${c2}mMMMMNdh${c1}sssss/ + .osssssssssssss${c2}yy${c1}ss${c2}mMmdy${c1}sssssso. + -+sssssssssssssss${c2}y${c1}ssssssss+- + `:+ssssssssssssssssss+:` + .:/+oossssoo+/:. diff --git a/src/logo/builtin.c b/src/logo/builtin.c index a12e1acba..237ee3e17 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -41,6 +41,20 @@ const FFlogo* ffLogoBuiltinGetUnknown(void) FF_LOGO_RETURN } +static const FFlogo* getLogoAIX(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("aix") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AIX) + FF_LOGO_COLORS( + "32", // green + "37" // yellow + ) + FF_LOGO_COLOR_KEYS("32"); // green + FF_LOGO_COLOR_TITLE("37"); // yellow + FF_LOGO_RETURN +} + static const FFlogo* getLogoAlmaLinux(void) { FF_LOGO_INIT @@ -331,6 +345,25 @@ static const FFlogo* getLogoArcoLinux(void) FF_LOGO_RETURN } +static const FFlogo* getLogoAsahi(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("asahi", "asahi-linux") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASAHI) + FF_LOGO_COLORS( + "33", //yellow + "32", //green + "31", //red + "38", //cyan + "37", //magenta + "36", //cyan + "34" //blue + ) + FF_LOGO_COLOR_KEYS("33"); //yellow + FF_LOGO_COLOR_TITLE("32"); //green + FF_LOGO_RETURN +} + static const FFlogo* getLogoBSD(void) { FF_LOGO_INIT @@ -1103,8 +1136,6 @@ static const FFlogo* getLogoGentooSmall(void) FF_LOGO_RETURN } -#define FF_RAW_STRING(x) #x - static const FFlogo* getLogoGhostBSD(void) { FF_LOGO_INIT @@ -1132,6 +1163,61 @@ static const FFlogo* getLogoGhostBSD(void) FF_LOGO_RETURN } +static const FFlogo* getLogoGnome(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Gnome") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GNOME) + FF_LOGO_COLORS( + "34" //blue + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + +static const FFlogo* getLogoGNU(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("GNU") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GNU) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + +static const FFlogo* getLogoHaiku(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Haiku") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_HAIKU) + FF_LOGO_COLORS( + "31", //red + "33", //yellow + "37", //white + "32" //green + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("33"); //yellow + FF_LOGO_RETURN +} + +static const FFlogo* getLogoHaikuSmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("Haiku-small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL) + FF_LOGO_COLORS( + "32" //green + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("33"); //yellow + FF_LOGO_RETURN +} + static const FFlogo* getLogoKDENeon(void) { FF_LOGO_INIT @@ -1302,6 +1388,20 @@ static const FFlogo* getLogoLinuxSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoLMDE(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("LMDE") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LMDE) + FF_LOGO_COLORS( + "32", //green + "37" //white + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoMacOS(void) { FF_LOGO_INIT @@ -1422,6 +1522,20 @@ static const FFlogo* getLogoMacOS2Small(void) FF_LOGO_RETURN } +static const FFlogo* getLogoMandriva(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("mandriva", "mandrake") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANDRIVA) + FF_LOGO_COLORS( + "34", //blue + "33" //yellow + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("33"); //yellow + FF_LOGO_RETURN +} + static const FFlogo* getLogoManjaro(void) { FF_LOGO_INIT @@ -1471,6 +1585,21 @@ static const FFlogo* getLogoManjaroSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoMinix(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("minix") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINIX) + FF_LOGO_COLORS( + "31", //red + "37", //white + "33" //yellow + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("33"); //yellow + FF_LOGO_RETURN +} + static const FFlogo* getLogoMint(void) { FF_LOGO_INIT @@ -1842,6 +1971,20 @@ static const FFlogo* getLogoNixOsSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoNetBSD(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("netbsd"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NETBSD) + FF_LOGO_COLORS( + "35", // blue + "37" // white + ) + FF_LOGO_COLOR_KEYS("35"); // blue + FF_LOGO_COLOR_TITLE("37"); // white + FF_LOGO_RETURN +} + static const FFlogo* getLogoNobara(void) { FF_LOGO_INIT @@ -1873,6 +2016,63 @@ static const FFlogo* getLogoNobara(void) FF_LOGO_RETURN } +static const FFlogo* getLogoNomadBSD(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("nomadbsd"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NOMADBSD) + FF_LOGO_COLORS( + "34" // blue + ) + FF_LOGO_COLOR_KEYS("34"); // blue + FF_LOGO_COLOR_TITLE("37"); // white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoOpenKylin(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("openkylin", "open-kylin"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENKYLIN) + FF_LOGO_COLORS( + "32", // cyan + "37" // white + ) + FF_LOGO_COLOR_KEYS("32"); // cyan + FF_LOGO_COLOR_TITLE("37"); // white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoOpenBSD(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("openbsd"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENBSD) + FF_LOGO_COLORS( + "33", // blue + "37", // white + "36", // yellow + "31" // red + ) + FF_LOGO_COLOR_KEYS("33"); // blue + FF_LOGO_COLOR_TITLE("37"); // white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoOpenBSDSmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("openbsd_small", "openbsd-small"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL) + FF_LOGO_COLORS( + "33", // blue + "37" // white + ) + FF_LOGO_COLOR_KEYS("33"); // blue + FF_LOGO_COLOR_TITLE("37"); // white + FF_LOGO_RETURN +} + static const FFlogo* getLogoOpenSuse(void) { FF_LOGO_INIT @@ -1984,6 +2184,19 @@ static const FFlogo* getLogoOpenSuseTumbleweed(void) FF_LOGO_RETURN } +static const FFlogo* getLogoOpenSuseTumbleweed2(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("opensuse_tumbleweed2") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSETUMBLEWEED2) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("32"); //green + FF_LOGO_RETURN +} + static const FFlogo* getLogoOpenMandriva(void) { FF_LOGO_INIT @@ -2011,9 +2224,6 @@ static const FFlogo* getLogoOpenMandriva(void) " `:oyhhhhhhhhhhhhhhhhhhyo:`\n" " .:+syhhhhhhhhys+:-`\n" " ``....``" - - - ) FF_LOGO_COLORS( "34" //blue @@ -2023,6 +2233,32 @@ static const FFlogo* getLogoOpenMandriva(void) FF_LOGO_RETURN } +static const FFlogo* getLogoOpenWrt(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("openwrt") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENWRT) + FF_LOGO_COLORS( + "34" //blue + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoOracle(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("oracle", "oracle linux") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORACLE) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoPop(void) { FF_LOGO_INIT @@ -2432,11 +2668,34 @@ static const FFlogo* getLogoSlackwareSmall(void) "| |________/\n" "|____________" ) + FF_LOGO_COLOR_KEYS("33"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoSolaris(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("solaris") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLARIS) FF_LOGO_COLORS( - "34" //blue + "33" //green ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue + FF_LOGO_COLOR_KEYS("33"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoSolarisSmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("solaris-small", "solaris_small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL) + FF_LOGO_COLORS( + "33" //green + ) + FF_LOGO_COLOR_KEYS("33"); //green + FF_LOGO_COLOR_TITLE("37"); //white FF_LOGO_RETURN } @@ -2513,27 +2772,27 @@ static const FFlogo* getLogoUbuntu(void) FF_LOGO_INIT FF_LOGO_NAMES("ubuntu", "ubuntu-linux") FF_LOGO_LINES( - " ....\n" - " .',:clooo: .:looooo:.\n" - " .;looooooooc .oooooooooo'\n" - " .;looooool:,''. :ooooooooooc\n" - " ;looool;. 'oooooooooo,\n" - " ;clool' .cooooooc. ,,\n" - " ... ...... .:oo,\n" - " .;clol:,. .loooo'\n" - " :ooooooooo, 'ooool\n" - "'ooooooooooo. loooo.\n" - "'ooooooooool coooo.\n" - " ,loooooooc. .loooo.\n" - " .,;;;'. ;ooooc\n" - " ... ,ooool.\n" - " .cooooc. ..',,'. .cooo.\n" - " ;ooooo:. ;oooooooc. :l.\n" - " .coooooc,.. coooooooooo.\n" - " .:ooooooolc:. .ooooooooooo'\n" - " .':loooooo; ,oooooooooc\n" - " ..';::c' .;loooo:'\n" - " ." + " ....\n" + " .',:clooo: .:looooo:.\n" + " .;looooooooc .oooooooooo'\n" + " .;looooool:,''. :ooooooooooc\n" + " ;looool;. 'oooooooooo,\n" + " ;clool' .cooooooc. ,,\n" + " ... ...... .:oo,\n" + " .;clol:,. .loooo'\n" + " :ooooooooo, 'ooool\n" + "'ooooooooooo. loooo.\n" + "'ooooooooool coooo.\n" + " ,loooooooc. .loooo.\n" + " .,;;;'. ;ooooc\n" + " ... ,ooool.\n" + " .cooooc. ..',,'. .cooo.\n" + " ;ooooo:. ;oooooooc. :l.\n" + " .coooooc,.. coooooooooo.\n" + " .:ooooooolc:. .ooooooooooo'\n" + " .':loooooo; ,oooooooooc\n" + " ..';::c' .;loooo:'\n" + " ." ) FF_LOGO_COLORS( "31", //red @@ -2544,6 +2803,35 @@ static const FFlogo* getLogoUbuntu(void) FF_LOGO_RETURN } +static const FFlogo* getLogoUbuntuKylin(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ubuntu kylin", "ubuntu-kylin") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTUKYLIN) + FF_LOGO_COLORS( + "31", //red + "37", //white + "33" //yellow + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoUbuntuMate(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ubuntu mate", "ubuntu-mate") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTUMATE) + FF_LOGO_COLORS( + "32", //green + "37" //white + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoUbuntuOld(void) { FF_LOGO_INIT @@ -2599,6 +2887,32 @@ static const FFlogo* getLogoUbuntuSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoUbuntu2Small(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("ubuntu2_small", "ubuntu2-small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + +static const FFlogo* getLogoUOS(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("UOS") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UOS) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("33"); //yellow + FF_LOGO_RETURN +} + static const FFlogo* getLogoVanilla(void) { @@ -2721,6 +3035,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) { static GetLogoMethod logoMethods[] = { ffLogoBuiltinGetUnknown, + getLogoAIX, getLogoAlmaLinux, getLogoAlpine, getLogoAlpineSmall, @@ -2731,6 +3046,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoArcoLinux, getLogoArtix, getLogoArtixSmall, + getLogoAsahi, getLogoBedrock, getLogoBSD, getLogoCachyOS, @@ -2758,18 +3074,25 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoGentoo, getLogoGentooSmall, getLogoGhostBSD, + getLogoGnome, + getLogoGNU, + getLogoHaiku, + getLogoHaikuSmall, getLogoKDENeon, getLogoKISSLinux, getLogoKubuntu, getLogoLangitKetujuh, getLogoLinux, getLogoLinuxSmall, + getLogoLMDE, getLogoMacOS, getLogoMacOSSmall, getLogoMacOS2, getLogoMacOS2Small, + getLogoMandriva, getLogoManjaro, getLogoManjaroSmall, + getLogoMinix, getLogoMint, getLogoMintSmall, getLogoMintOld, @@ -2782,12 +3105,20 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoNixOS, getLogoNixOsOld, getLogoNixOsSmall, + getLogoNomadBSD, + getLogoNetBSD, getLogoNobara, + getLogoOpenBSD, + getLogoOpenBSDSmall, + getLogoOpenKylin, getLogoOpenSuse, getLogoOpenSuseSmall, getLogoOpenSuseLeap, getLogoOpenSuseTumbleweed, + getLogoOpenSuseTumbleweed2, getLogoOpenMandriva, + getLogoOpenWrt, + getLogoOracle, getLogoPop, getLogoPopSmall, getLogoParabola, @@ -2800,13 +3131,19 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoRedstarOS, getLogoRockyLinux, getLogoRosaLinux, + getLogoSolaris, + getLogoSolarisSmall, getLogoSlackware, getLogoSlackwareSmall, getLogoSolus, getLogoSteamOS, getLogoUbuntu, + getLogoUbuntuKylin, + getLogoUbuntuMate, getLogoUbuntuOld, getLogoUbuntuSmall, + getLogoUbuntu2Small, + getLogoUOS, getLogoVanilla, getLogoVoid, getLogoVoidSmall, diff --git a/src/logo/builtin.h.in b/src/logo/builtin.h.in index 4695313c0..1e9c115d0 100644 --- a/src/logo/builtin.h.in +++ b/src/logo/builtin.h.in @@ -3,6 +3,29 @@ #ifndef FASTFETCH_INDLUDED_logo_builtin_h_in #define FASTFETCH_INDLUDED_logo_builtin_h_in +#define FASTFETCH_DATATEXT_LOGO_AIX @DATATEXT_LOGO_AIX@ +#define FASTFETCH_DATATEXT_LOGO_ASAHI @DATATEXT_LOGO_ASAHI@ +#define FASTFETCH_DATATEXT_LOGO_GNOME @DATATEXT_LOGO_GNOME@ +#define FASTFETCH_DATATEXT_LOGO_GNU @DATATEXT_LOGO_GNU@ +#define FASTFETCH_DATATEXT_LOGO_HAIKU @DATATEXT_LOGO_HAIKU@ +#define FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL @DATATEXT_LOGO_HAIKU_SMALL@ +#define FASTFETCH_DATATEXT_LOGO_LMDE @DATATEXT_LOGO_LMDE@ +#define FASTFETCH_DATATEXT_LOGO_MANDRIVA @DATATEXT_LOGO_MANDRIVA@ +#define FASTFETCH_DATATEXT_LOGO_MINIX @DATATEXT_LOGO_MINIX@ +#define FASTFETCH_DATATEXT_LOGO_NETBSD @DATATEXT_LOGO_NETBSD@ +#define FASTFETCH_DATATEXT_LOGO_NOMADBSD @DATATEXT_LOGO_NOMADBSD@ +#define FASTFETCH_DATATEXT_LOGO_OPENBSD @DATATEXT_LOGO_OPENBSD@ +#define FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL @DATATEXT_LOGO_OPENBSD_SMALL@ +#define FASTFETCH_DATATEXT_LOGO_OPENSUSETUMBLEWEED2 @DATATEXT_LOGO_OPENSUSETUMBLEWEED2@ +#define FASTFETCH_DATATEXT_LOGO_OPENWRT @DATATEXT_LOGO_OPENWRT@ +#define FASTFETCH_DATATEXT_LOGO_ORACLE @DATATEXT_LOGO_ORACLE@ +#define FASTFETCH_DATATEXT_LOGO_SOLARIS @DATATEXT_LOGO_SOLARIS@ +#define FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL @DATATEXT_LOGO_SOLARIS_SMALL@ +#define FASTFETCH_DATATEXT_LOGO_UBUNTUKYLIN @DATATEXT_LOGO_UBUNTUKYLIN@ +#define FASTFETCH_DATATEXT_LOGO_UBUNTUMATE @DATATEXT_LOGO_UBUNTUMATE@ +#define FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL @DATATEXT_LOGO_UBUNTU2_SMALL@ +#define FASTFETCH_DATATEXT_LOGO_UOS @DATATEXT_LOGO_UOS@ #define FASTFETCH_DATATEXT_LOGO_WINDOWS95 @DATATEXT_LOGO_WINDOWS95@ +#define FASTFETCH_DATATEXT_LOGO_OPENKYLIN @DATATEXT_LOGO_OPENKYLIN@ #endif From c78c18d63a0ddea2bf377cbf722f430c147ba036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 20:47:02 +0800 Subject: [PATCH 384/493] Logo: generate `logo_builtin.h` with CMake --- CMakeLists.txt | 7 ++++--- src/logo/builtin.c | 2 +- src/logo/builtin.h.in | 31 ------------------------------- src/logo/logo.c | 2 ++ 4 files changed, 7 insertions(+), 35 deletions(-) delete mode 100644 src/logo/builtin.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9906c36b0..1d99967f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,14 +253,15 @@ function(fastfetch_load_raw_text FILENAME OUTVAR) endfunction(fastfetch_load_raw_text) file(GLOB LOGO_FILES "src/logo/ascii/*.txt") +set(LOGO_BUILTIN_H "#pragma once\n\n") foreach(file ${LOGO_FILES}) fastfetch_load_raw_text("${file}" content) get_filename_component(file "${file}" NAME_WLE) string(TOUPPER "${file}" file) - string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" DATATEXT_LOGO_${file} "${content}") + string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" content "${content}") + set(LOGO_BUILTIN_H "${LOGO_BUILTIN_H}#define FASTFETCH_DATATEXT_LOGO_${file} ${content}\n") endforeach() - -configure_file(src/logo/builtin.h.in src_logo_builtin.h @ONLY) +file(GENERATE OUTPUT logo_builtin.h CONTENT "${LOGO_BUILTIN_H}") ####################### # libfastfetch target # diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 237ee3e17..4dafa87ed 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1,5 +1,5 @@ #include "logo.h" -#include "src_logo_builtin.h" // Generated with `src/logo/builtin.h` +#include "logo_builtin.h" #define FF_LOGO_INIT static FFlogo logo; static bool init = false; if(init) return &logo; init = true; // The names of small logo must end with `_small` or `-small` diff --git a/src/logo/builtin.h.in b/src/logo/builtin.h.in deleted file mode 100644 index 1e9c115d0..000000000 --- a/src/logo/builtin.h.in +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#ifndef FASTFETCH_INDLUDED_logo_builtin_h_in -#define FASTFETCH_INDLUDED_logo_builtin_h_in - -#define FASTFETCH_DATATEXT_LOGO_AIX @DATATEXT_LOGO_AIX@ -#define FASTFETCH_DATATEXT_LOGO_ASAHI @DATATEXT_LOGO_ASAHI@ -#define FASTFETCH_DATATEXT_LOGO_GNOME @DATATEXT_LOGO_GNOME@ -#define FASTFETCH_DATATEXT_LOGO_GNU @DATATEXT_LOGO_GNU@ -#define FASTFETCH_DATATEXT_LOGO_HAIKU @DATATEXT_LOGO_HAIKU@ -#define FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL @DATATEXT_LOGO_HAIKU_SMALL@ -#define FASTFETCH_DATATEXT_LOGO_LMDE @DATATEXT_LOGO_LMDE@ -#define FASTFETCH_DATATEXT_LOGO_MANDRIVA @DATATEXT_LOGO_MANDRIVA@ -#define FASTFETCH_DATATEXT_LOGO_MINIX @DATATEXT_LOGO_MINIX@ -#define FASTFETCH_DATATEXT_LOGO_NETBSD @DATATEXT_LOGO_NETBSD@ -#define FASTFETCH_DATATEXT_LOGO_NOMADBSD @DATATEXT_LOGO_NOMADBSD@ -#define FASTFETCH_DATATEXT_LOGO_OPENBSD @DATATEXT_LOGO_OPENBSD@ -#define FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL @DATATEXT_LOGO_OPENBSD_SMALL@ -#define FASTFETCH_DATATEXT_LOGO_OPENSUSETUMBLEWEED2 @DATATEXT_LOGO_OPENSUSETUMBLEWEED2@ -#define FASTFETCH_DATATEXT_LOGO_OPENWRT @DATATEXT_LOGO_OPENWRT@ -#define FASTFETCH_DATATEXT_LOGO_ORACLE @DATATEXT_LOGO_ORACLE@ -#define FASTFETCH_DATATEXT_LOGO_SOLARIS @DATATEXT_LOGO_SOLARIS@ -#define FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL @DATATEXT_LOGO_SOLARIS_SMALL@ -#define FASTFETCH_DATATEXT_LOGO_UBUNTUKYLIN @DATATEXT_LOGO_UBUNTUKYLIN@ -#define FASTFETCH_DATATEXT_LOGO_UBUNTUMATE @DATATEXT_LOGO_UBUNTUMATE@ -#define FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL @DATATEXT_LOGO_UBUNTU2_SMALL@ -#define FASTFETCH_DATATEXT_LOGO_UOS @DATATEXT_LOGO_UOS@ -#define FASTFETCH_DATATEXT_LOGO_WINDOWS95 @DATATEXT_LOGO_WINDOWS95@ -#define FASTFETCH_DATATEXT_LOGO_OPENKYLIN @DATATEXT_LOGO_OPENKYLIN@ - -#endif diff --git a/src/logo/logo.c b/src/logo/logo.c index 449901856..fece34793 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -540,6 +540,8 @@ void ffLogoBuiltinList(void) ++names; } + putchar('\n'); + puts(logo->data); putchar('\n'); ++methods; } From 09f73235aab1ec3d6e811c7181ee5b668b96be9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 21:18:26 +0800 Subject: [PATCH 385/493] FFstrbuf: add `ffStrbufUpperCase` and `ffStrbufLowerCase` --- src/util/FFstrbuf.c | 12 ++++++++++++ src/util/FFstrbuf.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index d714622a4..70a2a029d 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -429,3 +429,15 @@ uint16_t ffStrbufToUInt16(const FFstrbuf* strbuf, uint16_t defaultValue) unsigned long result = strtoul(strbuf->chars, &str_end, 10); return str_end == strbuf->chars || result > UINT16_MAX ? defaultValue : (uint16_t)result; } + +void ffStrbufUpperCase(FFstrbuf* strbuf) +{ + for (uint32_t i = 0; i < strbuf->length; ++i) + strbuf->chars[i] = (char) toupper(strbuf->chars[i]); +} + +void ffStrbufLowerCase(FFstrbuf* strbuf) +{ + for (uint32_t i = 0; i < strbuf->length; ++i) + strbuf->chars[i] = (char) tolower(strbuf->chars[i]); +} diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index fa8e66234..9e9bce198 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -83,6 +83,9 @@ void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file); FF_C_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf); FF_C_NODISCARD uint16_t ffStrbufToUInt16(const FFstrbuf* strbuf, uint16_t defaultValue); +void ffStrbufUpperCase(FFstrbuf* strbuf); +void ffStrbufLowerCase(FFstrbuf* strbuf); + FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) { FFstrbuf strbuf; From 90bf6cbe44aa8253baed6a298a19ab4875c58c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 21:19:51 +0800 Subject: [PATCH 386/493] Logo: remove old `.txt` --- src/logo/ascii/AIX.txt | 20 -------------------- src/logo/ascii/Asahi.txt | 18 ------------------ src/logo/ascii/GNU.txt | 18 ------------------ src/logo/ascii/Gnome.txt | 21 --------------------- src/logo/ascii/Haiku.txt | 12 ------------ src/logo/ascii/Haiku_Small.txt | 8 -------- src/logo/ascii/LMDE.txt | 17 ----------------- src/logo/ascii/Mandriva.txt | 15 --------------- src/logo/ascii/Minix.txt | 17 ----------------- src/logo/ascii/NetBSD.txt | 17 ----------------- src/logo/ascii/NomadBSD.txt | 13 ------------- src/logo/ascii/OpenBSD.txt | 23 ----------------------- src/logo/ascii/OpenBSD_Small.txt | 7 ------- src/logo/ascii/OpenKylin.txt | 18 ------------------ src/logo/ascii/OpenWrt.txt | 9 --------- src/logo/ascii/OpensuseTumbleweed2.txt | 13 ------------- src/logo/ascii/Oracle.txt | 11 ----------- src/logo/ascii/Solaris.txt | 8 -------- src/logo/ascii/Solaris_Small.txt | 5 ----- src/logo/ascii/UOS.txt | 20 -------------------- src/logo/ascii/Ubuntu2_Small.txt | 11 ----------- src/logo/ascii/UbuntuKylin.txt | 20 -------------------- src/logo/ascii/UbuntuMate.txt | 20 -------------------- src/logo/ascii/Windows95.txt | 18 ------------------ src/logo/logo.c | 2 -- 25 files changed, 361 deletions(-) delete mode 100644 src/logo/ascii/AIX.txt delete mode 100644 src/logo/ascii/Asahi.txt delete mode 100644 src/logo/ascii/GNU.txt delete mode 100644 src/logo/ascii/Gnome.txt delete mode 100644 src/logo/ascii/Haiku.txt delete mode 100644 src/logo/ascii/Haiku_Small.txt delete mode 100644 src/logo/ascii/LMDE.txt delete mode 100644 src/logo/ascii/Mandriva.txt delete mode 100644 src/logo/ascii/Minix.txt delete mode 100644 src/logo/ascii/NetBSD.txt delete mode 100644 src/logo/ascii/NomadBSD.txt delete mode 100644 src/logo/ascii/OpenBSD.txt delete mode 100644 src/logo/ascii/OpenBSD_Small.txt delete mode 100644 src/logo/ascii/OpenKylin.txt delete mode 100644 src/logo/ascii/OpenWrt.txt delete mode 100644 src/logo/ascii/OpensuseTumbleweed2.txt delete mode 100644 src/logo/ascii/Oracle.txt delete mode 100644 src/logo/ascii/Solaris.txt delete mode 100644 src/logo/ascii/Solaris_Small.txt delete mode 100644 src/logo/ascii/UOS.txt delete mode 100644 src/logo/ascii/Ubuntu2_Small.txt delete mode 100644 src/logo/ascii/UbuntuKylin.txt delete mode 100644 src/logo/ascii/UbuntuMate.txt delete mode 100644 src/logo/ascii/Windows95.txt diff --git a/src/logo/ascii/AIX.txt b/src/logo/ascii/AIX.txt deleted file mode 100644 index 2f2483701..000000000 --- a/src/logo/ascii/AIX.txt +++ /dev/null @@ -1,20 +0,0 @@ - `:+ssssossossss+-` - .oys///oyhddddhyo///sy+. - /yo:+hNNNNNNNNNNNNNNNNh+:oy/ - :h/:yNNNNNNNNNNNNNNNNNNNNNNy-+h: - `ys.yNNNNNNNNNNNNNNNNNNNNNNNNNNy.ys - `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oh - h+-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.oy -/d`mNNNNNNN/::mNNNd::m+:/dNNNo::dNNNd`m: -h//NNNNNNN: . .NNNh mNo od. -dNNNNN:+y -N.sNNNNNN+ -N/ -NNh mNNd. sNNNNNNNo-m -N.sNNNNNs +oo /Nh mNNs` ` /mNNNNNNo-m -h//NNNNh ossss` +h md- .hm/ `sNNNNN:+y -:d`mNNN+/yNNNNNd//y//h//oNNNNy//sNNNd`m- - yo-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNm.ss - `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oy - sy.yNNNNNNNNNNNNNNNNNNNNNNNNNNs.yo - :h+-yNNNNNNNNNNNNNNNNNNNNNNs-oh- - :ys:/yNNNNNNNNNNNNNNNmy/:sy: - .+ys///osyhhhhys+///sy+. - -/osssossossso/- diff --git a/src/logo/ascii/Asahi.txt b/src/logo/ascii/Asahi.txt deleted file mode 100644 index fef162fd0..000000000 --- a/src/logo/ascii/Asahi.txt +++ /dev/null @@ -1,18 +0,0 @@ -${c1} ## ${c2}** - ${c1}*####${c2}****. - ${c1}###${c2}, - ${c3}...,${c1}/#${c3},,,.. - ${c3}/*,,,,,,,,${c1}*${c3},........${c4},, - ${c3},((((((//*,,,,,,,,${c4},...... - ${c3}((((((((((((((${c5}%..${c4}.......... - ${c3},(((((((((((((((${c5}@@(${c4}............ - ${c3}(((((((((((((((((${c5}@@@@/${c4}............ - ${c3},((((((((((((((((((${c5}@@@@@&*${c4}........... - ${c3}((((((((((((((((((((${c5}@@@@@@@&${c4},........... -${c3}(((((((((((((((((((((${c5}@@@${c6}&%&${c5}@@@%${c4},.......... - ${c3}/(((((((((((((((((((${c5}@@@${c6}&%%&${c5}@@@@(${c4}........ - ${c3},((((((((((((((((${c5}@@@${c6}&&${c5}@@&/&@@@/${c4}.. - ${c3}/((((((((((((${c5}@@@@@@/${c4}.../&& - ${c3}.(((((((((${c5}@@@@(${c4}.... - ${c3}/(((((${c5}@@#${c4}... - ${c3}.((${c4}&, diff --git a/src/logo/ascii/GNU.txt b/src/logo/ascii/GNU.txt deleted file mode 100644 index 4d1af8d58..000000000 --- a/src/logo/ascii/GNU.txt +++ /dev/null @@ -1,18 +0,0 @@ - _-`````-, ,- '- . - .' .- - | | - -. `. - /.' / `. \ -:/ : _... ..._ `` : -:: : /._ .`:'_.._\. || : -:: `._ ./ ,` : \ . _.'' . -`:. / | -. \-. \\_ / - \:._ _/ .' .@) \@) ` `\ ,.' - _/,--' .- .\,-.`--`. - ,'/'' (( \ ` ) - /'/' \ `-' ( - '/'' `._,-----' - ''/' .,---' - ''/' ;: - ''/'' ''/ - ''/''/'' - '/'/' - `; diff --git a/src/logo/ascii/Gnome.txt b/src/logo/ascii/Gnome.txt deleted file mode 100644 index 822cf2aec..000000000 --- a/src/logo/ascii/Gnome.txt +++ /dev/null @@ -1,21 +0,0 @@ - ,@@@@@@@@, - @@@@@@ @@@@@@@@@@@@ - ,@@. @@@@@@@ *@@@@@@@@@@@@ - @@@@@% @@@@@@( @@@@@@@@@@@& - @@@@@@ @@@@* @@@@@@@@@# -@@@@* @@@@, *@@@@@% -@@@@@. - @@@@# @@@@@@@@@@@@@@@@ - ,@@@@@@@@@@@@@@@@@@@@@@@, - ,@@@@@@@@@@@@@@@@@@@@@@@@@@& - .@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - @@@@@@@@@@@@@@@@@@@@@@@@@@@ - @@@@@@@@@@@@@@@@@@@@@@@@( - @@@@@@@@@@@@@@@@@@@@% - @@@@@@@@@@@@@@@@ - @@@@@@@@@@@@* @@@@@@@@/ - &@@@@@@@@@@ @@@@@@@@@* - @@@@@@@@@@@, @@@@@@@@@* - ,@@@@@@@@@@@@@@@@@@@@& - &@@@@@@@@@@@@@@ - ... diff --git a/src/logo/ascii/Haiku.txt b/src/logo/ascii/Haiku.txt deleted file mode 100644 index ce164058f..000000000 --- a/src/logo/ascii/Haiku.txt +++ /dev/null @@ -1,12 +0,0 @@ -${c3} MMMM MMMM - MMMM MMMM - MMMM MMMM - MMMM MMMM - MMMM${c4} .ciO| /YMMMMM*" -${c3} MMMM${c4} .cOMMMMM|/MMMMM/` - , ,iMM|/MMMMMMMMMMMMMMM* - `*.__,-cMMMMMMMMMMMMMMMMM/`${c3}.MMM - MM${c4}MMMMMMM/`:MMM/ ${c3}MMMM - MMMM MMMM - MMMM MMMM - """" """" diff --git a/src/logo/ascii/Haiku_Small.txt b/src/logo/ascii/Haiku_Small.txt deleted file mode 100644 index 5c6b30a41..000000000 --- a/src/logo/ascii/Haiku_Small.txt +++ /dev/null @@ -1,8 +0,0 @@ - ,^, - / \\ -*--_ ; ; _--* -\\ '" "' / - '. .' -.-'" "'-. - '-.__. .__.-' - |_| diff --git a/src/logo/ascii/LMDE.txt b/src/logo/ascii/LMDE.txt deleted file mode 100644 index 4fcad0636..000000000 --- a/src/logo/ascii/LMDE.txt +++ /dev/null @@ -1,17 +0,0 @@ -${c2} `.-::---.. -${c1} .:++++ooooosssoo:. - .+o++::. `.:oos+. -${c1} :oo:.` -+oo${c2}: -${c1} ${c2}`${c1}+o/` .${c2}::::::${c1}-. .++-${c2}` -${c1}${c2}`${c1}/s/ .yyyyyyyyyyo: +o-${c2}` -${c1}${c2}`${c1}so .ss ohyo` :s-${c2}: -${c1}${c2}`${c1}s/ .ss h m myy/ /s`${c2}` -${c1}`s: `oo s m Myy+-o:` -`oo :+sdoohyoydyso/. - :o. .:////////++: -${c1} `/++ ${c2}-:::::- -${c1} ${c2}`${c1}++- -${c1} ${c2}`${c1}/+- -${c1} ${c2}.${c1}+/. -${c1} ${c2}.${c1}:+-. - `--.`` diff --git a/src/logo/ascii/Mandriva.txt b/src/logo/ascii/Mandriva.txt deleted file mode 100644 index ef3e84390..000000000 --- a/src/logo/ascii/Mandriva.txt +++ /dev/null @@ -1,15 +0,0 @@ -${c2} `` - `-. -${c1} ` ${c2}.--- -${c1} -/ ${c2}-::--` -${c1} `++ ${c2}`----...```-:::::. -${c1} `os. ${c2}.::::::::::::::-``` ` ` -${c1} +s+ ${c2}.::::::::::::::::---...--` -${c1}-ss: ${c2}`-::::::::::::::::-.``.`` -${c1}/ss- ${c2}.::::::::::::-.`` ` -${c1}+ss: ${c2}.::::::::::::- -${c1}/sso ${c2}.::::::-::::::- -${c1}.sss/ ${c2}-:::-.` .::::: -${c1} /sss+. ${c2}..`${c1} `--` ${c2}.::: -${c1} -ossso+/:://+/-` ${c2}.:` -${c1} -/+ooo+/-. ${c2}` diff --git a/src/logo/ascii/Minix.txt b/src/logo/ascii/Minix.txt deleted file mode 100644 index a0ff143ca..000000000 --- a/src/logo/ascii/Minix.txt +++ /dev/null @@ -1,17 +0,0 @@ -${c2} -sdhyo+:-` -/syymm: - sdyooymmNNy. `` .smNmmdysNd - odyoso+syNNmysoyhhdhsoomNmm+/osdm/ - :hhy+-/syNNmddhddddddmNMNo:sdNd: - `smNNdNmmNmddddddddddmmmmmmmy` - `ohhhhdddddmmNNdmddNmNNmdddddmdh- - odNNNmdyo/:/-/hNddNy-`..-+ydNNNmd: - `+mNho:` smmd/ sNNh :dmms` -+ymmo. --od/ -m${c1}mm${c2}mo -NN+ +m${c1}mm${c2}m- yms: -+sms -.` :so: .NN+ :os/ .-`mNh: -.-hyh+:////- -sNNd:` .--://ohNs- - `:hNNNNNNNMMd/sNMmhsdMMh/ymmNNNmmNNy/ - -+sNNNNMMNNNsmNMo: :NNmymNNNNMMMms: - //oydNMMMMydMMNysNMMmsMMMMMNyo/` - ../-yNMMy--/::/-.sMMmos+.` - -+oyhNsooo+omy/``` - `::ohdmds-` diff --git a/src/logo/ascii/NetBSD.txt b/src/logo/ascii/NetBSD.txt deleted file mode 100644 index 6048ee3a3..000000000 --- a/src/logo/ascii/NetBSD.txt +++ /dev/null @@ -1,17 +0,0 @@ -${c1} `-/oshdmNMNdhyo+:-` -${c2}y${c1}/s+:-`` `.-:+oydNMMMMNhs/-`` -${c2}-m+${c1}NMMMMMMMMMMMMMMMMMMMNdhmNMMMmdhs+/-` - ${c2}-m+${c1}NMMMMMMMMMMMMMMMMMMMMmy+:` - ${c2}-N/${c1}dMMMMMMMMMMMMMMMds:` - ${c2}-N/${c1}hMMMMMMMMMmho:` - ${c2}-N/${c1}-:/++/:.` -${c2} :M+ - :Mo - :Ms - :Ms - :Ms - :Ms - :Ms - :Ms - :Ms - :Ms diff --git a/src/logo/ascii/NomadBSD.txt b/src/logo/ascii/NomadBSD.txt deleted file mode 100644 index 867666efa..000000000 --- a/src/logo/ascii/NomadBSD.txt +++ /dev/null @@ -1,13 +0,0 @@ - _======__ - (===============\\ - (===================\\ - _ _---__ - (= ====- - (= ====== - (== ====== - (== ====== - (==\\ \\=-_ _=/ /====/ - (==\\ \\========/ /====/ /====-_ - (==\\ \\=====/ /==/ /===-- -/================/ /===- -\\===========/ diff --git a/src/logo/ascii/OpenBSD.txt b/src/logo/ascii/OpenBSD.txt deleted file mode 100644 index f758fbd82..000000000 --- a/src/logo/ascii/OpenBSD.txt +++ /dev/null @@ -1,23 +0,0 @@ -${c3} _ - (_) -${c1} | . -${c1} . |L /| . ${c3} _ -${c1} _ . |\ _| \--+._/| . ${c3}(_) -${c1} / ||\| Y J ) / |/| ./ - J |)'( | ` F`.'/ ${c3} _ -${c1} -<| F __ .-< ${c3}(_) -${c1} | / .-'${c3}. ${c1}`. /${c3}-. ${c1}L___ - J \\ < ${c3}\ ${c1} | | ${c5}O${c3}\\${c1}|.-' ${c3} _ -${c1} _J \\ .- \\${c3}/ ${c5}O ${c3}| ${c1}| \\ |${c1}F ${c3}(_) -${c1} '-F -<_. \\ .-' `-' L__ -__J _ _. >-' ${c1})${c4}._. ${c1}|-' -${c1} `-|.' /_. ${c4}\_| ${c1} F - /.- . _.< - /' /.' .' `\\ - /L /' |/ _.-'-\\ - /'J ___.---'\| - |\ .--' V | `. ` - |/`. `-. `._) - / .-.\\ - \\ ( `\\ - `.\\ diff --git a/src/logo/ascii/OpenBSD_Small.txt b/src/logo/ascii/OpenBSD_Small.txt deleted file mode 100644 index bb6e646ac..000000000 --- a/src/logo/ascii/OpenBSD_Small.txt +++ /dev/null @@ -1,7 +0,0 @@ -${c1} _____ - \\- -/ - \\_/ \\ - | ${c2}O O${c1} | - |_ < ) 3 ) - / \\ / - /-_____-\\ diff --git a/src/logo/ascii/OpenKylin.txt b/src/logo/ascii/OpenKylin.txt deleted file mode 100644 index f1af1f1c3..000000000 --- a/src/logo/ascii/OpenKylin.txt +++ /dev/null @@ -1,18 +0,0 @@ - - /KKK] - KKKKKKK` ]KKKK\ - KKKKK/ /KKKKKKKKK\ - KKKK/ ,KKKKKKKKKKKK^ - ,]KKK =KKK` /KKKKKKOOOOOO` -,KKKKKK =KK /` [\OOOOOOO\ - \KKKKK =K ,OOOOOOO` - ,KKKKK =^ \OOOOOO - ,KKKK ^ OOOOOO^ - *KKK^ =OOOOO^ - OOKK^ OOOOOO^ - \OOOK\ /OOOOOO` - OOOOOO] ,OOOOOOO^ - ,OOOOOOOO\] ,[OOOOOOOOO/ - \OOOOOOOOOOOOOOOOOOOOO` - [OOOOOOOOOOOOOOOO/` - ,[OOOOOOOOO] diff --git a/src/logo/ascii/OpenWrt.txt b/src/logo/ascii/OpenWrt.txt deleted file mode 100644 index 0ba1d9a12..000000000 --- a/src/logo/ascii/OpenWrt.txt +++ /dev/null @@ -1,9 +0,0 @@ - _______ -| |.-----.-----.-----. -| - || _ | -__| | -|_______|| __|_____|__|__| - |__| - ________ __ -| | | |.----.| |_ -| | | || _|| _| -|________||__| |____| diff --git a/src/logo/ascii/OpensuseTumbleweed2.txt b/src/logo/ascii/OpensuseTumbleweed2.txt deleted file mode 100644 index fbdcb2bcf..000000000 --- a/src/logo/ascii/OpensuseTumbleweed2.txt +++ /dev/null @@ -1,13 +0,0 @@ - ...... - .,cdxxxoc,. .:kKMMMNWMMMNk:. - cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. - ;WMK;' 'lKMMNM, :NMK' 'OMW; - cMW; WMMMN ,XMK' oMM. -.MMc ''^*~l. xMN: KM0 -'MM. .NMO oMM -.MM, .kMMl xMN - KM0 .kMM0' .dl>~,. .WMd - 'XM0. ,OMMK' OMMM7' .XMK - *WMO:. .;xNMMk' NNNMKl. .xWMx - ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' - ''''' ':dOOXXKOxl' diff --git a/src/logo/ascii/Oracle.txt b/src/logo/ascii/Oracle.txt deleted file mode 100644 index 076847ec8..000000000 --- a/src/logo/ascii/Oracle.txt +++ /dev/null @@ -1,11 +0,0 @@ - `-/+++++++++++++++++/-.` - `/syyyyyyyyyyyyyyyyyyyyyyys/. - :yyyyo/-...............-/oyyyy/ - /yyys- .oyyy+ -.yyyy` `syyy- -:yyyo /yyy/ -.yyyy` `syyy- - /yyys. .oyyyo - /yyyyo:-...............-:oyyyy/` - `/syyyyyyyyyyyyyyyyyyyyyyys+. - `.:/+ooooooooooooooo+/:.` diff --git a/src/logo/ascii/Solaris.txt b/src/logo/ascii/Solaris.txt deleted file mode 100644 index cd78b5d13..000000000 --- a/src/logo/ascii/Solaris.txt +++ /dev/null @@ -1,8 +0,0 @@ - `- ` - `-- `+- .: - .+: `++: -/+- . - `.::` -++/``:::`./+/ `.-/. - `++/-`.` ` /++:` - `` ./:` .: `..`.- -``./+/:- -+++:- - -/+` :. diff --git a/src/logo/ascii/Solaris_Small.txt b/src/logo/ascii/Solaris_Small.txt deleted file mode 100644 index 148d7537a..000000000 --- a/src/logo/ascii/Solaris_Small.txt +++ /dev/null @@ -1,5 +0,0 @@ - . .; . - . :; :: ;: . - .;. .. .. .;. -.. .. .. .. - .;, ,;. diff --git a/src/logo/ascii/UOS.txt b/src/logo/ascii/UOS.txt deleted file mode 100644 index e5d229db1..000000000 --- a/src/logo/ascii/UOS.txt +++ /dev/null @@ -1,20 +0,0 @@ - ....... - .............. - ...................... - ............................. -uuuuuu uuuuuu ooooooooooo ssssssssss -u::::u u::::u oo:::::::::::oo ss::::::::::s -u::::u u::::u o:::::::::::::::oss:::::::::::::s -u::::u u::::u o:::::ooooo:::::os::::::ssss:::::s -u::::u u::::u o::::o o::::o s:::::s ssssss -u::::u u::::u o::::o o::::o s::::::s -u::::u u::::u o::::o o::::o s::::::s -u:::::uuuu:::::u o::::o o::::ossssss s:::::s -u:::::::::::::::uuo:::::ooooo:::::os:::::ssss::::::s -u:::::::::::::::uo:::::::::::::::os::::::::::::::s -uu::::::::uu:::u oo:::::::::::oo s:::::::::::ss - uuuuuuuu uuuu ooooooooooo sssssssssss - ............................. - ..................... - ............. - ...... diff --git a/src/logo/ascii/Ubuntu2_Small.txt b/src/logo/ascii/Ubuntu2_Small.txt deleted file mode 100644 index 0a3146659..000000000 --- a/src/logo/ascii/Ubuntu2_Small.txt +++ /dev/null @@ -1,11 +0,0 @@ - ..;,; .,;,. - .,lool: .ooooo, - ;oo;: .coool. - .... ''' ,l; -:oooo, 'oo. -looooc :oo' - '::' ,oo: - ,., .... co, - lo:;. :oooo; . - ':ooo; cooooc - ''' '''' diff --git a/src/logo/ascii/UbuntuKylin.txt b/src/logo/ascii/UbuntuKylin.txt deleted file mode 100644 index c1ace067d..000000000 --- a/src/logo/ascii/UbuntuKylin.txt +++ /dev/null @@ -1,20 +0,0 @@ -${c1} .__=liiiiiii=__, - ._=liiliii|i|i|iiilii=_. - _=iiiii|ii|i|ii|i|inwwwzii=, - .=liiii|ii|ii|wwww|i${c2}3QWWWW${c1}ziii=, - =lii|i|ii|i|${c2}QQQWWWWWm]QWWQD${c1}||iiii= - =lii|iiivw${c2}Qm${c1}>3${c2}WWWWWQWQQwwQw${c1}cii|i|ii= - =lii|ii|n${c2}QWWWQ${c1}|)i${c2}|i${c1}%i|]${c2}TQWWWWm${c1}|ii|i|i= -.li|i|i|m${c2}WWWQV${c1}|ii${c2}wmD${c1}|iiii|${c2}TWWWWm${c1}|i|iiii, -=iii${c2}www|$WQWk${c1}|i${c2}aWWWD${c1}|i|i|ii]${c2}QQWQk${c1}|ii|i|= -iii${c2}QWWWQz$WW${c1}|i${c2}jQQWQm${c1}w|ii${c2}wW${c1}k|${c2}TTTTY${c1}i|i|iii -iiI${c2}QWQWWtyQQ${c1}|i|${c2}$WWWWWQWk${c1}||i|i|ii||i|ii|i -<|i|${c2}TTT|mQQWz${c1}|i${c2}3D${c1}]C|${c2}nD$W${c1}|ii${c2}vWWWWk${c1}||ii|i> --|ii|i|i${c2}WWWQw${c1}|${c2}Tt${c1}|i3${c2}T${c1}|${c2}T${c1}|i|${c2}nQWQWDk${c1}|ii|ii` - <|i|iii|${c2}VWQWWQ${c1}|i|i|||ii${c2}wmWWQWD${c1}||ii|ii+ - <|ii|i|i]${c2}$W@${c1}tv${c2}QQQWQQQWWTTHT${c1}1|iii|i|> - <|i|ii|ii||v${c2}QWWWQWWW@vmWWWm${c1}|i|i|i> - -<|i|ii|ii|i|${c2}TTTTTT${c1}|]${c2}QQWWWC${c1}|ii>` - -<|i|ii|i|ii|i|i|ii3${c2}TTT${c1}t|i>` - ~<|ii|ii|iiiii|i|||i>~ - -~~<|ii|i||i>~~` diff --git a/src/logo/ascii/UbuntuMate.txt b/src/logo/ascii/UbuntuMate.txt deleted file mode 100644 index 5711b8439..000000000 --- a/src/logo/ascii/UbuntuMate.txt +++ /dev/null @@ -1,20 +0,0 @@ -${c1} .:/+oossssoo+/:.` - `:+ssssssssssssssssss+:` - -+sssssssssssssss${c2}y${c1}ssssssss+- - .osssssssssssss${c2}yy${c1}ss${c2}mMmh${c1}ssssssso. - /sssssssss${c2}ydmNNNmmd${c1}s${c2}mMMMMNdy${c1}sssss/ - `+ssssssss${c2}hNNdy${c1}sssssss${c2}mMMMMNdy${c1}ssssss+` - +sssssss${c2}yNNh${c1}ss${c2}hmNNNNm${c1}s${c2}mMmh${c1}s${c2}ydy${c1}sssssss+ --sssss${c2}y${c1}ss${c2}Nm${c1}ss${c2}hNNh${c1}ssssss${c2}y${c1}s${c2}hh${c1}ss${c2}mMy${c1}sssssss- -+ssss${c2}yMNdy${c1}ss${c2}hMd${c1}ssssssssss${c2}hMd${c1}ss${c2}NN${c1}sssssss+ -sssss${c2}yMMMMMmh${c1}sssssssssssss${c2}NM${c1}ss${c2}dMy${c1}sssssss -sssss${c2}yMMMMMmhy${c1}ssssssssssss${c2}NM${c1}ss${c2}dMy${c1}sssssss -+ssss${c2}yMNdy${c1}ss${c2}hMd${c1}ssssssssss${c2}hMd${c1}ss${c2}NN${c1}sssssss+ --sssss${c2}y${c1}ss${c2}Nm${c1}ss${c2}hNNh${c1}ssssssss${c2}dh${c1}ss${c2}mMy${c1}sssssss- - +sssssss${c2}yNNh${c1}ss${c2}hmNNNNm${c1}s${c2}mNmh${c1}s${c2}ymy${c1}sssssss+ - +ssssssss${c2}hNNdy${c1}sssssss${c2}mMMMMmhy${c1}ssssss+ - /sssssssss${c2}ydmNNNNmd${c1}s${c2}mMMMMNdh${c1}sssss/ - .osssssssssssss${c2}yy${c1}ss${c2}mMmdy${c1}sssssso. - -+sssssssssssssss${c2}y${c1}ssssssss+- - `:+ssssssssssssssssss+:` - .:/+oossssoo+/:. diff --git a/src/logo/ascii/Windows95.txt b/src/logo/ascii/Windows95.txt deleted file mode 100644 index 77d20ea01..000000000 --- a/src/logo/ascii/Windows95.txt +++ /dev/null @@ -1,18 +0,0 @@ -${c6} ___ - .--=+++++=-:. -. _ *%@@@@@@@@@@@@@@* - *:+:.__ :+* @@@ @"${c5}_*&%${c6}@@${c4}%&&&*${c6}"@@@ - "+.-#+ +%* " _ ${c5}++&&&%${c6}@@${c4}%&&&&&#${c6}@@ -${c5}" , ${c6}%@@ ${c5}&&&&&%${c6}@@${c4}%&&&&&#${c6}@@ -${c5} * oo *# ${c6}" _ ${c5}&&&&&%${c6}@@${c4}%&&&&&#${c6}@@ -${c5}" , ${c6}%@@ ${c5}&&&&"${c6}@@@@#*${c4}"&&&${c6}@@ -.${c5} * oo *# ${c6}" _ %@@@@@@@@@@@@@@@@ - *:+:.__ :=* %@@ @"${c1}**&%${c6}@@${c3}%&&&*${c6}"@@@ - "+.-#+ +%* " _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ -${c1}" , ${c6}%@@ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ -${c1} * oo *# ${c6}" _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ -${c1}" , ${c6}%@@ ${c1}&&*"${c6}%@@@@@@${c3}"*%&${c6}@@ -.${c1} * oo *# ${c6}" _ @@@@@@@@@@@@@@@@@ - *:+:.__ :+# @@@ @%#=+""""""+==%#@ - "+.-#+ +%* %+" " ":@ - " " diff --git a/src/logo/logo.c b/src/logo/logo.c index fece34793..449901856 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -540,8 +540,6 @@ void ffLogoBuiltinList(void) ++names; } - putchar('\n'); - puts(logo->data); putchar('\n'); ++methods; } From 2fa7f1157f3016314c3212070ee6b2ab965c0ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 21:58:51 +0800 Subject: [PATCH 387/493] Logos: move logo lines to seperated plain text files --- src/logo/ascii/aix.txt | 20 + src/logo/ascii/almalinux.txt | 20 + src/logo/ascii/alpine.txt | 20 + src/logo/ascii/alpine_small.txt | 6 + src/logo/ascii/android.txt | 18 + src/logo/ascii/android_small.txt | 6 + src/logo/ascii/arch.txt | 19 + src/logo/ascii/arch_small.txt | 7 + src/logo/ascii/arco.txt | 20 + src/logo/ascii/artix.txt | 20 + src/logo/ascii/artix_small.txt | 7 + src/logo/ascii/asahi.txt | 18 + src/logo/ascii/bedrock.txt | 17 + src/logo/ascii/bsd.txt | 19 + src/logo/ascii/cachyos.txt | 22 + src/logo/ascii/cachyos_small.txt | 8 + src/logo/ascii/celos.txt | 15 + src/logo/ascii/centos.txt | 19 + src/logo/ascii/centos_small.txt | 7 + src/logo/ascii/crux.txt | 18 + src/logo/ascii/crystal.txt | 20 + src/logo/ascii/debian.txt | 17 + src/logo/ascii/debian_small.txt | 6 + src/logo/ascii/deepin.txt | 18 + src/logo/ascii/devuan.txt | 15 + src/logo/ascii/devuan_small.txt | 7 + src/logo/ascii/endeavour.txt | 15 + src/logo/ascii/enso.txt | 19 + src/logo/ascii/exherbo.txt | 22 + src/logo/ascii/fedora.txt | 19 + src/logo/ascii/fedora_old.txt | 17 + src/logo/ascii/fedora_small.txt | 9 + src/logo/ascii/freebsd.txt | 15 + src/logo/ascii/freebsd_small.txt | 6 + src/logo/ascii/garuda.txt | 18 + src/logo/ascii/garuda_small.txt | 5 + src/logo/ascii/gentoo.txt | 18 + src/logo/ascii/gentoo_small.txt | 7 + src/logo/ascii/ghostbsd.txt | 13 + src/logo/ascii/gnome.txt | 21 + src/logo/ascii/gnu.txt | 18 + src/logo/ascii/haiku.txt | 12 + src/logo/ascii/haiku_small.txt | 8 + src/logo/ascii/kde.txt | 19 + src/logo/ascii/kiss.txt | 7 + src/logo/ascii/kubuntu.txt | 20 + src/logo/ascii/langitketujuh.txt | 11 + src/logo/ascii/linux.txt | 12 + src/logo/ascii/linux_small.txt | 7 + src/logo/ascii/lmde.txt | 17 + src/logo/ascii/macos.txt | 17 + src/logo/ascii/macos2.txt | 17 + src/logo/ascii/macos2_small.txt | 7 + src/logo/ascii/macos_small.txt | 7 + src/logo/ascii/mandriva.txt | 15 + src/logo/ascii/manjaro.txt | 14 + src/logo/ascii/manjaro_small.txt | 7 + src/logo/ascii/minix.txt | 17 + src/logo/ascii/mint.txt | 19 + src/logo/ascii/mint_old.txt | 16 + src/logo/ascii/mint_small.txt | 7 + src/logo/ascii/msys2.txt | 25 + src/logo/ascii/netbsd.txt | 17 + src/logo/ascii/nixos.txt | 20 + src/logo/ascii/nixos_old.txt | 28 + src/logo/ascii/nixos_small.txt | 7 + src/logo/ascii/nobara.txt | 17 + src/logo/ascii/nomadbsd.txt | 13 + src/logo/ascii/openbsd.txt | 23 + src/logo/ascii/openbsd_small.txt | 7 + src/logo/ascii/openkylin.txt | 18 + src/logo/ascii/openmandriva.txt | 22 + src/logo/ascii/opensuse.txt | 18 + src/logo/ascii/opensuse_leap.txt | 16 + src/logo/ascii/opensuse_small.txt | 7 + src/logo/ascii/opensuse_tumbleweed.txt | 13 + src/logo/ascii/opensuse_tumbleweed2.txt | 13 + src/logo/ascii/openwrt.txt | 9 + src/logo/ascii/oracle.txt | 11 + src/logo/ascii/parabola.txt | 16 + src/logo/ascii/parabola_small.txt | 6 + src/logo/ascii/pop.txt | 20 + src/logo/ascii/pop_small.txt | 8 + src/logo/ascii/raspbian.txt | 23 + src/logo/ascii/raspbian_small.txt | 10 + src/logo/ascii/reborn.txt | 20 + src/logo/ascii/reborn_small.txt | 11 + src/logo/ascii/redstar.txt | 18 + src/logo/ascii/rhel.txt | 18 + src/logo/ascii/rocky.txt | 19 + src/logo/ascii/rosa.txt | 20 + src/logo/ascii/slackware.txt | 21 + src/logo/ascii/slackware_small.txt | 7 + src/logo/ascii/solaris.txt | 8 + src/logo/ascii/solaris_small.txt | 5 + src/logo/ascii/solus.txt | 20 + src/logo/ascii/steamos.txt | 18 + src/logo/ascii/ubuntu.txt | 21 + src/logo/ascii/ubuntu2_small.txt | 11 + src/logo/ascii/ubuntu_kylin.txt | 20 + src/logo/ascii/ubuntu_mate.txt | 20 + src/logo/ascii/ubuntu_old.txt | 20 + src/logo/ascii/ubuntu_small.txt | 6 + src/logo/ascii/unknown.txt | 18 + src/logo/ascii/uos.txt | 20 + src/logo/ascii/vanilla.txt | 18 + src/logo/ascii/void.txt | 18 + src/logo/ascii/void_small.txt | 7 + src/logo/ascii/windows.txt | 16 + src/logo/ascii/windows_11.txt | 17 + src/logo/ascii/windows_11_small.txt | 9 + src/logo/ascii/windows_8.txt | 19 + src/logo/ascii/windows_95.txt | 18 + src/logo/ascii/zorin.txt | 17 + src/logo/builtin.c | 1653 ++--------------------- 115 files changed, 1806 insertions(+), 1541 deletions(-) create mode 100644 src/logo/ascii/aix.txt create mode 100644 src/logo/ascii/almalinux.txt create mode 100644 src/logo/ascii/alpine.txt create mode 100644 src/logo/ascii/alpine_small.txt create mode 100644 src/logo/ascii/android.txt create mode 100644 src/logo/ascii/android_small.txt create mode 100644 src/logo/ascii/arch.txt create mode 100644 src/logo/ascii/arch_small.txt create mode 100644 src/logo/ascii/arco.txt create mode 100644 src/logo/ascii/artix.txt create mode 100644 src/logo/ascii/artix_small.txt create mode 100644 src/logo/ascii/asahi.txt create mode 100644 src/logo/ascii/bedrock.txt create mode 100644 src/logo/ascii/bsd.txt create mode 100644 src/logo/ascii/cachyos.txt create mode 100644 src/logo/ascii/cachyos_small.txt create mode 100644 src/logo/ascii/celos.txt create mode 100644 src/logo/ascii/centos.txt create mode 100644 src/logo/ascii/centos_small.txt create mode 100644 src/logo/ascii/crux.txt create mode 100644 src/logo/ascii/crystal.txt create mode 100644 src/logo/ascii/debian.txt create mode 100644 src/logo/ascii/debian_small.txt create mode 100644 src/logo/ascii/deepin.txt create mode 100644 src/logo/ascii/devuan.txt create mode 100644 src/logo/ascii/devuan_small.txt create mode 100644 src/logo/ascii/endeavour.txt create mode 100644 src/logo/ascii/enso.txt create mode 100644 src/logo/ascii/exherbo.txt create mode 100644 src/logo/ascii/fedora.txt create mode 100644 src/logo/ascii/fedora_old.txt create mode 100644 src/logo/ascii/fedora_small.txt create mode 100644 src/logo/ascii/freebsd.txt create mode 100644 src/logo/ascii/freebsd_small.txt create mode 100644 src/logo/ascii/garuda.txt create mode 100644 src/logo/ascii/garuda_small.txt create mode 100644 src/logo/ascii/gentoo.txt create mode 100644 src/logo/ascii/gentoo_small.txt create mode 100644 src/logo/ascii/ghostbsd.txt create mode 100644 src/logo/ascii/gnome.txt create mode 100644 src/logo/ascii/gnu.txt create mode 100644 src/logo/ascii/haiku.txt create mode 100644 src/logo/ascii/haiku_small.txt create mode 100644 src/logo/ascii/kde.txt create mode 100644 src/logo/ascii/kiss.txt create mode 100644 src/logo/ascii/kubuntu.txt create mode 100644 src/logo/ascii/langitketujuh.txt create mode 100644 src/logo/ascii/linux.txt create mode 100644 src/logo/ascii/linux_small.txt create mode 100644 src/logo/ascii/lmde.txt create mode 100644 src/logo/ascii/macos.txt create mode 100644 src/logo/ascii/macos2.txt create mode 100644 src/logo/ascii/macos2_small.txt create mode 100644 src/logo/ascii/macos_small.txt create mode 100644 src/logo/ascii/mandriva.txt create mode 100644 src/logo/ascii/manjaro.txt create mode 100644 src/logo/ascii/manjaro_small.txt create mode 100644 src/logo/ascii/minix.txt create mode 100644 src/logo/ascii/mint.txt create mode 100644 src/logo/ascii/mint_old.txt create mode 100644 src/logo/ascii/mint_small.txt create mode 100644 src/logo/ascii/msys2.txt create mode 100644 src/logo/ascii/netbsd.txt create mode 100644 src/logo/ascii/nixos.txt create mode 100644 src/logo/ascii/nixos_old.txt create mode 100644 src/logo/ascii/nixos_small.txt create mode 100644 src/logo/ascii/nobara.txt create mode 100644 src/logo/ascii/nomadbsd.txt create mode 100644 src/logo/ascii/openbsd.txt create mode 100644 src/logo/ascii/openbsd_small.txt create mode 100644 src/logo/ascii/openkylin.txt create mode 100644 src/logo/ascii/openmandriva.txt create mode 100644 src/logo/ascii/opensuse.txt create mode 100644 src/logo/ascii/opensuse_leap.txt create mode 100644 src/logo/ascii/opensuse_small.txt create mode 100644 src/logo/ascii/opensuse_tumbleweed.txt create mode 100644 src/logo/ascii/opensuse_tumbleweed2.txt create mode 100644 src/logo/ascii/openwrt.txt create mode 100644 src/logo/ascii/oracle.txt create mode 100644 src/logo/ascii/parabola.txt create mode 100644 src/logo/ascii/parabola_small.txt create mode 100644 src/logo/ascii/pop.txt create mode 100644 src/logo/ascii/pop_small.txt create mode 100644 src/logo/ascii/raspbian.txt create mode 100644 src/logo/ascii/raspbian_small.txt create mode 100644 src/logo/ascii/reborn.txt create mode 100644 src/logo/ascii/reborn_small.txt create mode 100644 src/logo/ascii/redstar.txt create mode 100644 src/logo/ascii/rhel.txt create mode 100644 src/logo/ascii/rocky.txt create mode 100644 src/logo/ascii/rosa.txt create mode 100644 src/logo/ascii/slackware.txt create mode 100644 src/logo/ascii/slackware_small.txt create mode 100644 src/logo/ascii/solaris.txt create mode 100644 src/logo/ascii/solaris_small.txt create mode 100644 src/logo/ascii/solus.txt create mode 100644 src/logo/ascii/steamos.txt create mode 100644 src/logo/ascii/ubuntu.txt create mode 100644 src/logo/ascii/ubuntu2_small.txt create mode 100644 src/logo/ascii/ubuntu_kylin.txt create mode 100644 src/logo/ascii/ubuntu_mate.txt create mode 100644 src/logo/ascii/ubuntu_old.txt create mode 100644 src/logo/ascii/ubuntu_small.txt create mode 100644 src/logo/ascii/unknown.txt create mode 100644 src/logo/ascii/uos.txt create mode 100644 src/logo/ascii/vanilla.txt create mode 100644 src/logo/ascii/void.txt create mode 100644 src/logo/ascii/void_small.txt create mode 100644 src/logo/ascii/windows.txt create mode 100644 src/logo/ascii/windows_11.txt create mode 100644 src/logo/ascii/windows_11_small.txt create mode 100644 src/logo/ascii/windows_8.txt create mode 100644 src/logo/ascii/windows_95.txt create mode 100644 src/logo/ascii/zorin.txt diff --git a/src/logo/ascii/aix.txt b/src/logo/ascii/aix.txt new file mode 100644 index 000000000..42b3f43ac --- /dev/null +++ b/src/logo/ascii/aix.txt @@ -0,0 +1,20 @@ + `:+ssssossossss+-` + .oys///oyhddddhyo///sy+. + /yo:+hNNNNNNNNNNNNNNNNh+:oy/ + :h/:yNNNNNNNNNNNNNNNNNNNNNNy-+h: + `ys.yNNNNNNNNNNNNNNNNNNNNNNNNNNy.ys + `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oh + h+-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.oy +/d`mNNNNNNN/::mNNNd::m+:/dNNNo::dNNNd`m: +h//NNNNNNN: . .NNNh mNo od. -dNNNNN:+y +N.sNNNNNN+ -N/ -NNh mNNd. sNNNNNNNo-m +N.sNNNNNs +oo /Nh mNNs` ` /mNNNNNNo-m +h//NNNNh ossss` +h md- .hm/ `sNNNNN:+y +:d`mNNN+/yNNNNNd//y//h//oNNNNy//sNNNd`m- + yo-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNm.ss + `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oy + sy.yNNNNNNNNNNNNNNNNNNNNNNNNNNs.yo + :h+-yNNNNNNNNNNNNNNNNNNNNNNs-oh- + :ys:/yNNNNNNNNNNNNNNNmy/:sy: + .+ys///osyhhhhys+///sy+. + -/osssossossso/- \ No newline at end of file diff --git a/src/logo/ascii/almalinux.txt b/src/logo/ascii/almalinux.txt new file mode 100644 index 000000000..6a1000fa8 --- /dev/null +++ b/src/logo/ascii/almalinux.txt @@ -0,0 +1,20 @@ +$1 'c:. +$1 lkkkx, .. $2.. ,cc, +$1 okkkk:ckkx' $2.lxkkx.okkkkd +$1 .:llcokkx' $2:kkkxkko:xkkd, +$1 .xkkkkdood: $2;kx, .lkxlll; +$1 xkkx. $2xk' xkkkkk: +$1 'xkx. $2xd .....,. +$3 .. $1:xkl' $2:c ..''.. +$3 .dkx' $1.:ldl:'. $2' $4':lollldkkxo; +$3 .''lkkko' $4ckkkx. +$3'xkkkd:kkd. .. $5;' $4:kkxo. +$3,xkkkd;kk' ,d; $5ld. $4':dkd::cc, +$3 .,,.;xkko'.';lxo. $5dx, $4:kkk'xkkkkc +$3 'dkkkkkxo:. $5;kx $4.kkk:;xkkd. +$3 ..... $5.;dk:. $5lkk. $4:;, + $5:kkkkkkkdoxkkx + ,c,,;;;:xkkd. + ;kkkkl... + ;kkkkl + ,od; \ No newline at end of file diff --git a/src/logo/ascii/alpine.txt b/src/logo/ascii/alpine.txt new file mode 100644 index 000000000..3379ff4ee --- /dev/null +++ b/src/logo/ascii/alpine.txt @@ -0,0 +1,20 @@ + .hddddddddddddddddddddddh. + :dddddddddddddddddddddddddd: + /dddddddddddddddddddddddddddd/ + +dddddddddddddddddddddddddddddd+ + `sdddddddddddddddddddddddddddddddds` + `ydddddddddddd++hdddddddddddddddddddy` +.hddddddddddd+` `+ddddh:-sdddddddddddh. +hdddddddddd+` `+y: .sddddddddddh +ddddddddh+` `//` `.` -sddddddddd +ddddddh+` `/hddh/` `:s- -sddddddd +ddddh+` `/+/dddddh/` `+s- -sddddd +ddd+` `/o` :dddddddh/` `oy- .yddd +hdddyo+ohddyosdddddddddho+oydddy++ohdddh +.hddddddddddddddddddddddddddddddddddddh. + `yddddddddddddddddddddddddddddddddddy` + `sdddddddddddddddddddddddddddddddds` + +dddddddddddddddddddddddddddddd+ + /dddddddddddddddddddddddddddd/ + :dddddddddddddddddddddddddd: + .hddddddddddddddddddddddh. \ No newline at end of file diff --git a/src/logo/ascii/alpine_small.txt b/src/logo/ascii/alpine_small.txt new file mode 100644 index 000000000..a0cb082a2 --- /dev/null +++ b/src/logo/ascii/alpine_small.txt @@ -0,0 +1,6 @@ + /\ /\ + // \ \ + // \ \ +/// \ \ +// \ \ + \ \ No newline at end of file diff --git a/src/logo/ascii/android.txt b/src/logo/ascii/android.txt new file mode 100644 index 000000000..dba9163b1 --- /dev/null +++ b/src/logo/ascii/android.txt @@ -0,0 +1,18 @@ + -o o- + +hydNNNNdyh+ + +mMMMMMMMMMMMMm+ + `dMM$2m:$1NMMMMMMN$2:m$1MMd` + hMMMMMMMMMMMMMMMMMMh + .. yyyyyyyyyyyyyyyyyyyy .. +.mMMm`MMMMMMMMMMMMMMMMMMMM`mMMm. +:MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM: +:MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM: +:MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM: +:MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM: +-MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM- + +yy+ MMMMMMMMMMMMMMMMMMMM +yy+ + mMMMMMMMMMMMMMMMMMMm + `/++MMMMh++hMMMM++/` + MMMMo oMMMM + MMMMo oMMMM + oNMm- -mMNs \ No newline at end of file diff --git a/src/logo/ascii/android_small.txt b/src/logo/ascii/android_small.txt new file mode 100644 index 000000000..0d7df96af --- /dev/null +++ b/src/logo/ascii/android_small.txt @@ -0,0 +1,6 @@ + ;, ,; + ';,.-----.,;' + ,' ', + / O O \ +| | +'-----------------' \ No newline at end of file diff --git a/src/logo/ascii/arch.txt b/src/logo/ascii/arch.txt new file mode 100644 index 000000000..933c7a200 --- /dev/null +++ b/src/logo/ascii/arch.txt @@ -0,0 +1,19 @@ +$1 -` + .o+` + `ooo/ + `+oooo: + `+oooooo: + -+oooooo+: + `/:-:++oooo+: + `/++++/+++++++: + `/++++++++++++++: + `/+++o$2oooooooo$1oooo/` + ./$2ooosssso++osssssso$1+` +$2 .oossssso-````/ossssss+` + -osssssso. :ssssssso. + :osssssss/ osssso+++. + /ossssssss/ +ssssooo/- + `/ossssso+/:- -:/+osssso+- + `+sso+:-` `.-/+oso: +`++:. `-/+/ +.` `/ \ No newline at end of file diff --git a/src/logo/ascii/arch_small.txt b/src/logo/ascii/arch_small.txt new file mode 100644 index 000000000..3688e2471 --- /dev/null +++ b/src/logo/ascii/arch_small.txt @@ -0,0 +1,7 @@ + /\ + / \ + / \ + / \ + / ,, \ + / | | \ +/_-'' ''-_\ \ No newline at end of file diff --git a/src/logo/ascii/arco.txt b/src/logo/ascii/arco.txt new file mode 100644 index 000000000..d24c3ca38 --- /dev/null +++ b/src/logo/ascii/arco.txt @@ -0,0 +1,20 @@ + /- + ooo: + yoooo/ + yooooooo + yooooooooo + yooooooooooo + .yooooooooooooo + .oooooooooooooooo + .oooooooarcoooooooo + .ooooooooo-oooooooooo + .ooooooooo- oooooooooo + :ooooooooo. :ooooooooo + :ooooooooo. :ooooooooo + :oooarcooo .oooarcooo + :ooooooooy .ooooooooo + $1:ooooooooo $2/ooooooooooooooooooo + $1:ooooooooo $2.-ooooooooooooooooo. + $1ooooooooo- $2-ooooooooooooo. + $1ooooooooo- $2.-oooooooooo. +$1ooooooooo. $2-ooooooooo \ No newline at end of file diff --git a/src/logo/ascii/artix.txt b/src/logo/ascii/artix.txt new file mode 100644 index 000000000..a1e26a804 --- /dev/null +++ b/src/logo/ascii/artix.txt @@ -0,0 +1,20 @@ + ' + 'o' + 'ooo' + 'ooxoo' + 'ooxxxoo' + 'oookkxxoo' + 'oiioxkkxxoo' + ':;:iiiioxxxoo' + `'.;::ioxxoo' + '-. `':;jiooo' + 'oooio-.. `'i:io' + 'ooooxxxxoio:,. `'-;' + 'ooooxxxxxkkxoooIi:-. `' + 'ooooxxxxxkkkkxoiiiiiji' + 'ooooxxxxxkxxoiiii:'` .i' + 'ooooxxxxxoi:::'` .;ioxo' + 'ooooxooi::'` .:iiixkxxo' + 'ooooi:'` `'';ioxxo' + 'i:'` '':io' +'` `' \ No newline at end of file diff --git a/src/logo/ascii/artix_small.txt b/src/logo/ascii/artix_small.txt new file mode 100644 index 000000000..7e016d82c --- /dev/null +++ b/src/logo/ascii/artix_small.txt @@ -0,0 +1,7 @@ + /\ + / \ + /`'.,\ + / ', + / ,`\ + / ,.'`. \ +/.,'` `'.\ \ No newline at end of file diff --git a/src/logo/ascii/asahi.txt b/src/logo/ascii/asahi.txt new file mode 100644 index 000000000..005f05613 --- /dev/null +++ b/src/logo/ascii/asahi.txt @@ -0,0 +1,18 @@ +$1 ## $2** + $1*####$2****. + $1###$2, + $3...,$1/#$3,,,.. + $3/*,,,,,,,,$1*$3,........$4,, + $3,((((((//*,,,,,,,,$4,...... + $3(((((((((((((($5%..$4.......... + $3,((((((((((((((($5@@($4............ + $3((((((((((((((((($5@@@@/$4............ + $3,(((((((((((((((((($5@@@@@&*$4........... + $3(((((((((((((((((((($5@@@@@@@&$4,........... +$3((((((((((((((((((((($5@@@$6&%&$5@@@%$4,.......... + $3/((((((((((((((((((($5@@@$6&%%&$5@@@@($4........ + $3,(((((((((((((((($5@@@$6&&$5@@&/&@@@/$4.. + $3/(((((((((((($5@@@@@@/$4.../&& + $3.((((((((($5@@@@($4.... + $3/((((($5@@#$4... + $3.(($4&, \ No newline at end of file diff --git a/src/logo/ascii/bedrock.txt b/src/logo/ascii/bedrock.txt new file mode 100644 index 000000000..6bbd44a1e --- /dev/null +++ b/src/logo/ascii/bedrock.txt @@ -0,0 +1,17 @@ +-------------------------------------- +-------------------------------------- +-------------------------------------- +---$2\\\\\\\\\\\\$1----------------------- +----$2\\\ \\\$1---------------------- +-----$2\\\ \\\$1--------------------- +------$2\\\ \\\\\\\\\\\\\\\\\$1------ +-------$2\\\ \\\$1----- +--------$2\\\ \\\$1---- +---------$2\\\ ______ \\\$1--- +----------$2\\\ ///$1--- +-----------$2\\\ ///$1---- +------------$2\\\ ///$1----- +-------------$2\\\////////////////$1------ +-------------------------------------- +-------------------------------------- +-------------------------------------- \ No newline at end of file diff --git a/src/logo/ascii/bsd.txt b/src/logo/ascii/bsd.txt new file mode 100644 index 000000000..adf0b8579 --- /dev/null +++ b/src/logo/ascii/bsd.txt @@ -0,0 +1,19 @@ +$1 , , + /( )` + \ \___ / | + /- _ `-/ ' + ($2/\/ \ $1\ /\ + $2/ / | ` $1\ + $3O O $2) $1/ | + $2`-^--'$1`< ' + (_.) _ ) / + `.___/` / + `-----' / +$4<----. __ / __ \ +$4<----|====$1O)))$4==$1) \) /$4====| +<----' $1`--' `.__,' \ + | | + \ / /\ + $5______$1( (_ / \______/ + $5,' ,-----' | + `--{__________) diff --git a/src/logo/ascii/cachyos.txt b/src/logo/ascii/cachyos.txt new file mode 100644 index 000000000..10c1e424d --- /dev/null +++ b/src/logo/ascii/cachyos.txt @@ -0,0 +1,22 @@ + $3.$1-------------------------: + .$2+=$1========================. + :$2++$1===$2++===$1===============- :$2++$1- + :$2*++$1====$2+++++==$1===========- .==: + -$2*+++$1=====$2+***++=$1=========: + =$2*++++=$1=======------------: + =$2*+++++=$1====- $3...$1 + .$2+*+++++$1=-===: .$2=+++=$1: + :$2++++$1=====-==: -***$2**$1+ + :$2++=$1=======-=. .=+**+$3.$1 +.$2+$1==========-. $3.$1 + :$2+++++++$1====- $3.$1--==-$3.$1 + :$2++$1==========. $3:$2+++++++$1$3: + $1.-===========. =*****+*+ + $1.-===========: .+*****+: + $1-=======$2++++$1:::::::::::::::::::::::::-: $3.$1---: + :======$2++++$1====$2+++******************=. + $1:=====$2+++$1==========$2++++++++++++++*- + $1.====$2++$1==============$2++++++++++*- + $1.===$2+$1==================$2+++++++: + $1.-=======================$2+++: + $3.......................... \ No newline at end of file diff --git a/src/logo/ascii/cachyos_small.txt b/src/logo/ascii/cachyos_small.txt new file mode 100644 index 000000000..f3ea5d87c --- /dev/null +++ b/src/logo/ascii/cachyos_small.txt @@ -0,0 +1,8 @@ + /''''''''''''/ + /''''''''''''/ + /''''''/ +/''''''/ +\......\ + \......\ + \.............../ + \............./ diff --git a/src/logo/ascii/celos.txt b/src/logo/ascii/celos.txt new file mode 100644 index 000000000..b5b766155 --- /dev/null +++ b/src/logo/ascii/celos.txt @@ -0,0 +1,15 @@ + `-:/++++/:-` + -/syyyyyyyyyyyyy+- + :ssssyyyyyyyyyyyyyyyy/ + .osy$2mmmmmmmmmmmmmmmNNNNNmmhy+ + $1.sssshhhhhhhddddddddddddddds- + $1`osssssssyyyyyyyyyyyyyyyyyyhy` + $1:ssssssyyyyyyyyyyyyyyyyyyyyhh/ +$2sMMMMMMMMMMMMMMMMMMMMMMMh$1yyyyyyhho + :sssssssyyyyyyyyyyyyyyyyyyyhh/ + `ssssssssyyyyyyyyyyyyyyyyyyhy. + -sssssyddddddddddddddddddddy + -ssss$2hmmmmmmmmmmmmmmmmmmmyssss- + $1`/ssssyyyyyyyyyyyyyyyy+` + $1`:osyyyyyyyyyyyyys/` + $1`.:/+ooooo+:-` \ No newline at end of file diff --git a/src/logo/ascii/centos.txt b/src/logo/ascii/centos.txt new file mode 100644 index 000000000..be42a9de5 --- /dev/null +++ b/src/logo/ascii/centos.txt @@ -0,0 +1,19 @@ + .. + .PLTJ. + <><><><> + $2KKSSV' 4KKK $1LJ$4 KKKL.'VSSKK + $2KKV' 4KKKKK $1LJ$4 KKKKAL 'VKK + $2V' ' 'VKKKK $1LJ$4 KKKKV' ' 'V + $2.4MA.' 'VKK $1LJ$4 KKV' '.4Mb. + $4. $2KKKKKA.' 'V $1LJ$4 V' '.4KKKKK $3. + $4.4D $2KKKKKKKA.'' $1LJ$4 ''.4KKKKKKK $3FA. +$4 + '$4VD $3KKKKKKKK'.. $2LJ $1..'KKKKKKKK $3FV + $4' $3VKKKKK'. .4 $2LJ $1K. .'KKKKKV $3' + $3'VK'. .4KK $2LJ $1KKA. .'KV' + $3A. . .4KKKK $2LJ $1KKKKA. . .4 + $3KKA. 'KKKKK $2LJ $1KKKKK' .4KK + $3KKSSA. VKKK $2LJ $1KKKV .4SSKK + $2<><><><> + $2'MKKM' + $2'' \ No newline at end of file diff --git a/src/logo/ascii/centos_small.txt b/src/logo/ascii/centos_small.txt new file mode 100644 index 000000000..52d8027a7 --- /dev/null +++ b/src/logo/ascii/centos_small.txt @@ -0,0 +1,7 @@ + $2____$1^$4____ + $2|\ $1|$4 /| + $2| \ $1|$4 / | +$4<---- $3----> + $3| / $2|$1 \ | + $3|/__$2|$1__\| + $2v \ No newline at end of file diff --git a/src/logo/ascii/crux.txt b/src/logo/ascii/crux.txt new file mode 100644 index 000000000..142bcbc50 --- /dev/null +++ b/src/logo/ascii/crux.txt @@ -0,0 +1,18 @@ + $1odddd + oddxkkkxxdoo + ddcoddxxxdoool + xdclodod olol + xoc xdd olol + xdc $2k00$1Okdlol + xxd$2kOKKKOkd$1ldd + xdco$2xOkdlo$1dldd + ddc:cl$2lll$1oooodo + odxxdd$3xkO000kx$1ooxdo + oxddx$30NMMMMMMWW0o$1dkkxo + oooxd$30WMMMMMMMMMW0o$1dxkx +docldkXW$3MMMMMMMWWN$1Odolco +xx$2dx$1kxxOKN$3WMMWN$10xdoxo::c +$2xOkkO$10oo$3odOW$2WW$1XkdodOxc:l +$2dkkkxkkk$3OKX$2NNNX0Oxx$1xc:cd + $2odxxdx$3xllo$2dddooxx$1dc:ldo + $2lodd$1dolccc$2ccox$1xoloo diff --git a/src/logo/ascii/crystal.txt b/src/logo/ascii/crystal.txt new file mode 100644 index 000000000..85cfd2523 --- /dev/null +++ b/src/logo/ascii/crystal.txt @@ -0,0 +1,20 @@ + mysssym + mysssym + mysssym + mysssym + mysssyd + mysssyd N + mysssyd mysym + mysssyd dysssym + mysssyd dysssym +mysssyd dysssym +mysssyd dysssym + mysssyd dysssym + mysssyd dysssym + mysym dysssym + N dysssym + dysssym + dysssym + dysssym + dysssym + dysssym \ No newline at end of file diff --git a/src/logo/ascii/debian.txt b/src/logo/ascii/debian.txt new file mode 100644 index 000000000..6c88f55c8 --- /dev/null +++ b/src/logo/ascii/debian.txt @@ -0,0 +1,17 @@ + $2_,met$$$$$$$$$$gg. + ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P. + ,g$$$$P" """Y$$$$.". + ,$$$$P' `$$$$$$. +',$$$$P ,ggs. `$$$$b: +`d$$$$' ,$P"' $1.$2 $$$$$$ + $$$$P d$' $1,$2 $$$$$$P + $$$$: $$. $1-$2 ,d$$$$' + $$$$; Y$b._ _,d$P' + Y$$$$. $1`.$2`"Y$$$$$$$$P"' + `$$$$b $1"-.__ + $2`Y$$$$ + `Y$$$$. + `$$$$b. + `Y$$$$b. + `"Y$$b._ + `""" \ No newline at end of file diff --git a/src/logo/ascii/debian_small.txt b/src/logo/ascii/debian_small.txt new file mode 100644 index 000000000..7db04d84b --- /dev/null +++ b/src/logo/ascii/debian_small.txt @@ -0,0 +1,6 @@ + _____ + / __ \ +| / | +| \___- +-_ + --_ \ No newline at end of file diff --git a/src/logo/ascii/deepin.txt b/src/logo/ascii/deepin.txt new file mode 100644 index 000000000..d79eaa42f --- /dev/null +++ b/src/logo/ascii/deepin.txt @@ -0,0 +1,18 @@ +$1 ............ + .';;;;;. .,;,. + .,;;;;;;;. ';;;;;;;. + .;::::::::' .,::;;,''''',. + ,'.:::::::: .;;'. '; + ;' 'cccccc, ,' :: '.. .: + ,, :ccccc. ;: .c, '' :. ,; +.l. cllll' ., .lc :; .l' l. +.c :lllc ;cl: .l' .ll. :' +.l 'looc. . ,o: 'oo' c, +.o. .:ool::coc' .ooo' o. + :: ..... .;dddo ;c + l:... .';lddddo. ,o + lxxxxxdoolllodxxxxxxxxxc :l + ,dxxxxxxxxxxxxxxxxxxl. 'o, + ,dkkkkkkkkkkkkko;. .;o; + .;okkkkkdl;. .,cl:. + .,:cccccccc:,. \ No newline at end of file diff --git a/src/logo/ascii/devuan.txt b/src/logo/ascii/devuan.txt new file mode 100644 index 000000000..d400acec8 --- /dev/null +++ b/src/logo/ascii/devuan.txt @@ -0,0 +1,15 @@ + ..,,;;;::;,.. + `':ddd;:,. + `'dPPd:,. + `:b$$b`. + 'P$$$d` + .$$$$$` + ;$$$$$P + .:P$$$$$$` + .,:b$$$$$$$;' + .,:dP$$$$$$$$b:' + .,:;db$$$$$$$$$$Pd'` + ,db$$$$$$$$$$$$$$b:'` +:$$$$$$$$$$$$b:'` + `$$$$$bd:''` + `'''` diff --git a/src/logo/ascii/devuan_small.txt b/src/logo/ascii/devuan_small.txt new file mode 100644 index 000000000..c56ceae8b --- /dev/null +++ b/src/logo/ascii/devuan_small.txt @@ -0,0 +1,7 @@ + ..:::. + ..-==- + .+#: + =@@ + :+%@#: +.:=+#@@%*: +#@@@#=: diff --git a/src/logo/ascii/endeavour.txt b/src/logo/ascii/endeavour.txt new file mode 100644 index 000000000..2bdf27dd9 --- /dev/null +++ b/src/logo/ascii/endeavour.txt @@ -0,0 +1,15 @@ + $2./$1o$3. + $2./$1sssso$3- + $2`:$1osssssss+$3- + $2`:+$1sssssssssso$3/. + $2`-/o$1ssssssssssssso$3/. + $2`-/+$1sssssssssssssssso$3+:` + $2`-:/+$1sssssssssssssssssso$3+/. + $2`.://o$1sssssssssssssssssssso$3++- + $2.://+$1ssssssssssssssssssssssso$3++: + $2.:///o$1ssssssssssssssssssssssssso$3++: + $2`:////$1ssssssssssssssssssssssssssso$3+++. +$2`-////+$1ssssssssssssssssssssssssssso$3++++- + $2`..-+$1oosssssssssssssssssssssssso$3+++++/` + $3./++++++++++++++++++++++++++++++/:. + `:::::::::::::::::::::::::------`` \ No newline at end of file diff --git a/src/logo/ascii/enso.txt b/src/logo/ascii/enso.txt new file mode 100644 index 000000000..5177215b0 --- /dev/null +++ b/src/logo/ascii/enso.txt @@ -0,0 +1,19 @@ + .:--==--:. + :=*#############*+-. + .+##################*##*: + .*##########+==-==++*####*##- + =########=: .-+**#***. + *#######- ++*#**. + +######+ -*+#** + :######* .*+**= + *######: --#*# + ####### +++#. + #######. ++=*. + *######+ .-+*+ + :#######- -:*+: + =#######*. :.*+- + +########*- :*=- + =###########+=: =+=: + .+#############. .-==: + .=###########= ..:--:. + .-+######+ diff --git a/src/logo/ascii/exherbo.txt b/src/logo/ascii/exherbo.txt new file mode 100644 index 000000000..0d7ed1bd4 --- /dev/null +++ b/src/logo/ascii/exherbo.txt @@ -0,0 +1,22 @@ +$2 , +OXo. +NXdX0: .cok0KXNNXXK0ko:. +KX '0XdKMMK;.xMMMk, .0MMMMMXx; ... +'NO..xWkMMx kMMM cMMMMMX,NMWOxOXd. + cNMk NK .oXM. OMMMMO. 0MMNo kW. + lMc o: ., .oKNk; ;NMMWlxW' + ;Mc .. .,,' .0M$1g;$2WMN'dWMMMMMMO + XX ,WMMMMW. cM$1cfli$2WMKlo. .kMk +.Mo .WM$1GD$2MW. XM$1WO0$2MMk oMl +,M: ,XMMWx::,''oOK0x; NM. +'Ml ,kNKOxxxxxkkO0XXKOd:. oMk + NK .0Nxc$3:::::::::::::::$2fkKNk, .MW + ,Mo .NXc$3::$2qXWXb$3::::::::::$2oo$3::$2lNK. .MW + ;Wo oMd$3:::$2oNMNP$3::::::::$2oWMMMx$3:$2c0M; lMO + 'NO;W0c$3:::::::::::::::$2dMMMMO$3::$2lMk .WM' + xWONXdc$3::::::::::::::$2oOOo$3::$2lXN. ,WMd + 'KWWNXXK0Okxxo,$3:::::::$2,lkKNo xMMO + :XMNxl,';:lodxkOO000Oxc. .oWMMo + 'dXMMXkl;,. .,o0MMNo' + ':d0XWMMMMWNNNNMMMNOl' + ':okKXWNKkl' diff --git a/src/logo/ascii/fedora.txt b/src/logo/ascii/fedora.txt new file mode 100644 index 000000000..f0cfe76a0 --- /dev/null +++ b/src/logo/ascii/fedora.txt @@ -0,0 +1,19 @@ + .',;::::;,'. + .';:cccccccccccc:;,. + .;cccccccccccccccccccccc;. + .:cccccccccccccccccccccccccc:. + .;ccccccccccccc;$2.:dddl:.$1;ccccccc;. + .:ccccccccccccc;$2OWMKOOXMWd$1;ccccccc:. +.:ccccccccccccc;$2KMMc$1;cc;$2xMMc$1;ccccccc:. +,cccccccccccccc;$2MMM.$1;cc;$2;WW:$1;cccccccc, +:cccccccccccccc;$2MMM.$1;cccccccccccccccc: +:ccccccc;$2oxOOOo$1;$2MMM000k.$1;cccccccccccc: +cccccc;$20MMKxdd:$1;$2MMMkddc.$1;cccccccccccc; +ccccc;$2XMO'$1;cccc;$2MMM.$1;cccccccccccccccc' +ccccc;$2MMo$1;ccccc;$2MMW.$1;ccccccccccccccc; +ccccc;$20MNc.$1ccc$2.xMMd$1;ccccccccccccccc; +cccccc;$2dNMWXXXWM0:$1;cccccccccccccc:, +cccccccc;$2.:odl:.$1;cccccccccccccc:,. +ccccccccccccccccccccccccccccc:'. +:ccccccccccccccccccccccc:;,.. + ':cccccccccccccccc::;,. \ No newline at end of file diff --git a/src/logo/ascii/fedora_old.txt b/src/logo/ascii/fedora_old.txt new file mode 100644 index 000000000..b943ce9a2 --- /dev/null +++ b/src/logo/ascii/fedora_old.txt @@ -0,0 +1,17 @@ + /:-------------:\ + :-------------------:: + :-----------$2/shhOHbmp$1---:\ + /-----------$2omMMMNNNMMD$1 ---: + :-----------$2sMMMMNMNMP$1. ---: + :-----------$2:MMMdP$1------- ---\ +,------------$2:MMMd$1-------- ---: +:------------$2:MMMd$1------- .---: +:---- $2oNMMMMMMMMMNho$1 .----: +:-- .$2+shhhMMMmhhy++$1 .------/ +:- -------$2:MMMd$1--------------: +:- --------$2/MMMd$1-------------; +:- ------$2/hMMMy$1------------: +:--$2 :dMNdhhdNMMNo$1------------; +:---$2:sdNMMMMNds:$1------------: +:------$2:://:$1-------------:: +:---------------------:// \ No newline at end of file diff --git a/src/logo/ascii/fedora_small.txt b/src/logo/ascii/fedora_small.txt new file mode 100644 index 000000000..0220cc530 --- /dev/null +++ b/src/logo/ascii/fedora_small.txt @@ -0,0 +1,9 @@ + ,'''''. + | ,. | + | | '_' + ,....| |.. +.' ,_;| ..' +| | | | +| ',_,' | + '. ,' + ''''' \ No newline at end of file diff --git a/src/logo/ascii/freebsd.txt b/src/logo/ascii/freebsd.txt new file mode 100644 index 000000000..8526f4202 --- /dev/null +++ b/src/logo/ascii/freebsd.txt @@ -0,0 +1,15 @@ +``` $2` + $1` `.....---...$2....--.``` -/ + $1+o .--` $2/y:` +. + $1yo`:. $2:o `+- + $1y/ $2-/` -o/ + $1.- $2::/sy+:. + $1/ $2`-- / + $1`: $2:` + $1`: $2:` + $1/ $2/ + $1.- $2-. + $1-- $2-. + $1`:` $2`:` + .-- `--. + .---.....----. \ No newline at end of file diff --git a/src/logo/ascii/freebsd_small.txt b/src/logo/ascii/freebsd_small.txt new file mode 100644 index 000000000..ee345f892 --- /dev/null +++ b/src/logo/ascii/freebsd_small.txt @@ -0,0 +1,6 @@ +$1/\,-'''''-,/\ +\_) (_/ +| | +| | + ; ; + '-_____-' \ No newline at end of file diff --git a/src/logo/ascii/garuda.txt b/src/logo/ascii/garuda.txt new file mode 100644 index 000000000..2234a61dd --- /dev/null +++ b/src/logo/ascii/garuda.txt @@ -0,0 +1,18 @@ + .%;888:8898898: + x;XxXB%89b8:b8%b88: + .8Xxd 8X:. + .8Xx; 8x:. + .tt8x .d x88; + .@8x8; .db: xx@; + ,tSXX° .bbbbbbbbbbbbbbbbbbbB8x@; + .SXxx bBBBBBBBBBBBBBBBBBBBbSBX8; + ,888S pd! +8X88/ q +8X88/ +GBB. + x%88 d888@8@X@X@X88X@@XX@@X@8@X. + dxXd dB8b8b8B8B08bB88b998888b88x. + dxx8o .@@;. + dx88 .t@x. + d:SS@8ba89aa67a853Sxxad. + .d988999889889899dd. \ No newline at end of file diff --git a/src/logo/ascii/garuda_small.txt b/src/logo/ascii/garuda_small.txt new file mode 100644 index 000000000..7716d673e --- /dev/null +++ b/src/logo/ascii/garuda_small.txt @@ -0,0 +1,5 @@ + .----. + .' , '. + .' '-----| +'. -----, + '.____.' \ No newline at end of file diff --git a/src/logo/ascii/gentoo.txt b/src/logo/ascii/gentoo.txt new file mode 100644 index 000000000..a90dd3310 --- /dev/null +++ b/src/logo/ascii/gentoo.txt @@ -0,0 +1,18 @@ + -/oyddmdhs+:. + -o$2dNMMMMMMMMNNmhy+$1-` + -y$2NMMMMMMMMMMMNNNmmdhy$1+- + `o$2mMMMMMMMMMMMMNmdmmmmddhhy$1/` + om$2MMMMMMMMMMMN$1hhyyyo$2hmdddhhhd$1o` +.y$2dMMMMMMMMMMd$1hs++so/s$2mdddhhhhdm$1+` + oy$2hdmNMMMMMMMN$1dyooy$2dmddddhhhhyhN$1d. + :o$2yhhdNNMMMMMMMNNNmmdddhhhhhyym$1Mh + .:$2+sydNMMMMMNNNmmmdddhhhhhhmM$1my + /m$2MMMMMMNNNmmmdddhhhhhmMNh$1s: + `o$2NMMMMMMMNNNmmmddddhhdmMNhs$1+` + `s$2NMMMMMMMMNNNmmmdddddmNMmhs$1/. + /N$2MMMMMMMMNNNNmmmdddmNMNdso$1:` ++M$2MMMMMMNNNNNmmmmdmNMNdso$1/- +yM$2MNNNNNNNmmmmmNNMmhs+/$1-` +/h$2MMNNNNNNNNMNdhs++/$1-` +`/$2ohdmmddhys+++/:$1.` + `-//////:--. \ No newline at end of file diff --git a/src/logo/ascii/gentoo_small.txt b/src/logo/ascii/gentoo_small.txt new file mode 100644 index 000000000..5c471a7a5 --- /dev/null +++ b/src/logo/ascii/gentoo_small.txt @@ -0,0 +1,7 @@ + _-----_ +( \ +\ 0 \ + $2\ ) + / _/ +( _- +\____- \ No newline at end of file diff --git a/src/logo/ascii/ghostbsd.txt b/src/logo/ascii/ghostbsd.txt new file mode 100644 index 000000000..f77302680 --- /dev/null +++ b/src/logo/ascii/ghostbsd.txt @@ -0,0 +1,13 @@ + ,gggggg. + ,agg9* .g) + .agg* ._.,gg* + ,gga* (ggg*' + ,ga* ,ga* + ,ga' .ag* + ,ga' .agga' + 9g' .agg'g*,a + 'gggg*',gga' + .gg*' + .gga* + .gga* + (ga* diff --git a/src/logo/ascii/gnome.txt b/src/logo/ascii/gnome.txt new file mode 100644 index 000000000..71e7b21b1 --- /dev/null +++ b/src/logo/ascii/gnome.txt @@ -0,0 +1,21 @@ + ,@@@@@@@@, + @@@@@@ @@@@@@@@@@@@ + ,@@. @@@@@@@ *@@@@@@@@@@@@ + @@@@@% @@@@@@( @@@@@@@@@@@& + @@@@@@ @@@@* @@@@@@@@@# +@@@@* @@@@, *@@@@@% +@@@@@. + @@@@# @@@@@@@@@@@@@@@@ + ,@@@@@@@@@@@@@@@@@@@@@@@, + ,@@@@@@@@@@@@@@@@@@@@@@@@@@& + .@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@( + @@@@@@@@@@@@@@@@@@@@% + @@@@@@@@@@@@@@@@ + @@@@@@@@@@@@* @@@@@@@@/ + &@@@@@@@@@@ @@@@@@@@@* + @@@@@@@@@@@, @@@@@@@@@* + ,@@@@@@@@@@@@@@@@@@@@& + &@@@@@@@@@@@@@@ + ... \ No newline at end of file diff --git a/src/logo/ascii/gnu.txt b/src/logo/ascii/gnu.txt new file mode 100644 index 000000000..0b9c3e249 --- /dev/null +++ b/src/logo/ascii/gnu.txt @@ -0,0 +1,18 @@ + _-`````-, ,- '- . + .' .- - | | - -. `. + /.' / `. \ +:/ : _... ..._ `` : +:: : /._ .`:'_.._\. || : +:: `._ ./ ,` : \ . _.'' . +`:. / | -. \-. \\_ / + \:._ _/ .' .@) \@) ` `\ ,.' + _/,--' .- .\,-.`--`. + ,'/'' (( \ ` ) + /'/' \ `-' ( + '/'' `._,-----' + ''/' .,---' + ''/' ;: + ''/'' ''/ + ''/''/'' + '/'/' + `; \ No newline at end of file diff --git a/src/logo/ascii/haiku.txt b/src/logo/ascii/haiku.txt new file mode 100644 index 000000000..36b432aa6 --- /dev/null +++ b/src/logo/ascii/haiku.txt @@ -0,0 +1,12 @@ +$3 MMMM MMMM + MMMM MMMM + MMMM MMMM + MMMM MMMM + MMMM$4 .ciO| /YMMMMM*" +$3 MMMM$4 .cOMMMMM|/MMMMM/` + , ,iMM|/MMMMMMMMMMMMMMM* + `*.__,-cMMMMMMMMMMMMMMMMM/`$3.MMM + MM$4MMMMMMM/`:MMM/ $3MMMM + MMMM MMMM + MMMM MMMM + """" """" \ No newline at end of file diff --git a/src/logo/ascii/haiku_small.txt b/src/logo/ascii/haiku_small.txt new file mode 100644 index 000000000..595c3225d --- /dev/null +++ b/src/logo/ascii/haiku_small.txt @@ -0,0 +1,8 @@ + ,^, + / \\ +*--_ ; ; _--* +\\ '" "' / + '. .' +.-'" "'-. + '-.__. .__.-' + |_| \ No newline at end of file diff --git a/src/logo/ascii/kde.txt b/src/logo/ascii/kde.txt new file mode 100644 index 000000000..716339e21 --- /dev/null +++ b/src/logo/ascii/kde.txt @@ -0,0 +1,19 @@ + `..---+/---..` + `---.`` `` `.---.` + .--.` `` `-:-. + `:/: `.----//----.` :/- + .:. `---` `--.` .:` + .:` `--` .:- `:. + `/ `:. `.-::-.` -:` `/` + /. /. `:++++++++:` .: .: +`/ .: `+++++++++++/ /` `+` +/+` -- .++++++++++++` :. .+: +`/ .: `+++++++++++/ /` `+` + /` /. `:++++++++:` .: .: + ./ `:. `.:::-.` -:` `/` + .:` `--` .:- `:. + .:. `---` `--.` .:` + `:/: `.----//----.` :/- + .-:.` `` `-:-. + `---.`` `` `.---.` + `..---+/---..` \ No newline at end of file diff --git a/src/logo/ascii/kiss.txt b/src/logo/ascii/kiss.txt new file mode 100644 index 000000000..b9d7cad31 --- /dev/null +++ b/src/logo/ascii/kiss.txt @@ -0,0 +1,7 @@ + $3 ___ + ($2.· $3| + ($1<> $3| + / $2__$3 \ + ( $1/ \ $3/| +$1_$3/\ $2__)$3/$1_$3) +$1\/$3-____$1\/$2 diff --git a/src/logo/ascii/kubuntu.txt b/src/logo/ascii/kubuntu.txt new file mode 100644 index 000000000..d19bca23e --- /dev/null +++ b/src/logo/ascii/kubuntu.txt @@ -0,0 +1,20 @@ +$1 `.:/ossyyyysso/:. + .:oyyyyyyyyyyyyyyyyyyo:` + -oyyyyyyyo$2dMMy$1yyyyyyysyyyyo- + -syyyyyyyyyy$2dMMy$1oyyyy$2dmMMy$1yyyys- + oyyys$2dMy$1syyyy$2dMMMMMMMMMMMMMy$1yyyyyyo + `oyyyy$2dMMMMy$1syysoooooo$2dMMMMy$1yyyyyyyyo` + oyyyyyy$2dMMMMy$1yyyyyyyyyyys$2dMMy$1sssssyyyo +-yyyyyyyy$2dMy$1syyyyyyyyyyyyyys$2dMMMMMy$1syyy- +oyyyysoo$2dMy$1yyyyyyyyyyyyyyyyyy$2dMMMMy$1syyyo +yyys$2dMMMMMy$1yyyyyyyyyyyyyyyyyysosyyyyyyyy +yyys$2dMMMMMy$1yyyyyyyyyyyyyyyyyyyyyyyyyyyyy +oyyyyysos$2dy$1yyyyyyyyyyyyyyyyyy$2dMMMMy$1syyyo +-yyyyyyyy$2dMy$1syyyyyyyyyyyyyys$2dMMMMMy$1syyy- + oyyyyyy$2dMMMy$1syyyyyyyyyyys$2dMMy$1oyyyoyyyo + `oyyyy$2dMMMy$1syyyoooooo$2dMMMMy$1oyyyyyyyyo + oyyysyyoyyyys$2dMMMMMMMMMMMy$1yyyyyyyo + -syyyyyyyyy$2dMMMy$1syyy$2dMMMy$1syyyys- + -oyyyyyyy$2dMMy$1yyyyyysosyyyyo- + ./oyyyyyyyyyyyyyyyyyyo/. + `.:/oosyyyysso/:.` \ No newline at end of file diff --git a/src/logo/ascii/langitketujuh.txt b/src/logo/ascii/langitketujuh.txt new file mode 100644 index 000000000..6b72d3f01 --- /dev/null +++ b/src/logo/ascii/langitketujuh.txt @@ -0,0 +1,11 @@ +$2. $1'7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7 +$2L7. $1'7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7 +$2L7L7L $17L7L7L7L7L7L7L7L7L7L7L7L7L7 +$2L7L7L7 $1L7L7L7 +$2L7L7L7 $1'L7L7L7L7L7L7L7L7L7L7 +$2L7L7L7 $1'L7L7L7L7L7L7L7L7 +$2L7L7L7 $1'L7L7L7L7L7L7 +$2L7L7L7 $1L7L7L7 +$2L7L7L7L7L7L7L7L7L7L7LL7L7L7. $1'7L7L7 +$2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L. $1'L7 +$2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7. $1' diff --git a/src/logo/ascii/linux.txt b/src/logo/ascii/linux.txt new file mode 100644 index 000000000..fc8a5b456 --- /dev/null +++ b/src/logo/ascii/linux.txt @@ -0,0 +1,12 @@ + $2##### + $2####### + $2##$1O$2#$1O$2## + $2#$3#####$2# + $2##$1##$3###$1##$2## + $2#$1##########$2## + $2#$1############$2## + $2#$1############$2### + $3##$2#$1###########$2##$3# +$3######$2#$1#######$2#$3###### +$3#######$2#$1#####$2#$3####### + $3#####$2#######$3##### \ No newline at end of file diff --git a/src/logo/ascii/linux_small.txt b/src/logo/ascii/linux_small.txt new file mode 100644 index 000000000..7446180b5 --- /dev/null +++ b/src/logo/ascii/linux_small.txt @@ -0,0 +1,7 @@ + $1___ + ($2.. $1\ + ($3<> $1| + /$2/ \ $1\ + ( $2| | $1/| +$3_$1/\ $2__)$1/$3_$1) +$3\/$1-____$3\/ diff --git a/src/logo/ascii/lmde.txt b/src/logo/ascii/lmde.txt new file mode 100644 index 000000000..9e45de835 --- /dev/null +++ b/src/logo/ascii/lmde.txt @@ -0,0 +1,17 @@ +$2 `.-::---.. +$1 .:++++ooooosssoo:. + .+o++::. `.:oos+. +$1 :oo:.` -+oo$2: +$1 $2`$1+o/` .$2::::::$1-. .++-$2` +$1$2`$1/s/ .yyyyyyyyyyo: +o-$2` +$1$2`$1so .ss ohyo` :s-$2: +$1$2`$1s/ .ss h m myy/ /s`$2` +$1`s: `oo s m Myy+-o:` +`oo :+sdoohyoydyso/. + :o. .:////////++: +$1 `/++ $2-:::::- +$1 $2`$1++- +$1 $2`$1/+- +$1 $2.$1+/. +$1 $2.$1:+-. + `--.`` \ No newline at end of file diff --git a/src/logo/ascii/macos.txt b/src/logo/ascii/macos.txt new file mode 100644 index 000000000..6ecf8840e --- /dev/null +++ b/src/logo/ascii/macos.txt @@ -0,0 +1,17 @@ + $1..' + ,xNMM. + .OMMMMo + lMM" + .;loddo:. .olloddol;. + cKMMMMMMMMMMNWMMMMMMMMMM0: + $2.KMMMMMMMMMMMMMMMMMMMMMMMWd. + XMMMMMMMMMMMMMMMMMMMMMMMX. +$3;MMMMMMMMMMMMMMMMMMMMMMMM: +:MMMMMMMMMMMMMMMMMMMMMMMM: +.MMMMMMMMMMMMMMMMMMMMMMMMX. + kMMMMMMMMMMMMMMMMMMMMMMMMWd. + $4'XMMMMMMMMMMMMMMMMMMMMMMMMMMk + 'XMMMMMMMMMMMMMMMMMMMMMMMMK. + $5kMMMMMMMMMMMMMMMMMMMMMMd + ;KMMMMMMMWXXWMMMMMMMk. + "cooc*" "*coo'" \ No newline at end of file diff --git a/src/logo/ascii/macos2.txt b/src/logo/ascii/macos2.txt new file mode 100644 index 000000000..af4248e11 --- /dev/null +++ b/src/logo/ascii/macos2.txt @@ -0,0 +1,17 @@ + $1..' + ,xN . + .O o + l " + .;loddo:. .olloddol;. + cK NW 0: + $2.K Wd. + X X. +$3; : +: : +. X. + k Wd. + $4'X k + 'X K. + $5k d + ;K WXXW k. + "cooc*" "*coo'" \ No newline at end of file diff --git a/src/logo/ascii/macos2_small.txt b/src/logo/ascii/macos2_small.txt new file mode 100644 index 000000000..bb108fda7 --- /dev/null +++ b/src/logo/ascii/macos2_small.txt @@ -0,0 +1,7 @@ +$1 .:' + __ :'__ +$2 .'` `-' ``. +$3: .-' +$4: : + : `-; +$5 `.__.-.__.' \ No newline at end of file diff --git a/src/logo/ascii/macos_small.txt b/src/logo/ascii/macos_small.txt new file mode 100644 index 000000000..2d90ee3e4 --- /dev/null +++ b/src/logo/ascii/macos_small.txt @@ -0,0 +1,7 @@ +$1 .:' + __ :'__ +$2 .'`__`-'__``. +$3:__________.-' +$4:_________: + :_________`-; +$5 `.__.-.__.' \ No newline at end of file diff --git a/src/logo/ascii/mandriva.txt b/src/logo/ascii/mandriva.txt new file mode 100644 index 000000000..635d1b1a6 --- /dev/null +++ b/src/logo/ascii/mandriva.txt @@ -0,0 +1,15 @@ +$2 `` + `-. +$1 ` $2.--- +$1 -/ $2-::--` +$1 `++ $2`----...```-:::::. +$1 `os. $2.::::::::::::::-``` ` ` +$1 +s+ $2.::::::::::::::::---...--` +$1-ss: $2`-::::::::::::::::-.``.`` +$1/ss- $2.::::::::::::-.`` ` +$1+ss: $2.::::::::::::- +$1/sso $2.::::::-::::::- +$1.sss/ $2-:::-.` .::::: +$1 /sss+. $2..`$1 `--` $2.::: +$1 -ossso+/:://+/-` $2.:` +$1 -/+ooo+/-. $2` \ No newline at end of file diff --git a/src/logo/ascii/manjaro.txt b/src/logo/ascii/manjaro.txt new file mode 100644 index 000000000..7f35123e2 --- /dev/null +++ b/src/logo/ascii/manjaro.txt @@ -0,0 +1,14 @@ +██████████████████ ████████ +██████████████████ ████████ +██████████████████ ████████ +██████████████████ ████████ +████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ +████████ ████████ ████████ \ No newline at end of file diff --git a/src/logo/ascii/manjaro_small.txt b/src/logo/ascii/manjaro_small.txt new file mode 100644 index 000000000..e6aceacdb --- /dev/null +++ b/src/logo/ascii/manjaro_small.txt @@ -0,0 +1,7 @@ +||||||||| |||| +||||||||| |||| +|||| |||| +|||| |||| |||| +|||| |||| |||| +|||| |||| |||| +|||| |||| |||| \ No newline at end of file diff --git a/src/logo/ascii/minix.txt b/src/logo/ascii/minix.txt new file mode 100644 index 000000000..da32a8eb0 --- /dev/null +++ b/src/logo/ascii/minix.txt @@ -0,0 +1,17 @@ +$2 -sdhyo+:-` -/syymm: + sdyooymmNNy. `` .smNmmdysNd + odyoso+syNNmysoyhhdhsoomNmm+/osdm/ + :hhy+-/syNNmddhddddddmNMNo:sdNd: + `smNNdNmmNmddddddddddmmmmmmmy` + `ohhhhdddddmmNNdmddNmNNmdddddmdh- + odNNNmdyo/:/-/hNddNy-`..-+ydNNNmd: + `+mNho:` smmd/ sNNh :dmms` -+ymmo. +-od/ -m$1mm$2mo -NN+ +m$1mm$2m- yms: ++sms -.` :so: .NN+ :os/ .-`mNh: +.-hyh+:////- -sNNd:` .--://ohNs- + `:hNNNNNNNMMd/sNMmhsdMMh/ymmNNNmmNNy/ + -+sNNNNMMNNNsmNMo: :NNmymNNNNMMMms: + //oydNMMMMydMMNysNMMmsMMMMMNyo/` + ../-yNMMy--/::/-.sMMmos+.` + -+oyhNsooo+omy/``` + `::ohdmds-` \ No newline at end of file diff --git a/src/logo/ascii/mint.txt b/src/logo/ascii/mint.txt new file mode 100644 index 000000000..ed7e6f4c6 --- /dev/null +++ b/src/logo/ascii/mint.txt @@ -0,0 +1,19 @@ + $2...-:::::-... + .-MMMMMMMMMMMMMMM-. + .-MMMM$1`..-:::::::-..`$2MMMM-. + .:MMMM$1.:MMMMMMMMMMMMMMM:.$2MMMM:. + -MMM$1-M---MMMMMMMMMMMMMMMMMMM.$2MMM- + `:MMM$1:MM` :MMMM:....::-...-MMMM:$2MMM:` + :MMM$1:MMM` :MM:` `` `` `:MMM:$2MMM: +.MMM$1.MMMM` :MM. -MM. .MM- `MMMM.$2MMM. +:MMM$1:MMMM` :MM. -MM- .MM: `MMMM-$2MMM: +:MMM$1:MMMM` :MM. -MM- .MM: `MMMM:$2MMM: +:MMM$1:MMMM` :MM. -MM- .MM: `MMMM-$2MMM: +.MMM$1.MMMM` :MM:--:MM:--:MM: `MMMM.$2MMM. + :MMM$1:MMM- `-MMMMMMMMMMMM-` -MMM-$2MMM: + :MMM$1:MMM:` `:MMM:$2MMM: + .MMM$1.MMMM:--------------:MMMM.$2MMM. + '-MMMM$1.-MMMMMMMMMMMMMMM-.$2MMMM-' + '.-MMMM$1``--:::::--``$2MMMM-.' + '-MMMMMMMMMMMMM-' + ``-:::::-`` \ No newline at end of file diff --git a/src/logo/ascii/mint_old.txt b/src/logo/ascii/mint_old.txt new file mode 100644 index 000000000..e94eca0c2 --- /dev/null +++ b/src/logo/ascii/mint_old.txt @@ -0,0 +1,16 @@ +MMMMMMMMMMMMMMMMMMMMMMMMMmds+. +MMm----::-://////////////oymNMd+` +MMd $2/++ $1-sNMd: +MMNso/` $2dMM `.::-. .-::.` $1.hMN: +ddddMMh $2dMM :hNMNMNhNMNMNh: $1`NMm + NMm $2dMM .NMN/-+MMM+-/NMN` $1dMM + NMm $2dMM -MMm `MMM dMM. $1dMM + NMm $2dMM -MMm `MMM dMM. $1dMM + NMm $2dMM .mmd `mmm yMM. $1dMM + NMm $2dMM` ..` ... ydm. $1dMM + hMM- $2+MMd/-------...-:sdds $1dMM + -NMm- $2:hNMNNNmdddddddddy/` $1dMM + -dMNs-$2``-::::-------.`` $1dMM + `/dMNmy+/:-------------:/yMMM + ./ydNMMMMMMMMMMMMMMMMMMMMM + .MMMMMMMMMMMMMMMMMMM \ No newline at end of file diff --git a/src/logo/ascii/mint_small.txt b/src/logo/ascii/mint_small.txt new file mode 100644 index 000000000..9d294e0df --- /dev/null +++ b/src/logo/ascii/mint_small.txt @@ -0,0 +1,7 @@ + __________ +|_ \ + | $2| _____ $1| + | $2| | | | $1| + | $2| | | | $1| + | $2\__$2___/ $1| + \_________/ \ No newline at end of file diff --git a/src/logo/ascii/msys2.txt b/src/logo/ascii/msys2.txt new file mode 100644 index 000000000..32a7ed32e --- /dev/null +++ b/src/logo/ascii/msys2.txt @@ -0,0 +1,25 @@ +$2 ... + 5GB###GJ. !YPGGGG + 7@@@@@@@B. :G@@@@@@@ + 7@@@@@@@@Y ~&@@@@@@@@$3YJYY5YY?L + $2!@@@@@@@@@@^ ^&@@@@@@@$3#PP555555PBY + $2~&@@@@@@@@@@? ^&@@@@@@$3#5YY5YYYYYYYY#7 + $2^&@@@@@@@@@@@B :#@@@@@@@$3G5BBYGPYYYYYY#J + $2^#@@@&J#@@@@@@@~ .B@@@@@@@@@@@P $3?#YYYYYPB. + $2:#@@@@7 G@@@@@@@J P@@@#!&@@@@@@G$3.GGYYYYGB^ + $2:#@@@@J Y@@@@@@@B 5@@@&:.&@@@@@@&$3BBYYY5B5. + $2:#@@@@Y !@@@@@@@@!Y@@@&~ .#@@@@@@$3GYYYYYBP JP~ + $2:#@@@@P :&@@@@@@@@@@@&~ B@@@@@$3#5YYYYYPGPGPGG + $2^#@@@@G. P@@@@@@@@@@@! P@@@@$3GYYYYYYYYYYYYBY + $2^#@@@@B: ^@@@@@@@@@@7 !@@@$3#GGGGGGGPPPP5GB: + $2!&@@@@B: Y@@@@@@@@? P@@@@@@@@@&? $3^PY: + $27&@@@@5. P@@@@@@? P@@@@@@@@@B + Y@@@&P! 5@@@@7 7G@@@@@&P~ +.JJ?~: ^JY~ ^!5J!^: + $1:@P5#B. #G 7&^ :@P5#B. + !&P^. ?@~ #P !&P^. + .?BG! #G5@~ .?BG! + :.B@. 7@@5 :.B@. + !PYY5Y :&@^ !PYY5Y + ~@Y + !5: \ No newline at end of file diff --git a/src/logo/ascii/netbsd.txt b/src/logo/ascii/netbsd.txt new file mode 100644 index 000000000..6308771de --- /dev/null +++ b/src/logo/ascii/netbsd.txt @@ -0,0 +1,17 @@ +$1 `-/oshdmNMNdhyo+:-` +$2y$1/s+:-`` `.-:+oydNMMMMNhs/-`` +$2-m+$1NMMMMMMMMMMMMMMMMMMMNdhmNMMMmdhs+/-` + $2-m+$1NMMMMMMMMMMMMMMMMMMMMmy+:` + $2-N/$1dMMMMMMMMMMMMMMMds:` + $2-N/$1hMMMMMMMMMmho:` + $2-N/$1-:/++/:.` +$2 :M+ + :Mo + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms + :Ms \ No newline at end of file diff --git a/src/logo/ascii/nixos.txt b/src/logo/ascii/nixos.txt new file mode 100644 index 000000000..7bbf9b63a --- /dev/null +++ b/src/logo/ascii/nixos.txt @@ -0,0 +1,20 @@ +$1 ▗▄▄▄ $2▗▄▄▄▄ ▄▄▄▖ +$1 ▜███▙ $2▜███▙ ▟███▛ +$1 ▜███▙ $2▜███▙▟███▛ +$1 ▜███▙ $2▜██████▛ +$1 ▟█████████████████▙ $2▜████▛ $1▟▙ +$1 ▟███████████████████▙ $2▜███▙ $1▟██▙ +$2 ▄▄▄▄▖ ▜███▙ $1▟███▛ +$2 ▟███▛ ▜██▛ $1▟███▛ +$2 ▟███▛ ▜▛ $1▟███▛ +$2▟███████████▛ $1▟██████████▙ +$2▜██████████▛ $1▟███████████▛ +$2 ▟███▛ $1▟▙ ▟███▛ +$2 ▟███▛ $1▟██▙ ▟███▛ +$2 ▟███▛ $1▜███▙ ▝▀▀▀▀ +$2 ▜██▛ $1▜███▙ $2▜██████████████████▛ +$2 ▜▛ $1▟████▙ $2▜████████████████▛ +$1 ▟██████▙ $2▜███▙ +$1 ▟███▛▜███▙ $2▜███▙ +$1 ▟███▛ ▜███▙ $2▜███▙ +$1 ▝▀▀▀ ▀▀▀▀▘ $2▀▀▀▘ \ No newline at end of file diff --git a/src/logo/ascii/nixos_old.txt b/src/logo/ascii/nixos_old.txt new file mode 100644 index 000000000..3b2670803 --- /dev/null +++ b/src/logo/ascii/nixos_old.txt @@ -0,0 +1,28 @@ +$1 ____ $2_______ ____ +$1 /####\ $2\######\ /####\ +$1 ######\ $2\######\ /#####/ +$1 \######\ $2\######\ /#####/ +$1 \######\ $2\######\/#####/ $1/\ +$1 \######\ $2\###########/ $1/##\ +$1 ________\######\______$2\#########/ $1/####\ +$1 /#######################$2\#######/ $1/###### +$1 /#########################$2\######\ $1/######/ +$1 /###########################$2\######\ $1/######/ +$1 ¯¯¯¯¯¯¯¯¯¯¯¯$2/######/$1¯¯¯¯¯¯¯¯¯$2\######$1/######/ +$2 /######/ $2\####$1/######/________ +$2 _____________/######/ $2\##$1/################\ +$2 /###################/ $2\$1/##################\ +$2 \##################/$1\ /###################/ +$2 \################/$1##\ /######/¯¯¯¯¯¯¯¯¯¯¯¯¯ +$2 ¯¯¯¯¯¯¯¯/######/$1####\ /######/ +$2 /######/$1######\$2_________$1/######/$2____________ +$2 /######/ $1\######\$2###########################/ +$2 /######/ $1\######\$2#########################/ +$2 ######/ $1/#######\$2#######################/ +$2 \####/ $1/#########\$2¯¯¯¯¯¯\######\¯¯¯¯¯¯¯¯ +$2 \##/ $1/###########\$2 \######\ +$2 \/ $1/#####/\######\$2 \######\ +$1 $1/#####/ \######\$2 \######\ +$1 $1/#####/ \######\$2 \###### +$1 $1\####/ \######\$2 \####/ +$1 $1¯¯¯¯ ¯¯¯¯¯¯¯$2 ¯¯¯¯ \ No newline at end of file diff --git a/src/logo/ascii/nixos_small.txt b/src/logo/ascii/nixos_small.txt new file mode 100644 index 000000000..b7b3367dd --- /dev/null +++ b/src/logo/ascii/nixos_small.txt @@ -0,0 +1,7 @@ +$1 \\ \\ // + ==\\__\\/ // + // \\// +==// //== + //\\___// +// /\\ \\== + // \\ \\ \ No newline at end of file diff --git a/src/logo/ascii/nobara.txt b/src/logo/ascii/nobara.txt new file mode 100644 index 000000000..dd05b8bb7 --- /dev/null +++ b/src/logo/ascii/nobara.txt @@ -0,0 +1,17 @@ +⢀⣤⣴⣶⣶⣶⣦⣤⡀⠀⣀⣠⣤⣴⣶⣶⣶⣶⣶⣶⣶⣶⣤⣤⣀⡀ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⡀ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠁⠀⠀⠉⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⢀⣀⣀⡀⠀⠀⠀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⢠⣾⣿⣿⣿⣿⣷⡄⠀⠀⠀⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⣀⣀⣬⣽⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠈⠻⢿⣿⣿⡿⠟⠁⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⣤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ +⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠉⠉⠛⠛⢿⣿⣿⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿ +⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⠟⠁ + ⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁ diff --git a/src/logo/ascii/nomadbsd.txt b/src/logo/ascii/nomadbsd.txt new file mode 100644 index 000000000..e30917e7a --- /dev/null +++ b/src/logo/ascii/nomadbsd.txt @@ -0,0 +1,13 @@ + _======__ + (===============\\ + (===================\\ + _ _---__ + (= ====- + (= ====== + (== ====== + (== ====== + (==\\ \\=-_ _=/ /====/ + (==\\ \\========/ /====/ /====-_ + (==\\ \\=====/ /==/ /===-- +/================/ /===- +\\===========/ \ No newline at end of file diff --git a/src/logo/ascii/openbsd.txt b/src/logo/ascii/openbsd.txt new file mode 100644 index 000000000..3a09b3af0 --- /dev/null +++ b/src/logo/ascii/openbsd.txt @@ -0,0 +1,23 @@ +$3 _ + (_) +$1 | . +$1 . |L /| . $3 _ +$1 _ . |\ _| \--+._/| . $3(_) +$1 / ||\| Y J ) / |/| ./ + J |)'( | ` F`.'/ $3 _ +$1 -<| F __ .-< $3(_) +$1 | / .-'$3. $1`. /$3-. $1L___ + J \\ < $3\ $1 | | $5O$3\\$1|.-' $3 _ +$1 _J \\ .- \\$3/ $5O $3| $1| \\ |$1F $3(_) +$1 '-F -<_. \\ .-' `-' L__ +__J _ _. >-' $1)$4._. $1|-' +$1 `-|.' /_. $4\_| $1 F + /.- . _.< + /' /.' .' `\\ + /L /' |/ _.-'-\\ + /'J ___.---'\| + |\ .--' V | `. ` + |/`. `-. `._) + / .-.\\ + \\ ( `\\ + `.\\ \ No newline at end of file diff --git a/src/logo/ascii/openbsd_small.txt b/src/logo/ascii/openbsd_small.txt new file mode 100644 index 000000000..a96b2f1c1 --- /dev/null +++ b/src/logo/ascii/openbsd_small.txt @@ -0,0 +1,7 @@ +$1 _____ + \\- -/ + \\_/ \\ + | $2O O$1 | + |_ < ) 3 ) + / \\ / + /-_____-\\ \ No newline at end of file diff --git a/src/logo/ascii/openkylin.txt b/src/logo/ascii/openkylin.txt new file mode 100644 index 000000000..288e2b54d --- /dev/null +++ b/src/logo/ascii/openkylin.txt @@ -0,0 +1,18 @@ + + /KKK] + KKKKKKK` ]KKKK\ + KKKKK/ /KKKKKKKKK\ + KKKK/ ,KKKKKKKKKKKK^ + ,]KKK =KKK` /KKKKKKOOOOOO` +,KKKKKK =KK /` [\OOOOOOO\ + \KKKKK =K ,OOOOOOO` + ,KKKKK =^ \OOOOOO + ,KKKK ^ OOOOOO^ + *KKK^ =OOOOO^ + OOKK^ OOOOOO^ + \OOOK\ /OOOOOO` + OOOOOO] ,OOOOOOO^ + ,OOOOOOOO\] ,[OOOOOOOOO/ + \OOOOOOOOOOOOOOOOOOOOO` + [OOOOOOOOOOOOOOOO/` + ,[OOOOOOOOO] \ No newline at end of file diff --git a/src/logo/ascii/openmandriva.txt b/src/logo/ascii/openmandriva.txt new file mode 100644 index 000000000..7a036bbc1 --- /dev/null +++ b/src/logo/ascii/openmandriva.txt @@ -0,0 +1,22 @@ + `````` + `-:/+++++++//:-.` + .:+++oooo+/:.`` `` + `:+ooooooo+:. `-:/++++++/:.` + -+oooooooo:` `-++o+/::::://+o+/- + `/ooooooooo- -+oo/.` `-/oo+. + `+ooooooooo. :os/` .+so: + +sssssssss/ :ss/ `+ss- + :ssssssssss` sss` .sso + ossssssssss `yyo sys +`sssssssssss` `yys `yys +`sssssssssss: +yy/ +yy: + oyyyyyyyyyys. `oyy/` `+yy+ + :yyyyyyyyyyyo. `+yhs:. `./shy/ + oyyyyyyyyyyys:` .oyhys+:----/+syhy+. ` + `syyyyyyyyyyyyo-` .:osyhhhhhyys+:``.:` + `oyyyyyyyyyyyyys+-`` `.----.```./oo. + /yhhhhhhhhhhhhhhyso+//://+osyhy/` + `/yhhhhhhhhhhhhhhhhhhhhhhhhy/` + `:oyhhhhhhhhhhhhhhhhhhyo:` + .:+syhhhhhhhhys+:-` + ``....`` \ No newline at end of file diff --git a/src/logo/ascii/opensuse.txt b/src/logo/ascii/opensuse.txt new file mode 100644 index 000000000..a407c4bfb --- /dev/null +++ b/src/logo/ascii/opensuse.txt @@ -0,0 +1,18 @@ + $2.;ldkO0000Okdl;. + .;d00xl:^''''''^:ok00d;. + .d00l' 'o00d. + .d0Kd'$1 Okxol:;,. $2:O0d + .OK$1KKK0kOKKKKKKKKKKOxo:, $2lKO. + ,0K$1KKKKKKKKKKKKKKK0P^$2,,,$1^dx:$2 ;00, +.OK$1KKKKKKKKKKKKKKKk'$2.oOPPb.$1'0k.$2 cKO. +:KK$1KKKKKKKKKKKKKKK: $2kKx..dd $1lKd$2 'OK: +dKK$1KKKKKKKKKOx0KKKd $2^0KKKO' $1kKKc$2 dKd +dKK$1KKKKKKKKKK;.;oOKx,..$2^$1..;kKKK0.$2 dKd +:KK$1KKKKKKKKKK0o;...^cdxxOK0O/^^' $2.0K: + kKK$1KKKKKKKKKKKKK0x;,,......,;od $2lKk + '0K$1KKKKKKKKKKKKKKKKKKKK00KKOo^ $2c00' + 'kK$1KKOxddxkOO00000Okxoc;'' $2.dKk' + l0Ko. .c00l' + 'l0Kk:. .;xK0l' + 'lkK0xl:;,,,,;:ldO0kl' + '^:ldxkkkkxdl:^' \ No newline at end of file diff --git a/src/logo/ascii/opensuse_leap.txt b/src/logo/ascii/opensuse_leap.txt new file mode 100644 index 000000000..e0d8cddc8 --- /dev/null +++ b/src/logo/ascii/opensuse_leap.txt @@ -0,0 +1,16 @@ + .-++:. + ./oooooo/- + `:oooooooooooo:. + -+oooooooooooooooo+-` + ./oooooooooooooooooooooo/- + :oooooooooooooooooooooooooo: + ` `-+oooooooooooooooooooo/- ` + `:oo/- .:ooooooooooooooo+:` `-+oo/. +`/oooooo:. -/oooooooooo/. ./oooooo/. + `:+ooooo+-` `:+oooo+- `:oooooo+:` + .:oooooo/. .::` -+oooooo/. + -/oooooo:. ./oooooo+- + `:+ooooo+-:+oooooo:` + ./oooooooooo/. + -/oooo+:` + `:/. \ No newline at end of file diff --git a/src/logo/ascii/opensuse_small.txt b/src/logo/ascii/opensuse_small.txt new file mode 100644 index 000000000..0099a0295 --- /dev/null +++ b/src/logo/ascii/opensuse_small.txt @@ -0,0 +1,7 @@ + _______ +__| __ \ + / .\ \ + \__/ | + _______| + \_______ +__________/ \ No newline at end of file diff --git a/src/logo/ascii/opensuse_tumbleweed.txt b/src/logo/ascii/opensuse_tumbleweed.txt new file mode 100644 index 000000000..519e0258a --- /dev/null +++ b/src/logo/ascii/opensuse_tumbleweed.txt @@ -0,0 +1,13 @@ + ...... + .,cdxxxoc,. .:kKMMMNWMMMNk:. + cKMMN0OOOKWMMXo. ; ;0MWk:. .:OMMk. + ;WMK;. .lKMMNM, :NMK, .OMW; + cMW; 'WMMMN ,XMK, oMM' +.MMc ..;l. xMN: KM0 +'MM. 'NMO oMM +.MM, .kMMl xMN + KM0 .kMM0. .dl:,.. .WMd + .XM0. ,OMMK, OMMMK. .XMK + oWMO:. .;xNMMk, NNNMKl. .xWMx + :ONMMNXMMMKx; . ,xNMWKkxllox0NMWk, + ..... .:dOOXXKOxl, \ No newline at end of file diff --git a/src/logo/ascii/opensuse_tumbleweed2.txt b/src/logo/ascii/opensuse_tumbleweed2.txt new file mode 100644 index 000000000..fefdeee4a --- /dev/null +++ b/src/logo/ascii/opensuse_tumbleweed2.txt @@ -0,0 +1,13 @@ + ...... + .,cdxxxoc,. .:kKMMMNWMMMNk:. + cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. + ;WMK;' 'lKMMNM, :NMK' 'OMW; + cMW; WMMMN ,XMK' oMM. +.MMc ''^*~l. xMN: KM0 +'MM. .NMO oMM +.MM, .kMMl xMN + KM0 .kMM0' .dl>~,. .WMd + 'XM0. ,OMMK' OMMM7' .XMK + *WMO:. .;xNMMk' NNNMKl. .xWMx + ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' + ''''' ':dOOXXKOxl' \ No newline at end of file diff --git a/src/logo/ascii/openwrt.txt b/src/logo/ascii/openwrt.txt new file mode 100644 index 000000000..47e4e1944 --- /dev/null +++ b/src/logo/ascii/openwrt.txt @@ -0,0 +1,9 @@ + _______ +| |.-----.-----.-----. +| - || _ | -__| | +|_______|| __|_____|__|__| + |__| + ________ __ +| | | |.----.| |_ +| | | || _|| _| +|________||__| |____| \ No newline at end of file diff --git a/src/logo/ascii/oracle.txt b/src/logo/ascii/oracle.txt new file mode 100644 index 000000000..988ebea54 --- /dev/null +++ b/src/logo/ascii/oracle.txt @@ -0,0 +1,11 @@ + `-/+++++++++++++++++/-.` + `/syyyyyyyyyyyyyyyyyyyyyyys/. + :yyyyo/-...............-/oyyyy/ + /yyys- .oyyy+ +.yyyy` `syyy- +:yyyo /yyy/ +.yyyy` `syyy- + /yyys. .oyyyo + /yyyyo:-...............-:oyyyy/` + `/syyyyyyyyyyyyyyyyyyyyyyys+. + `.:/+ooooooooooooooo+/:.` \ No newline at end of file diff --git a/src/logo/ascii/parabola.txt b/src/logo/ascii/parabola.txt new file mode 100644 index 000000000..3fd077655 --- /dev/null +++ b/src/logo/ascii/parabola.txt @@ -0,0 +1,16 @@ + `.-. `. + `.` `:++. `-+o+. + `` `:+/. `:+/. `-+oooo+ + ``-::-.:+/. `:+/. `-+oooooo+ + `.-:///- ..` .-. `-+oooooooo- + `..-..` `+ooooooooo: +`` :oooooooo/ + `ooooooo: + `oooooo: + -oooo+. + +ooo/` + -ooo- + `+o/. + /+- + //` + -. \ No newline at end of file diff --git a/src/logo/ascii/parabola_small.txt b/src/logo/ascii/parabola_small.txt new file mode 100644 index 000000000..da9f704e4 --- /dev/null +++ b/src/logo/ascii/parabola_small.txt @@ -0,0 +1,6 @@ + __ __ __ _ +.`_//_//_/ / `. + / .` + / .` + /.` + /` \ No newline at end of file diff --git a/src/logo/ascii/pop.txt b/src/logo/ascii/pop.txt new file mode 100644 index 000000000..b562610e5 --- /dev/null +++ b/src/logo/ascii/pop.txt @@ -0,0 +1,20 @@ + ///////////// + ///////////////////// + ///////$2*767$1//////////////// + //////$27676767676*$1////////////// + /////$276767$1//$27676767$1////////////// + /////$2767676$1///$2*76767$1/////////////// + ///////$2767676$1///$276767$1.///$27676*$1/////// +/////////$2767676$1//$276767$1///$2767676$1//////// +//////////$276767676767$1////$276767$1///////// +///////////$276767676$1//////$27676$1////////// +////////////,$27676$1,///////$2767$1/////////// +/////////////*$27676$1///////$276$1//////////// +///////////////$27676$1//////////////////// + ///////////////$27676$1///$2767$1//////////// + //////////////////////$2'$1//////////// + //////$2.7676767676767676767,$1////// + /////$2767676767676767676767$1///// + /////////////////////////// + ///////////////////// + ///////////// \ No newline at end of file diff --git a/src/logo/ascii/pop_small.txt b/src/logo/ascii/pop_small.txt new file mode 100644 index 000000000..4865dd946 --- /dev/null +++ b/src/logo/ascii/pop_small.txt @@ -0,0 +1,8 @@ +______ +\ _ \ __ + \ \ \ \ / / + \ \_\ \ / / + \ ___\ /_/ + \ \ _ + __\_\__(_)_ + (___________)` \ No newline at end of file diff --git a/src/logo/ascii/raspbian.txt b/src/logo/ascii/raspbian.txt new file mode 100644 index 000000000..ec8020cdb --- /dev/null +++ b/src/logo/ascii/raspbian.txt @@ -0,0 +1,23 @@ + $2`.::///+:/-. --///+//-:` + `+oooooooooooo: `+oooooooooooo: + /oooo++//ooooo: ooooo+//+ooooo. + `+ooooooo:-:oo- +o+::/ooooooo: + `:oooooooo+`` `.oooooooo+- + `:++ooo/. :+ooo+/.`$1 + ...` `.----.` ``.. + .::::-``:::::::::.`-:::-` + -:::-` .:::::::-` `-:::- + `::. `.--.` `` `.---.``.::` + .::::::::` -::::::::` ` + .::` .:::::::::- `::::::::::``::. +-:::` ::::::::::. ::::::::::.`:::- +:::: -::::::::. `-:::::::: :::: +-::- .-:::-.``....``.-::-. -::- + .. `` .::::::::. `..`.. + -:::-` -::::::::::` .:::::` + :::::::` -::::::::::` :::::::. + .::::::: -::::::::. :::::::: + `-:::::` ..--.` ::::::. + `...` `...--..` `...` + .:::::::::: + `.-::::-` \ No newline at end of file diff --git a/src/logo/ascii/raspbian_small.txt b/src/logo/ascii/raspbian_small.txt new file mode 100644 index 000000000..eceb8c3ae --- /dev/null +++ b/src/logo/ascii/raspbian_small.txt @@ -0,0 +1,10 @@ + $2.~~. .~~. + '. \ ' ' / .'$1 + .~ .~~~..~. + : .~.'~'.~. : + ~ ( ) ( ) ~ +( : '~'.~.'~' : ) + ~ .~ ( ) ~. ~ + ( : '~' : ) + '~ .~~~. ~' + '~' \ No newline at end of file diff --git a/src/logo/ascii/reborn.txt b/src/logo/ascii/reborn.txt new file mode 100644 index 000000000..8aaaf0de2 --- /dev/null +++ b/src/logo/ascii/reborn.txt @@ -0,0 +1,20 @@ + ::::::::::::::::::::::: + .:^!!!!!!!!!^.^!!!!!!!!!^:. + .:~!!!!!!!!!!^.^!!!!!!!!!!~:. + .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:. + .^!!!!!~::$2=====:.:=====$1::~!!!!!^. + .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::. + .:~~^:::^.$2^77777!!^.^7!77777^$1.^:::^~~:. + .:~!!!!~::::$2^~!!::^^^^^::!!~^$1::::~!!!!~:. + .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^. +.:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:. +.:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:. + .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^. + .:~!!!!~::$2::^~!!::^^^^^::!!~^::$1::~!!!!~:. + .:~~^:::^.$2^77777!!^.^7!77777^.$1^:::^~~:. + .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::. + .^!!!!!~::$2=====:.:=====$1::~!!!!!^. + .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:. + .:~!!!!!!!!!!^.^!!!!!!!!!!~:. + .:^!!!!!!!!!^.^!!!!!!!!!^:. + ::::::::::::::::::::::: diff --git a/src/logo/ascii/reborn_small.txt b/src/logo/ascii/reborn_small.txt new file mode 100644 index 000000000..a5f6980bc --- /dev/null +++ b/src/logo/ascii/reborn_small.txt @@ -0,0 +1,11 @@ + _______________ + / \ / \ + / \_______/ \ + / / \ / \ \ + / / \___/ \ \ +/____/____/ \____\____\ +\ \ \___/ / / + \ \ / \ / / + \ \/_______\/ / + \ / \ / + \_/___________\_/ diff --git a/src/logo/ascii/redstar.txt b/src/logo/ascii/redstar.txt new file mode 100644 index 000000000..de489776a --- /dev/null +++ b/src/logo/ascii/redstar.txt @@ -0,0 +1,18 @@ +$1 .. + .oK0l + :0KKKKd. + .xKO0KKKKd + ,Od' .d0000l + .c;. .'''... ..'. +.,:cloddxxxkkkkOOOOkkkkkkkkxxxxxxxxxkkkx: +;kOOOOOOOkxOkc'...',;;;;,,,'',;;:cllc:,. + .okkkkd,.lko .......',;:cllc:;,,'''''. + .cdo. :xd' cd:. ..';'',,,'',,;;;,'. + . .ddl.;doooc'..;oc;'..';::;,'. + coo;.oooolllllllcccc:'. . + .ool''lllllccccccc:::::;. + ;lll. .':cccc:::::::;;;;' + :lcc:'',..';::::;;;;;;;,,. + :cccc::::;...';;;;;,,,,,,. + ,::::::;;;,'. ..',,,,'''. + ........ ...... \ No newline at end of file diff --git a/src/logo/ascii/rhel.txt b/src/logo/ascii/rhel.txt new file mode 100644 index 000000000..d2fa4eff1 --- /dev/null +++ b/src/logo/ascii/rhel.txt @@ -0,0 +1,18 @@ + .MMM..:MMMMMMM + MMMMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMMMMMM. + MMMMMMMMMMMMMMMMMMMMMM + ,MMMMMMMMMMMMMMMMMMMMMM: + MMMMMMMMMMMMMMMMMMMMMMMM + .MMMM' MMMMMMMMMMMMMMMMMMMMMM + MMMMMM `MMMMMMMMMMMMMMMMMMMM. +MMMMMMMM MMMMMMMMMMMMMMMMMM . +MMMMMMMMM. `MMMMMMMMMMMMM' MM. +MMMMMMMMMMM. MMMM +`MMMMMMMMMMMMM. ,MMMMM. + `MMMMMMMMMMMMMMMMM. ,MMMMMMMM. + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM: + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + `MMMMMMMMMMMMMMMMMMMMMMMM: + ``MMMMMMMMMMMMMMMMM' \ No newline at end of file diff --git a/src/logo/ascii/rocky.txt b/src/logo/ascii/rocky.txt new file mode 100644 index 000000000..084313127 --- /dev/null +++ b/src/logo/ascii/rocky.txt @@ -0,0 +1,19 @@ + __wgliliiligw_, + _williiiiiiliilililw, + _%iiiiiilililiiiiiiiiiii_ + .Qliiiililiiiiiiililililiilm. + _iiiiiliiiiiililiiiiiiiiiiliil, + .lililiiilililiiiilililililiiiii, +_liiiiiiliiiiiiiliiiiiF{iiiiiilili, +jliililiiilililiiili@` ~ililiiiiiL +iiiliiiiliiiiiiili>` ~liililii +liliiiliiilililii` -9liiiil +iiiiiliiliiiiii~ "4lili +4ililiiiiilil~| -w, )4lf +-liiiiililiF' _liig, )' + )iiiliii@` _QIililig, + )iiii>` .Qliliiiililw + )<>~ .mliiiiiliiiiiil, + _gllilililiililii~ + giliiiiiiiiiiiiT` + -^~$ililili@~~' \ No newline at end of file diff --git a/src/logo/ascii/rosa.txt b/src/logo/ascii/rosa.txt new file mode 100644 index 000000000..297c19f39 --- /dev/null +++ b/src/logo/ascii/rosa.txt @@ -0,0 +1,20 @@ + ROSAROSAROSAROSAR + ROSA AROS + ROS SAROSAROSAROSAR AROS + RO ROSAROSAROSAROSAROSAR RO + ARO AROSAROSAROSARO AROS ROS + ARO ROSAROS OSAR ROSA ROS + RO AROSA ROSAROSAROSA ROSAR RO +RO ROSAR ROSAROSAROSAR R ROSARO RO +RO ROSA AROSAROSAROSA AR ROSARO AR +RO AROS ROSAROSAROSA ROS AROSARO AR +RO AROS ROSAROSARO ROSARO ROSARO AR +RO ROS AROSAROS ROSAROSA AROSAR AR +RO ROSA ROS ROSAROSAR ROSARO RO + RO ROS AROSAROSAROSA ROSARO AR + ARO ROSA ROSAROSAROS AROSAR ARO + ARO OROSA R ROSAROS ROS + RO AROSAROS AROSAROSAR RO + AROS AROSAROSAROSARO AROS + ROSA SARO + ROSAROSAROSAROSAR \ No newline at end of file diff --git a/src/logo/ascii/slackware.txt b/src/logo/ascii/slackware.txt new file mode 100644 index 000000000..df15ecd3b --- /dev/null +++ b/src/logo/ascii/slackware.txt @@ -0,0 +1,21 @@ + ::::::::: + ::::::::::::::::::: + ::::::::::::::::::::::::: + ::::::::$2cllcccccllllllll$1:::::: + :::::::::$2lc dc$1::::::: + ::::::::$2cl clllccllll oc$1::::::::: + :::::::::$2o lc$1::::::::$2co oc$1:::::::::: + ::::::::::$2o cccclc$1:::::$2clcc$1:::::::::::: + :::::::::::$2lc cclccclc$1::::::::::::: +::::::::::::::$2lcclcc lc$1:::::::::::: +::::::::::$2cclcc$1:::::$2lccclc oc$1::::::::::: +::::::::::$2o l$1::::::::::$2l lc$1::::::::::: + :::::$2cll$1:$2o clcllcccll o$1::::::::::: + :::::$2occ$1:$2o clc$1::::::::::: + ::::$2ocl$1:$2ccslclccclclccclclc$1::::::::::::: + :::$2oclcccccccccccccllllllllllllll$1::::: + ::$2lcc1lcccccccccccccccccccccccco$1:::: + :::::::::::::::::::::::::::::::: + :::::::::::::::::::::::::::: + :::::::::::::::::::::: + :::::::::::: \ No newline at end of file diff --git a/src/logo/ascii/slackware_small.txt b/src/logo/ascii/slackware_small.txt new file mode 100644 index 000000000..c04b0834c --- /dev/null +++ b/src/logo/ascii/slackware_small.txt @@ -0,0 +1,7 @@ + ________ + / ______| + | |______ + \______ \ + ______| | +| |________/ +|____________ \ No newline at end of file diff --git a/src/logo/ascii/solaris.txt b/src/logo/ascii/solaris.txt new file mode 100644 index 000000000..1af14835b --- /dev/null +++ b/src/logo/ascii/solaris.txt @@ -0,0 +1,8 @@ + `- ` + `-- `+- .: + .+: `++: -/+- . + `.::` -++/``:::`./+/ `.-/. + `++/-`.` ` /++:` + `` ./:` .: `..`.- +``./+/:- -+++:- + -/+` :. \ No newline at end of file diff --git a/src/logo/ascii/solaris_small.txt b/src/logo/ascii/solaris_small.txt new file mode 100644 index 000000000..8769217ca --- /dev/null +++ b/src/logo/ascii/solaris_small.txt @@ -0,0 +1,5 @@ + . .; . + . :; :: ;: . + .;. .. .. .;. +.. .. .. .. + .;, ,;. \ No newline at end of file diff --git a/src/logo/ascii/solus.txt b/src/logo/ascii/solus.txt new file mode 100644 index 000000000..6bc9f84f6 --- /dev/null +++ b/src/logo/ascii/solus.txt @@ -0,0 +1,20 @@ +$2 -``````````` + `-+/------------.` + .---:mNo---------------. + .-----yMMMy:---------------. + `------oMMMMMm/----------------` + .------/MMMMMMMN+----------------. + .------/NMMMMMMMMm-+/--------------. +`------/NMMMMMMMMMN-:mh/-------------` +.-----/NMMMMMMMMMMM:-+MMd//oso/:-----. +-----/NMMMMMMMMMMMM+--mMMMh::smMmyo:-- +----+NMMMMMMMMMMMMMo--yMMMMNo-:yMMMMd/. +.--oMMMMMMMMMMMMMMMy--yMMMMMMh:-yMMMy-` +`-sMMMMMMMMMMMMMMMMh--dMMMMMMMd:/Ny+y. +`-/+osyhhdmmNNMMMMMm-/MMMMMMMmh+/ohm+ + .------------:://+-/++++++$1oshddys: + -hhhhyyyyyyyyyyyhhhhddddhysssso- + `:ossssssyysssssssssssssssso:` + `:+ssssssssssssssssssss+- + `-/+ssssssssssso+/-` + `.-----..` diff --git a/src/logo/ascii/steamos.txt b/src/logo/ascii/steamos.txt new file mode 100644 index 000000000..e231a5c65 --- /dev/null +++ b/src/logo/ascii/steamos.txt @@ -0,0 +1,18 @@ +$1 .,,,,. + .,'onNMMMMMNNnn',. + .'oNMANKMMMMMMMMMMMNNn'. + .'ANMMMMMMMXKNNWWWPFFWNNMNn. + ;NNMMMMMMMMMMNWW'' ,.., 'WMMM, + ;NMMMMV+##+VNWWW' .+;'':+, 'WMW, +,VNNWP+$2######$1+WW, $2+: $1:+, +MMM, +'$2+#############, +. ,+' $1+NMMM +$2 '*#########*' '*,,*' $1.+NMMMM. +$2 `'*###*' ,.,;###$1+WNM, +$2 .,;;, .;##########$1+W +$2,',. '; ,+##############' + '###+. :,. .,; ,###############' + '####.. `'' .,###############' + '#####+++################' + '*##################*' + ''*##########*'' + '''''' diff --git a/src/logo/ascii/ubuntu.txt b/src/logo/ascii/ubuntu.txt new file mode 100644 index 000000000..0947f04fc --- /dev/null +++ b/src/logo/ascii/ubuntu.txt @@ -0,0 +1,21 @@ + .... + .',:clooo: .:looooo:. + .;looooooooc .oooooooooo' + .;looooool:,''. :ooooooooooc + ;looool;. 'oooooooooo, + ;clool' .cooooooc. ,, + ... ...... .:oo, + .;clol:,. .loooo' + :ooooooooo, 'ooool +'ooooooooooo. loooo. +'ooooooooool coooo. + ,loooooooc. .loooo. + .,;;;'. ;ooooc + ... ,ooool. + .cooooc. ..',,'. .cooo. + ;ooooo:. ;oooooooc. :l. + .coooooc,.. coooooooooo. + .:ooooooolc:. .ooooooooooo' + .':loooooo; ,oooooooooc + ..';::c' .;loooo:' + . \ No newline at end of file diff --git a/src/logo/ascii/ubuntu2_small.txt b/src/logo/ascii/ubuntu2_small.txt new file mode 100644 index 000000000..4275646bc --- /dev/null +++ b/src/logo/ascii/ubuntu2_small.txt @@ -0,0 +1,11 @@ + ..;,; .,;,. + .,lool: .ooooo, + ;oo;: .coool. + .... ''' ,l; +:oooo, 'oo. +looooc :oo' + '::' ,oo: + ,., .... co, + lo:;. :oooo; . + ':ooo; cooooc + ''' '''' \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_kylin.txt b/src/logo/ascii/ubuntu_kylin.txt new file mode 100644 index 000000000..d03aa91fd --- /dev/null +++ b/src/logo/ascii/ubuntu_kylin.txt @@ -0,0 +1,20 @@ +$1 .__=liiiiiii=__, + ._=liiliii|i|i|iiilii=_. + _=iiiii|ii|i|ii|i|inwwwzii=, + .=liiii|ii|ii|wwww|i$23QWWWW$1ziii=, + =lii|i|ii|i|$2QQQWWWWWm]QWWQD$1||iiii= + =lii|iiivw$2Qm$1>3$2WWWWWQWQQwwQw$1cii|i|ii= + =lii|ii|n$2QWWWQ$1|)i$2|i$1%i|]$2TQWWWWm$1|ii|i|i= +.li|i|i|m$2WWWQV$1|ii$2wmD$1|iiii|$2TWWWWm$1|i|iiii, +=iii$2www|$WQWk$1|i$2aWWWD$1|i|i|ii]$2QQWQk$1|ii|i|= +iii$2QWWWQz$WW$1|i$2jQQWQm$1w|ii$2wW$1k|$2TTTTY$1i|i|iii +iiI$2QWQWWtyQQ$1|i|$2$WWWWWQWk$1||i|i|ii||i|ii|i +<|i|$2TTT|mQQWz$1|i$23D$1]C|$2nD$W$1|ii$2vWWWWk$1||ii|i> +-|ii|i|i$2WWWQw$1|$2Tt$1|i3$2T$1|$2T$1|i|$2nQWQWDk$1|ii|ii` + <|i|iii|$2VWQWWQ$1|i|i|||ii$2wmWWQWD$1||ii|ii+ + <|ii|i|i]$2$W@$1tv$2QQQWQQQWWTTHT$11|iii|i|> + <|i|ii|ii||v$2QWWWQWWW@vmWWWm$1|i|i|i> + -<|i|ii|ii|i|$2TTTTTT$1|]$2QQWWWC$1|ii>` + -<|i|ii|i|ii|i|i|ii3$2TTT$1t|i>` + ~<|ii|ii|iiiii|i|||i>~ + -~~<|ii|i||i>~~` \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_mate.txt b/src/logo/ascii/ubuntu_mate.txt new file mode 100644 index 000000000..71bddca1d --- /dev/null +++ b/src/logo/ascii/ubuntu_mate.txt @@ -0,0 +1,20 @@ +$1 .:/+oossssoo+/:.` + `:+ssssssssssssssssss+:` + -+sssssssssssssss$2y$1ssssssss+- + .osssssssssssss$2yy$1ss$2mMmh$1ssssssso. + /sssssssss$2ydmNNNmmd$1s$2mMMMMNdy$1sssss/ + `+ssssssss$2hNNdy$1sssssss$2mMMMMNdy$1ssssss+` + +sssssss$2yNNh$1ss$2hmNNNNm$1s$2mMmh$1s$2ydy$1sssssss+ +-sssss$2y$1ss$2Nm$1ss$2hNNh$1ssssss$2y$1s$2hh$1ss$2mMy$1sssssss- ++ssss$2yMNdy$1ss$2hMd$1ssssssssss$2hMd$1ss$2NN$1sssssss+ +sssss$2yMMMMMmh$1sssssssssssss$2NM$1ss$2dMy$1sssssss +sssss$2yMMMMMmhy$1ssssssssssss$2NM$1ss$2dMy$1sssssss ++ssss$2yMNdy$1ss$2hMd$1ssssssssss$2hMd$1ss$2NN$1sssssss+ +-sssss$2y$1ss$2Nm$1ss$2hNNh$1ssssssss$2dh$1ss$2mMy$1sssssss- + +sssssss$2yNNh$1ss$2hmNNNNm$1s$2mNmh$1s$2ymy$1sssssss+ + +ssssssss$2hNNdy$1sssssss$2mMMMMmhy$1ssssss+ + /sssssssss$2ydmNNNNmd$1s$2mMMMMNdh$1sssss/ + .osssssssssssss$2yy$1ss$2mMmdy$1sssssso. + -+sssssssssssssss$2y$1ssssssss+- + `:+ssssssssssssssssss+:` + .:/+oossssoo+/:. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_old.txt b/src/logo/ascii/ubuntu_old.txt new file mode 100644 index 000000000..5a816363b --- /dev/null +++ b/src/logo/ascii/ubuntu_old.txt @@ -0,0 +1,20 @@ + .-/+oossssoo+/-. + `:+ssssssssssssssssss+:` + -+ssssssssssssssssssyyssss+- + .ossssssssssssssssssd$2MMMNy$1sssso. + /sssssssssss$2hdmmNNmmyNMMMMh$1ssssss/ + +sssssssss$2hmydMMMMMMMNddddy$1ssssssss+ + /ssssssss$2hNMMMyhhyyyyhmNMMMNh$1ssssssss/ +.ssssssss$2dMMMNh$1ssssssssss$2hNMMMd$1ssssssss. ++ssss$2hhhyNMMNy$1ssssssssssss$2yNMMMy$1sssssss+ +oss$2yNMMMNyMMh$1ssssssssssssss$2hmmmh$1ssssssso +oss$2yNMMMNyMMh$1ssssssssssssss$2hmmmh$1ssssssso ++ssss$2hhhyNMMNy$1ssssssssssss$2yNMMMy$1sssssss+ +.ssssssss$2dMMMNh$1ssssssssss$2hNMMMd$1ssssssss. + /ssssssss$2hNMMMyhhyyyyhdNMMMNh$1ssssssss/ + +sssssssss$2dmydMMMMMMMMddddy$1ssssssss+ + /sssssssssss$2hdmNNNNmyNMMMMh$1ssssss/ + .ossssssssssssssssss$2dMMMNy$1sssso. + -+sssssssssssssssss$2yyy$1ssss+- + `:+ssssssssssssssssss+:` + .-/+oossssoo+/-. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_small.txt b/src/logo/ascii/ubuntu_small.txt new file mode 100644 index 000000000..491b534a6 --- /dev/null +++ b/src/logo/ascii/ubuntu_small.txt @@ -0,0 +1,6 @@ + _ + ---(_) + _/ --- \ +(_) | | + \ --- _/ + ---(_) \ No newline at end of file diff --git a/src/logo/ascii/unknown.txt b/src/logo/ascii/unknown.txt new file mode 100644 index 000000000..ed7418eaa --- /dev/null +++ b/src/logo/ascii/unknown.txt @@ -0,0 +1,18 @@ + ________ + _jgN########Ngg_ + _N##N@@"" ""9NN##Np_ +d###P N####p +"^^" T#### + d###P + _g###@F + _gN##@P + gN###F" + d###F + 0###F + 0###F + 0###F + "NN@' + + ___ + q###r + "" \ No newline at end of file diff --git a/src/logo/ascii/uos.txt b/src/logo/ascii/uos.txt new file mode 100644 index 000000000..82d968866 --- /dev/null +++ b/src/logo/ascii/uos.txt @@ -0,0 +1,20 @@ + ....... + .............. + ...................... + ............................. +uuuuuu uuuuuu ooooooooooo ssssssssss +u::::u u::::u oo:::::::::::oo ss::::::::::s +u::::u u::::u o:::::::::::::::oss:::::::::::::s +u::::u u::::u o:::::ooooo:::::os::::::ssss:::::s +u::::u u::::u o::::o o::::o s:::::s ssssss +u::::u u::::u o::::o o::::o s::::::s +u::::u u::::u o::::o o::::o s::::::s +u:::::uuuu:::::u o::::o o::::ossssss s:::::s +u:::::::::::::::uuo:::::ooooo:::::os:::::ssss::::::s +u:::::::::::::::uo:::::::::::::::os::::::::::::::s +uu::::::::uu:::u oo:::::::::::oo s:::::::::::ss + uuuuuuuu uuuu ooooooooooo sssssssssss + ............................. + ..................... + ............. + ...... \ No newline at end of file diff --git a/src/logo/ascii/vanilla.txt b/src/logo/ascii/vanilla.txt new file mode 100644 index 000000000..ab5631ca7 --- /dev/null +++ b/src/logo/ascii/vanilla.txt @@ -0,0 +1,18 @@ + .----: + .-------. + :---::----: + .----::-----. + ......... :----::-----: ..:::-::::.. +.-----------------::------------------: + ----::-----------::----------::::---: + -----:::--------::-------:::------- + :------::::--::...:::::---------: + .---------::.. ..:---------. + .::-----::.. .::----::. + .:------:.......:-------: + .--------::::::::-:::-------. + .-------::-----.:-----::------. + -----::------: :------::----- + :--::--------: .-------::---: + :----------:: .:---------- + :--------: :--------: \ No newline at end of file diff --git a/src/logo/ascii/void.txt b/src/logo/ascii/void.txt new file mode 100644 index 000000000..4b1ad9a5d --- /dev/null +++ b/src/logo/ascii/void.txt @@ -0,0 +1,18 @@ + __.;=====;.__ + _.=+==++=++=+=+===;. + -=+++=+===+=+=+++++=_ + . -=:`` `--==+=++==. + _vi, ` --+=++++: + .uvnvi. _._ -==+==+. + .vvnvnI` .;==|==;. :|=||=|. +$2+QmQQm$1pvvnv;$2 _yYsyQQWUUQQQm #QmQ#$1:$2QQQWUV$QQm. + $2-QQWQW$1pvvo$2wZ?.wQQQE$1==<$2QWWQ/QWQW.QQWW$1(:$2 jQWQE + $2-$QQQQmmU' jQQQ$1@+=<$2QWQQ)mQQQ.mQQQC$1+;$2jWQQ@' + $2-$WQ8Y$1nI:$2 QWQQwgQQWV$1`$2mWQQ.jQWQQgyyWW@! + $1-1vvnvv. `~+++` ++|+++ + +vnvnnv, `-|=== + +vnvnvns. . :=- + -Invnvvnsi..___..=sv=. ` + +Invnvnvnnnnnnnnvvnn;. + ~|Invnvnvvnvvvnnv}+` + -~|{*l}*|~ \ No newline at end of file diff --git a/src/logo/ascii/void_small.txt b/src/logo/ascii/void_small.txt new file mode 100644 index 000000000..e9602b027 --- /dev/null +++ b/src/logo/ascii/void_small.txt @@ -0,0 +1,7 @@ + _______ + _ \______ - +| \ ___ \ | +| | / \ | | +| | \___/ | | +| \______ \_| + -_______\ \ No newline at end of file diff --git a/src/logo/ascii/windows.txt b/src/logo/ascii/windows.txt new file mode 100644 index 000000000..ffe0410ef --- /dev/null +++ b/src/logo/ascii/windows.txt @@ -0,0 +1,16 @@ +$1 ,.=:!!t3Z3z., + :tt:::tt333EE3 +$1 Et:::ztt33EEEL$2 @Ee., .., +$1 ;tt:::tt333EE7$2 ;EEEEEEttttt33# +$1 :Et:::zt333EEQ.$2 $EEEEEttttt33QL +$1 it::::tt333EEF$2 @EEEEEEttttt33F +$1 ;3=*^```"*4EEV$2 :EEEEEEttttt33@. +$3 ,.=::::!t=., $1`$2 @EEEEEEtttz33QF +$3 ;::::::::zt33)$2 "4EEEtttji3P* +$3 :t::::::::tt33.$4:Z3z..$2 ``$4 ,..g. +$3 i::::::::zt33F$4 AEEEtttt::::ztF +$3 ;:::::::::t33V$4 ;EEEttttt::::t3 +$3 E::::::::zt33L$4 @EEEtttt::::z3F +$3{3=*^```"*4E3)$4 ;EEEtttt:::::tZ` +$3 `$4 :EEEEtttt::::z7 + "VEzjt:;;z>*` \ No newline at end of file diff --git a/src/logo/ascii/windows_11.txt b/src/logo/ascii/windows_11.txt new file mode 100644 index 000000000..1fd966753 --- /dev/null +++ b/src/logo/ascii/windows_11.txt @@ -0,0 +1,17 @@ +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// +$1///////////////// $2///////////////// + +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// +$3///////////////// $4///////////////// \ No newline at end of file diff --git a/src/logo/ascii/windows_11_small.txt b/src/logo/ascii/windows_11_small.txt new file mode 100644 index 000000000..c04184f24 --- /dev/null +++ b/src/logo/ascii/windows_11_small.txt @@ -0,0 +1,9 @@ +$1lllllllll $2lllllllll +$1lllllllll $2lllllllll +$1lllllllll $2lllllllll +$1lllllllll $2lllllllll + +$3lllllllll $4lllllllll +$3lllllllll $4lllllllll +$3lllllllll $4lllllllll +$3lllllllll $4lllllllll diff --git a/src/logo/ascii/windows_8.txt b/src/logo/ascii/windows_8.txt new file mode 100644 index 000000000..a357dda2f --- /dev/null +++ b/src/logo/ascii/windows_8.txt @@ -0,0 +1,19 @@ + $2.., + ....,,:;+ccllll +$1 ...,,+:; $2cllllllllllllllllll +$1,cclllllllllll $2lllllllllllllllllll +$1llllllllllllll $2lllllllllllllllllll +$1llllllllllllll $2lllllllllllllllllll +$1llllllllllllll $2lllllllllllllllllll +$1llllllllllllll $2lllllllllllllllllll +$1llllllllllllll $2lllllllllllllllllll + +$3llllllllllllll $4lllllllllllllllllll +$3llllllllllllll $4lllllllllllllllllll +$3llllllllllllll $4lllllllllllllllllll +$3llllllllllllll $4lllllllllllllllllll +$3llllllllllllll $4lllllllllllllllllll +$3`'ccllllllllll $4lllllllllllllllllll +$3 `' \*:: $4:ccllllllllllllllll + ````''*::cll + `` \ No newline at end of file diff --git a/src/logo/ascii/windows_95.txt b/src/logo/ascii/windows_95.txt new file mode 100644 index 000000000..7cb886ccf --- /dev/null +++ b/src/logo/ascii/windows_95.txt @@ -0,0 +1,18 @@ +$6 ___ + .--=+++++=-:. +. _ *%@@@@@@@@@@@@@@* + *:+:.__ :+* @@@ @"$5_*&%$6@@$4%&&&*$6"@@@ + "+.-#+ +%* " _ $5++&&&%$6@@$4%&&&&&#$6@@ +$5" , $6%@@ $5&&&&&%$6@@$4%&&&&&#$6@@ +$5 * oo *# $6" _ $5&&&&&%$6@@$4%&&&&&#$6@@ +$5" , $6%@@ $5&&&&"$6@@@@#*$4"&&&$6@@ +.$5 * oo *# $6" _ %@@@@@@@@@@@@@@@@ + *:+:.__ :=* %@@ @"$1**&%$6@@$3%&&&*$6"@@@ + "+.-#+ +%* " _ $1&&&&&%$6@@$3%&&&&&#$6@@ +$1" , $6%@@ $1&&&&&%$6@@$3%&&&&&#$6@@ +$1 * oo *# $6" _ $1&&&&&%$6@@$3%&&&&&#$6@@ +$1" , $6%@@ $1&&*"$6%@@@@@@$3"*%&$6@@ +.$1 * oo *# $6" _ @@@@@@@@@@@@@@@@@ + *:+:.__ :+# @@@ @%#=+""""""+==%#@ + "+.-#+ +%* %+" " ":@ + " " \ No newline at end of file diff --git a/src/logo/ascii/zorin.txt b/src/logo/ascii/zorin.txt new file mode 100644 index 000000000..886f74b23 --- /dev/null +++ b/src/logo/ascii/zorin.txt @@ -0,0 +1,17 @@ + `osssssssssssssssssssso` + .osssssssssssssssssssssso. + .+oooooooooooooooooooooooo+. + + + `::::::::::::::::::::::. .:` + `+ssssssssssssssssss+:.` `.:+ssso` +.ossssssssssssssso/. `-+ossssssso. +ssssssssssssso/-` `-/osssssssssssss +.ossssssso/-` .-/ossssssssssssssso. + `+sss+:. `.:+ssssssssssssssssss+` + `:. .::::::::::::::::::::::` + + + .+oooooooooooooooooooooooo+. + -osssssssssssssssssssssso- + `osssssssssssssssssssso` \ No newline at end of file diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4dafa87ed..41e9ce89f 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -15,26 +15,7 @@ const FFlogo* ffLogoBuiltinGetUnknown(void) { FF_LOGO_INIT FF_LOGO_NAMES("unknown", "question mark", "?") - FF_LOGO_LINES( - " ________\n" - " _jgN########Ngg_\n" - " _N##N@@\"\" \"\"9NN##Np_\n" - "d###P N####p\n" - "\"^^\" T####\n" - " d###P\n" - " _g###@F\n" - " _gN##@P\n" - " gN###F\"\n" - " d###F\n" - " 0###F\n" - " 0###F\n" - " 0###F\n" - " \"NN@'\n" - "\n" - " ___\n" - " q###r\n" - " \"\"" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UNKNOWN) FF_LOGO_COLORS("") FF_LOGO_COLOR_KEYS("") FF_LOGO_COLOR_TITLE("") @@ -59,28 +40,7 @@ static const FFlogo* getLogoAlmaLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("almalinux") - FF_LOGO_LINES( - "$1 'c:.\n" - "$1 lkkkx, .. $2.. ,cc,\n" - "$1 okkkk:ckkx' $2.lxkkx.okkkkd\n" - "$1 .:llcokkx' $2:kkkxkko:xkkd,\n" - "$1 .xkkkkdood: $2;kx, .lkxlll;\n" - "$1 xkkx. $2xk' xkkkkk:\n" - "$1 'xkx. $2xd .....,.\n" - "$3 .. $1:xkl' $2:c ..''..\n" - "$3 .dkx' $1.:ldl:'. $2' $4':lollldkkxo;\n" - "$3 .''lkkko' $4ckkkx.\n" - "$3'xkkkd:kkd. .. $5;' $4:kkxo.\n" - "$3,xkkkd;kk' ,d; $5ld. $4':dkd::cc,\n" - "$3 .,,.;xkko'.';lxo. $5dx, $4:kkk'xkkkkc\n" - "$3 'dkkkkkxo:. $5;kx $4.kkk:;xkkd.\n" - "$3 ..... $5.;dk:. $5lkk. $4:;,\n" - " $5:kkkkkkkdoxkkx\n" - " ,c,,;;;:xkkd.\n" - " ;kkkkl...\n" - " ;kkkkl\n" - " ,od;"; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALMALINUX) FF_LOGO_COLORS( "31", // red "1;33", // yellow @@ -97,28 +57,7 @@ static const FFlogo* getLogoAlpine(void) { FF_LOGO_INIT FF_LOGO_NAMES("alpine", "alpinelinux", "alpine-linux") - FF_LOGO_LINES( - " .hddddddddddddddddddddddh.\n" - " :dddddddddddddddddddddddddd:\n" - " /dddddddddddddddddddddddddddd/\n" - " +dddddddddddddddddddddddddddddd+\n" - " `sdddddddddddddddddddddddddddddddds`\n" - " `ydddddddddddd++hdddddddddddddddddddy`\n" - ".hddddddddddd+` `+ddddh:-sdddddddddddh.\n" - "hdddddddddd+` `+y: .sddddddddddh\n" - "ddddddddh+` `//` `.` -sddddddddd\n" - "ddddddh+` `/hddh/` `:s- -sddddddd\n" - "ddddh+` `/+/dddddh/` `+s- -sddddd\n" - "ddd+` `/o` :dddddddh/` `oy- .yddd\n" - "hdddyo+ohddyosdddddddddho+oydddy++ohdddh\n" - ".hddddddddddddddddddddddddddddddddddddh.\n" - " `yddddddddddddddddddddddddddddddddddy`\n" - " `sdddddddddddddddddddddddddddddddds`\n" - " +dddddddddddddddddddddddddddddd+\n" - " /dddddddddddddddddddddddddddd/\n" - " :dddddddddddddddddddddddddd:\n" - " .hddddddddddddddddddddddh."; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE) FF_LOGO_COLORS( "34" //blue ) @@ -131,14 +70,7 @@ static const FFlogo* getLogoAlpineSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("alpine_small", "alpine-linux-small") - FF_LOGO_LINES( - " /\\ /\\\n" - " // \\ \\\n" - " // \\ \\\n" - "/// \\ \\\n" - "// \\ \\\n" - " \\" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL) FF_LOGO_COLORS( "34" //blue ) @@ -151,26 +83,7 @@ static const FFlogo* getLogoAndroid(void) { FF_LOGO_INIT FF_LOGO_NAMES("android") - FF_LOGO_LINES( - " -o o-\n" - " +hydNNNNdyh+\n" - " +mMMMMMMMMMMMMm+\n" - " `dMM$2m:$1NMMMMMMN$2:m$1MMd`\n" - " hMMMMMMMMMMMMMMMMMMh\n" - " .. yyyyyyyyyyyyyyyyyyyy ..\n" - ".mMMm`MMMMMMMMMMMMMMMMMMMM`mMMm.\n" - ":MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM:\n" - ":MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM:\n" - ":MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM:\n" - ":MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM:\n" - "-MMMM-MMMMMMMMMMMMMMMMMMMM-MMMM-\n" - " +yy+ MMMMMMMMMMMMMMMMMMMM +yy+\n" - " mMMMMMMMMMMMMMMMMMMm\n" - " `/++MMMMh++hMMMM++/`\n" - " MMMMo oMMMM\n" - " MMMMo oMMMM\n" - " oNMm- -mMNs" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANDROID) FF_LOGO_COLORS( "32", //green "37" //white @@ -184,14 +97,7 @@ static const FFlogo* getLogoAndroidSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("android-small", "android_small") - FF_LOGO_LINES( - " ;, ,;\n" - " ';,.-----.,;'\n" - " ,' ',\n" - " / O O \\\n" - "| |\n" - "'-----------------'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANDROID_SMALL) FF_LOGO_COLORS( "32" //green ) @@ -204,27 +110,7 @@ static const FFlogo* getLogoArch(void) { FF_LOGO_INIT FF_LOGO_NAMES("arch", "archlinux", "arch-linux") - FF_LOGO_LINES( - "$1 -`\n" - " .o+`\n" - " `ooo/\n" - " `+oooo:\n" - " `+oooooo:\n" - " -+oooooo+:\n" - " `/:-:++oooo+:\n" - " `/++++/+++++++:\n" - " `/++++++++++++++:\n" - " `/+++o$2oooooooo$1oooo/`\n" - " ./$2ooosssso++osssssso$1+`\n" - "$2 .oossssso-````/ossssss+`\n" - " -osssssso. :ssssssso.\n" - " :osssssss/ osssso+++.\n" - " /ossssssss/ +ssssooo/-\n" - " `/ossssso+/:- -:/+osssso+-\n" - " `+sso+:-` `.-/+oso:\n" - "`++:. `-/+/\n" - ".` `/"; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCH) FF_LOGO_COLORS( "36", //cyan "36" //cyan @@ -238,15 +124,7 @@ static const FFlogo* getLogoArchSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("arch_small", "archlinux_small", "arch-linux-small") - FF_LOGO_LINES( - " /\\\n" - " / \\\n" - " / \\\n" - " / \\\n" - " / ,, \\\n" - " / | | \\\n" - "/_-'' ''-_\\" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCH_SMALL) FF_LOGO_COLORS( "36" //cyan ) @@ -259,28 +137,7 @@ static const FFlogo* getLogoArtix(void) { FF_LOGO_INIT FF_LOGO_NAMES("artix", "artixlinux", "artix-linux") - FF_LOGO_LINES( - " '\n" - " 'o'\n" - " 'ooo'\n" - " 'ooxoo'\n" - " 'ooxxxoo'\n" - " 'oookkxxoo'\n" - " 'oiioxkkxxoo'\n" - " ':;:iiiioxxxoo'\n" - " `'.;::ioxxoo'\n" - " '-. `':;jiooo'\n" - " 'oooio-.. `'i:io'\n" - " 'ooooxxxxoio:,. `'-;'\n" - " 'ooooxxxxxkkxoooIi:-. `'\n" - " 'ooooxxxxxkkkkxoiiiiiji'\n" - " 'ooooxxxxxkxxoiiii:'` .i'\n" - " 'ooooxxxxxoi:::'` .;ioxo'\n" - " 'ooooxooi::'` .:iiixkxxo'\n" - " 'ooooi:'` `'';ioxxo'\n" - " 'i:'` '':io'\n" - "'` `'"; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX) FF_LOGO_COLORS( "36" //cyan ) @@ -293,15 +150,7 @@ static const FFlogo* getLogoArtixSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("artix_small", "artixlinux_small", "artix-linux-small") - FF_LOGO_LINES( - " /\\\n" - " / \\\n" - " /`'.,\\\n" - " / ',\n" - " / ,`\\\n" - " / ,.'`. \\\n" - "/.,'` `'.\\" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX_SMALL) FF_LOGO_COLORS( "36" //cyan ) @@ -314,28 +163,7 @@ static const FFlogo* getLogoArcoLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("arco", "arcolinux", "arco-linux") - FF_LOGO_LINES( - " /-\n" - " ooo:\n" - " yoooo/\n" - " yooooooo\n" - " yooooooooo\n" - " yooooooooooo\n" - " .yooooooooooooo\n" - " .oooooooooooooooo\n" - " .oooooooarcoooooooo\n" - " .ooooooooo-oooooooooo\n" - " .ooooooooo- oooooooooo\n" - " :ooooooooo. :ooooooooo\n" - " :ooooooooo. :ooooooooo\n" - " :oooarcooo .oooarcooo\n" - " :ooooooooy .ooooooooo\n" - " $1:ooooooooo $2/ooooooooooooooooooo\n" - " $1:ooooooooo $2.-ooooooooooooooooo.\n" - " $1ooooooooo- $2-ooooooooooooo.\n" - " $1ooooooooo- $2.-oooooooooo.\n" - "$1ooooooooo. $2-ooooooooo"; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCO) FF_LOGO_COLORS( "34", //blue "32" //green @@ -368,27 +196,7 @@ static const FFlogo* getLogoBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("bsd") - FF_LOGO_LINES( - "$1 , ,\n" - " /( )`\n" - " \\ \\___ / |\n" - " /- _ `-/ '\n" - " ($2/\\/ \\ $1\\ /\\\n" - " $2/ / | ` $1\\\n" - " $3O O $2) $1/ |\n" - " $2`-^--'$1`< '\n" - " (_.) _ ) /\n" - " `.___/` /\n" - " `-----' /\n" - "$4<----. __ / __ \\\n" - "$4<----|====$1O)))$4==$1) \\) /$4====|\n" - "<----' $1`--' `.__,' \\\n" - " | |\n" - " \\ / /\\\n" - " $5______$1( (_ / \\______/\n" - " $5,' ,-----' |\n" - " `--{__________)\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_BSD) FF_LOGO_COLORS( "31", "37", @@ -405,25 +213,7 @@ static const FFlogo* getLogoBedrock(void) { FF_LOGO_INIT FF_LOGO_NAMES("bedrock", "bedrocklinux", "bedrock-linux") - FF_LOGO_LINES( - "--------------------------------------\n" - "--------------------------------------\n" - "--------------------------------------\n" - "---$2\\\\\\\\\\\\\\\\\\\\\\\\$1-----------------------\n" - "----$2\\\\\\ \\\\\\$1----------------------\n" - "-----$2\\\\\\ \\\\\\$1---------------------\n" - "------$2\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$1------\n" - "-------$2\\\\\\ \\\\\\$1-----\n" - "--------$2\\\\\\ \\\\\\$1----\n" - "---------$2\\\\\\ ______ \\\\\\$1---\n" - "----------$2\\\\\\ ///$1---\n" - "-----------$2\\\\\\ ///$1----\n" - "------------$2\\\\\\ ///$1-----\n" - "-------------$2\\\\\\////////////////$1------\n" - "--------------------------------------\n" - "--------------------------------------\n" - "--------------------------------------" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_BEDROCK) FF_LOGO_COLORS( "90", //grey "37" //white @@ -437,30 +227,7 @@ static const FFlogo* getLogoCachyOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cachy", "cachyos", "cachy-linux", "cachyos-linux") - FF_LOGO_LINES( - " $3.$1-------------------------:\n" - " .$2+=$1========================.\n" - " :$2++$1===$2++===$1===============- :$2++$1-\n" - " :$2*++$1====$2+++++==$1===========- .==:\n" - " -$2*+++$1=====$2+***++=$1=========:\n" - " =$2*++++=$1=======------------:\n" - " =$2*+++++=$1====- $3...$1\n" - " .$2+*+++++$1=-===: .$2=+++=$1:\n" - " :$2++++$1=====-==: -***$2**$1+\n" - " :$2++=$1=======-=. .=+**+$3.$1\n" - ".$2+$1==========-. $3.$1\n" - " :$2+++++++$1====- $3.$1--==-$3.$1\n" - " :$2++$1==========. $3:$2+++++++$1$3:\n" - " $1.-===========. =*****+*+\n" - " $1.-===========: .+*****+:\n" - " $1-=======$2++++$1:::::::::::::::::::::::::-: $3.$1---:\n" - " :======$2++++$1====$2+++******************=.\n" - " $1:=====$2+++$1==========$2++++++++++++++*-\n" - " $1.====$2++$1==============$2++++++++++*-\n" - " $1.===$2+$1==================$2+++++++:\n" - " $1.-=======================$2+++:\n" - " $3.........................." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CACHYOS) FF_LOGO_COLORS( "36", //cyan "32", //green @@ -475,16 +242,7 @@ static const FFlogo* getLogoCachyOSSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small") - FF_LOGO_LINES( - " /''''''''''''/\n" - " /''''''''''''/\n" - " /''''''/\n" - "/''''''/\n" - "\\......\\\n" - " \\......\\\n" - " \\.............../\n" - " \\............./\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL) FF_LOGO_COLORS( "36" //cyan ) @@ -498,23 +256,7 @@ static const FFlogo* getLogoCelOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cel", "celos", "cel-linux", "celos-linux") - FF_LOGO_LINES( - " `-:/++++/:-`\n" - " -/syyyyyyyyyyyyy+-\n" - " :ssssyyyyyyyyyyyyyyyy/\n" - " .osy$2mmmmmmmmmmmmmmmNNNNNmmhy+\n" - " $1.sssshhhhhhhddddddddddddddds-\n" - " $1`osssssssyyyyyyyyyyyyyyyyyyhy`\n" - " $1:ssssssyyyyyyyyyyyyyyyyyyyyhh/\n" - "$2sMMMMMMMMMMMMMMMMMMMMMMMh$1yyyyyyhho\n" - " :sssssssyyyyyyyyyyyyyyyyyyyhh/\n" - " `ssssssssyyyyyyyyyyyyyyyyyyhy.\n" - " -sssssyddddddddddddddddddddy\n" - " -ssss$2hmmmmmmmmmmmmmmmmmmmyssss-\n" - " $1`/ssssyyyyyyyyyyyyyyyy+`\n" - " $1`:osyyyyyyyyyyyyys/`\n" - " $1`.:/+ooooo+:-`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CELOS) FF_LOGO_COLORS( "35", //magenta "30" //black @@ -528,27 +270,7 @@ static const FFlogo* getLogoCentOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("cent", "centos", "cent-linux", "centos-linux") - FF_LOGO_LINES( - " ..\n" - " .PLTJ.\n" - " <><><><>\n" - " $2KKSSV' 4KKK $1LJ$4 KKKL.'VSSKK\n" - " $2KKV' 4KKKKK $1LJ$4 KKKKAL 'VKK\n" - " $2V' ' 'VKKKK $1LJ$4 KKKKV' ' 'V\n" - " $2.4MA.' 'VKK $1LJ$4 KKV' '.4Mb.\n" - " $4. $2KKKKKA.' 'V $1LJ$4 V' '.4KKKKK $3.\n" - " $4.4D $2KKKKKKKA.'' $1LJ$4 ''.4KKKKKKK $3FA.\n" - "$4\n" - " '$4VD $3KKKKKKKK'.. $2LJ $1..'KKKKKKKK $3FV\n" - " $4' $3VKKKKK'. .4 $2LJ $1K. .'KKKKKV $3'\n" - " $3'VK'. .4KK $2LJ $1KKA. .'KV'\n" - " $3A. . .4KKKK $2LJ $1KKKKA. . .4\n" - " $3KKA. 'KKKKK $2LJ $1KKKKK' .4KK\n" - " $3KKSSA. VKKK $2LJ $1KKKV .4SSKK\n" - " $2<><><><>\n" - " $2'MKKM'\n" - " $2''" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CENTOS) FF_LOGO_COLORS( "33", //yellow "32", //green @@ -565,15 +287,7 @@ static const FFlogo* getLogoCentOSSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small") - FF_LOGO_LINES( - " $2____$1^$4____\n" - " $2|\\ $1|$4 /|\n" - " $2| \\ $1|$4 / |\n" - "$4<---- $3---->\n" - " $3| / $2|$1 \\ |\n" - " $3|/__$2|$1__\\|\n" - " $2v" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL) FF_LOGO_COLORS( "33", //yellow "32", //green @@ -588,27 +302,8 @@ static const FFlogo* getLogoCentOSSmall(void) static const FFlogo* getLogoCRUX(void) { FF_LOGO_INIT - FF_LOGO_NAMES("CRUX", "crux") - FF_LOGO_LINES( - " $1odddd\n" - " oddxkkkxxdoo\n" - " ddcoddxxxdoool\n" - " xdclodod olol\n" - " xoc xdd olol\n" - " xdc $2k00$1Okdlol\n" - " xxd$2kOKKKOkd$1ldd\n" - " xdco$2xOkdlo$1dldd\n" - " ddc:cl$2lll$1oooodo\n" - " odxxdd$3xkO000kx$1ooxdo\n" - " oxddx$30NMMMMMMWW0o$1dkkxo\n" - " oooxd$30WMMMMMMMMMW0o$1dxkx\n" - "docldkXW$3MMMMMMMWWN$1Odolco\n" - "xx$2dx$1kxxOKN$3WMMWN$10xdoxo::c\n" - "$2xOkkO$10oo$3odOW$2WW$1XkdodOxc:l\n" - "$2dkkkxkkk$3OKX$2NNNX0Oxx$1xc:cd\n" - " $2odxxdx$3xllo$2dddooxx$1dc:ldo\n" - " $2lodd$1dolccc$2ccox$1xoloo\n" - ) + FF_LOGO_NAMES("crux") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CRUX) FF_LOGO_COLORS( "34", //blue "35", //magenta @@ -623,28 +318,7 @@ static const FFlogo* getLogoCrystalLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("crystal", "Crystal", "crystal-linux", "Crystal-Linux") - FF_LOGO_LINES( - " mysssym\n" - " mysssym\n" - " mysssym\n" - " mysssym\n" - " mysssyd\n" - " mysssyd N\n" - " mysssyd mysym\n" - " mysssyd dysssym\n" - " mysssyd dysssym\n" - "mysssyd dysssym\n" - "mysssyd dysssym\n" - " mysssyd dysssym\n" - " mysssyd dysssym\n" - " mysym dysssym\n" - " N dysssym\n" - " dysssym\n" - " dysssym\n" - " dysssym\n" - " dysssym\n" - " dysssym"; - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CRYSTAL) FF_LOGO_COLORS( "35" //magenta ) @@ -653,31 +327,11 @@ static const FFlogo* getLogoCrystalLinux(void) FF_LOGO_RETURN } - - static const FFlogo* getLogoDebian(void) { FF_LOGO_INIT FF_LOGO_NAMES("debian", "debian-linux") - FF_LOGO_LINES( - " $2_,met$$$$$$$$$$gg.\n" - " ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P.\n" - " ,g$$$$P\" \"\"\"Y$$$$.\".\n" - " ,$$$$P' `$$$$$$.\n" - "',$$$$P ,ggs. `$$$$b:\n" - "`d$$$$' ,$P\"' $1.$2 $$$$$$\n" - " $$$$P d$' $1,$2 $$$$$$P\n" - " $$$$: $$. $1-$2 ,d$$$$'\n" - " $$$$; Y$b._ _,d$P'\n" - " Y$$$$. $1`.$2`\"Y$$$$$$$$P\"'\n" - " `$$$$b $1\"-.__\n" - " $2`Y$$$$\n" - " `Y$$$$.\n" - " `$$$$b.\n" - " `Y$$$$b.\n" - " `\"Y$$b._\n" - " `\"\"\"" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEBIAN) FF_LOGO_COLORS( "31", //red "37" //white @@ -691,14 +345,7 @@ static const FFlogo* getLogoDebianSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("debian_small", "debian-linux-small") - FF_LOGO_LINES( - " _____\n" - " / __ \\\n" - "| / |\n" - "| \\___-\n" - "-_\n" - " --_" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL) FF_LOGO_COLORS( "31" //red ) @@ -711,23 +358,7 @@ static const FFlogo* getLogoDevuan(void) { FF_LOGO_INIT FF_LOGO_NAMES("devuan", "devuan-linux") - FF_LOGO_LINES( - " ..,,;;;::;,..\n" - " `':ddd;:,.\n" - " `'dPPd:,.\n" - " `:b$$b`.\n" - " 'P$$$d`\n" - " .$$$$$`\n" - " ;$$$$$P\n" - " .:P$$$$$$`\n" - " .,:b$$$$$$$;'\n" - " .,:dP$$$$$$$$b:'\n" - " .,:;db$$$$$$$$$$Pd'`\n" - " ,db$$$$$$$$$$$$$$b:'`\n" - ":$$$$$$$$$$$$b:'`\n" - " `$$$$$bd:''`\n" - " `'''`\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEVUAN) FF_LOGO_COLORS( "35" //magenta ) @@ -740,15 +371,7 @@ static const FFlogo* getLogoDevuanSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("devuan_small", "devuan-linux-small") - FF_LOGO_LINES( - " ..:::.\n" - " ..-==-\n" - " .+#:\n" - " =@@\n" - " :+%@#:\n" - ".:=+#@@%*:\n" - "#@@@#=:\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL) FF_LOGO_COLORS( "35" //magenta ) @@ -761,26 +384,7 @@ static const FFlogo* getLogoDeepin(void) { FF_LOGO_INIT FF_LOGO_NAMES("deepin", "deepin-linux") - FF_LOGO_LINES( - "$1 ............\n" - " .';;;;;. .,;,.\n" - " .,;;;;;;;. ';;;;;;;.\n" - " .;::::::::' .,::;;,''''',.\n" - " ,'.:::::::: .;;'. ';\n" - " ;' 'cccccc, ,' :: '.. .:\n" - " ,, :ccccc. ;: .c, '' :. ,;\n" - ".l. cllll' ., .lc :; .l' l.\n" - ".c :lllc ;cl: .l' .ll. :'\n" - ".l 'looc. . ,o: 'oo' c,\n" - ".o. .:ool::coc' .ooo' o.\n" - " :: ..... .;dddo ;c\n" - " l:... .';lddddo. ,o\n" - " lxxxxxdoolllodxxxxxxxxxc :l\n" - " ,dxxxxxxxxxxxxxxxxxxl. 'o,\n" - " ,dkkkkkkkkkkkkko;. .;o;\n" - " .;okkkkkdl;. .,cl:.\n" - " .,:cccccccc:,." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEEPIN) FF_LOGO_COLORS( "32" //green ) @@ -793,23 +397,7 @@ static const FFlogo* getLogoEndeavour(void) { FF_LOGO_INIT FF_LOGO_NAMES("endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux") - FF_LOGO_LINES( - " $2./$1o$3.\n" - " $2./$1sssso$3-\n" - " $2`:$1osssssss+$3-\n" - " $2`:+$1sssssssssso$3/.\n" - " $2`-/o$1ssssssssssssso$3/.\n" - " $2`-/+$1sssssssssssssssso$3+:`\n" - " $2`-:/+$1sssssssssssssssssso$3+/.\n" - " $2`.://o$1sssssssssssssssssssso$3++-\n" - " $2.://+$1ssssssssssssssssssssssso$3++:\n" - " $2.:///o$1ssssssssssssssssssssssssso$3++:\n" - " $2`:////$1ssssssssssssssssssssssssssso$3+++.\n" - "$2`-////+$1ssssssssssssssssssssssssssso$3++++-\n" - " $2`..-+$1oosssssssssssssssssssssssso$3+++++/`\n" - " $3./++++++++++++++++++++++++++++++/:.\n" - " `:::::::::::::::::::::::::------``" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ENDEAVOUR) FF_LOGO_COLORS( "35", //magenta "31", //red @@ -824,27 +412,7 @@ static const FFlogo* getLogoEnso(void) { FF_LOGO_INIT FF_LOGO_NAMES("enso", "uqc") - FF_LOGO_LINES( - " .:--==--:. \n" - " :=*#############*+-. \n" - " .+##################*##*: \n" - " .*##########+==-==++*####*##- \n" - " =########=: .-+**#***. \n" - " *#######- ++*#**. \n" - " +######+ -*+#** \n" - " :######* .*+**= \n" - " *######: --#*# \n" - " ####### +++#. \n" - " #######. ++=*. \n" - " *######+ .-+*+ \n" - " :#######- -:*+: \n" - " =#######*. :.*+- \n" - " +########*- :*=- \n" - " =###########+=: =+=: \n" - " .+#############. .-==: \n" - " .=###########= ..:--:. \n" - " .-+######+ \n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ENSO) FF_LOGO_COLORS( "37" //white ) @@ -857,30 +425,7 @@ static const FFlogo* getLogoExherbo(void) { FF_LOGO_INIT FF_LOGO_NAMES("exherbo", "exherbo-linux") - FF_LOGO_LINES( - "$2 ,\n" - "OXo.\n" - "NXdX0: .cok0KXNNXXK0ko:.\n" - "KX '0XdKMMK;.xMMMk, .0MMMMMXx; ...\n" - "'NO..xWkMMx kMMM cMMMMMX,NMWOxOXd.\n" - " cNMk NK .oXM. OMMMMO. 0MMNo kW.\n" - " lMc o: ., .oKNk; ;NMMWlxW'\n" - " ;Mc .. .,,' .0M$1g;$2WMN'dWMMMMMMO\n" - " XX ,WMMMMW. cM$1cfli$2WMKlo. .kMk\n" - ".Mo .WM$1GD$2MW. XM$1WO0$2MMk oMl\n" - ",M: ,XMMWx::,''oOK0x; NM.\n" - "'Ml ,kNKOxxxxxkkO0XXKOd:. oMk\n" - " NK .0Nxc$3:::::::::::::::$2fkKNk, .MW\n" - " ,Mo .NXc$3::$2qXWXb$3::::::::::$2oo$3::$2lNK. .MW\n" - " ;Wo oMd$3:::$2oNMNP$3::::::::$2oWMMMx$3:$2c0M; lMO\n" - " 'NO;W0c$3:::::::::::::::$2dMMMMO$3::$2lMk .WM'\n" - " xWONXdc$3::::::::::::::$2oOOo$3::$2lXN. ,WMd\n" - " 'KWWNXXK0Okxxo,$3:::::::$2,lkKNo xMMO\n" - " :XMNxl,';:lodxkOO000Oxc. .oWMMo\n" - " 'dXMMXkl;,. .,o0MMNo'\n" - " ':d0XWMMMMWNNNNMMMNOl'\n" - " ':okKXWNKkl'\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_EXHERBO) FF_LOGO_COLORS( "34", //blue "37", //white @@ -895,27 +440,7 @@ static const FFlogo* getLogoFedora(void) { FF_LOGO_INIT FF_LOGO_NAMES("fedora", "fedora-linux") - FF_LOGO_LINES( - " .',;::::;,'.\n" - " .';:cccccccccccc:;,.\n" - " .;cccccccccccccccccccccc;.\n" - " .:cccccccccccccccccccccccccc:.\n" - " .;ccccccccccccc;$2.:dddl:.$1;ccccccc;.\n" - " .:ccccccccccccc;$2OWMKOOXMWd$1;ccccccc:.\n" - ".:ccccccccccccc;$2KMMc$1;cc;$2xMMc$1;ccccccc:.\n" - ",cccccccccccccc;$2MMM.$1;cc;$2;WW:$1;cccccccc,\n" - ":cccccccccccccc;$2MMM.$1;cccccccccccccccc:\n" - ":ccccccc;$2oxOOOo$1;$2MMM000k.$1;cccccccccccc:\n" - "cccccc;$20MMKxdd:$1;$2MMMkddc.$1;cccccccccccc;\n" - "ccccc;$2XMO'$1;cccc;$2MMM.$1;cccccccccccccccc'\n" - "ccccc;$2MMo$1;ccccc;$2MMW.$1;ccccccccccccccc;\n" - "ccccc;$20MNc.$1ccc$2.xMMd$1;ccccccccccccccc;\n" - "cccccc;$2dNMWXXXWM0:$1;cccccccccccccc:,\n" - "cccccccc;$2.:odl:.$1;cccccccccccccc:,.\n" - "ccccccccccccccccccccccccccccc:'.\n" - ":ccccccccccccccccccccccc:;,..\n" - " ':cccccccccccccccc::;,." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA) FF_LOGO_COLORS( "34", //blue "37" //white @@ -929,17 +454,7 @@ static const FFlogo* getLogoFedoraSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("fedora_small", "fedora-linux-small") - FF_LOGO_LINES( - " ,'''''.\n" - " | ,. |\n" - " | | '_'\n" - " ,....| |..\n" - ".' ,_;| ..'\n" - "| | | |\n" - "| ',_,' |\n" - " '. ,'\n" - " '''''" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL) FF_LOGO_COLORS( "34" //blue ) @@ -952,25 +467,7 @@ static const FFlogo* getLogoFedoraOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old") - FF_LOGO_LINES( - " /:-------------:\\\n" - " :-------------------::\n" - " :-----------$2/shhOHbmp$1---:\\\n" - " /-----------$2omMMMNNNMMD$1 ---:\n" - " :-----------$2sMMMMNMNMP$1. ---:\n" - " :-----------$2:MMMdP$1------- ---\\\n" - ",------------$2:MMMd$1-------- ---:\n" - ":------------$2:MMMd$1------- .---:\n" - ":---- $2oNMMMMMMMMMNho$1 .----:\n" - ":-- .$2+shhhMMMmhhy++$1 .------/\n" - ":- -------$2:MMMd$1--------------:\n" - ":- --------$2/MMMd$1-------------;\n" - ":- ------$2/hMMMy$1------------:\n" - ":--$2 :dMNdhhdNMMNo$1------------;\n" - ":---$2:sdNMMMMNds:$1------------:\n" - ":------$2:://:$1-------------::\n" - ":---------------------://" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA_OLD) FF_LOGO_COLORS( "34", //blue "37" //white @@ -984,23 +481,7 @@ static const FFlogo* getLogoFreeBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("freebsd") - FF_LOGO_LINES( - "``` $2`\n" - " $1` `.....---...$2....--.``` -/\n" - " $1+o .--` $2/y:` +.\n" - " $1yo`:. $2:o `+-\n" - " $1y/ $2-/` -o/\n" - " $1.- $2::/sy+:.\n" - " $1/ $2`-- /\n" - " $1`: $2:`\n" - " $1`: $2:`\n" - " $1/ $2/\n" - " $1.- $2-.\n" - " $1-- $2-.\n" - " $1`:` $2`:`\n" - " .-- `--.\n" - " .---.....----." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FREEBSD) FF_LOGO_COLORS( "37", //white "31" //red @@ -1014,14 +495,7 @@ static const FFlogo* getLogoFreeBSDSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("freebsd_small") - FF_LOGO_LINES( - "$1/\\,-'''''-,/\\\n" - "\\_) (_/\n" - "| |\n" - "| |\n" - " ; ;\n" - " '-_____-'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FREEBSD_SMALL) FF_LOGO_COLORS( "31" //red ) @@ -1034,26 +508,7 @@ static const FFlogo* getLogoGaruda(void) { FF_LOGO_INIT FF_LOGO_NAMES("garuda", "garuda-linux") - FF_LOGO_LINES( - " .%;888:8898898:\n" - " x;XxXB%89b8:b8%b88:\n" - " .8Xxd 8X:.\n" - " .8Xx; 8x:.\n" - " .tt8x .d x88;\n" - " .@8x8; .db: xx@;\n" - " ,tSXX° .bbbbbbbbbbbbbbbbbbbB8x@;\n" - " .SXxx bBBBBBBBBBBBBBBBBBBBbSBX8;\n" - " ,888S pd!\n" - "8X88/ q\n" - "8X88/\n" - "GBB.\n" - " x%88 d888@8@X@X@X88X@@XX@@X@8@X.\n" - " dxXd dB8b8b8B8B08bB88b998888b88x.\n" - " dxx8o .@@;.\n" - " dx88 .t@x.\n" - " d:SS@8ba89aa67a853Sxxad.\n" - " .d988999889889899dd." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA) FF_LOGO_COLORS( "31" //red ) @@ -1066,13 +521,7 @@ static const FFlogo* getLogoGarudaSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("garuda_small", "garudalinux_small", "garuda-linux-small") - FF_LOGO_LINES( - " .----.\n" - " .' , '.\n" - " .' '-----|\n" - "'. -----,\n" - " '.____.'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL) FF_LOGO_COLORS( "31" //red ) @@ -1085,26 +534,7 @@ static const FFlogo* getLogoGentoo(void) { FF_LOGO_INIT FF_LOGO_NAMES("gentoo", "gentoo-linux") - FF_LOGO_LINES( - " -/oyddmdhs+:.\n" - " -o$2dNMMMMMMMMNNmhy+$1-`\n" - " -y$2NMMMMMMMMMMMNNNmmdhy$1+-\n" - " `o$2mMMMMMMMMMMMMNmdmmmmddhhy$1/`\n" - " om$2MMMMMMMMMMMN$1hhyyyo$2hmdddhhhd$1o`\n" - ".y$2dMMMMMMMMMMd$1hs++so/s$2mdddhhhhdm$1+`\n" - " oy$2hdmNMMMMMMMN$1dyooy$2dmddddhhhhyhN$1d.\n" - " :o$2yhhdNNMMMMMMMNNNmmdddhhhhhyym$1Mh\n" - " .:$2+sydNMMMMMNNNmmmdddhhhhhhmM$1my\n" - " /m$2MMMMMMNNNmmmdddhhhhhmMNh$1s:\n" - " `o$2NMMMMMMMNNNmmmddddhhdmMNhs$1+`\n" - " `s$2NMMMMMMMMNNNmmmdddddmNMmhs$1/.\n" - " /N$2MMMMMMMMNNNNmmmdddmNMNdso$1:`\n" - "+M$2MMMMMMNNNNNmmmmdmNMNdso$1/-\n" - "yM$2MNNNNNNNmmmmmNNMmhs+/$1-`\n" - "/h$2MMNNNNNNNNMNdhs++/$1-`\n" - "`/$2ohdmmddhys+++/:$1.`\n" - " `-//////:--." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GENTOO) FF_LOGO_COLORS( "35", //magenta "37" //white @@ -1118,15 +548,7 @@ static const FFlogo* getLogoGentooSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("gentoo_small", "gentoo-linux-small") - FF_LOGO_LINES( - " _-----_\n" - "( \\\n" - "\\ 0 \\\n" - " $2\\ )\n" - " / _/\n" - "( _-\n" - "\\____-" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL) FF_LOGO_COLORS( "35", //magenta "37" //white @@ -1140,21 +562,7 @@ static const FFlogo* getLogoGhostBSD(void) { FF_LOGO_INIT FF_LOGO_NAMES("ghostbsd") - FF_LOGO_LINES( - "$1 ,gggggg.\n" - " ,agg9* .g)\n" - " .agg* ._.,gg*\n" - " ,gga* (ggg*'\n" - " ,ga* ,ga*\n" - " ,ga' .ag*\n" - " ,ga' .agga'\n" - " 9g' .agg'g*,a\n" - " 'gggg*',gga'\n" - " .gg*'\n" - " .gga*\n" - " .gga*\n" - " (ga*" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GHOSTBSD) FF_LOGO_COLORS( "34" //blue ) @@ -1222,27 +630,7 @@ static const FFlogo* getLogoKDENeon(void) { FF_LOGO_INIT FF_LOGO_NAMES("kde", "kde-neon", "neon") - FF_LOGO_LINES( - " `..---+/---..`\n" - " `---.`` `` `.---.`\n" - " .--.` `` `-:-.\n" - " `:/: `.----//----.` :/-\n" - " .:. `---` `--.` .:`\n" - " .:` `--` .:- `:.\n" - " `/ `:. `.-::-.` -:` `/`\n" - " /. /. `:++++++++:` .: .:\n" - "`/ .: `+++++++++++/ /` `+`\n" - "/+` -- .++++++++++++` :. .+:\n" - "`/ .: `+++++++++++/ /` `+`\n" - " /` /. `:++++++++:` .: .:\n" - " ./ `:. `.:::-.` -:` `/`\n" - " .:` `--` .:- `:.\n" - " .:. `---` `--.` .:`\n" - " `:/: `.----//----.` :/-\n" - " .-:.` `` `-:-.\n" - " `---.`` `` `.---.`\n" - " `..---+/---..`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KDE) FF_LOGO_COLORS( "32" //green ) @@ -1255,15 +643,7 @@ static const FFlogo* getLogoKISSLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("kiss", "kiss-linux", "kisslinux") - FF_LOGO_LINES( - " $3 ___ \n" - " ($2.· $3| \n" - " ($1<> $3| \n" - " / $2__$3 \\ \n" - " ( $1/ \\ $3/| \n" - "$1_$3/\\ $2__)$3/$1_$3) \n" - "$1\\/$3-____$1\\/$2 \n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KISS) FF_LOGO_COLORS( "35", //magenta "37", //white @@ -1278,28 +658,7 @@ static const FFlogo* getLogoKubuntu(void) { FF_LOGO_INIT FF_LOGO_NAMES("kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma") - FF_LOGO_LINES( - "$1 `.:/ossyyyysso/:.\n" - " .:oyyyyyyyyyyyyyyyyyyo:`\n" - " -oyyyyyyyo$2dMMy$1yyyyyyysyyyyo-\n" - " -syyyyyyyyyy$2dMMy$1oyyyy$2dmMMy$1yyyys-\n" - " oyyys$2dMy$1syyyy$2dMMMMMMMMMMMMMy$1yyyyyyo\n" - " `oyyyy$2dMMMMy$1syysoooooo$2dMMMMy$1yyyyyyyyo`\n" - " oyyyyyy$2dMMMMy$1yyyyyyyyyyys$2dMMy$1sssssyyyo\n" - "-yyyyyyyy$2dMy$1syyyyyyyyyyyyyys$2dMMMMMy$1syyy-\n" - "oyyyysoo$2dMy$1yyyyyyyyyyyyyyyyyy$2dMMMMy$1syyyo\n" - "yyys$2dMMMMMy$1yyyyyyyyyyyyyyyyyysosyyyyyyyy\n" - "yyys$2dMMMMMy$1yyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n" - "oyyyyysos$2dy$1yyyyyyyyyyyyyyyyyy$2dMMMMy$1syyyo\n" - "-yyyyyyyy$2dMy$1syyyyyyyyyyyyyys$2dMMMMMy$1syyy-\n" - " oyyyyyy$2dMMMy$1syyyyyyyyyyys$2dMMy$1oyyyoyyyo\n" - " `oyyyy$2dMMMy$1syyyoooooo$2dMMMMy$1oyyyyyyyyo\n" - " oyyysyyoyyyys$2dMMMMMMMMMMMy$1yyyyyyyo\n" - " -syyyyyyyyy$2dMMMy$1syyy$2dMMMy$1syyyys-\n" - " -oyyyyyyy$2dMMy$1yyyyyysosyyyyo-\n" - " ./oyyyyyyyyyyyyyyyyyyo/.\n" - " `.:/oosyyyysso/:.`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KUBUNTU) FF_LOGO_COLORS( "34", //blue "37" //white @@ -1312,22 +671,8 @@ static const FFlogo* getLogoKubuntu(void) static const FFlogo* getLogoLangitKetujuh(void) { FF_LOGO_INIT - FF_LOGO_NAMES("l7", "langitketujuh", "LangitKetujuh") - FF_LOGO_LINES( - "\n" - "\n" - " $2. '7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7\n" - " $2L7. '7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7\n" - " $2L7L7L 7L7L7L7L7L7L7L7L7L7L7L7L7L7\n" - " $2L7L7L7 L7L7L7\n" - " $2L7L7L7 'L7L7L7L7L7L7L7L7L7L7\n" - " $2L7L7L7 'L7L7L7L7L7L7L7L7\n" - " $2L7L7L7 'L7L7L7L7L7L7\n" - " $2L7L7L7 L7L7L7\n" - " $2L7L7L7L7L7L7L7L7L7L7LL7L7L7. '7L7L7\n" - " $2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L. 'L7\n" - " $2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7. '\n" - ) + FF_LOGO_NAMES("langitketujuh", "l7") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LANGITKETUJUH) FF_LOGO_COLORS( "34", //blue "37" //white @@ -1341,20 +686,7 @@ static const FFlogo* getLogoLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("linux", "linux-generic") - FF_LOGO_LINES( - " $2#####\n" - " $2#######\n" - " $2##$1O$2#$1O$2##\n" - " $2#$3#####$2#\n" - " $2##$1##$3###$1##$2##\n" - " $2#$1##########$2##\n" - " $2#$1############$2##\n" - " $2#$1############$2###\n" - " $3##$2#$1###########$2##$3#\n" - "$3######$2#$1#######$2#$3######\n" - "$3#######$2#$1#####$2#$3#######\n" - " $3#####$2#######$3#####" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LINUX) FF_LOGO_COLORS( "37", //white "30", //black @@ -1369,15 +701,7 @@ static const FFlogo* getLogoLinuxSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("linux_small", "linux-generic_small") - FF_LOGO_LINES( - " $1___\n" - " ($2.. $1\\\n" - " ($3<> $1|\n" - " /$2/ \\ $1\\\n" - " ( $2| | $1/|\n" - "$3_$1/\\ $2__)$1/$3_$1)\n" - "$3\\/$1-____$3\\/\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LINUX_SMALL) FF_LOGO_COLORS( "30", //black "37", //white @@ -1406,25 +730,7 @@ static const FFlogo* getLogoMacOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("macos", "mac", "apple", "darwin", "osx") - FF_LOGO_LINES( - " $1..'\n" - " ,xNMM.\n" - " .OMMMMo\n" - " lMM\"\n" - " .;loddo:. .olloddol;.\n" - " cKMMMMMMMMMMNWMMMMMMMMMM0:\n" - " $2.KMMMMMMMMMMMMMMMMMMMMMMMWd.\n" - " XMMMMMMMMMMMMMMMMMMMMMMMX.\n" - "$3;MMMMMMMMMMMMMMMMMMMMMMMM:\n" - ":MMMMMMMMMMMMMMMMMMMMMMMM:\n" - ".MMMMMMMMMMMMMMMMMMMMMMMMX.\n" - " kMMMMMMMMMMMMMMMMMMMMMMMMWd.\n" - " $4'XMMMMMMMMMMMMMMMMMMMMMMMMMMk\n" - " 'XMMMMMMMMMMMMMMMMMMMMMMMMK.\n" - " $5kMMMMMMMMMMMMMMMMMMMMMMd\n" - " ;KMMMMMMMWXXWMMMMMMMk.\n" - " \"cooc*\" \"*coo'\"" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS) FF_LOGO_COLORS( "32", //green "33", //yellow @@ -1441,15 +747,7 @@ static const FFlogo* getLogoMacOSSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("macos_small", "mac_small", "apple_small", "darwin_small", "osx_small") - FF_LOGO_LINES( - "$1 .:'\n" - " __ :'__\n" - "$2 .'`__`-'__``.\n" - "$3:__________.-'\n" - "$4:_________:\n" - " :_________`-;\n" - "$5 `.__.-.__.'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS_SMALL) FF_LOGO_COLORS( "32", //green "33", //yellow @@ -1466,25 +764,7 @@ static const FFlogo* getLogoMacOS2(void) { FF_LOGO_INIT FF_LOGO_NAMES("macos2", "mac2", "apple2", "darwin2", "osx2") - FF_LOGO_LINES( - " $1..'\n" - " ,xN .\n" - " .O o\n" - " l \"\n" - " .;loddo:. .olloddol;.\n" - " cK NW 0:\n" - " $2.K Wd.\n" - " X X.\n" - "$3; :\n" - ": :\n" - ". X.\n" - " k Wd.\n" - " $4'X k\n" - " 'X K.\n" - " $5k d\n" - " ;K WXXW k.\n" - " \"cooc*\" \"*coo'\"" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS2) FF_LOGO_COLORS( "32", //green "33", //yellow @@ -1501,15 +781,7 @@ static const FFlogo* getLogoMacOS2Small(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("macos2_small", "mac2_small", "apple2_small", "darwin2_small", "osx2_small") - FF_LOGO_LINES( - "$1 .:'\n" - " __ :'__\n" - "$2 .'` `-' ``.\n" - "$3: .-'\n" - "$4: :\n" - " : `-;\n" - "$5 `.__.-.__.'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL) FF_LOGO_COLORS( "32", //green "33", //yellow @@ -1540,22 +812,7 @@ static const FFlogo* getLogoManjaro(void) { FF_LOGO_INIT FF_LOGO_NAMES("manjaro", "manjaro-linux") - FF_LOGO_LINES( - "██████████████████ ████████\n" - "██████████████████ ████████\n" - "██████████████████ ████████\n" - "██████████████████ ████████\n" - "████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████\n" - "████████ ████████ ████████" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANJARO) FF_LOGO_COLORS( "32" //green ) @@ -1568,15 +825,7 @@ static const FFlogo* getLogoManjaroSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("manjaro_small", "manjaro-linux-small") - FF_LOGO_LINES( - "||||||||| ||||\n" - "||||||||| ||||\n" - "|||| ||||\n" - "|||| |||| ||||\n" - "|||| |||| ||||\n" - "|||| |||| ||||\n" - "|||| |||| ||||" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANJARO_SMALL) FF_LOGO_COLORS( "32" //green ) @@ -1604,27 +853,7 @@ static const FFlogo* getLogoMint(void) { FF_LOGO_INIT FF_LOGO_NAMES("mint", "linuxmint", "mint-linux", "linux-mint") - FF_LOGO_LINES( - " $2...-:::::-...\n" - " .-MMMMMMMMMMMMMMM-.\n" - " .-MMMM$1`..-:::::::-..`$2MMMM-.\n" - " .:MMMM$1.:MMMMMMMMMMMMMMM:.$2MMMM:.\n" - " -MMM$1-M---MMMMMMMMMMMMMMMMMMM.$2MMM-\n" - " `:MMM$1:MM` :MMMM:....::-...-MMMM:$2MMM:`\n" - " :MMM$1:MMM` :MM:` `` `` `:MMM:$2MMM:\n" - ".MMM$1.MMMM` :MM. -MM. .MM- `MMMM.$2MMM.\n" - ":MMM$1:MMMM` :MM. -MM- .MM: `MMMM-$2MMM:\n" - ":MMM$1:MMMM` :MM. -MM- .MM: `MMMM:$2MMM:\n" - ":MMM$1:MMMM` :MM. -MM- .MM: `MMMM-$2MMM:\n" - ".MMM$1.MMMM` :MM:--:MM:--:MM: `MMMM.$2MMM.\n" - " :MMM$1:MMM- `-MMMMMMMMMMMM-` -MMM-$2MMM:\n" - " :MMM$1:MMM:` `:MMM:$2MMM:\n" - " .MMM$1.MMMM:--------------:MMMM.$2MMM.\n" - " '-MMMM$1.-MMMMMMMMMMMMMMM-.$2MMMM-'\n" - " '.-MMMM$1``--:::::--``$2MMMM-.'\n" - " '-MMMMMMMMMMMMM-'\n" - " ``-:::::-``" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT) FF_LOGO_COLORS( "32", //green "37" //white @@ -1638,15 +867,7 @@ static const FFlogo* getLogoMintSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("mint_small", "linuxmint_small", "mint-linux-small") - FF_LOGO_LINES( - " __________\n" - "|_ \\\n" - " | $2| _____ $1|\n" - " | $2| | | | $1|\n" - " | $2| | | | $1|\n" - " | $2\\__$2___/ $1|\n" - " \\_________/" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT_SMALL) FF_LOGO_COLORS( "32", //green "37" //white @@ -1660,24 +881,7 @@ static const FFlogo* getLogoMintOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old") - FF_LOGO_LINES( - "MMMMMMMMMMMMMMMMMMMMMMMMMmds+.\n" - "MMm----::-://////////////oymNMd+`\n" - "MMd $2/++ $1-sNMd:\n" - "MMNso/` $2dMM `.::-. .-::.` $1.hMN:\n" - "ddddMMh $2dMM :hNMNMNhNMNMNh: $1`NMm\n" - " NMm $2dMM .NMN/-+MMM+-/NMN` $1dMM\n" - " NMm $2dMM -MMm `MMM dMM. $1dMM\n" - " NMm $2dMM -MMm `MMM dMM. $1dMM\n" - " NMm $2dMM .mmd `mmm yMM. $1dMM\n" - " NMm $2dMM` ..` ... ydm. $1dMM\n" - " hMM- $2+MMd/-------...-:sdds $1dMM\n" - " -NMm- $2:hNMNNNmdddddddddy/` $1dMM\n" - " -dMNs-$2``-::::-------.`` $1dMM\n" - " `/dMNmy+/:-------------:/yMMM\n" - " ./ydNMMMMMMMMMMMMMMMMMMMMM\n" - " .MMMMMMMMMMMMMMMMMMM" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT_OLD) FF_LOGO_COLORS( "32", //green "37" //white @@ -1691,33 +895,7 @@ static const FFlogo* getLogoMsys2(void) { FF_LOGO_INIT FF_LOGO_NAMES("msys2") - FF_LOGO_LINES( - "$2 ...\n" - " 5GB###GJ. !YPGGGG\n" - " 7@@@@@@@B. :G@@@@@@@\n" - " 7@@@@@@@@Y ~&@@@@@@@@$3YJYY5YY?L\n" - " $2!@@@@@@@@@@^ ^&@@@@@@@$3#PP555555PBY\n" - " $2~&@@@@@@@@@@? ^&@@@@@@$3#5YY5YYYYYYYY#7\n" - " $2^&@@@@@@@@@@@B :#@@@@@@@$3G5BBYGPYYYYYY#J\n" - " $2^#@@@&J#@@@@@@@~ .B@@@@@@@@@@@P $3?#YYYYYPB.\n" - " $2:#@@@@7 G@@@@@@@J P@@@#!&@@@@@@G$3.GGYYYYGB^\n" - " $2:#@@@@J Y@@@@@@@B 5@@@&:.&@@@@@@&$3BBYYY5B5.\n" - " $2:#@@@@Y !@@@@@@@@!Y@@@&~ .#@@@@@@$3GYYYYYBP JP~\n" - " $2:#@@@@P :&@@@@@@@@@@@&~ B@@@@@$3#5YYYYYPGPGPGG\n" - " $2^#@@@@G. P@@@@@@@@@@@! P@@@@$3GYYYYYYYYYYYYBY\n" - " $2^#@@@@B: ^@@@@@@@@@@7 !@@@$3#GGGGGGGPPPP5GB:\n" - " $2!&@@@@B: Y@@@@@@@@? P@@@@@@@@@&? $3^PY:\n" - " $27&@@@@5. P@@@@@@? P@@@@@@@@@B\n" - " Y@@@&P! 5@@@@7 7G@@@@@&P~\n" - ".JJ?~: ^JY~ ^!5J!^:\n" - " $1:@P5#B. #G 7&^ :@P5#B.\n" - " !&P^. ?@~ #P !&P^. \n" - " .?BG! #G5@~ .?BG! \n" - " :.B@. 7@@5 :.B@.\n" - " !PYY5Y :&@^ !PYY5Y \n" - " ~@Y\n" - " !5:" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MSYS2) FF_LOGO_COLORS( "35", //magenta "37", //white @@ -1732,25 +910,7 @@ static const FFlogo* getLogoWindows11(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows 11", "Windows Server 2022") - FF_LOGO_LINES( - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "$1///////////////// $2/////////////////\n" - "\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////\n" - "$3///////////////// $4/////////////////" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_11) FF_LOGO_COLORS( "34", //blue "34", //blue @@ -1766,17 +926,7 @@ static const FFlogo* getLogoWindows11Small(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") - FF_LOGO_LINES( - "$1lllllllll $2lllllllll\n" - "$1lllllllll $2lllllllll\n" - "$1lllllllll $2lllllllll\n" - "$1lllllllll $2lllllllll\n" - "\n" - "$3lllllllll $4lllllllll\n" - "$3lllllllll $4lllllllll\n" - "$3lllllllll $4lllllllll\n" - "$3lllllllll $4lllllllll\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL) FF_LOGO_COLORS( "34" //blue ) @@ -1789,27 +939,7 @@ static const FFlogo* getLogoWindows8(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019") - FF_LOGO_LINES( - " $2..,\n" - " ....,,:;+ccllll\n" - "$1 ...,,+:; $2cllllllllllllllllll\n" - "$1,cclllllllllll $2lllllllllllllllllll\n" - "$1llllllllllllll $2lllllllllllllllllll\n" - "$1llllllllllllll $2lllllllllllllllllll\n" - "$1llllllllllllll $2lllllllllllllllllll\n" - "$1llllllllllllll $2lllllllllllllllllll\n" - "$1llllllllllllll $2lllllllllllllllllll\n" - "\n" - "$3llllllllllllll $4lllllllllllllllllll\n" - "$3llllllllllllll $4lllllllllllllllllll\n" - "$3llllllllllllll $4lllllllllllllllllll\n" - "$3llllllllllllll $4lllllllllllllllllll\n" - "$3llllllllllllll $4lllllllllllllllllll\n" - "$3`'ccllllllllll $4lllllllllllllllllll\n" - "$3 `' \\*:: $4:ccllllllllllllllll\n" - " ````''*::cll\n" - " ``" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_8) FF_LOGO_COLORS( "36", //cyan "36", //cyan @@ -1825,24 +955,7 @@ static const FFlogo* getLogoWindows(void) { FF_LOGO_INIT FF_LOGO_NAMES("Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2") - FF_LOGO_LINES( - "$1 ,.=:!!t3Z3z.,\n" - " :tt:::tt333EE3\n" - "$1 Et:::ztt33EEEL$2 @Ee., ..,\n" - "$1 ;tt:::tt333EE7$2 ;EEEEEEttttt33#\n" - "$1 :Et:::zt333EEQ.$2 $EEEEEttttt33QL\n" - "$1 it::::tt333EEF$2 @EEEEEEttttt33F\n" - "$1 ;3=*^```\"*4EEV$2 :EEEEEEttttt33@.\n" - "$3 ,.=::::!t=., $1`$2 @EEEEEEtttz33QF\n" - "$3 ;::::::::zt33)$2 \"4EEEtttji3P*\n" - "$3 :t::::::::tt33.$4:Z3z..$2 ``$4 ,..g.\n" - "$3 i::::::::zt33F$4 AEEEtttt::::ztF\n" - "$3 ;:::::::::t33V$4 ;EEEttttt::::t3\n" - "$3 E::::::::zt33L$4 @EEEtttt::::z3F\n" - "$3{3=*^```\"*4E3)$4 ;EEEtttt:::::tZ`\n" - "$3 `$4 :EEEEtttt::::z7\n" - " \"VEzjt:;;z>*`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS) FF_LOGO_COLORS( "31", //red "32", //green @@ -1857,8 +970,8 @@ static const FFlogo* getLogoWindows(void) static const FFlogo* getLogoWindows95(void) { FF_LOGO_INIT - FF_LOGO_NAMES("Windows 9x", "Windows 95") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS95) + FF_LOGO_NAMES("Windows 95", "Windows 9x") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_95) FF_LOGO_COLORS( "36", //cyan "34", //blue @@ -1876,28 +989,7 @@ static const FFlogo* getLogoNixOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux") - FF_LOGO_LINES( - "$1 ▗▄▄▄ $2▗▄▄▄▄ ▄▄▄▖\n" - "$1 ▜███▙ $2▜███▙ ▟███▛\n" - "$1 ▜███▙ $2▜███▙▟███▛\n" - "$1 ▜███▙ $2▜██████▛\n" - "$1 ▟█████████████████▙ $2▜████▛ $1▟▙\n" - "$1 ▟███████████████████▙ $2▜███▙ $1▟██▙\n" - "$2 ▄▄▄▄▖ ▜███▙ $1▟███▛\n" - "$2 ▟███▛ ▜██▛ $1▟███▛\n" - "$2 ▟███▛ ▜▛ $1▟███▛\n" - "$2▟███████████▛ $1▟██████████▙\n" - "$2▜██████████▛ $1▟███████████▛\n" - "$2 ▟███▛ $1▟▙ ▟███▛\n" - "$2 ▟███▛ $1▟██▙ ▟███▛\n" - "$2 ▟███▛ $1▜███▙ ▝▀▀▀▀\n" - "$2 ▜██▛ $1▜███▙ $2▜██████████████████▛\n" - "$2 ▜▛ $1▟████▙ $2▜████████████████▛\n" - "$1 ▟██████▙ $2▜███▙\n" - "$1 ▟███▛▜███▙ $2▜███▙\n" - "$1 ▟███▛ ▜███▙ $2▜███▙\n" - "$1 ▝▀▀▀ ▀▀▀▀▘ $2▀▀▀▘" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS) FF_LOGO_COLORS( "34", //blue "36" //cyan @@ -1911,36 +1003,7 @@ static const FFlogo* getLogoNixOsOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old") - FF_LOGO_LINES( - "$1 ____ $2_______ ____\n" - "$1 /####\\ $2\\######\\ /####\\\n" - "$1 ######\\ $2\\######\\ /#####/\n" - "$1 \\######\\ $2\\######\\ /#####/\n" - "$1 \\######\\ $2\\######\\/#####/ $1/\\\n" - "$1 \\######\\ $2\\###########/ $1/##\\\n" - "$1 ________\\######\\______$2\\#########/ $1/####\\\n" - "$1 /#######################$2\\#######/ $1/######\n" - "$1 /#########################$2\\######\\ $1/######/\n" - "$1 /###########################$2\\######\\ $1/######/\n" - "$1 ¯¯¯¯¯¯¯¯¯¯¯¯$2/######/$1¯¯¯¯¯¯¯¯¯$2\\######$1/######/\n" - "$2 /######/ $2\\####$1/######/________\n" - "$2 _____________/######/ $2\\##$1/################\\\n" - "$2 /###################/ $2\\$1/##################\\\n" - "$2 \\##################/$1\\ /###################/\n" - "$2 \\################/$1##\\ /######/¯¯¯¯¯¯¯¯¯¯¯¯¯\n" - "$2 ¯¯¯¯¯¯¯¯/######/$1####\\ /######/\n" - "$2 /######/$1######\\$2_________$1/######/$2____________\n" - "$2 /######/ $1\\######\\$2###########################/\n" - "$2 /######/ $1\\######\\$2#########################/\n" - "$2 ######/ $1/#######\\$2#######################/\n" - "$2 \\####/ $1/#########\\$2¯¯¯¯¯¯\\######\\¯¯¯¯¯¯¯¯\n" - "$2 \\##/ $1/###########\\$2 \\######\\\n" - "$2 \\/ $1/#####/\\######\\$2 \\######\\\n" - "$1 $1/#####/ \\######\\$2 \\######\\\n" - "$1 $1/#####/ \\######\\$2 \\######\n" - "$1 $1\\####/ \\######\\$2 \\####/\n" - "$1 $1¯¯¯¯ ¯¯¯¯¯¯¯$2 ¯¯¯¯" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS_OLD) FF_LOGO_COLORS( "34", //blue "36" //cyan @@ -1954,15 +1017,7 @@ static const FFlogo* getLogoNixOsSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small") - FF_LOGO_LINES( - "$1 \\\\ \\\\ //\n" - " ==\\\\__\\\\/ //\n" - " // \\\\//\n" - "==// //==\n" - " //\\\\___//\n" - "// /\\\\ \\\\==\n" - " // \\\\ \\\\" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL) FF_LOGO_COLORS( "34" //blue ) @@ -1989,25 +1044,7 @@ static const FFlogo* getLogoNobara(void) { FF_LOGO_INIT FF_LOGO_NAMES("nobara", "nobara-linux"); - FF_LOGO_LINES( - "⢀⣤⣴⣶⣶⣶⣦⣤⡀⠀⣀⣠⣤⣴⣶⣶⣶⣶⣶⣶⣶⣶⣤⣤⣀⡀\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⡀\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠁⠀⠀⠉⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⢀⣀⣀⡀⠀⠀⠀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⢠⣾⣿⣿⣿⣿⣷⡄⠀⠀⠀⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⣀⣀⣬⣽⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠈⠻⢿⣿⣿⡿⠟⠁⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⣤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n" - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠉⠉⠛⠛⢿⣿⣿⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿\n" - "⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⠟⠁\n" - " ⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NOBARA) FF_LOGO_COLORS( "37" // white ) @@ -2077,26 +1114,7 @@ static const FFlogo* getLogoOpenSuse(void) { FF_LOGO_INIT FF_LOGO_NAMES("suse", "opensuse", "open_suse", "open-suse", "suse-linux") - FF_LOGO_LINES( - " $2.;ldkO0000Okdl;.\n" - " .;d00xl:^''''''^:ok00d;.\n" - " .d00l' 'o00d.\n" - " .d0Kd'$1 Okxol:;,. $2:O0d\n" - " .OK$1KKK0kOKKKKKKKKKKOxo:, $2lKO.\n" - " ,0K$1KKKKKKKKKKKKKKK0P^$2,,,$1^dx:$2 ;00,\n" - ".OK$1KKKKKKKKKKKKKKKk'$2.oOPPb.$1'0k.$2 cKO.\n" - ":KK$1KKKKKKKKKKKKKKK: $2kKx..dd $1lKd$2 'OK:\n" - "dKK$1KKKKKKKKKOx0KKKd $2^0KKKO' $1kKKc$2 dKd\n" - "dKK$1KKKKKKKKKK;.;oOKx,..$2^$1..;kKKK0.$2 dKd\n" - ":KK$1KKKKKKKKKK0o;...^cdxxOK0O/^^' $2.0K:\n" - " kKK$1KKKKKKKKKKKKK0x;,,......,;od $2lKk\n" - " '0K$1KKKKKKKKKKKKKKKKKKKK00KKOo^ $2c00'\n" - " 'kK$1KKOxddxkOO00000Okxoc;'' $2.dKk'\n" - " l0Ko. .c00l'\n" - " 'l0Kk:. .;xK0l'\n" - " 'lkK0xl:;,,,,;:ldO0kl'\n" - " '^:ldxkkkkxdl:^'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE) FF_LOGO_COLORS( "32", //green "37" //white @@ -2110,15 +1128,7 @@ static const FFlogo* getLogoOpenSuseSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("suse_small", "opensuse_small", "open_suse_small", "open-suse_small") - FF_LOGO_LINES( - " _______\n" - "__| __ \\\n" - " / .\\ \\\n" - " \\__/ |\n" - " _______|\n" - " \\_______\n" - "__________/" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL) FF_LOGO_COLORS( "32" //green ) @@ -2131,24 +1141,7 @@ static const FFlogo* getLogoOpenSuseLeap(void) { FF_LOGO_INIT FF_LOGO_NAMES("opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap") - FF_LOGO_LINES( - " .-++:.\n" - " ./oooooo/-\n" - " `:oooooooooooo:.\n" - " -+oooooooooooooooo+-`\n" - " ./oooooooooooooooooooooo/-\n" - " :oooooooooooooooooooooooooo:\n" - " ` `-+oooooooooooooooooooo/- `\n" - " `:oo/- .:ooooooooooooooo+:` `-+oo/.\n" - "`/oooooo:. -/oooooooooo/. ./oooooo/.\n" - " `:+ooooo+-` `:+oooo+- `:oooooo+:`\n" - " .:oooooo/. .::` -+oooooo/.\n" - " -/oooooo:. ./oooooo+-\n" - " `:+ooooo+-:+oooooo:`\n" - " ./oooooooooo/.\n" - " -/oooo+:`\n" - " `:/." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP) FF_LOGO_COLORS( "37" //white ) @@ -2161,21 +1154,7 @@ static const FFlogo* getLogoOpenSuseTumbleweed(void) { FF_LOGO_INIT FF_LOGO_NAMES("opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed") - FF_LOGO_LINES( - " ......\n" - " .,cdxxxoc,. .:kKMMMNWMMMNk:.\n" - " cKMMN0OOOKWMMXo. ; ;0MWk:. .:OMMk.\n" - " ;WMK;. .lKMMNM, :NMK, .OMW;\n" - " cMW; 'WMMMN ,XMK, oMM'\n" - ".MMc ..;l. xMN: KM0\n" - "'MM. 'NMO oMM\n" - ".MM, .kMMl xMN\n" - " KM0 .kMM0. .dl:,.. .WMd\n" - " .XM0. ,OMMK, OMMMK. .XMK\n" - " oWMO:. .;xNMMk, NNNMKl. .xWMx\n" - " :ONMMNXMMMKx; . ,xNMWKkxllox0NMWk,\n" - " ..... .:dOOXXKOxl," - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED) FF_LOGO_COLORS( "37" //white ) @@ -2188,7 +1167,7 @@ static const FFlogo* getLogoOpenSuseTumbleweed2(void) { FF_LOGO_INIT FF_LOGO_NAMES("opensuse_tumbleweed2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSETUMBLEWEED2) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2) FF_LOGO_COLORS( "37" //white ) @@ -2201,30 +1180,7 @@ static const FFlogo* getLogoOpenMandriva(void) { FF_LOGO_INIT FF_LOGO_NAMES("openmandriva", "open-mandriva", "open_mandriva") - FF_LOGO_LINES( - " ``````\n" - " `-:/+++++++//:-.`\n" - " .:+++oooo+/:.`` ``\n" - " `:+ooooooo+:. `-:/++++++/:.`\n" - " -+oooooooo:` `-++o+/::::://+o+/-\n" - " `/ooooooooo- -+oo/.` `-/oo+.\n" - " `+ooooooooo. :os/` .+so:\n" - " +sssssssss/ :ss/ `+ss-\n" - " :ssssssssss` sss` .sso\n" - " ossssssssss `yyo sys\n" - "`sssssssssss` `yys `yys\n" - "`sssssssssss: +yy/ +yy:\n" - " oyyyyyyyyyys. `oyy/` `+yy+\n" - " :yyyyyyyyyyyo. `+yhs:. `./shy/\n" - " oyyyyyyyyyyys:` .oyhys+:----/+syhy+. `\n" - " `syyyyyyyyyyyyo-` .:osyhhhhhyys+:``.:`\n" - " `oyyyyyyyyyyyyys+-`` `.----.```./oo.\n" - " /yhhhhhhhhhhhhhhyso+//://+osyhy/`\n" - " `/yhhhhhhhhhhhhhhhhhhhhhhhhy/`\n" - " `:oyhhhhhhhhhhhhhhhhhhyo:`\n" - " .:+syhhhhhhhhys+:-`\n" - " ``....``" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENMANDRIVA) FF_LOGO_COLORS( "34" //blue ) @@ -2259,63 +1215,11 @@ static const FFlogo* getLogoOracle(void) FF_LOGO_RETURN } -static const FFlogo* getLogoPop(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("pop", "popos", "pop_os", "pop-linux") - FF_LOGO_LINES( - " /////////////\n" - " /////////////////////\n" - " ///////$2*767$1////////////////\n" - " //////$27676767676*$1//////////////\n" - " /////$276767$1//$27676767$1//////////////\n" - " /////$2767676$1///$2*76767$1///////////////\n" - " ///////$2767676$1///$276767$1.///$27676*$1///////\n" - "/////////$2767676$1//$276767$1///$2767676$1////////\n" - "//////////$276767676767$1////$276767$1/////////\n" - "///////////$276767676$1//////$27676$1//////////\n" - "////////////,$27676$1,///////$2767$1///////////\n" - "/////////////*$27676$1///////$276$1////////////\n" - "///////////////$27676$1////////////////////\n" - " ///////////////$27676$1///$2767$1////////////\n" - " //////////////////////$2'$1////////////\n" - " //////$2.7676767676767676767,$1//////\n" - " /////$2767676767676767676767$1/////\n" - " ///////////////////////////\n" - " /////////////////////\n" - " /////////////" - ) - FF_LOGO_COLORS( - "36", //cyan - "37" //white - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - static const FFlogo* getLogoParabola(void) { FF_LOGO_INIT FF_LOGO_NAMES("parabola", "parabola-gnulinux") - FF_LOGO_LINES( - " `.-. `.\n" - " `.` `:++. `-+o+.\n" - " `` `:+/. `:+/. `-+oooo+\n" - " ``-::-.:+/. `:+/. `-+oooooo+\n" - " `.-:///- ..` .-. `-+oooooooo-\n" - " `..-..` `+ooooooooo:\n" - "`` :oooooooo/\n" - " `ooooooo:\n" - " `oooooo:\n" - " -oooo+.\n" - " +ooo/`\n" - " -ooo-\n" - " `+o/.\n" - " /+-\n" - " //`\n" - " -." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PARABOLA) FF_LOGO_COLORS( "35" //magenta ) @@ -2328,14 +1232,7 @@ static const FFlogo* getLogoParabolaSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("parabola_small", "parabola-gnulinux_small") - FF_LOGO_LINES( - " __ __ __ _\n" - ".`_//_//_/ / `.\n" - " / .`\n" - " / .`\n" - " /.`\n" - " /`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PARABOLA_SMALL) FF_LOGO_COLORS( "35" //magenta ) @@ -2344,20 +1241,25 @@ static const FFlogo* getLogoParabolaSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoPop(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("pop", "popos", "pop_os", "pop-linux") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_POP) + FF_LOGO_COLORS( + "36", //cyan + "37" //white + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + static const FFlogo* getLogoPopSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("pop_small", "popos_small", "pop_os_small", "pop-linux-small") - FF_LOGO_LINES( - "______\n" - "\\ _ \\ __\n" - " \\ \\ \\ \\ / /\n" - " \\ \\_\\ \\ / /\n" - " \\ ___\\ /_/\n" - " \\ \\ _\n" - " __\\_\\__(_)_\n" - " (___________)`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_POP_SMALL) FF_LOGO_COLORS( "36" //cyan ) @@ -2368,32 +1270,8 @@ static const FFlogo* getLogoPopSmall(void) static const FFlogo* getLogoRaspbian(void) { FF_LOGO_INIT - FF_LOGO_NAMES("raspbian", "raspi", "raspberrypi" "raspberrypios" "pios") - FF_LOGO_LINES( - " $2`.::///+:/-. --///+//-:`\n" - " `+oooooooooooo: `+oooooooooooo:\n" - " /oooo++//ooooo: ooooo+//+ooooo.\n" - " `+ooooooo:-:oo- +o+::/ooooooo:\n" - " `:oooooooo+`` `.oooooooo+-\n" - " `:++ooo/. :+ooo+/.`$1\n" - " ...` `.----.` ``..\n" - " .::::-``:::::::::.`-:::-`\n" - " -:::-` .:::::::-` `-:::-\n" - " `::. `.--.` `` `.---.``.::`\n" - " .::::::::` -::::::::` `\n" - " .::` .:::::::::- `::::::::::``::.\n" - "-:::` ::::::::::. ::::::::::.`:::-\n" - ":::: -::::::::. `-:::::::: ::::\n" - "-::- .-:::-.``....``.-::-. -::-\n" - " .. `` .::::::::. `..`..\n" - " -:::-` -::::::::::` .:::::`\n" - " :::::::` -::::::::::` :::::::.\n" - " .::::::: -::::::::. ::::::::\n" - " `-:::::` ..--.` ::::::.\n" - " `...` `...--..` `...`\n" - " .::::::::::\n" - " `.-::::-`" - ) + FF_LOGO_NAMES("raspbian", "raspi", "raspberrypi", "raspberrypios", "pios") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RASPBIAN) FF_LOGO_COLORS( "31", //red "32" //green @@ -2407,18 +1285,7 @@ static const FFlogo* getLogoRaspbianSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small") - FF_LOGO_LINES( - " $2.~~. .~~.\n" - " '. \\ ' ' / .'$1\n" - " .~ .~~~..~.\n" - " : .~.'~'.~. :\n" - " ~ ( ) ( ) ~\n" - "( : '~'.~.'~' : )\n" - " ~ .~ ( ) ~. ~\n" - " ( : '~' : )\n" - " '~ .~~~. ~'\n" - " '~'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL) FF_LOGO_COLORS( "31", //red "32" //green @@ -2432,28 +1299,7 @@ static const FFlogo* getLogoReborn(void) { FF_LOGO_INIT FF_LOGO_NAMES("reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux") - FF_LOGO_LINES( - " :::::::::::::::::::::::\n" - " .:^!!!!!!!!!^.^!!!!!!!!!^:.\n" - " .:~!!!!!!!!!!^.^!!!!!!!!!!~:.\n" - " .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:.\n" - " .^!!!!!~::$2=====:.:=====$1::~!!!!!^.\n" - " .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::.\n" - " .:~~^:::^.$2^77777!!^.^7!77777^$1.^:::^~~:.\n" - " .:~!!!!~::::$2^~!!::^^^^^::!!~^$1::::~!!!!~:.\n" - " .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^.\n" - ".:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:.\n" - ".:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:.\n" - " .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^.\n" - " .:~!!!!~::$2::^~!!::^^^^^::!!~^::$1::~!!!!~:.\n" - " .:~~^:::^.$2^77777!!^.^7!77777^.$1^:::^~~:.\n" - " .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::.\n" - " .^!!!!!~::$2=====:.:=====$1::~!!!!!^.\n" - " .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:.\n" - " .:~!!!!!!!!!!^.^!!!!!!!!!!~:.\n" - " .:^!!!!!!!!!^.^!!!!!!!!!^:.\n" - " :::::::::::::::::::::::\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REBORN) FF_LOGO_COLORS( "34", //blue "36" //cyan @@ -2467,19 +1313,7 @@ static const FFlogo* getLogoRebornSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small") - FF_LOGO_LINES( - " _______________\n" - " / \\ / \\\n" - " / \\_______/ \\\n" - " / / \\ / \\ \\\n" - " / / \\___/ \\ \\\n" - "/____/____/ \\____\\____\\\n" - "\\ \\ \\___/ / /\n" - " \\ \\ / \\ / /\n" - " \\ \\/_______\\/ /\n" - " \\ / \\ /\n" - " \\_/___________\\_/\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REBORN_SMALL) FF_LOGO_COLORS( "34" //blue ) @@ -2492,26 +1326,7 @@ static const FFlogo* getLogoRedHatEnterpriseLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rhel", "redhat", "redhat-linux") - FF_LOGO_LINES( - " .MMM..:MMMMMMM\n" - " MMMMMMMMMMMMMMMMMM\n" - " MMMMMMMMMMMMMMMMMMMM.\n" - " MMMMMMMMMMMMMMMMMMMMMM\n" - " ,MMMMMMMMMMMMMMMMMMMMMM:\n" - " MMMMMMMMMMMMMMMMMMMMMMMM\n" - " .MMMM' MMMMMMMMMMMMMMMMMMMMMM\n" - " MMMMMM `MMMMMMMMMMMMMMMMMMMM.\n" - "MMMMMMMM MMMMMMMMMMMMMMMMMM .\n" - "MMMMMMMMM. `MMMMMMMMMMMMM' MM.\n" - "MMMMMMMMMMM. MMMM\n" - "`MMMMMMMMMMMMM. ,MMMMM.\n" - " `MMMMMMMMMMMMMMMMM. ,MMMMMMMM.\n" - " MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n" - " MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM:\n" - " MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n" - " `MMMMMMMMMMMMMMMMMMMMMMMM:\n" - " ``MMMMMMMMMMMMMMMMM'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RHEL) FF_LOGO_COLORS( "31" //red ) @@ -2524,26 +1339,7 @@ static const FFlogo* getLogoRedstarOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux") - FF_LOGO_LINES( - "$1 ..\n" - " .oK0l\n" - " :0KKKKd.\n" - " .xKO0KKKKd\n" - " ,Od' .d0000l\n" - " .c;. .'''... ..'.\n" - ".,:cloddxxxkkkkOOOOkkkkkkkkxxxxxxxxxkkkx:\n" - ";kOOOOOOOkxOkc'...',;;;;,,,'',;;:cllc:,.\n" - " .okkkkd,.lko .......',;:cllc:;,,'''''.\n" - " .cdo. :xd' cd:. ..';'',,,'',,;;;,'.\n" - " . .ddl.;doooc'..;oc;'..';::;,'.\n" - " coo;.oooolllllllcccc:'. .\n" - " .ool''lllllccccccc:::::;.\n" - " ;lll. .':cccc:::::::;;;;'\n" - " :lcc:'',..';::::;;;;;;;,,.\n" - " :cccc::::;...';;;;;,,,,,,.\n" - " ,::::::;;;,'. ..',,,,'''.\n" - " ........ ......" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REDSTAR) FF_LOGO_COLORS( "31" //red ) @@ -2556,27 +1352,7 @@ static const FFlogo* getLogoRockyLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rocky", "rocky-linux", "rockylinux") - FF_LOGO_LINES( - " __wgliliiligw_,\n" - " _williiiiiiliilililw,\n" - " _%iiiiiilililiiiiiiiiiii_\n" - " .Qliiiililiiiiiiililililiilm.\n" - " _iiiiiliiiiiililiiiiiiiiiiliil,\n" - " .lililiiilililiiiilililililiiiii,\n" - "_liiiiiiliiiiiiiliiiiiF{iiiiiilili,\n" - "jliililiiilililiiili@` ~ililiiiiiL\n" - "iiiliiiiliiiiiiili>` ~liililii\n" - "liliiiliiilililii` -9liiiil\n" - "iiiiiliiliiiiii~ \"4lili\n" - "4ililiiiiilil~| -w, )4lf\n" - "-liiiiililiF' _liig, )'\n" - " )iiiliii@` _QIililig,\n" - " )iiii>` .Qliliiiililw\n" - " )<>~ .mliiiiiliiiiiil,\n" - " _gllilililiililii~\n" - " giliiiiiiiiiiiiT`\n" - " -^~$ililili@~~'" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ROCKY) FF_LOGO_COLORS( "32" //green ) @@ -2589,28 +1365,7 @@ static const FFlogo* getLogoRosaLinux(void) { FF_LOGO_INIT FF_LOGO_NAMES("rosa", "rosa-linux", "rosalinux") - FF_LOGO_LINES( - " ROSAROSAROSAROSAR\n" - " ROSA AROS\n" - " ROS SAROSAROSAROSAR AROS\n" - " RO ROSAROSAROSAROSAROSAR RO\n" - " ARO AROSAROSAROSARO AROS ROS\n" - " ARO ROSAROS OSAR ROSA ROS\n" - " RO AROSA ROSAROSAROSA ROSAR RO\n" - "RO ROSAR ROSAROSAROSAR R ROSARO RO\n" - "RO ROSA AROSAROSAROSA AR ROSARO AR\n" - "RO AROS ROSAROSAROSA ROS AROSARO AR\n" - "RO AROS ROSAROSARO ROSARO ROSARO AR\n" - "RO ROS AROSAROS ROSAROSA AROSAR AR\n" - "RO ROSA ROS ROSAROSAR ROSARO RO\n" - " RO ROS AROSAROSAROSA ROSARO AR\n" - " ARO ROSA ROSAROSAROS AROSAR ARO\n" - " ARO OROSA R ROSAROS ROS\n" - " RO AROSAROS AROSAROSAR RO\n" - " AROS AROSAROSAROSARO AROS\n" - " ROSA SARO\n" - " ROSAROSAROSAROSAR" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ROSA) FF_LOGO_COLORS( "34" //blue ) @@ -2623,29 +1378,7 @@ static const FFlogo* getLogoSlackware(void) { FF_LOGO_INIT FF_LOGO_NAMES("slackware", "slackware-linux", "slackwarelinux") - FF_LOGO_LINES( - " :::::::::\n" - " :::::::::::::::::::\n" - " :::::::::::::::::::::::::\n" - " ::::::::$2cllcccccllllllll$1::::::\n" - " :::::::::$2lc dc$1:::::::\n" - " ::::::::$2cl clllccllll oc$1:::::::::\n" - " :::::::::$2o lc$1::::::::$2co oc$1::::::::::\n" - " ::::::::::$2o cccclc$1:::::$2clcc$1::::::::::::\n" - " :::::::::::$2lc cclccclc$1:::::::::::::\n" - "::::::::::::::$2lcclcc lc$1::::::::::::\n" - "::::::::::$2cclcc$1:::::$2lccclc oc$1:::::::::::\n" - "::::::::::$2o l$1::::::::::$2l lc$1:::::::::::\n" - " :::::$2cll$1:$2o clcllcccll o$1:::::::::::\n" - " :::::$2occ$1:$2o clc$1:::::::::::\n" - " ::::$2ocl$1:$2ccslclccclclccclclc$1:::::::::::::\n" - " :::$2oclcccccccccccccllllllllllllll$1:::::\n" - " ::$2lcc1lcccccccccccccccccccccccco$1::::\n" - " ::::::::::::::::::::::::::::::::\n" - " ::::::::::::::::::::::::::::\n" - " ::::::::::::::::::::::\n" - " ::::::::::::" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SLACKWARE) FF_LOGO_COLORS( "34", //blue "37" //white @@ -2659,15 +1392,7 @@ static const FFlogo* getLogoSlackwareSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small") - FF_LOGO_LINES( - " ________\n" - " / ______|\n" - " | |______\n" - " \\______ \\\n" - " ______| |\n" - "| |________/\n" - "|____________" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SLACKWARE_SMALL) FF_LOGO_COLOR_KEYS("33"); //green FF_LOGO_COLOR_TITLE("37"); //white FF_LOGO_RETURN @@ -2703,28 +1428,7 @@ static const FFlogo* getLogoSolus(void) { FF_LOGO_INIT FF_LOGO_NAMES("solus", "solus-linux") - FF_LOGO_LINES( -"$2 -```````````\n" -" `-+/------------.`\n" -" .---:mNo---------------.\n" -" .-----yMMMy:---------------.\n" -" `------oMMMMMm/----------------`\n" -" .------/MMMMMMMN+----------------.\n" -" .------/NMMMMMMMMm-+/--------------.\n" -"`------/NMMMMMMMMMN-:mh/-------------`\n" -".-----/NMMMMMMMMMMM:-+MMd//oso/:-----.\n" -"-----/NMMMMMMMMMMMM+--mMMMh::smMmyo:--\n" -"----+NMMMMMMMMMMMMMo--yMMMMNo-:yMMMMd/.\n" -".--oMMMMMMMMMMMMMMMy--yMMMMMMh:-yMMMy-`\n" -"`-sMMMMMMMMMMMMMMMMh--dMMMMMMMd:/Ny+y.\n" -"`-/+osyhhdmmNNMMMMMm-/MMMMMMMmh+/ohm+\n" -" .------------:://+-/++++++$1oshddys:\n" -" -hhhhyyyyyyyyyyyhhhhddddhysssso-\n" -" `:ossssssyysssssssssssssssso:`\n" -" `:+ssssssssssssssssssss+-\n" -" `-/+ssssssssssso+/-`\n" -" `.-----..`\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLUS) FF_LOGO_COLORS( "34", //blue "37" //white @@ -2738,26 +1442,7 @@ static const FFlogo* getLogoSteamOS(void) { FF_LOGO_INIT FF_LOGO_NAMES("steamos") - FF_LOGO_LINES( - "$1 .,,,,.\n" - " .,'onNMMMMMNNnn',.\n" - " .'oNMANKMMMMMMMMMMMNNn'.\n" - " .'ANMMMMMMMXKNNWWWPFFWNNMNn.\n" - " ;NNMMMMMMMMMMNWW'' ,.., 'WMMM,\n" - " ;NMMMMV+##+VNWWW' .+;'':+, 'WMW,\n" - ",VNNWP+$2######$1+WW, $2+: $1:+, +MMM,\n" - "'$2+#############, +. ,+' $1+NMMM\n" - "$2 '*#########*' '*,,*' $1.+NMMMM.\n" - "$2 `'*###*' ,.,;###$1+WNM,\n" - "$2 .,;;, .;##########$1+W\n" - "$2,',. '; ,+##############'\n" - " '###+. :,. .,; ,###############'\n" - " '####.. `'' .,###############'\n" - " '#####+++################'\n" - " '*##################*'\n" - " ''*##########*''\n" - " ''''''\n" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_STEAMOS) FF_LOGO_COLORS( "34", //blue "37" //white @@ -2771,29 +1456,7 @@ static const FFlogo* getLogoUbuntu(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu", "ubuntu-linux") - FF_LOGO_LINES( - " ....\n" - " .',:clooo: .:looooo:.\n" - " .;looooooooc .oooooooooo'\n" - " .;looooool:,''. :ooooooooooc\n" - " ;looool;. 'oooooooooo,\n" - " ;clool' .cooooooc. ,,\n" - " ... ...... .:oo,\n" - " .;clol:,. .loooo'\n" - " :ooooooooo, 'ooool\n" - "'ooooooooooo. loooo.\n" - "'ooooooooool coooo.\n" - " ,loooooooc. .loooo.\n" - " .,;;;'. ;ooooc\n" - " ... ,ooool.\n" - " .cooooc. ..',,'. .cooo.\n" - " ;ooooo:. ;oooooooc. :l.\n" - " .coooooc,.. coooooooooo.\n" - " .:ooooooolc:. .ooooooooooo'\n" - " .':loooooo; ,oooooooooc\n" - " ..';::c' .;loooo:'\n" - " ." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU) FF_LOGO_COLORS( "31", //red "37" //white @@ -2807,7 +1470,7 @@ static const FFlogo* getLogoUbuntuKylin(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu kylin", "ubuntu-kylin") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTUKYLIN) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_KYLIN) FF_LOGO_COLORS( "31", //red "37", //white @@ -2822,7 +1485,7 @@ static const FFlogo* getLogoUbuntuMate(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu mate", "ubuntu-mate") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTUMATE) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_MATE) FF_LOGO_COLORS( "32", //green "37" //white @@ -2836,28 +1499,7 @@ static const FFlogo* getLogoUbuntuOld(void) { FF_LOGO_INIT FF_LOGO_NAMES("ubuntu_old", "ubuntu-linux_old") - FF_LOGO_LINES( - " .-/+oossssoo+/-.\n" - " `:+ssssssssssssssssss+:`\n" - " -+ssssssssssssssssssyyssss+-\n" - " .ossssssssssssssssssd$2MMMNy$1sssso.\n" - " /sssssssssss$2hdmmNNmmyNMMMMh$1ssssss/\n" - " +sssssssss$2hmydMMMMMMMNddddy$1ssssssss+\n" - " /ssssssss$2hNMMMyhhyyyyhmNMMMNh$1ssssssss/\n" - ".ssssssss$2dMMMNh$1ssssssssss$2hNMMMd$1ssssssss.\n" - "+ssss$2hhhyNMMNy$1ssssssssssss$2yNMMMy$1sssssss+\n" - "oss$2yNMMMNyMMh$1ssssssssssssss$2hmmmh$1ssssssso\n" - "oss$2yNMMMNyMMh$1ssssssssssssss$2hmmmh$1ssssssso\n" - "+ssss$2hhhyNMMNy$1ssssssssssss$2yNMMMy$1sssssss+\n" - ".ssssssss$2dMMMNh$1ssssssssss$2hNMMMd$1ssssssss.\n" - " /ssssssss$2hNMMMyhhyyyyhdNMMMNh$1ssssssss/\n" - " +sssssssss$2dmydMMMMMMMMddddy$1ssssssss+\n" - " /sssssssssss$2hdmNNNNmyNMMMMh$1ssssss/\n" - " .ossssssssssssssssss$2dMMMNy$1sssso.\n" - " -+sssssssssssssssss$2yyy$1ssss+-\n" - " `:+ssssssssssssssssss+:`\n" - " .-/+oossssoo+/-." - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_OLD) FF_LOGO_COLORS( "31", //red "37" //white @@ -2871,14 +1513,7 @@ static const FFlogo* getLogoUbuntuSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("ubuntu_small", "ubuntu-linux-small") - FF_LOGO_LINES( - " _\n" - " ---(_)\n" - " _/ --- \\\n" - "(_) | |\n" - " \\ --- _/\n" - " ---(_)" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_SMALL) FF_LOGO_COLORS( "31" //red ) @@ -2917,27 +1552,8 @@ static const FFlogo* getLogoVanilla(void) { FF_LOGO_INIT - FF_LOGO_NAMES("vanilla", "vanilla-os","vanilla-linux"); - FF_LOGO_LINES( -" .----: \n" -" .-------.\n" -" :---::----:\n" -" .----::-----.\n" -" ......... :----::-----: ..:::-::::..\n" -".-----------------::------------------:\n" -" ----::-----------::----------::::---:\n" -" -----:::--------::-------:::-------\n" -" :------::::--::...:::::---------:\n" -" .---------::.. ..:---------.\n" -" .::-----::.. .::----::.\n" -" .:------:.......:-------:\n" -" .--------::::::::-:::-------.\n" -" .-------::-----.:-----::------.\n" -" -----::------: :------::-----\n" -" :--::--------: .-------::---:\n" -" :----------:: .:----------\n" -" :--------: :--------:" - ) + FF_LOGO_NAMES("vanilla", "vanilla-os", "vanilla-linux"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VANILLA) FF_LOGO_COLORS( "33" //yellow ) @@ -2950,26 +1566,7 @@ static const FFlogo* getLogoVoid(void) { FF_LOGO_INIT FF_LOGO_NAMES("void", "void-linux") - FF_LOGO_LINES( - " __.;=====;.__\n" - " _.=+==++=++=+=+===;.\n" - " -=+++=+===+=+=+++++=_\n" - " . -=:`` `--==+=++==.\n" - " _vi, ` --+=++++:\n" - " .uvnvi. _._ -==+==+.\n" - " .vvnvnI` .;==|==;. :|=||=|.\n" - "$2+QmQQm$1pvvnv;$2 _yYsyQQWUUQQQm #QmQ#$1:$2QQQWUV$QQm.\n" - " $2-QQWQW$1pvvo$2wZ?.wQQQE$1==<$2QWWQ/QWQW.QQWW$1(:$2 jQWQE\n" - " $2-$QQQQmmU' jQQQ$1@+=<$2QWQQ)mQQQ.mQQQC$1+;$2jWQQ@'\n" - " $2-$WQ8Y$1nI:$2 QWQQwgQQWV$1`$2mWQQ.jQWQQgyyWW@!\n" - " $1-1vvnvv. `~+++` ++|+++\n" - " +vnvnnv, `-|===\n" - " +vnvnvns. . :=-\n" - " -Invnvvnsi..___..=sv=. `\n" - " +Invnvnvnnnnnnnnvvnn;.\n" - " ~|Invnvnvvnvvvnnv}+`\n" - " -~|{*l}*|~" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VOID) FF_LOGO_COLORS( "32", //green "30" //black @@ -2983,15 +1580,7 @@ static const FFlogo* getLogoVoidSmall(void) { FF_LOGO_INIT_SMALL FF_LOGO_NAMES("void_small", "void-linux-small") - FF_LOGO_LINES( - " _______\n" - " _ \\______ -\n" - "| \\ ___ \\ |\n" - "| | / \\ | |\n" - "| | \\___/ | |\n" - "| \\______ \\_|\n" - " -_______\\" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VOID_SMALL) FF_LOGO_COLORS( "32" //green ) @@ -3004,25 +1593,7 @@ static const FFlogo* getLogoZorin(void) { FF_LOGO_INIT FF_LOGO_NAMES("zorin", "zorin-linux", "zorinos", "zorinos-linux") - FF_LOGO_LINES( - " `osssssssssssssssssssso`\n" - " .osssssssssssssssssssssso.\n" - " .+oooooooooooooooooooooooo+.\n" - "\n" - "\n" - " `::::::::::::::::::::::. .:`\n" - " `+ssssssssssssssssss+:.` `.:+ssso`\n" - ".ossssssssssssssso/. `-+ossssssso.\n" - "ssssssssssssso/-` `-/osssssssssssss\n" - ".ossssssso/-` .-/ossssssssssssssso.\n" - " `+sss+:. `.:+ssssssssssssssssss+`\n" - " `:. .::::::::::::::::::::::`\n" - "\n" - "\n" - " .+oooooooooooooooooooooooo+.\n" - " -osssssssssssssssssssssso-\n" - " `osssssssssssssssssssso`" - ) + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ZORIN) FF_LOGO_COLORS( "34" //blue ) From 0bc8ccd87011c8a2c68739714e947515c48eb241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 22:13:28 +0800 Subject: [PATCH 388/493] Doc: update changelog for newly added logos --- CHANGELOG.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d0f4905..4cd2d83e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: 1. Although konsole was said to support `kitty` image protocol, it doesn't support `kitty-direct` 2. wezterm support more image formats other than `.png` (tested with `.jpg` and `.webp`) -* Add `Windows 95` +* Add `Windows 95` and more # 1.12.2 diff --git a/README.md b/README.md index ff1e4b8d3..0264c733c 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers From 2a39fd35a31868fe6baf902cef1f6f19f0a2aac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 22:43:16 +0800 Subject: [PATCH 389/493] Logo: add Garuda Dragon --- README.md | 2 +- src/logo/ascii/garuda_dragon.txt | 24 ++++++++++++++++++++++++ src/logo/builtin.c | 14 ++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/logo/ascii/garuda_dragon.txt diff --git a/README.md b/README.md index 0264c733c..9ff87a285 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/logo/ascii/garuda_dragon.txt b/src/logo/ascii/garuda_dragon.txt new file mode 100644 index 000000000..26f7013b8 --- /dev/null +++ b/src/logo/ascii/garuda_dragon.txt @@ -0,0 +1,24 @@ + .:--=========--:.. + .:-=+++++===-----=======-:. + :=++++-:.. ..:-===-:. + .+++=:. .-=---. + . :-: :---: + := . :---: + .=-: :-. .---: + :-===--::. .::::. ---: + .::--====-===+=-----=-: ---: + :: :-++++====--=-:=====--=--: .--- ++**=:+++===++++++==- -===== -==-. ---: +*****+==++==--::::::======== . ===-. :--- +****==++-::.:::::-.::--======-.-=== .--- +***+=+-::::--:. -==:-==--=======-::. . :--- +=**++-::::== -+===-==: :::.:-=-==--- :--: +.*+*-:::-+= ...::==== .:: .=-:--. .. + -*++:::=+-: .:=- -- .: . ... + =*++:.++-+: .:. =-.: :-: :: :. + -*++-=+=-+=-=++===-. .====: .::::. + :++++++-:::--.-:=== --. + .=+++++- .= +.=:= .:: + :=+++++:. .: : . :---- + .-++++=-:.. .:--===-. + .-=+++++===-----=======-:. diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 41e9ce89f..e8aae38af 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -517,6 +517,19 @@ static const FFlogo* getLogoGaruda(void) FF_LOGO_RETURN } +static const FFlogo* getLogoGarudaDragon() +{ + FF_LOGO_INIT + FF_LOGO_NAMES("garudadragon", "garuda-dragon", "garuda-linux-dragon") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA_DRAGON) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + static const FFlogo* getLogoGarudaSmall(void) { FF_LOGO_INIT_SMALL @@ -1641,6 +1654,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoFreeBSD, getLogoFreeBSDSmall, getLogoGaruda, + getLogoGarudaDragon, getLogoGarudaSmall, getLogoGentoo, getLogoGentooSmall, From 893f45e6b12bee0915116f0c29b01a7391018510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 23:03:10 +0800 Subject: [PATCH 390/493] Logo: add Orchid --- README.md | 2 +- src/logo/ascii/orchid.txt | 20 ++++++++++++++++++++ src/logo/ascii/orchid_small.txt | 13 +++++++++++++ src/logo/builtin.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/logo/ascii/orchid.txt create mode 100644 src/logo/ascii/orchid_small.txt diff --git a/README.md b/README.md index 9ff87a285..70da67379 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/logo/ascii/orchid.txt b/src/logo/ascii/orchid.txt new file mode 100644 index 000000000..aa1fec39c --- /dev/null +++ b/src/logo/ascii/orchid.txt @@ -0,0 +1,20 @@ +${c2} .==. + .-${c3}#${c1}@@${c3}#${c2}-. + .-${c3}##${c1}@@@@${c3}##${c2}-. + .-${c3}##${c1}@@@@@@@@${c3}##${c2}-. + :*${c1}@@@@@${c3}####${c1}@@@@@${c2}*: + ..:*${c1}@@@@${c2}==--==${c1}@@@@${c2}*:.. + .-*${c1}%%${c3}#${c2}==${c3}#${c1}@@${c3}#${c2}====${c3}#${c1}@@${c3}#${c2}==${c3}#${c1}%%${c2}*-. + .-${c3}#${c1}@@@@@${c3}##${c2}==${c3}#${c1}@@${c2}++${c1}@@${c3}##${c2}==${c3}#${c1}@@@@@${c3}#${c2}-. + .-${c3}#${c1}@@@@@${c2}#${c1}@@@${c3}#${c2}++#====${c3}#${c2}++#${c1}@@@${c2}#${c1}@@@@@${c3}#${c2}-. +.-${c3}#${c1}@@@@@${c3}#${c2}-==**${c3}###${c2}+:--:+${c3}###${c2}**==-${c3}#${c1}@@@@@${c3}#${c2}-. +.-${c3}#${c1}@@@@@${c3}#${c2}-==**${c3}###${c2}+:--:+${c3}###${c2}**==-${c3}#${c1}@@@@@${c3}#${c2}-. + .-${c3}#${c1}@@@@@${c2}#${c1}@@@${c3}#${c2}++#====${c3}#${c2}++#${c1}@@@${c2}#${c1}@@@@@${c3}#${c2}-. + .-${c3}#${c1}@@@@@${c3}##${c2}==${c3}#${c1}@@${c2}++${c1}@@${c3}##${c2}==${c3}#${c1}@@@@@${c3}#${c2}-. + .-*${c1}%%${c3}#${c2}==${c3}#${c1}@@${c3}#${c2}====${c3}#${c1}@@${c3}#${c2}==${c3}#${c1}%%${c2}*-. + ..:*${c1}@@@@${c2}==--==${c1}@@@@${c2}*:.. + :*${c1}@@@@@${c3}####${c1}@@@@@${c2}*: + .-${c3}##${c1}@@@@@@@@${c3}##${c2}-. + .-${c3}##${c1}@@@@${c3}##${c2}-. + .-${c3}#${c1}@@${c3}#${c2}-. + .==. diff --git a/src/logo/ascii/orchid_small.txt b/src/logo/ascii/orchid_small.txt new file mode 100644 index 000000000..a124cbedd --- /dev/null +++ b/src/logo/ascii/orchid_small.txt @@ -0,0 +1,13 @@ + ${c2}:##: + -#${c1}@@@@${c2}#- + #${c1}@@${c2}=..=${c1}@@${c2}# + +${c1}@@${c2}- -${c1}@@${c2}+ + -#${c1}@@${c2}*..*${c1}@${c2}..${c1}@${c2}*..*${c1}@@${c2}#- + :#${c1}@@${c2}*+%${c1}@${c2}= . . =${c1}@${c2}%+*${c1}@@${c2}#: ++${c1}@@@${c2}: :-. .-: :${c1}@@@${c2}+ + :#${c1}@@${c2}*+%${c1}@${c2}= . . =${c1}@${c2}%+*${c1}@@${c2}#: + -#${c1}@@${c2}*..*${c1}@${c2}..${c1}@${c2}*..*${c1}@@${c2}#- + +${c1}@@${c2}- -${c1}@@${c2}+ + #${c1}@@${c2}=..=${c1}@@${c2}# + -#${c1}@@@@${c2}#- + :##: diff --git a/src/logo/builtin.c b/src/logo/builtin.c index e8aae38af..367038564 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1228,6 +1228,36 @@ static const FFlogo* getLogoOracle(void) FF_LOGO_RETURN } +static const FFlogo* getLogoOrchid(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("orchid") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORCHID) + FF_LOGO_COLORS( + "37", //white + "35", //magenta + "35" //magenta + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("35"); //magenta + FF_LOGO_RETURN +} + +static const FFlogo* getLogoOrchidSmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("orchid_small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORCHID_SMALL) + FF_LOGO_COLORS( + "37", //white + "35", //magenta + "35" //magenta + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("35"); //magenta + FF_LOGO_RETURN +} + static const FFlogo* getLogoParabola(void) { FF_LOGO_INIT @@ -1703,6 +1733,8 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoOpenSuseTumbleweed2, getLogoOpenMandriva, getLogoOpenWrt, + getLogoOrchid, + getLogoOrchidSmall, getLogoOracle, getLogoPop, getLogoPopSmall, From b3f8798f73ff9050825f69b1495dc86d20b30d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 29 Jul 2023 23:10:14 +0800 Subject: [PATCH 391/493] Logo: add Ubuntu Budgie and Ubuntu Gnome --- src/logo/ascii/ubuntu_budgie.txt | 20 +++++++++++++++++++ src/logo/ascii/ubuntu_gnome.txt | 16 ++++++++++++++++ src/logo/builtin.c | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/logo/ascii/ubuntu_budgie.txt create mode 100644 src/logo/ascii/ubuntu_gnome.txt diff --git a/src/logo/ascii/ubuntu_budgie.txt b/src/logo/ascii/ubuntu_budgie.txt new file mode 100644 index 000000000..732c9ab48 --- /dev/null +++ b/src/logo/ascii/ubuntu_budgie.txt @@ -0,0 +1,20 @@ + ./oydmMMMMMMmdyo/. + :smMMMMMMMMMMMhs+:++yhs: + `omMMMMMMMMMMMN+` `odo` + /NMMMMMMMMMMMMN- `sN/ + `hMMMMmhhmMMMMMMh sMh` + .mMmo- /yMMMMm` `MMm. + mN/ yMMMMMMMd- MMMm +oN- oMMMMMMMMMms+//+o+: :MMMMo +m/ +NMMMMMMMMMMMMMMMMm. :NMMMMm +M` .NMMMMMMMMMMMMMMMNodMMMMMMM +M- sMMMMMMMMMMMMMMMMMMMMMMMMM +mm` mMMMMMMMMMNdhhdNMMMMMMMMMm +oMm/ .dMMMMMMMMh: :dMMMMMMMo + mMMNyo/:/sdMMMMMMMMM+ sMMMMMm + .mMMMMMMMMMMMMMMMMMs `NMMMm. + `hMMMMMMMMMMM.oo+. `MMMh` + /NMMMMMMMMMo sMN/ + `omMMMMMMMMy. :dmo` + :smMMMMMMMh+-` `.:ohs: + ./oydmMMMMMMdhyo/. diff --git a/src/logo/ascii/ubuntu_gnome.txt b/src/logo/ascii/ubuntu_gnome.txt new file mode 100644 index 000000000..096dca3d0 --- /dev/null +++ b/src/logo/ascii/ubuntu_gnome.txt @@ -0,0 +1,16 @@ +${c3} ./o. + .oooooooo + .oooo```soooo + .oooo` `soooo + .ooo` ${c4}.o.${c3} `\/ooo. + :ooo ${c4}:oooo.${c3} `\/ooo. + sooo ${c4}`ooooo${c3} \/oooo + \/ooo ${c4}`soooo${c3} `ooooo + `soooo ${c4}`\/ooo${c3} `soooo +${c4}./oo ${c3}`\/ooo ${c4}`/oooo.${c3} `/ooo +${c4}`\/ooo. ${c3}`/oooo. ${c4}`/oooo.${c3} `` +${c4} `\/ooo. ${c3}/oooo ${c4}/ooo` +${c4} `ooooo ${c3}`` ${c4}.oooo +${c4} `soooo. .oooo` + `\/oooooooooo` + ``\/oo`` diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 367038564..cfe230ea1 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1509,6 +1509,37 @@ static const FFlogo* getLogoUbuntu(void) FF_LOGO_RETURN } +static const FFlogo* getLogoUbuntuBudgie(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ubuntu-budgie") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_BUDGIE) + FF_LOGO_COLORS( + "34", //blue + "37", //white + "31" //red + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoUbuntuGnome(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ubuntu-gnome") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME) + FF_LOGO_COLORS( + "34", //blue + "35", //magenta + "37", //white + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("35"); //magenta + FF_LOGO_RETURN +} + static const FFlogo* getLogoUbuntuKylin(void) { FF_LOGO_INIT @@ -1755,6 +1786,8 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoSolus, getLogoSteamOS, getLogoUbuntu, + getLogoUbuntuBudgie, + getLogoUbuntuGnome, getLogoUbuntuKylin, getLogoUbuntuMate, getLogoUbuntuOld, From 4f54eab672fc97c40132577fef70f0aa8f0960f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 30 Jul 2023 00:36:47 +0800 Subject: [PATCH 392/493] LM (Linux): fix gdm version detection on Ubuntu --- src/detection/lm/lm_linux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 6b96db254..6416c80a7 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -16,8 +16,15 @@ static const char* getGdmVersion(FFstrbuf* version) "--version", NULL }); - if (error) - return error; + if (error || version->length == 0) + { + error = ffProcessAppendStdOut(version, (char* const[]) { + "gdm3", + "--version", + NULL + }); + if (error || version->length == 0) return "Failed to get GDM version"; + } // GDM 44.1 ffStrbufSubstrAfterFirstC(version, ' '); From 6e7652e5be3bf33bd2f7817e12a84548a62bcecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 30 Jul 2023 11:32:44 +0800 Subject: [PATCH 393/493] Terminal: support yakuake --- CHANGELOG.md | 1 + README.md | 2 +- src/detection/terminalfont/terminalfont_linux.c | 14 ++++++++++---- src/detection/terminalshell/terminalshell.c | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cd2d83e1..aa6b22708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Features: * Add module `Terminal Size` which prints the number of terminal width and height in charactors and pixels * Add new option `--temperature-unit` * Better CPU and Host detection for Android (Android) +* Support yakuake terminal version & font detection (Terminal, Linux) Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/README.md b/README.md index 70da67379..4fee6d926 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4 ##### Terminal fonts ``` -Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, MATE Terminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal +Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, MATE Terminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal, Yakuake ``` ## Building diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index d95f94376..6833ba086 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -70,14 +70,18 @@ static void detectFromConfigFile(const char* configFile, const char* start, FFTe ffFontInitPango(&terminalFont->font, fontName.chars); } -static void detectKonsole(FFTerminalFontResult* terminalFont) +static void detectKonsole(FFTerminalFontResult* terminalFont, const char* rcFile) { FF_STRBUF_AUTO_DESTROY profile = ffStrbufCreate(); - ffParsePropFileConfig("konsolerc", "DefaultProfile =", &profile); + if(!ffParsePropFileConfig(rcFile, "DefaultProfile =", &profile)) + { + ffStrbufAppendF(&terminalFont->error, "Configuration \".config/%s\" doesn't exist", rcFile); + return; + } if(profile.length == 0) { - ffStrbufAppendS(&terminalFont->error, "Couldn't find \"DefaultProfile=%[^\\n]\" in \".config/konsolerc\""); + ffStrbufAppendS(&terminalFont->error, "Built-in profile is used"); return; } @@ -228,7 +232,9 @@ static void detectXterm(FFTerminalFontResult* terminalFont) void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "konsole")) - detectKonsole(terminalFont); + detectKonsole(terminalFont, "konsolerc"); + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "yakuake")) + detectKonsole(terminalFont, "yakuakerc"); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "xfce4-terminal")) detectXFCETerminal(terminalFont); else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "lxterminal")) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 86c7f2e67..18a9b79c8 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -309,6 +309,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "konsole")) return getTerminalVersionKonsole(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "yakuake")) + return getExeVersionGeneral(exe, version);//yakuake 22.12.3 + if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal")) return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)... From f906d0272014390a18b5c0b3e7a2eda0a8bde5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 30 Jul 2023 12:38:47 +0800 Subject: [PATCH 394/493] Title (Windows): remove the trailing white space of user name on WIndows 7 --- src/util/platform/FFPlatform_windows.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index faddd9194..13fc97246 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -104,31 +104,31 @@ static void getDataDirs(FFPlatform* platform) static void getUserName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->userName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->userName); - if(GetUserNameA(platform->userName.chars, &len)) - platform->userName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetUserNameW(buffer, &len)) + ffStrbufSetWS(&platform->userName, buffer); } static void getHostName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->hostName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->hostName); - if(GetComputerNameExA(ComputerNameDnsHostname, platform->hostName.chars, &len)) - platform->hostName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetComputerNameExW(ComputerNameDnsHostname, buffer, &len)) + ffStrbufSetWS(&platform->hostName, buffer); } static void getDomainName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->domainName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->domainName); - if(GetComputerNameExA(ComputerNameDnsDomain, platform->domainName.chars, &len)) - platform->domainName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetComputerNameExW(ComputerNameDnsDomain, buffer, &len)) + ffStrbufSetWS(&platform->domainName, buffer); } static void getSystemName(FFPlatform* platform) { - ffStrbufAppendS(&platform->systemName, "Windows_NT"); + ffStrbufAppendS(&platform->systemName, getenv("OS")); } static void getSystemReleaseAndVersion(FFPlatform* platform) From b4d1c97d2c95cecfd314ff88082cce6d9c5260da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 14:10:53 +0800 Subject: [PATCH 395/493] Separator: support Unicode / double width separator string Fixes #504 --- CMakeLists.txt | 12 +- src/common/init.c | 6 +- src/fastfetch.h | 1 - src/modules/separator/separator.c | 67 +++++-- src/modules/title/title.c | 1 - src/util/wcwidth.c | 309 ++++++++++++++++++++++++++++++ src/util/wcwidth.h | 21 ++ 7 files changed, 399 insertions(+), 18 deletions(-) create mode 100644 src/util/wcwidth.c create mode 100644 src/util/wcwidth.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d99967f1..bc31ea211 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,11 +607,17 @@ elseif(WIN32) ) endif() +include(CheckFunctionExists) +check_function_exists(wcwidth HAVE_WCWIDTH) +if(NOT HAVE_WCWIDTH) + list(APPEND LIBFASTFETCH_SRC src/util/wcwidth.c) +endif() + add_library(libfastfetch OBJECT ${LIBFASTFETCH_SRC} ) -target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE) +target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE) if(WIN32) target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1) endif() @@ -621,6 +627,10 @@ if(HAVE_UTMPX_H) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX_H) endif() +if(HAVE_WCWIDTH) + target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH) +endif() + function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) if(NOT ENABLE_${VARNAME}) return() diff --git a/src/common/init.c b/src/common/init.c index 1b5659f46..50794b3d7 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -7,9 +7,9 @@ #include #include +#include #ifdef _WIN32 #include - #include #include "util/windows/unicode.h" #else #include @@ -24,7 +24,6 @@ static void initState(FFstate* state) state->logoWidth = 0; state->logoHeight = 0; state->keysHeight = 0; - state->titleLength = 0; ffPlatformInit(&state->platform); state->configDoc = NULL; @@ -153,6 +152,9 @@ void ffInitInstance(void) #ifdef WIN32 //https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support setlocale(LC_ALL, ".UTF8"); + #else + // used for mbsrtowcs in Module `separator` + setlocale(LC_ALL, ""); #endif initState(&instance.state); diff --git a/src/fastfetch.h b/src/fastfetch.h index 90cc4e9aa..f54334eca 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -153,7 +153,6 @@ typedef struct FFstate uint32_t logoWidth; uint32_t logoHeight; uint32_t keysHeight; - uint32_t titleLength; FFPlatform platform; yyjson_doc* configDoc; diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 79b53d27b..a8d1d212c 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -2,19 +2,34 @@ #include "common/jsonconfig.h" #include "modules/separator/separator.h" #include "util/stringUtils.h" +#include "util/mallocHelper.h" +#include "util/wcwidth.h" + +static inline uint32_t max(uint32_t a, uint32_t b) +{ + return a > b ? a : b; +} + +static inline uint32_t getWcsWidth(const FFstrbuf* mbstr, wchar_t* wstr, mbstate_t* state) +{ + const char* str = mbstr->chars; + uint32_t wstrLength = (uint32_t) mbsrtowcs(wstr, &str, mbstr->length, state); + int result = mk_wcswidth(wstr, wstrLength); + return result > 0 ? (uint32_t) result : mbstr->length; +} void ffPrintSeparator(FFSeparatorOptions* options) { - uint32_t titleLength = instance.state.titleLength; - if (titleLength == 0) - { - // Title was not printed, should we support this case? - titleLength = instance.state.platform.userName.length + 1 + (instance.config.title.fqdn ? - instance.state.platform.domainName.length : - instance.state.platform.hostName.length - ); - } + mbstate_t state = {}; + bool fqdn = instance.config.title.fqdn; + const FFPlatform* platform = &instance.state.platform; + FF_AUTO_FREE wchar_t* wstr = malloc((max( + platform->userName.length, options->string.length) + 1) * sizeof(*wstr)); + + uint32_t titleLength = 1 // @ + + getWcsWidth(&platform->userName, wstr, &state) // user name + + (fqdn ? platform->domainName.length : platform->hostName.length); // host name ffLogoPrintLine(); if(options->string.length == 0) @@ -23,13 +38,39 @@ void ffPrintSeparator(FFSeparatorOptions* options) } else { + uint32_t wcsLength = getWcsWidth(&options->string, wstr, &state); + + int remaining = (int) titleLength; //Write the whole separator as often as it fits fully into titleLength - for(uint32_t i = 0; i < titleLength / options->string.length; i++) + for (; remaining >= (int) wcsLength; remaining -= (int) wcsLength) ffStrbufWriteTo(&options->string, stdout); - //Write as much of the separator as needed to fill titleLength - for(uint32_t i = 0; i < titleLength % options->string.length; i++) - putchar(options->string.chars[i]); + if (remaining > 0) + { + //Write as much of the separator as needed to fill titleLength + if (wcsLength != options->string.length) + { + // Unicode chars + for(int i = 0; remaining > 0; ++i) + { + #ifdef __linux__ + // https://stackoverflow.com/questions/75126743/i-have-difficulties-with-putwchar-in-c#answer-75137784 + char wch[16] = ""; + uint32_t wchLength = (uint32_t) wcrtomb(wch, wstr[i], &state); + fwrite(wch, wchLength, 1, stdout); + #else + putwchar(wstr[i]); + #endif + int width = mk_wcwidth(wstr[i]); + remaining -= width < 0 ? 0 : width; + } + } + else + { + for(int i = 0; i < remaining; i++) + putchar(options->string.chars[i]); + } + } } putchar('\n'); } diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 3c29acb11..c9dc9b8eb 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -46,7 +46,6 @@ void ffPrintTitle(FFTitleOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, host}, }); } - instance.state.titleLength = instance.state.platform.userName.length + host->length + 1; } void ffInitTitleOptions(FFTitleOptions* options) diff --git a/src/util/wcwidth.c b/src/util/wcwidth.c new file mode 100644 index 000000000..3b799da66 --- /dev/null +++ b/src/util/wcwidth.c @@ -0,0 +1,309 @@ +/* + * This is an implementation of wcwidth() and wcswidth() (defined in + * IEEE Std 1002.1-2001) for Unicode. + * + * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html + * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html + * + * In fixed-width output devices, Latin characters all occupy a single + * "cell" position of equal width, whereas ideographic CJK characters + * occupy two such cells. Interoperability between terminal-line + * applications and (teletype-style) character terminals using the + * UTF-8 encoding requires agreement on which character should advance + * the cursor by how many cell positions. No established formal + * standards exist at present on which Unicode character shall occupy + * how many cell positions on character terminals. These routines are + * a first attempt of defining such behavior based on simple rules + * applied to data provided by the Unicode Consortium. + * + * For some graphical characters, the Unicode standard explicitly + * defines a character-cell width via the definition of the East Asian + * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes. + * In all these cases, there is no ambiguity about which width a + * terminal shall use. For characters in the East Asian Ambiguous (A) + * class, the width choice depends purely on a preference of backward + * compatibility with either historic CJK or Western practice. + * Choosing single-width for these characters is easy to justify as + * the appropriate long-term solution, as the CJK practice of + * displaying these characters as double-width comes from historic + * implementation simplicity (8-bit encoded characters were displayed + * single-width and 16-bit ones double-width, even for Greek, + * Cyrillic, etc.) and not any typographic considerations. + * + * Much less clear is the choice of width for the Not East Asian + * (Neutral) class. Existing practice does not dictate a width for any + * of these characters. It would nevertheless make sense + * typographically to allocate two character cells to characters such + * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be + * represented adequately with a single-width glyph. The following + * routines at present merely assign a single-cell width to all + * neutral characters, in the interest of simplicity. This is not + * entirely satisfactory and should be reconsidered before + * establishing a formal standard in this area. At the moment, the + * decision which Not East Asian (Neutral) characters should be + * represented by double-width glyphs cannot yet be answered by + * applying a simple rule from the Unicode database content. Setting + * up a proper standard for the behavior of UTF-8 character terminals + * will require a careful analysis not only of each Unicode character, + * but also of each presentation form, something the author of these + * routines has avoided to do so far. + * + * http://www.unicode.org/unicode/reports/tr11/ + * + * Markus Kuhn -- 2007-05-26 (Unicode 5.0) + * + * Permission to use, copy, modify, and distribute this software + * for any purpose and without fee is hereby granted. The author + * disclaims all warranties with regard to this software. + * + * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c + */ + +#include + +struct interval { + int first; + int last; +}; + +/* auxiliary function for binary search in interval table */ +static int bisearch(wchar_t ucs, const struct interval *table, int max) { + int min = 0; + int mid; + + if (ucs < table[0].first || ucs > table[max].last) + return 0; + while (max >= min) { + mid = (min + max) / 2; + if (ucs > table[mid].last) + min = mid + 1; + else if (ucs < table[mid].first) + max = mid - 1; + else + return 1; + } + + return 0; +} + + +/* The following two functions define the column width of an ISO 10646 + * character as follows: + * + * - The null character (U+0000) has a column width of 0. + * + * - Other C0/C1 control characters and DEL will lead to a return + * value of -1. + * + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. + * + * - SOFT HYPHEN (U+00AD) has a column width of 1. + * + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. + * + * - Spacing characters in the East Asian Wide (W) or East Asian + * Full-width (F) category as defined in Unicode Technical + * Report #11 have a column width of 2. + * + * - All remaining characters (including all printable + * ISO 8859-1 and WGL4 characters, Unicode control characters, + * etc.) have a column width of 1. + * + * This implementation assumes that wchar_t characters are encoded + * in ISO 10646. + */ + +int mk_wcwidth(wchar_t ucs) +{ + /* sorted list of non-overlapping intervals of non-spacing characters */ + /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */ + static const struct interval combining[] = { + { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 }, + { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, + { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, + { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 }, + { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, + { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, + { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 }, + { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, + { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, + { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, + { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, + { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, + { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, + { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, + { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, + { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D }, + { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 }, + { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC }, + { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, + { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, + { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, + { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, + { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, + { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, + { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, + { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, + { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, + { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, + { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F }, + { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, + { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, + { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, + { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B }, + { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, + { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, + { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, + { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, + { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, + { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, + { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, + { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, + { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF } + }; + + /* test for 8-bit control characters */ + if (ucs == 0) + return 0; + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) + return -1; + + /* binary search in table of non-spacing characters */ + if (bisearch(ucs, combining, + sizeof(combining) / sizeof(struct interval) - 1)) + return 0; + + /* if we arrive here, ucs is not a combining or C0/C1 control character */ + + return 1 + + (ucs >= 0x1100 && + (ucs <= 0x115f || /* Hangul Jamo init. consonants */ + ucs == 0x2329 || ucs == 0x232a || + (ucs >= 0x2e80 && ucs <= 0xa4cf && + ucs != 0x303f) || /* CJK ... Yi */ + (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ + (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ + (ucs >= 0xfe10 && ucs <= 0xfe19) || /* Vertical forms */ + (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ + (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */ + (ucs >= 0xffe0 && ucs <= 0xffe6) || + (ucs >= 0x20000 && ucs <= 0x2fffd) || + (ucs >= 0x30000 && ucs <= 0x3fffd))); +} + + +int mk_wcswidth(const wchar_t *pwcs, size_t n) +{ + int w, width = 0; + + for (;*pwcs && n-- > 0; pwcs++) + if ((w = mk_wcwidth(*pwcs)) < 0) + return -1; + else + width += w; + + return width; +} + + +/* + * The following functions are the same as mk_wcwidth() and + * mk_wcswidth(), except that spacing characters in the East Asian + * Ambiguous (A) category as defined in Unicode Technical Report #11 + * have a column width of 2. This variant might be useful for users of + * CJK legacy encodings who want to migrate to UCS without changing + * the traditional terminal character-width behaviour. It is not + * otherwise recommended for general use. + */ +int mk_wcwidth_cjk(wchar_t ucs) +{ + /* sorted list of non-overlapping intervals of East Asian Ambiguous + * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ + static const struct interval ambiguous[] = { + { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, + { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 }, + { 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 }, + { 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 }, + { 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED }, + { 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA }, + { 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 }, + { 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B }, + { 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 }, + { 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 }, + { 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 }, + { 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE }, + { 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 }, + { 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA }, + { 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 }, + { 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB }, + { 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB }, + { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0391, 0x03A1 }, + { 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, + { 0x0401, 0x0401 }, { 0x0410, 0x044F }, { 0x0451, 0x0451 }, + { 0x2010, 0x2010 }, { 0x2013, 0x2016 }, { 0x2018, 0x2019 }, + { 0x201C, 0x201D }, { 0x2020, 0x2022 }, { 0x2024, 0x2027 }, + { 0x2030, 0x2030 }, { 0x2032, 0x2033 }, { 0x2035, 0x2035 }, + { 0x203B, 0x203B }, { 0x203E, 0x203E }, { 0x2074, 0x2074 }, + { 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, + { 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 }, + { 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 }, + { 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 }, + { 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 }, + { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, + { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, + { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B }, + { 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 }, + { 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 }, + { 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E }, + { 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 }, + { 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 }, + { 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F }, + { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 }, + { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, + { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B }, + { 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 }, + { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 }, + { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 }, + { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 }, + { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 }, + { 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 }, + { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 }, + { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 }, + { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F }, + { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF }, + { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } + }; + + /* binary search in table of non-spacing characters */ + if (bisearch(ucs, ambiguous, + sizeof(ambiguous) / sizeof(struct interval) - 1)) + return 2; + + return mk_wcwidth(ucs); +} + + +int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n) +{ + int w, width = 0; + + for (;*pwcs && n-- > 0; pwcs++) + if ((w = mk_wcwidth_cjk(*pwcs)) < 0) + return -1; + else + width += w; + + return width; +} diff --git a/src/util/wcwidth.h b/src/util/wcwidth.h new file mode 100644 index 000000000..eaeceed22 --- /dev/null +++ b/src/util/wcwidth.h @@ -0,0 +1,21 @@ +#pragma once + +#ifndef FF_INCLUDED_UTIL_WCWIDTH_H +#define FF_INCLUDED_UTIL_WCWIDTH_H + +#include + +#ifdef FF_HAVE_WCWIDTH +static inline int mk_wcwidth(wchar_t ucs) { + return wcwidth(ucs); +} +static inline int mk_wcswidth(const wchar_t *pwcs, size_t n) { + return wcswidth(pwcs, n); +} +#else +// https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c +int mk_wcwidth(wchar_t ucs); +int mk_wcswidth(const wchar_t *pwcs, size_t n); +#endif + +#endif From fd8794e6c8e026e8896c3b5c8cbe456948ea89ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 20:29:33 +0800 Subject: [PATCH 396/493] Disk (Linux): support hyperlink in WSL --- src/modules/disk/disk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index be61a902c..151596c27 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -18,7 +18,19 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) if(instance.config.pipe) ffStrbufAppendF(&key, "%s (%s)", FF_DISK_MODULE_NAME, disk->mountpoint.chars); else + { + #ifdef __linux__ + if (getenv("WSL_DISTRO_NAME") != NULL && getenv("WT_SESSION") != NULL) + { + if (ffStrbufEqualS(&disk->filesystem, "9p") && ffStrbufStartsWithS(&disk->mountpoint, "/mnt/")) + ffStrbufAppendF(&key, "%s (\e]8;;file:///%c:/\e\\%s\e]8;;\e\\)", FF_DISK_MODULE_NAME, disk->mountpoint.chars[5], disk->mountpoint.chars); + else + ffStrbufAppendF(&key, "%s (\e]8;;file:////wsl.localhost/%s%s\e\\%s\e]8;;\e\\)", FF_DISK_MODULE_NAME, getenv("WSL_DISTRO_NAME"), disk->mountpoint.chars, disk->mountpoint.chars); + } + else + #endif ffStrbufAppendF(&key, "%s (\e]8;;file://%s\e\\%s\e]8;;\e\\)", FF_DISK_MODULE_NAME, disk->mountpoint.chars, disk->mountpoint.chars); + } } else { From ca31f67c82e2bb7e9f622026980bdf1b3d7162c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 20:29:57 +0800 Subject: [PATCH 397/493] Host (Linux): display WSL distro name --- src/detection/host/host_linux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 386affbcc..05e48cbbc 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -50,10 +50,13 @@ const char* ffDetectHost(FFHostResult* host) if(host->productFamily.length == 0 && host->productName.length == 0) { + const char* wslDistroName = getenv("WSL_DISTRO_NAME"); //On WSL, the real host can't be detected. Instead use WSL as host. - if(getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) + if(wslDistroName != NULL || getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) { ffStrbufAppendS(&host->productName, "Windows Subsystem for Linux"); + if (wslDistroName) + ffStrbufAppendF(&host->productName, " - %s", wslDistroName); ffStrbufAppendS(&host->productFamily, "WSL"); FF_STRBUF_AUTO_DESTROY wslVer = ffStrbufCreate(); //Wide charactors From 9e64e6625447593588a0830f78ff6503dd7bb230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 22:34:10 +0800 Subject: [PATCH 398/493] TerminalShell: don't detect *.sh as shell or terminal Fixes #366 --- .../terminalshell/terminalshell_linux.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 88d6519a4..497cbc88d 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -132,16 +132,17 @@ static void getTerminalShell(FFTerminalShellResult* result, pid_t pid) //Common programs that are between terminal and own process, but are not the shell if( - strcasecmp(name, "sh") == 0 || //This prevents us from detecting things like pipes and redirects, i hope nobody uses plain `sh` as shell - strcasecmp(name, "sudo") == 0 || - strcasecmp(name, "su") == 0 || - strcasecmp(name, "doas") == 0 || - strcasecmp(name, "strace") == 0 || - strcasecmp(name, "sshd") == 0 || - strcasecmp(name, "gdb") == 0 || - strcasecmp(name, "lldb") == 0 || - strcasecmp(name, "guake-wrapped") == 0 || - strcasestr(name, "debug") != NULL + strcasecmp(name, "sh") == 0 || //This prevents us from detecting things like pipes and redirects, i hope nobody uses plain `sh` as shell + strcasecmp(name, "sudo") == 0 || + strcasecmp(name, "su") == 0 || + strcasecmp(name, "strace") == 0 || + strcasecmp(name, "sshd") == 0 || + strcasecmp(name, "gdb") == 0 || + strcasecmp(name, "lldb") == 0 || + strcasecmp(name, "guake-wrapped") == 0 || + strcasestr(name, "debug") != NULL || + strcasestr(name, "command-not-found") != NULL || + ffStrEndsWith(name, ".sh") ) { getTerminalShell(result, ppid); return; From 674618930d3c76c5587c9f300a5964b0f5fa6954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 23:11:39 +0800 Subject: [PATCH 399/493] DisplayServer: add option `--ds-force-drm` Fixes #505 --- doc/json_schema.json | 8 ++++- src/common/init.c | 1 + src/common/jsonconfig.c | 2 ++ src/data/config_user.txt | 8 +++++ src/data/help.txt | 1 + .../displayserver/linux/displayserver_linux.c | 31 ++++++++++--------- src/fastfetch.c | 2 ++ src/fastfetch.h | 1 + 8 files changed, 39 insertions(+), 15 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index a4eed6218..8e54130d1 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -240,9 +240,15 @@ "type": "string", "title": "Set the path to the file containing OS information. Linux only" }, + "dsForceDrm": { + "type": "boolean", + "title": "Force display detection to use `/sys/class/drm`. Linux only", + "default": false + }, "wmiTimeout": { "type": "integer", - "title": "Set the timeout (ms) for WMI queries, `-1` for no timeout. Windows only" + "title": "Set the timeout (ms) for WMI queries, `-1` for no timeout. Windows only", + "default": 5000 } }, "additionalProperties": false diff --git a/src/common/init.c b/src/common/init.c index 50794b3d7..8ffadbc98 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -41,6 +41,7 @@ static void defaultConfig(void) #if defined(__linux__) || defined(__FreeBSD__) ffStrbufInit(&instance.config.playerName); ffStrbufInit(&instance.config.osFile); + instance.config.dsForceDrm = false; #elif defined(_WIN32) instance.config.wmiTimeout = 5000; #endif diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 0b327ca4f..1b91c0035 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -318,6 +318,8 @@ const char* ffParseGeneralJsonConfig(void) ffStrbufSetS(&config->playerName, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "osFile")) ffStrbufSetS(&config->osFile, yyjson_get_str(val)); + else if (ffStrEqualsIgnCase(key, "dsForceDrm")) + config->dsForceDrm = yyjson_get_bool(val); #elif defined(_WIN32) else if (ffStrEqualsIgnCase(key, "wmiTimeout")) config->wmiTimeout = (int32_t) yyjson_get_int(val); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index e7ea439e0..29152b3d8 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -250,6 +250,14 @@ # Default is the first match starting with org.mpris.MediaPlayer2. #--player-name spotify +# Display server force DRM option +# Sets if fastfetch should only use `/sys/class/drm` to detect displays if you get issues with the default behavior. +# Note DRM doesn't support refresh rate or scaled resolution detection. +# Only supported on Linux. +# Must be true or false. +# Default is false. +#--ds-force-drm false + # Escape bedrock option # Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one # Must be true or false. diff --git a/src/data/help.txt b/src/data/help.txt index 097fc518d..f2cc97318 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -26,6 +26,7 @@ General options: --pipe : Disable logo and all escape sequences --wmi-timeout : Set the timeout (ms) for WMI queries. Windows only. Default is 5000 --processing-timeout : Set the timeout (ms) when waiting for child processes. Default is 1000 + --ds-force-drm : Set if only DRM should be used to detect displays. Default is false Logo options: -l,--logo : Set the logo; if default, the name of a builtin logo or a path to a file diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 506f519b1..13ffcf5e6 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -75,25 +75,28 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 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(ds); + if (!instance.config.dsForceDrm) + { + //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(ds); - //Try the x11 libs, from most feature rich to least. - //We use the display list to detect if a connection is needed. - //They respect wmProtocolName, and only detect display if it is set. + //Try the x11 libs, from most feature rich to least. + //We use the display list to detect if a connection is needed. + //They respect wmProtocolName, and only detect display if it is set. - if(ds->displays.length == 0) - ffdsConnectXcbRandr(ds); + if(ds->displays.length == 0) + ffdsConnectXcbRandr(ds); - if(ds->displays.length == 0) - ffdsConnectXrandr(ds); + if(ds->displays.length == 0) + ffdsConnectXrandr(ds); - if(ds->displays.length == 0) - ffdsConnectXcb(ds); + if(ds->displays.length == 0) + ffdsConnectXcb(ds); - if(ds->displays.length == 0) - ffdsConnectXlib(ds); + if(ds->displays.length == 0) + ffdsConnectXlib(ds); + } //This display detection method is display server independent. //Use it if all connections failed diff --git a/src/fastfetch.c b/src/fastfetch.c index f7fa7f3d4..2b0ac906f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -869,6 +869,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) ffOptionParseString(key, value, &instance.config.playerName); else if (ffStrEqualsIgnCase(key, "--os-file")) ffOptionParseString(key, value, &instance.config.osFile); + else if(ffStrEqualsIgnCase(key, "--ds-force-drm")) + instance.config.dsForceDrm = ffOptionParseBoolean(value); #elif defined(_WIN32) else if (ffStrEqualsIgnCase(key, "--wmi-timeout")) instance.config.wmiTimeout = ffOptionParseInt32(key, value); diff --git a/src/fastfetch.h b/src/fastfetch.h index f54334eca..fde4923f1 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -61,6 +61,7 @@ typedef struct FFconfig #if defined(__linux__) || defined(__FreeBSD__) FFstrbuf playerName; FFstrbuf osFile; + bool dsForceDrm; #elif defined(_WIN32) int32_t wmiTimeout; #endif From a986edbffb8f83549e05aded684af24561a9bf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 09:38:47 +0800 Subject: [PATCH 400/493] Logo: add Proxmox Fixes #507 --- src/logo/ascii/proxmox.txt | 20 ++++++++++++++++++++ src/logo/builtin.c | 15 +++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/logo/ascii/proxmox.txt diff --git a/src/logo/ascii/proxmox.txt b/src/logo/ascii/proxmox.txt new file mode 100644 index 000000000..a601cdbd9 --- /dev/null +++ b/src/logo/ascii/proxmox.txt @@ -0,0 +1,20 @@ +${c1} .://:` `://:. + `hMMMMMMd/ /dMMMMMMh` + `sMMMMMMMd: :mMMMMMMMs` +${c2}`-/+oo+/:${c1}`.yMMMMMMMh- -hMMMMMMMy.`${c2}:/+oo+/-` +`:oooooooo/${c1}`-hMMMMMMMyyMMMMMMMh-`${c2}/oooooooo:` + `/oooooooo:${c1}`:mMMMMMMMMMMMMm:`${c2}:oooooooo/` + ./ooooooo+-${c1} +NMMMMMMMMN+ ${c2}-+ooooooo/. + .+ooooooo+-${c1}`oNMMMMNo`${c2}-+ooooooo+. + -+ooooooo/.${c1}`sMMs`${c2}./ooooooo+- + :oooooooo/${c1}`..`${c2}/oooooooo: + :oooooooo/`${c1}..${c2}`/oooooooo: + -+ooooooo/.`${c1}sMMs${c2}`./ooooooo+- + .+ooooooo+-`${c1}oNMMMMNo${c2}`-+ooooooo+. + ./ooooooo+-${c1} +NMMMMMMMMN+ ${c2}-+ooooooo/. + `/oooooooo:`${c1}:mMMMMMMMMMMMMm:${c2}`:oooooooo/` +`:oooooooo/`${c1}-hMMMMMMMyyMMMMMMMh-${c2}`/oooooooo:` +`-/+oo+/:`${c1}.yMMMMMMMh- -hMMMMMMMy.${c2}`:/+oo+/-` +${c1} `sMMMMMMMm: :dMMMMMMMs` + `hMMMMMMd/ /dMMMMMMh` + `://:` `://:` diff --git a/src/logo/builtin.c b/src/logo/builtin.c index cfe230ea1..20e0c0fcd 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1417,6 +1417,20 @@ static const FFlogo* getLogoRosaLinux(void) FF_LOGO_RETURN } +static const FFlogo* getLogoProxmox(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("proxmox") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PROXMOX) + FF_LOGO_COLORS( + "37", //blue + "38;5;202" + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("38;5;202"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoSlackware(void) { FF_LOGO_INIT @@ -1771,6 +1785,7 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoPopSmall, getLogoParabola, getLogoParabolaSmall, + getLogoProxmox, getLogoRaspbian, getLogoRaspbianSmall, getLogoReborn, From 5562bc6264bdb499aa24e97c0af5d2c1b0fcd00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 10:23:36 +0800 Subject: [PATCH 401/493] Command (Linux): use `/bin/sh` as the default shell --- CHANGELOG.md | 1 + doc/json_schema.json | 2 +- src/data/help.txt | 2 +- src/modules/command/command.c | 8 +++----- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa6b22708..1fe242644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Changes: * Remove the special handling of Command module (it can be set once in the triditional `config.conf`). Use JSON config with Command module instead * Change `--wm-theme-*` to `--wmtheme-*`. Affect `key` and `format` * Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` +* Module `Command` uses `/bin/sh` as the default shell on systems other than Windows Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine diff --git a/doc/json_schema.json b/doc/json_schema.json index 8e54130d1..6e92ac2ea 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -692,7 +692,7 @@ "const": "command" }, "shell": { - "title": "Set the shell program to execute the command text\nDefault: cmd for Windows, csh for FreeBSD, bash for others", + "title": "Set the shell program to execute the command text\nDefault: cmd for Windows, /bin/sh for *nix", "type": "string" }, "text": { diff --git a/src/data/help.txt b/src/data/help.txt index f2cc97318..2eb23e67f 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -144,7 +144,7 @@ Module specific options: --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use --opengl-library : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto - --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others + --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, /bin/sh for *nix --command-key : Set the module key to display --command-text : Set the command text to be executed --colors-symbol : Set the symbol to be printed by Colors module. Default is block diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 319aed606..7337e7553 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -39,13 +39,11 @@ void ffInitCommandOptions(FFCommandOptions* options) options->moduleName = FF_COMMAND_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); - ffStrbufInitS(&options->shell, + ffStrbufInitStatic(&options->shell, #ifdef _WIN32 - "cmd" - #elif defined(__FreeBSD__) - "csh" + "cmd.exe" #else - "bash" + "/bin/sh" #endif ); From aa498776108eb0df31535f6be3261e63f8c7b7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 15:15:03 +0800 Subject: [PATCH 402/493] DisplayServer (Linux): try fixing #505 --- .../displayserver/linux/displayserver_linux.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 13ffcf5e6..3d6c76402 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -1,4 +1,5 @@ #include "displayserver_linux.h" +#include "common/io/io.h" #include "util/stringUtils.h" #include @@ -81,21 +82,25 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) //This method can't detect the name of our WM / DE ffdsConnectWayland(ds); - //Try the x11 libs, from most feature rich to least. - //We use the display list to detect if a connection is needed. - //They respect wmProtocolName, and only detect display if it is set. - if(ds->displays.length == 0) + { + //Try the x11 libs, from most feature rich to least. + //We use the display list to detect if a connection is needed. + //They respect wmProtocolName, and only detect display if it is set. + + FF_SUPPRESS_IO(); // #505 + ffdsConnectXcbRandr(ds); - if(ds->displays.length == 0) - ffdsConnectXrandr(ds); + if(ds->displays.length == 0) + ffdsConnectXrandr(ds); - if(ds->displays.length == 0) - ffdsConnectXcb(ds); + if(ds->displays.length == 0) + ffdsConnectXcb(ds); - if(ds->displays.length == 0) - ffdsConnectXlib(ds); + if(ds->displays.length == 0) + ffdsConnectXlib(ds); + } } //This display detection method is display server independent. From f1ec86a371eee29a678b247c226dca388ad73646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 15:15:54 +0800 Subject: [PATCH 403/493] IO: only suppress IO in release mode It can be annoy when printing debug messages --- src/common/io/io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/io/io.h b/src/common/io/io.h index cfe730550..aff080dc8 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -96,7 +96,11 @@ static inline void ffUnsuppressIO(bool* suppressed) *suppressed = false; } -#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true) +#ifdef NDEBUG + #define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true) +#else + #define FF_SUPPRESS_IO() +#endif void ffListFilesRecursively(const char* path); From 81f7861147ac632f10dfd80c43b3e29373356e8c Mon Sep 17 00:00:00 2001 From: xzl Date: Tue, 1 Aug 2023 07:24:56 +0000 Subject: [PATCH 404/493] Disk(Linux): fix byteUsed not correctly in ext4 --- src/detection/disk/disk_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 6cca83dab..afde1887e 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -197,7 +197,7 @@ static void detectStats(FFDisk* disk) memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too disk->bytesTotal = fs.f_blocks * fs.f_frsize; - disk->bytesUsed = disk->bytesTotal - (fs.f_bavail * fs.f_frsize); + disk->bytesUsed = disk->bytesTotal - (fs.f_bfree * fs.f_frsize); disk->filesTotal = (uint32_t) fs.f_files; disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree); From 172b3b2968831cff3425c030a7dfdc18171e7f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 16:09:20 +0800 Subject: [PATCH 405/493] Disk (BSD): fix bytesUsed calculation Follow up of #508 --- CHANGELOG.md | 1 + src/detection/disk/disk_bsd.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fe242644..9267e211d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Bugfixes: * Properly detect CPU on POWER (CPU, Linux) * Fix compatibility with Fig (Terminal, macOS) * Fix option `--title-fqdn` doesn't work (Title) +* Fix used spaces calculation (Disk, Linux / BSD / macOS, #508) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index e9911eb72..746a17052 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -45,7 +45,7 @@ const char* ffDetectDisksImpl(FFlist* disks) #endif disk->bytesTotal = fs->f_blocks * fs->f_bsize; - disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bavail * fs->f_bsize); + disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bfree * fs->f_bsize); disk->filesTotal = (uint32_t) fs->f_files; disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree); From df374f823468819ac73561a865d00e18566d933c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 16:19:58 +0800 Subject: [PATCH 406/493] Revert "DisplayServer (Linux): try fixing #505" This reverts commit aa498776108eb0df31535f6be3261e63f8c7b7e5. --- .../displayserver/linux/displayserver_linux.c | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 3d6c76402..13ffcf5e6 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -1,5 +1,4 @@ #include "displayserver_linux.h" -#include "common/io/io.h" #include "util/stringUtils.h" #include @@ -82,25 +81,21 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) //This method can't detect the name of our WM / DE ffdsConnectWayland(ds); + //Try the x11 libs, from most feature rich to least. + //We use the display list to detect if a connection is needed. + //They respect wmProtocolName, and only detect display if it is set. + if(ds->displays.length == 0) - { - //Try the x11 libs, from most feature rich to least. - //We use the display list to detect if a connection is needed. - //They respect wmProtocolName, and only detect display if it is set. - - FF_SUPPRESS_IO(); // #505 - ffdsConnectXcbRandr(ds); - if(ds->displays.length == 0) - ffdsConnectXrandr(ds); + if(ds->displays.length == 0) + ffdsConnectXrandr(ds); - if(ds->displays.length == 0) - ffdsConnectXcb(ds); + if(ds->displays.length == 0) + ffdsConnectXcb(ds); - if(ds->displays.length == 0) - ffdsConnectXlib(ds); - } + if(ds->displays.length == 0) + ffdsConnectXlib(ds); } //This display detection method is display server independent. From 5137b7d64637e4a20a6bedd3c91d53309971945a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 16:20:00 +0800 Subject: [PATCH 407/493] Revert "IO: only suppress IO in release mode" This reverts commit f1ec86a371eee29a678b247c226dca388ad73646. --- src/common/io/io.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/common/io/io.h b/src/common/io/io.h index aff080dc8..cfe730550 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -96,11 +96,7 @@ static inline void ffUnsuppressIO(bool* suppressed) *suppressed = false; } -#ifdef NDEBUG - #define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true) -#else - #define FF_SUPPRESS_IO() -#endif +#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true) void ffListFilesRecursively(const char* path); From 0c86e458ceee6de31d90e8e401b433e61fd04788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 23:19:33 +0800 Subject: [PATCH 408/493] Wifi (Linux): don't make `iw` a slow operation --- src/detection/wifi/wifi_linux.c | 38 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 0186179e2..f15d0932f 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -143,16 +143,20 @@ static const char* detectWifiWithLibnm(FFlist* result) item->conn.signalQuality = ffnm_access_point_get_strength(ap); item->conn.rxRate = ffnm_access_point_get_max_bitrate(ap); - if(instance.config.allowSlowOperations) + FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); + if(!ffProcessAppendStdOut(&output, (char* const[]){ + "iw", + "dev", + item->inf.description.chars, + "link", + NULL + })) { - FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); - if(!ffProcessAppendStdOut(&output, (char* const[]){ - "iw", - "dev", - item->inf.description.chars, - "link", - NULL - }) && ffParsePropLines(output.chars, "tx bitrate: ", &item->conn.protocol)) + if(ffParsePropLines(output.chars, "rx bitrate: ", &item->conn.protocol)) + { + sscanf(item->conn.protocol.chars, "%lf", &item->conn.rxRate); + } + if(ffParsePropLines(output.chars, "tx bitrate: ", &item->conn.protocol)) { if(ffStrbufContainS(&item->conn.protocol, " HE-MCS ")) ffStrbufSetS(&item->conn.protocol, "802.11ax (Wi-Fi 6)"); @@ -162,6 +166,8 @@ static const char* detectWifiWithLibnm(FFlist* result) ffStrbufSetS(&item->conn.protocol, "802.11n (Wi-Fi 4)"); else ffStrbufSetS(&item->conn.protocol, "802.11a/b/g"); + + sscanf(item->conn.protocol.chars, "%lf", &item->conn.txRate); } } @@ -171,28 +177,28 @@ static const char* detectWifiWithLibnm(FFlist* result) if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpaFlags == NM_802_11_AP_SEC_NONE) && (rsnFlags == NM_802_11_AP_SEC_NONE)) - ffStrbufAppendS(&item->conn.security, "WEP "); + ffStrbufAppendS(&item->conn.security, "WEP/"); if (wpaFlags != NM_802_11_AP_SEC_NONE) - ffStrbufAppendS(&item->conn.security, "WPA "); + ffStrbufAppendS(&item->conn.security, "WPA/"); if ((rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_PSK) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - ffStrbufAppendS(&item->conn.security, "WPA2 "); + ffStrbufAppendS(&item->conn.security, "WPA2/"); } if (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_SAE) { - ffStrbufAppendS(&item->conn.security, "WPA3 "); + ffStrbufAppendS(&item->conn.security, "WPA3/"); } if ((rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_OWE) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) { - ffStrbufAppendS(&item->conn.security, "OWE "); + ffStrbufAppendS(&item->conn.security, "OWE/"); } if ((wpaFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - ffStrbufAppendS(&item->conn.security, "802.1X "); + ffStrbufAppendS(&item->conn.security, "802.1X/"); } if (!item->conn.security.length) ffStrbufAppendS(&item->conn.security, "Insecure"); else - ffStrbufTrimRight(&item->conn.security, ' '); + ffStrbufTrimRight(&item->conn.security, '/'); } ffg_object_unref(client); From 9686467886c0fc34590fa5303ed6d7ec401b5e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Aug 2023 23:49:22 +0800 Subject: [PATCH 409/493] Logo: add elementary and mx --- README.md | 2 +- src/logo/ascii/elementary.txt | 17 +++++++++ src/logo/ascii/elementary_small.txt | 6 +++ src/logo/ascii/mx.txt | 17 +++++++++ src/logo/ascii/mx_small.txt | 7 ++++ src/logo/builtin.c | 58 ++++++++++++++++++++++++++++- 6 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/logo/ascii/elementary.txt create mode 100644 src/logo/ascii/elementary_small.txt create mode 100644 src/logo/ascii/mx.txt create mode 100644 src/logo/ascii/mx_small.txt diff --git a/README.md b/README.md index 4fee6d926..69fb874bf 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MX, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/logo/ascii/elementary.txt b/src/logo/ascii/elementary.txt new file mode 100644 index 000000000..e347f52ee --- /dev/null +++ b/src/logo/ascii/elementary.txt @@ -0,0 +1,17 @@ + eeeeeeeeeeeeeeeee + eeeeeeeeeeeeeeeeeeeeeee + eeeee eeeeeeeeeeee eeeee + eeee eeeee eee eeee + eeee eeee eee eeee +eee eee eee eee +eee eee eee eee +ee eee eeee eeee +ee eee eeeee eeeeee +ee eee eeeee eeeee ee +eee eeee eeeeee eeeee eee +eee eeeeeeeeee eeeeee eee + eeeeeeeeeeeeeeeeeeeeeeee eeeee + eeeeeeee eeeeeeeeeeee eeee + eeeee eeeee + eeeeeee eeeeeee + eeeeeeeeeeeeeeeee diff --git a/src/logo/ascii/elementary_small.txt b/src/logo/ascii/elementary_small.txt new file mode 100644 index 000000000..161031330 --- /dev/null +++ b/src/logo/ascii/elementary_small.txt @@ -0,0 +1,6 @@ + _______ + / ____ \\ +/ | / /\\ +|__\\ / / | +\\ /__/ / + \\_______/ diff --git a/src/logo/ascii/mx.txt b/src/logo/ascii/mx.txt new file mode 100644 index 000000000..b80cb098e --- /dev/null +++ b/src/logo/ascii/mx.txt @@ -0,0 +1,17 @@ +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMM +MMMMMMMMMMNs..yMMMMMMMMMMMMMm: +NMMMMMMM +MMMMMMMMMN+ :mMMMMMMMMMNo` -dMMMMMMMM +MMMMMMMMMMMs. `oNMMMMMMh- `sNMMMMMMMMM +MMMMMMMMMMMMN/ -hMMMN+ :dMMMMMMMMMMM +MMMMMMMMMMMMMMh- +ms. .sMMMMMMMMMMMMM +MMMMMMMMMMMMMMMN+` ` +NMMMMMMMMMMMMMM +MMMMMMMMMMMMMMNMMd: .dMMMMMMMMMMMMMMM +MMMMMMMMMMMMm/-hMd- `sNMMMMMMMMMMMMM +MMMMMMMMMMNo` -` :h/ -dMMMMMMMMMMMM +MMMMMMMMMd: /NMMh- `+NMMMMMMMMMM +MMMMMMMNo` :mMMN+` `-hMMMMMMMM +MMMMMMh. `oNMMd: `/mMMMMMM +MMMMm/ -hMd- `sNMMMM +MMNs` - :dMMM +Mm: `oMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM diff --git a/src/logo/ascii/mx_small.txt b/src/logo/ascii/mx_small.txt new file mode 100644 index 000000000..b12cdd474 --- /dev/null +++ b/src/logo/ascii/mx_small.txt @@ -0,0 +1,7 @@ + \\\\ / + \\\\/ + \\\\ + /\\/ \\\\ + / \\ /\\ + / \\/ \\ +/__________\\ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 20e0c0fcd..7370801b3 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -380,6 +380,32 @@ static const FFlogo* getLogoDevuanSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoElementary(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("elementary") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ELEMENTARY) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoElementarySmall(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("elementary_small", "elementary-small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoDeepin(void) { FF_LOGO_INIT @@ -1039,6 +1065,32 @@ static const FFlogo* getLogoNixOsSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoMX(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("mx"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MX) + FF_LOGO_COLORS( + "37" // white + ) + FF_LOGO_COLOR_KEYS("34"); // blue + FF_LOGO_COLOR_TITLE("36"); // cyan + FF_LOGO_RETURN +} + +static const FFlogo* getLogoMXSmall(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("mx_small", "mx-small"); + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MX_SMALL) + FF_LOGO_COLORS( + "37" // white + ) + FF_LOGO_COLOR_KEYS("34"); // blue + FF_LOGO_COLOR_TITLE("36"); // cyan + FF_LOGO_RETURN +} + static const FFlogo* getLogoNetBSD(void) { FF_LOGO_INIT @@ -1715,10 +1767,12 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoCentOSSmall, getLogoCRUX, getLogoCrystalLinux, + getLogoElementary, + getLogoElementarySmall, getLogoDebian, + getLogoDebianSmall, getLogoDevuan, getLogoDevuanSmall, - getLogoDebianSmall, getLogoDeepin, getLogoEndeavour, getLogoEnso, @@ -1766,6 +1820,8 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoNixOsOld, getLogoNixOsSmall, getLogoNomadBSD, + getLogoMX, + getLogoMXSmall, getLogoNetBSD, getLogoNobara, getLogoOpenBSD, From 04ede28dbe0675d43224a6c4a7d7b3a92f611911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 2 Aug 2023 15:18:40 +0800 Subject: [PATCH 410/493] Logo: add more logos --- README.md | 2 +- src/logo/ascii/alpine2_small.txt | 6 +++ src/logo/ascii/alter.txt | 20 ++++++++ src/logo/ascii/amazon.txt | 19 ++++++++ src/logo/ascii/amogos.txt | 19 ++++++++ src/logo/ascii/anarchy.txt | 28 +++++++++++ src/logo/builtin.c | 81 ++++++++++++++++++++++++++++++-- 7 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 src/logo/ascii/alpine2_small.txt create mode 100644 src/logo/ascii/alter.txt create mode 100644 src/logo/ascii/amazon.txt create mode 100644 src/logo/ascii/amogos.txt create mode 100644 src/logo/ascii/anarchy.txt diff --git a/README.md b/README.md index 69fb874bf..a7bbd959a 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AIX, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MX, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, Alter, Amazon, Amogos, Anarchy, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MX, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/logo/ascii/alpine2_small.txt b/src/logo/ascii/alpine2_small.txt new file mode 100644 index 000000000..8f231cc2b --- /dev/null +++ b/src/logo/ascii/alpine2_small.txt @@ -0,0 +1,6 @@ +${c1} /\\ /\\ + /${c2}/ ${c1}\\ \\ + /${c2}// ${c1}\\ \\ +/${c2}// ${c1}\\ \\ +${c2}// ${c1}\\ \\ + \\ diff --git a/src/logo/ascii/alter.txt b/src/logo/ascii/alter.txt new file mode 100644 index 000000000..990221c90 --- /dev/null +++ b/src/logo/ascii/alter.txt @@ -0,0 +1,20 @@ + %, + ^WWWw + 'wwwwww + !wwwwwwww + #`wwwwwwwww + @wwwwwwwwwwww + wwwwwwwwwwwwwww + wwwwwwwwwwwwwwwww + wwwwwwwwwwwwwwwwwww + wwwwwwwwwwwwwwwwwwww, + w~1i.wwwwwwwwwwwwwwwww, + 3~:~1lli.wwwwwwwwwwwwwwww. + :~~:~?ttttzwwwwwwwwwwwwwwww + #<~:~~~~?llllltO-.wwwwwwwwwww + #~:~~:~:~~?ltlltlttO-.wwwwwwwww + @~:~~:~:~:~~(zttlltltlOda.wwwwwww + @~:~~: ~:~~:~:(zltlltlO a,wwwwww + 8~~:~~:~~~~:~~~~_1ltltu ,www + 5~~:~~:~~:~~:~~:~~~_1ltq N,, + g~:~~:~~~:~~:~~:~:~~~~1q N, diff --git a/src/logo/ascii/amazon.txt b/src/logo/ascii/amazon.txt new file mode 100644 index 000000000..e995cfdff --- /dev/null +++ b/src/logo/ascii/amazon.txt @@ -0,0 +1,19 @@ + `-/oydNNdyo:.` + `.:+shmMMMMMMMMMMMMMMmhs+:.` + -+hNNMMMMMMMMMMMMMMMMMMMMMMNNho- +.`` -/+shmNNMMMMMMNNmhs+/- ``. +dNmhs+:. `.:/oo/:.` .:+shmNd +dMMMMMMMNdhs+:.. ..:+shdNMMMMMMMd +dMMMMMMMMMMMMMMNds odNMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +dMMMMMMMMMMMMMMMMh yMMMMMMMMMMMMMMMMd +.:+ydNMMMMMMMMMMMh yMMMMMMMMMMMNdy+:. + `.:+shNMMMMMh yMMMMMNhs+:`` + `-+shy shs+:` diff --git a/src/logo/ascii/amogos.txt b/src/logo/ascii/amogos.txt new file mode 100644 index 000000000..4b1919133 --- /dev/null +++ b/src/logo/ascii/amogos.txt @@ -0,0 +1,19 @@ +${c1} ___________ + / \ + / ${c2}______${c1} \ + / ${c2}/ \${c1} \ + | ${c2}( )${c1} \ + / ${c2}\______/${c1} | + | | + / \ + | | + | | + / | + | | + | _______ | + ____/ / \ | + / | | | + | / ____/ | + \_________/ / | + \ __/ + \_______/ diff --git a/src/logo/ascii/anarchy.txt b/src/logo/ascii/anarchy.txt new file mode 100644 index 000000000..76b74cd35 --- /dev/null +++ b/src/logo/ascii/anarchy.txt @@ -0,0 +1,28 @@ + ${c2}..${c1} + ${c2}..${c1} + ${c2}:..${c1} + ${c2}:+++.${c1} + .:::++${c2}++++${c1}+::. + .:+######${c2}++++${c1}######+:. + .+#########${c2}+++++${c1}##########:. + .+##########${c2}+++++++${c1}##${c2}+${c1}#########+. + +###########${c2}+++++++++${c1}############: + +##########${c2}++++++${c1}#${c2}++++${c1}#${c2}+${c1}###########+ + +###########${c2}+++++${c1}###${c2}++++${c1}#${c2}+${c1}###########+ + :##########${c2}+${c1}#${c2}++++${c1}####${c2}++++${c1}#${c2}+${c1}############: + ###########${c2}+++++${c1}#####${c2}+++++${c1}#${c2}+${c1}###${c2}++${c1}######+ +.##########${c2}++++++${c1}#####${c2}++++++++++++${c1}#######. +.##########${c2}+++++++++++++++++++${c1}###########. + #####${c2}++++++++++++++${c1}###${c2}++++++++${c1}#########+ + :###${c2}++++++++++${c1}#########${c2}+++++++${c1}#########: + +######${c2}+++++${c1}##########${c2}++++++++${c1}#######+ + +####${c2}+++++${c1}###########${c2}+++++++++${c1}#####+ + :##${c2}++++++${c1}############${c2}++++++++++${c1}##: + .${c2}++++++${c1}#############${c2}++++++++++${c1}+. + :${c2}++++${c1}###############${c2}+++++++${c1}:: + .${c2}++. .:+${c1}##############${c2}+++++++${c1}.. + ${c2}.:.${c1} ..::++++++::..:${c2}++++${c1}+. + ${c2}.${c1} ${c2}.:+++${c1}. + ${c2}.:${c1}: + ${c2}..${c1} + ${c2}..${c1} diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 7370801b3..a470a58c4 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -72,13 +72,83 @@ static const FFlogo* getLogoAlpineSmall(void) FF_LOGO_NAMES("alpine_small", "alpine-linux-small") FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL) FF_LOGO_COLORS( - "34" //blue + "34", //blue + "37" //white ) FF_LOGO_COLOR_KEYS("35"); //magenta FF_LOGO_COLOR_TITLE("34"); //blue FF_LOGO_RETURN } +static const FFlogo* getLogoAlpine2Small(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("alpine2_small", "alpine-linux2-small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE2_SMALL) + FF_LOGO_COLORS( + "34", //blue + "37" //white + ) + FF_LOGO_COLOR_KEYS("35"); //magenta + FF_LOGO_COLOR_TITLE("34"); //blue + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAlter(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Alter") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALTER) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAmazon(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Amazon") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AMAZON) + FF_LOGO_COLORS( + "33", //yellow + "37" //white + ) + FF_LOGO_COLOR_KEYS("33"); //yellow + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAmogOS(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("AmogOS") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AMOGOS) + FF_LOGO_COLORS( + "37", //white + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAnarchy(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Anarchy") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANARCHY) + FF_LOGO_COLORS( + "37", //white + "34" //blue + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("34"); //blue + FF_LOGO_RETURN +} + static const FFlogo* getLogoAndroid(void) { FF_LOGO_INIT @@ -109,7 +179,7 @@ static const FFlogo* getLogoAndroidSmall(void) static const FFlogo* getLogoArch(void) { FF_LOGO_INIT - FF_LOGO_NAMES("arch", "archlinux", "arch-linux") + FF_LOGO_NAMES("arch", "archlinux", "arch-linux", "archmerge") FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCH) FF_LOGO_COLORS( "36", //cyan @@ -506,7 +576,7 @@ static const FFlogo* getLogoFedoraOld(void) static const FFlogo* getLogoFreeBSD(void) { FF_LOGO_INIT - FF_LOGO_NAMES("freebsd") + FF_LOGO_NAMES("freebsd", "HardenedBSD") FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FREEBSD) FF_LOGO_COLORS( "37", //white @@ -1750,6 +1820,11 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoAlmaLinux, getLogoAlpine, getLogoAlpineSmall, + getLogoAlpine2Small, + getLogoAlter, + getLogoAmazon, + getLogoAmogOS, + getLogoAnarchy, getLogoAndroid, getLogoAndroidSmall, getLogoArch, From c0317e2086c4f5cc1eeb37496d94707b6cce72b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 2 Aug 2023 15:58:18 +0800 Subject: [PATCH 411/493] Logo: more --- README.md | 2 +- src/logo/ascii/antergos.txt | 19 +++ src/logo/ascii/antix.txt | 12 ++ src/logo/ascii/aoscos.txt | 20 +++ src/logo/ascii/aoscosretro.txt | 18 +++ src/logo/ascii/aoscosretro_small.txt | 9 ++ src/logo/ascii/aperture.txt | 20 +++ src/logo/ascii/apricity.txt | 18 +++ src/logo/ascii/archbox.txt | 19 +++ src/logo/ascii/archcraft.txt | 20 +++ src/logo/ascii/archcraft2.txt | 20 +++ src/logo/ascii/archlabs.txt | 21 +++ src/logo/ascii/archstrike.txt | 17 +++ src/logo/ascii/arco_small.txt | 11 ++ src/logo/ascii/artix2_small.txt | 13 ++ src/logo/builtin.c | 207 ++++++++++++++++++++++++++- 16 files changed, 443 insertions(+), 3 deletions(-) create mode 100644 src/logo/ascii/antergos.txt create mode 100644 src/logo/ascii/antix.txt create mode 100644 src/logo/ascii/aoscos.txt create mode 100644 src/logo/ascii/aoscosretro.txt create mode 100644 src/logo/ascii/aoscosretro_small.txt create mode 100644 src/logo/ascii/aperture.txt create mode 100644 src/logo/ascii/apricity.txt create mode 100644 src/logo/ascii/archbox.txt create mode 100644 src/logo/ascii/archcraft.txt create mode 100644 src/logo/ascii/archcraft2.txt create mode 100644 src/logo/ascii/archlabs.txt create mode 100644 src/logo/ascii/archstrike.txt create mode 100644 src/logo/ascii/arco_small.txt create mode 100644 src/logo/ascii/artix2_small.txt diff --git a/README.md b/README.md index a7bbd959a..f9069d9bb 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -AIX, Alter, Amazon, Amogos, Anarchy, Asahi, AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, BSD, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, Garuda, Garuda Dragon, Gentoo, GhostBSD, GNU, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, LMDE, MacOS, Mandriva, Manjaro, NetBSD, Mint, Minix, MX, MSYS2, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Orchid, Oracle, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, Ubuntu, Ubuntu Kylin, UOS, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin +AIX, AlmaLinux, Alpine, Alter, Amazon, Amogos, Anarchy, Android, Antergos, AntiX, Aosc OS, Aperture, Apricity, Arch, ArchBox, Archcraft, Arco, Artix, Asahi, BSD, Bedrock, CRUX, CachyOS, CentOS, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, GNU, Garuda, Garuda Dragon, Gentoo, GhostBSD, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LMDE, LangitKetujuh, Linux, MSYS2, MX, MacOS, Mandriva, Manjaro, Minix, Mint, NetBSD, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Orchid, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, UOS, Ubuntu, Ubuntu Kylin, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin ``` ##### Package managers diff --git a/src/logo/ascii/antergos.txt b/src/logo/ascii/antergos.txt new file mode 100644 index 000000000..023af9bd8 --- /dev/null +++ b/src/logo/ascii/antergos.txt @@ -0,0 +1,19 @@ +${c2} `.-/::/-`` + .-/osssssssso/. + :osyysssssssyyys+- + `.+yyyysssssssssyyyyy+. + `/syyyyyssssssssssyyyyys-` + `/yhyyyyysss${c1}++${c2}ssosyyyyhhy/` + .ohhhyyyys${c1}o++/+o${c2}so${c1}+${c2}syy${c1}+${c2}shhhho. + .shhhhys${c1}oo++//+${c2}sss${c1}+++${c2}yyy${c1}+s${c2}hhhhs. + -yhhhhs${c1}+++++++o${c2}ssso${c1}+++${c2}yyy${c1}s+o${c2}hhddy: + -yddhhy${c1}o+++++o${c2}syyss${c1}++++${c2}yyy${c1}yooy${c2}hdddy- + .yddddhs${c1}o++o${c2}syyyyys${c1}+++++${c2}yyhh${c1}sos${c2}hddddy` +`odddddhyosyhyyyyyy${c1}++++++${c2}yhhhyosddddddo +.dmdddddhhhhhhhyyyo${c1}+++++${c2}shhhhhohddddmmh. +ddmmdddddhhhhhhhso${c1}++++++${c2}yhhhhhhdddddmmdy +dmmmdddddddhhhyso${c1}++++++${c2}shhhhhddddddmmmmh +-dmmmdddddddhhys${c1}o++++o${c2}shhhhdddddddmmmmd- +.smmmmddddddddhhhhhhhhhdddddddddmmmms. + `+ydmmmdddddddddddddddddddmmmmdy/. + `.:+ooyyddddddddddddyyso+:.` diff --git a/src/logo/ascii/antix.txt b/src/logo/ascii/antix.txt new file mode 100644 index 000000000..57a97dafa --- /dev/null +++ b/src/logo/ascii/antix.txt @@ -0,0 +1,12 @@ + \ + , - ~ ^ ~ - \ / + , ' \ ' , / + , \ '/ + , \ / , + ,___, \/ , + / | _ _ _|_ o /\ , +|, | / |/ | | | / \ , + \,_/\_/ | |_/|_/|_/_/ \, + , / ,\ + , / , ' \ + ' - , _ _ _ , ' diff --git a/src/logo/ascii/aoscos.txt b/src/logo/ascii/aoscos.txt new file mode 100644 index 000000000..2886c092d --- /dev/null +++ b/src/logo/ascii/aoscos.txt @@ -0,0 +1,20 @@ + .:+syhhhhys+:. + .ohNMMMMMMMMMMMMMMNho. + `+mMMMMMMMMMMmdmNMMMMMMMMm+` + +NMMMMMMMMMMMM/ `./smMMMMMN+ + .mMMMMMMMMMMMMMMo -yMMMMMm. + :NMMMMMMMMMMMMMMMs .hMMMMN: + .NMMMMhmMMMMMMMMMMm+/- oMMMMN. + dMMMMs ./ymMMMMMMMMMMNy. sMMMMd +-MMMMN` oMMMMMMMMMMMN: `NMMMM- +/MMMMh NMMMMMMMMMMMMm hMMMM/ +/MMMMh NMMMMMMMMMMMMm hMMMM/ +-MMMMN` :MMMMMMMMMMMMy. `NMMMM- + dMMMMs .yNMMMMMMMMMMMNy/. sMMMMd + .NMMMMo -/+sMMMMMMMMMMMmMMMMN. + :NMMMMh. .MMMMMMMMMMMMMMMN: + .mMMMMMy- NMMMMMMMMMMMMMm. + +NMMMMMms/.` mMMMMMMMMMMMN+ + `+mMMMMMMMMNmddMMMMMMMMMMm+` + .ohNMMMMMMMMMMMMMMNho. + .:+syhhhhys+:. diff --git a/src/logo/ascii/aoscosretro.txt b/src/logo/ascii/aoscosretro.txt new file mode 100644 index 000000000..1ae7f8748 --- /dev/null +++ b/src/logo/ascii/aoscosretro.txt @@ -0,0 +1,18 @@ +${c2} ......... + ................... + .....................${c1}################${c2} + .............. ....${c1}################${c2} +.............. ...${c1}################${c2} +............. ..${c1}****************${c2} +............ . .${c1}****************${c2} +........... ... ${c1}................${c2} +.......... ..... ${c1}...............${c2} +......... ....... ... + .${c3}...... ${c2}. + ${c3}..... .....${c2}.... ${c4}........... + ${c3}.... ......${c2}. ${c4}........... + ${c3}... ....... ${c4}........... + ${c3}................ ${c4}*********** + ${c3}................ ${c4}########### + ${c3}**************** + ${c3}################ diff --git a/src/logo/ascii/aoscosretro_small.txt b/src/logo/ascii/aoscosretro_small.txt new file mode 100644 index 000000000..9a6798062 --- /dev/null +++ b/src/logo/ascii/aoscosretro_small.txt @@ -0,0 +1,9 @@ +${c2} _____ ${c1}_____${c2} + -' '-${c1}| |${c2} + / ___ ${c1}| |${c2} +| / _ \\${c1}|_____|${c2} +' / /_\\ \\ + \\ / _____ \\${c4}___ + ${c3}|${c2}/_/ ${c3}| ${c4}| | + ${c3}| | ${c4}|___| + ${c3}|_____| diff --git a/src/logo/ascii/aperture.txt b/src/logo/ascii/aperture.txt new file mode 100644 index 000000000..a3ffb5889 --- /dev/null +++ b/src/logo/ascii/aperture.txt @@ -0,0 +1,20 @@ + .,-:;//;:=, + . :H@@@MM@M#H/.,+%;, + ,/X+ +M@@M@MM%=,-%HMMM@X/, + -+@MM; SM@@MH+-,;XMMMM@MMMM@+- + ;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/. + ,%MM@@MH ,@%= .---=-=:=,. + =@#@@@MX., -%HXSS%%%:; + =-./@M@MS .;@MMMM@MM: + X@/ -SMM/ . +MM@@@MS +,@M@H: :@: . =X#@@@@- +,@@@MMX, . /H- ;@M@M= +.H@@@@M@+, %MM+..%#S. + /MMMM@MMH/. XM@MH; =; + /%+%SXHH@S= , .H@@@@MX, + .=--------. -%H.,@@@@@MX, + .%MM@@@HHHXXSSS%+- .:SMMX =M@@MM%. + =XMMM@MM@MM#H;,-+HMM@M+ /MMMX= + =%@M@M#@S-.=S@MM@@@M; %M%= + ,:+S+-,/H#MMMMMMM@= =, + =++%%%%+/:-. diff --git a/src/logo/ascii/apricity.txt b/src/logo/ascii/apricity.txt new file mode 100644 index 000000000..1f3166583 --- /dev/null +++ b/src/logo/ascii/apricity.txt @@ -0,0 +1,18 @@ + ./o- + ``...`` `:. -/: + `-+ymNMMMMMNmho-` :sdNNm/ + `+dMMMMMMMMMMMMMMMmo` sh:.:::- + /mMMMMMMMMMMMMMMMMMMMm/`sNd/ + oMMMMMMMMMMMMMMMMMMMMMMMs -` +:MMMMMMMMMMMMMMMMMMMMMMMMM/ +NMMMMMMMMMMMMMMMMMMMMMMMMMd +MMMMMMMmdmMMMMMMMMMMMMMMMMd +MMMMMMy` .mMMMMMMMMMMMmho:` +MMMMMMNo/sMMMMMMMNdy+-.`-/ +MMMMMMMMMMMMNdy+:.`.:ohmm: +MMMMMMMmhs+-.`.:+ymNMMMy. +MMMMMM/`.-/ohmNMMMMMMy- +MMMMMMNmNNMMMMMMMMmo. +MMMMMMMMMMMMMMMms:` +MMMMMMMMMMNds/. +dhhyys+/-` diff --git a/src/logo/ascii/archbox.txt b/src/logo/ascii/archbox.txt new file mode 100644 index 000000000..682a183ae --- /dev/null +++ b/src/logo/ascii/archbox.txt @@ -0,0 +1,19 @@ + ...:+oh/:::.. + ..-/oshhhhhh` `::::-. + .:/ohhhhhhhhhhhh` `-::::. + .+shhhhhhhhhhhhhhhhh` `.::-. + /`-:+shhhhhhhhhhhhhh` .-/+shh + / .:/ohhhhhhhhh` .:/ohhhhhhhh + / `-:+shhh` ..:+shhhhhhhhhhhh + / .:ohhhhhhhhhhhhhhhhhhh + / `hhhhhhhhhhhhhhhhhhhh + / `hhhhhhhhhhhhhhhhhhhh + / `hhhhhhhhhhhhhhhhhhhh + / `hhhhhhhhhhhhhhhhhhhh + / .+o+ `hhhhhhhhhhhhhhhhhhhh + / -hhhhh `hhhhhhhhhhhhhhhhhhhh + / ohhhhho `hhhhhhhhhhhhhhhhhhhh + /:::+`hhhhoos` `hhhhhhhhhhhhhhhhhs+` + `--/:` /: `hhhhhhhhhhhho/- + -/:. `hhhhhhs+:-` + ::::/ho/-` diff --git a/src/logo/ascii/archcraft.txt b/src/logo/ascii/archcraft.txt new file mode 100644 index 000000000..a57f7b7bf --- /dev/null +++ b/src/logo/ascii/archcraft.txt @@ -0,0 +1,20 @@ +${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢰⡆${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢠⣿⣿⡄${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⡀${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣷⡀${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⣿⣷${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢼⣿⣿⣿⣿⣿⣿⣿⣿⣧${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣤⣈⠻⢿⣿⣿⣿⣿⣿⣿⣧${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣮⣿⣿⣿⣿⣿⣿⣿⣧${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⡿⣿⣿⡟${c6}⠄⠄${c1}⠸⣿⣿⡿⣿⣿⣿⣿⣿⣷⡀${c6}⠄⠄⠄⠄⠄⠄⠄⠄ +${c1}⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⡏${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠈⣿⣿⣿⣿⣿⣷⡀${c1}⠄⠄⠄⠄⠄⠄⠄ +${c2}⠄⠄⠄⠄⠄⠄${c1}⢀⣼⣿⣿⣿⣿⣿⣿⡗${c2}⠄⠄⠄${c1}⢀⣠⣤⣀⠄⠄⠄${c1}⠸⣿⣿⣿⣿⣿⣿⣷⡀${c2}⠄⠄⠄⠄⠄⠄ +${c3}⠄⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⣿⣿⡏⠁${c3}⠄⠄⠄${c1}⢠⣿⣿⣿⣿⡇${c3}⠄⠄⠄⠄${c1}⢙⣿⣿⣻⠿⣿⣷⡀${c3}⠄⠄⠄⠄⠄ +${c4}⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⣿⣿⣿⣷⣤⡀${c4}⠄⠄⠄${c1}⠻⣿⣿⡿⠃${c4}⠄⠄⠄${c1}⢀⣼⣿⣿⣿⣿⣦⣌⠙⠄${c4}⠄⠄⠄⠄ +${c5}⠄⠄⠄${c1}⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀${c5}⠄⠄⠄ +${c6}⠄⠄${c1}⢠⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠁${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⡄${c6}⠄⠄ +${c1}⠄${c1}⣠⣿⣿⣿⣿⠿⠛⠋⠁${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠉⠙⠻⢿⣿⣿⣿⣿⣆${c1}⠄ +${c1}⡰⠟⠛⠉⠁${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠉⠙⠛⠿⢆ diff --git a/src/logo/ascii/archcraft2.txt b/src/logo/ascii/archcraft2.txt new file mode 100644 index 000000000..75e553bf6 --- /dev/null +++ b/src/logo/ascii/archcraft2.txt @@ -0,0 +1,20 @@ + -o\ + :ooo: + .ooooo. + ooooooo. + +oooooooo. + -oooooooooo. + --:-+oooooooo. + yooo+=+sooooooo. + yoooooosooooooooo. + y+ooooooooooooooooo. + yoooooooooooooooooooo` + yoooooo+oo= :oo++ooooo` + :oooooo. +ooooo- + -ooooooo. .::. +ooosoo= + -oooooo` .oooo` +os-=o= + =ooooooo=: `oo+ :=ooo=--`. + +ooooooooos. .=sooooooo+- + .+osossos+-` `-+osososs+. + :sss+=-:` `:-=+ssss: +:=-:` `-=+: diff --git a/src/logo/ascii/archlabs.txt b/src/logo/ascii/archlabs.txt new file mode 100644 index 000000000..49af8b709 --- /dev/null +++ b/src/logo/ascii/archlabs.txt @@ -0,0 +1,21 @@ + 'c' + 'kKk, + .dKKKx. + .oKXKXKd. + .l0XXXXKKo. + c0KXXXXKX0l. + :0XKKOxxOKX0l. + :OXKOc. .c0XX0l. + :OK0o. $2...$1'dKKX0l. + :OX0c $2;xOx'$1'dKXX0l. + :0KKo.$2.o0XXKd'.$1lKXX0l. + c0XKd.$2.oKXXXXKd..$1oKKX0l. + .c0XKk;$2.l0K0OO0XKd..$1oKXXKo. + .l0XXXk:$2,dKx,.'l0XKo.$1.kXXXKo. + .o0XXXX0d,$2:x; .oKKx'$1.dXKXXKd. + .oKXXXXKK0c.$2;. :00c'$1cOXXXXXKd. + .dKXXXXXXXXk,$2. cKx'$1'xKXXXXXXKx' + 'xKXXXXK0kdl:. $2.ok; $1.cdk0KKXXXKx' + 'xKK0koc,.. $2'c, $1 ..,cok0KKk, + ,xko:'. $2.. $1 .':okx; + .,'. .',. diff --git a/src/logo/ascii/archstrike.txt b/src/logo/ascii/archstrike.txt new file mode 100644 index 000000000..a65d51011 --- /dev/null +++ b/src/logo/ascii/archstrike.txt @@ -0,0 +1,17 @@ +${c1} * + **. + **** + ****** + ******* + ** ******* + **** ******* + ${c1}****${c2}_____${c1}***${c2}/${c1}* + ***${c2}/${c1}*******${c2}//${c1}*** + **${c2}/${c1}********${c2}///${c1}*${c2}/${c1}** + **${c2}/${c1}*******${c2}////${c1}***${c2}/${c1}** + **${c2}/${c1}****${c2}//////.,${c1}****${c2}/${c1}** + ***${c2}/${c1}*****${c2}/////////${c1}**${c2}/${c1}*** + ****${c2}/${c1}**** ${c2}/////${c1}***${c2}/${c1}**** + ******${c2}/${c1}*** ${c2}//// ${c1}**${c2}/${c1}****** + ********${c2}/${c1}* ${c2}/// ${c1}*${c2}/${c1}******** + ,****** ${c2}// ______ / ${c1}******, diff --git a/src/logo/ascii/arco_small.txt b/src/logo/ascii/arco_small.txt new file mode 100644 index 000000000..cafcc5441 --- /dev/null +++ b/src/logo/ascii/arco_small.txt @@ -0,0 +1,11 @@ +${c1} A + ooo + ooooo + ooooooo + ooooooooo + ooooo ooooo + ooooo ooooo + ooooo ooooo + ooooo ${c2}${c1} + ooooo ${c2}${c1} +ooooo ${c2} diff --git a/src/logo/ascii/artix2_small.txt b/src/logo/ascii/artix2_small.txt new file mode 100644 index 000000000..14e70835a --- /dev/null +++ b/src/logo/ascii/artix2_small.txt @@ -0,0 +1,13 @@ + ' + 'A' + 'ooo' + 'ookxo' + `ookxxo' + '. `ooko' + 'ooo`. `oo' + 'ooxxxoo`. `' + 'ookxxxkooo.` . + 'ookxxkoo'` .'oo' + 'ooxoo'` .:ooxxo' + 'io'` `'oo' +'` `' diff --git a/src/logo/builtin.c b/src/logo/builtin.c index a470a58c4..4bc1d372d 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -176,6 +176,140 @@ static const FFlogo* getLogoAndroidSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoAntergos(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Antergos") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANTERGOS) + FF_LOGO_COLORS( + "34", //blue + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAntix(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("antiX") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANTIX) + FF_LOGO_COLORS( + "31" //red + ) + FF_LOGO_COLOR_KEYS("31"); //red + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAoscOsRetro(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Aosc OS/Retro", "aoscosretro") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO) + FF_LOGO_COLORS( + "34", //blue + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAoscOsRetro_small(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Aosc OS/Retro_small", "aoscosretro_small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO_SMALL) + FF_LOGO_COLORS( + "34", //blue + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAoscOS(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Aosc OS", "aoscos") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOS) + FF_LOGO_COLORS( + "34", //blue + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAperture(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Aperture") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_APERTURE) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoApricity(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Apricity") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_APRICITY) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //blue + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoArchBox(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ArchBox") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHBOX) + FF_LOGO_COLORS( + "32" //green + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoArchcraft(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Archcraft") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHCRAFT) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + +static const FFlogo* getLogoArchcraft2(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Archcraft2") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHCRAFT2) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + static const FFlogo* getLogoArch(void) { FF_LOGO_INIT @@ -203,6 +337,34 @@ static const FFlogo* getLogoArchSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoArchlabs(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ARCHlabs") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHLABS) + FF_LOGO_COLORS( + "36", //cyan + "31" //red + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + +static const FFlogo* getLogoArchStrike(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("ArchStrike") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHSTRIKE) + FF_LOGO_COLORS( + "36", //cyan + "30" //black + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + static const FFlogo* getLogoArtix(void) { FF_LOGO_INIT @@ -229,6 +391,19 @@ static const FFlogo* getLogoArtixSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoArtix2Small(void) +{ + FF_LOGO_INIT_SMALL + FF_LOGO_NAMES("artix2_small", "artixlinux2_small", "artix-linux2-small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX2_SMALL) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + static const FFlogo* getLogoArcoLinux(void) { FF_LOGO_INIT @@ -243,6 +418,20 @@ static const FFlogo* getLogoArcoLinux(void) FF_LOGO_RETURN } +static const FFlogo* getLogoArcoLinuxSmall(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("arco_small", "arcolinux_small", "arco-linux_small") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCO_SMALL) + FF_LOGO_COLORS( + "34", //blue + "32" //green + ) + FF_LOGO_COLOR_KEYS("34"); //green + FF_LOGO_COLOR_TITLE("34"); //green + FF_LOGO_RETURN +} + static const FFlogo* getLogoAsahi(void) { FF_LOGO_INIT @@ -1086,8 +1275,8 @@ static const FFlogo* getLogoWindows95(void) "34", //blue "33", //yellow "32", //green - "31", - "30" + "31", //red + "30" //black ) FF_LOGO_COLOR_KEYS("36"); //cyan FF_LOGO_COLOR_TITLE("34"); //blue @@ -1827,11 +2016,25 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoAnarchy, getLogoAndroid, getLogoAndroidSmall, + getLogoAntergos, + getLogoAntix, + getLogoAoscOsRetro, + getLogoAoscOsRetro_small, + getLogoAoscOS, + getLogoAperture, + getLogoApricity, + getLogoArchBox, + getLogoArchcraft, + getLogoArchcraft2, getLogoArch, getLogoArchSmall, + getLogoArchlabs, + getLogoArchStrike, getLogoArcoLinux, + getLogoArcoLinuxSmall, getLogoArtix, getLogoArtixSmall, + getLogoArtix2Small, getLogoAsahi, getLogoBedrock, getLogoBSD, From e4a99b2d6d07ecff2493195d71a5812e23512a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 2 Aug 2023 16:47:32 +0800 Subject: [PATCH 412/493] Logo: more --- README.md | 5 +-- src/logo/ascii/arselinux.txt | 15 +++++++ src/logo/ascii/arya.txt | 15 +++++++ src/logo/ascii/aster.txt | 18 +++++++++ src/logo/ascii/asteroidos.txt | 17 ++++++++ src/logo/ascii/astos.txt | 23 +++++++++++ src/logo/builtin.c | 75 +++++++++++++++++++++++++++++++++++ 7 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 src/logo/ascii/arselinux.txt create mode 100644 src/logo/ascii/arya.txt create mode 100644 src/logo/ascii/aster.txt create mode 100644 src/logo/ascii/asteroidos.txt create mode 100644 src/logo/ascii/astos.txt diff --git a/README.md b/README.md index f9069d9bb..3ff4717ef 100644 --- a/README.md +++ b/README.md @@ -95,9 +95,8 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ``` ##### Builtin logos -``` -AIX, AlmaLinux, Alpine, Alter, Amazon, Amogos, Anarchy, Android, Antergos, AntiX, Aosc OS, Aperture, Apricity, Arch, ArchBox, Archcraft, Arco, Artix, Asahi, BSD, Bedrock, CRUX, CachyOS, CentOS, Crystal, Debian, Deepin, Devuan, Elementary, Endeavour, Enso, Exherbo, Fedora, FreeBSD, GNU, Garuda, Garuda Dragon, Gentoo, GhostBSD, Gnome, Haiku, KDE Neon, KISS, Kubuntu, LMDE, LangitKetujuh, Linux, MSYS2, MX, MacOS, Mandriva, Manjaro, Minix, Mint, NetBSD, NixOS, Nobara, NomadBSD, OpenBSD, OpenKylin, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, OpenWrt, Oracle, Orchid, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solaris, Solus, SteamOS, UOS, Ubuntu, Ubuntu Kylin, Vanilla, Void, Windows, Windows 11, Windows 8, Windows 95, Zorin -``` + +See files in ##### Package managers ``` diff --git a/src/logo/ascii/arselinux.txt b/src/logo/ascii/arselinux.txt new file mode 100644 index 000000000..6e673bc81 --- /dev/null +++ b/src/logo/ascii/arselinux.txt @@ -0,0 +1,15 @@ + ⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⣶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⣴⣶⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣄⠀⠀⠀⠀⣼⠟⠁⠀⠀⢀⣀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⢀⣤⡀⠀⠀⠀⠉⢻⣷⡄⠀⠀⠁⠀⢀⣤⣾⡿⠟⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣷⣿⠏⠀⠀⠀⠀⠀⠀⠹⣿⡄⠀⠀⠀⠙⠉⠁⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⡄⠀⠀⠀⠀⠀⠀⠀⢹⣿⠀⠀⠀⠀⠠⣶⣶⣶⡶ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⢠⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠂⠀⠀⠀⠀⠀⢀⣾⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠇⠀⠀⠀⠀⠀⣠⣾⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣿⣇⣀⣀⣀⣠⣴⣾⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⠀⠀⠀⠀⠀⣤⣤⣴⣶⣾⠿⠟⣿⡏⠙⠛⠛⠛⠋⠉⢀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⣿⡄⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠇⠀⠀⠀⠀⠀⠀⠘⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ diff --git a/src/logo/ascii/arya.txt b/src/logo/ascii/arya.txt new file mode 100644 index 000000000..7d603e20d --- /dev/null +++ b/src/logo/ascii/arya.txt @@ -0,0 +1,15 @@ +${c1} `oyyy/${c2}-yyyyyy+ +${c1} -syyyy/${c2}-yyyyyy+ +${c1} .syyyyy/${c2}-yyyyyy+ +${c1} :yyyyyy/${c2}-yyyyyy+ +${c1} `/ :yyyyyy/${c2}-yyyyyy+ +${c1} .+s :yyyyyy/${c2}-yyyyyy+ +${c1} .oys :yyyyyy/${c2}-yyyyyy+ +${c1} -oyys :yyyyyy/${c2}-yyyyyy+ +${c1} :syyys :yyyyyy/${c2}-yyyyyy+ +${c1} /syyyys :yyyyyy/${c2}-yyyyyy+ +${c1} +yyyyyys :yyyyyy/${c2}-yyyyyy+ +${c1} .oyyyyyyo. :yyyyyy/${c2}-yyyyyy+ --------- +${c1} .syyyyyy+` :yyyyyy/${c2}-yyyyy+-+syyyyyyyy +${c1} -syyyyyy/ :yyyyyy/${c2}-yyys:.syyyyyyyyyy +${c1}:syyyyyy/ :yyyyyy/${c2}-yyo.:syyyyyyyyyyy diff --git a/src/logo/ascii/aster.txt b/src/logo/ascii/aster.txt new file mode 100644 index 000000000..52d893d1d --- /dev/null +++ b/src/logo/ascii/aster.txt @@ -0,0 +1,18 @@ + ...''... + .;oOXWMWNXXXNMMN0d:. + .oXMWOo;.. ..:oO; + ;KMWx, co, + 'KMNl dMMW. + oMMx xMMMMk + xMM: dMMMMMM; + cMMl dMMMMMMMW + NMK xMMMx::dXMx +,MMl xMMN' .o. +cMM; dMMW' +;MMc oMMW, + WMK dMMW, ccccccc. + lMMl oMMM; ooooooo. + OMMc ... + xMMx + ;XMN: + ,. diff --git a/src/logo/ascii/asteroidos.txt b/src/logo/ascii/asteroidos.txt new file mode 100644 index 000000000..124bf92a2 --- /dev/null +++ b/src/logo/ascii/asteroidos.txt @@ -0,0 +1,17 @@ +${c1} *** +${c1} ***** +${c1} ********** +${c1} *************** +${c1} *///****////****////. +${c2} (/////// /////// ///////( +${c2} /(((((//* //, //((((((. +${c2} ((((((((((( ((( (((((((( +${c2} *((((((((((((((((((((((( (((((((( +${c3} (((((#(((((((#((((( ((#((((( +${c3} (#(#(#####(#(#, ####(#(# +${c3} ######### ######## +${c3} /######## ######## +${c4} #######%####### +${c4} (#%%%%%%%# +${c4} %%%%% +${c4} %%% diff --git a/src/logo/ascii/astos.txt b/src/logo/ascii/astos.txt new file mode 100644 index 000000000..3e06aefd7 --- /dev/null +++ b/src/logo/ascii/astos.txt @@ -0,0 +1,23 @@ + oQA#$%UMn + H 9 + G # + 6 % + ?#M#%KW3" + // \\\ + // \\\ + // \\\ + // \\\ + n%@$DK&ML .0O3#@&M_ + P # 8 W + H U G # + B N O @ + C&&#%HNAR 'WS3QMHB" + // \\\ \\\ + // \\\ \\\ + // \\\ \\\ + // \\\ \\\ +uURF$##Bv nKWB$%ABc aM@3R@D@b +8 M @ O # % +% & G U @ @ +& @ # % % # +!HGN@MNCf t&S9#%HQr ?@G#6S@QP diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4bc1d372d..94798cfda 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -432,6 +432,34 @@ static const FFlogo* getLogoArcoLinuxSmall(void) FF_LOGO_RETURN } +static const FFlogo* getLogoArseLinux(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("arse", "arselinux", "arse-linux") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARSELINUX) + FF_LOGO_COLORS( + "34", //blue + "37" //white + ) + FF_LOGO_COLOR_KEYS("34"); //green + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + +static const FFlogo* getLogoArya(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("Arya") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARYA) + FF_LOGO_COLORS( + "32", //green + "31" //red + ) + FF_LOGO_COLOR_KEYS("32"); //green + FF_LOGO_COLOR_TITLE("31"); //red + FF_LOGO_RETURN +} + static const FFlogo* getLogoAsahi(void) { FF_LOGO_INIT @@ -451,6 +479,48 @@ static const FFlogo* getLogoAsahi(void) FF_LOGO_RETURN } +static const FFlogo* getLogoAster(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("aster") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTER) + FF_LOGO_COLORS( + "36" //cyan + ) + FF_LOGO_COLOR_KEYS("36"); //cyan + FF_LOGO_COLOR_TITLE("36"); //cyan + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAsteroidOS(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("AsteroidOS") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTEROIDOS) + FF_LOGO_COLORS( + "38;5;160", + "38;5;208", + "38;5;202", + "38;5;214" + ) + FF_LOGO_COLOR_KEYS("38;5;160"); + FF_LOGO_COLOR_TITLE("38;5;208"); + FF_LOGO_RETURN +} + +static const FFlogo* getLogoAstOS(void) +{ + FF_LOGO_INIT + FF_LOGO_NAMES("astOS") + FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTOS) + FF_LOGO_COLORS( + "37" //white + ) + FF_LOGO_COLOR_KEYS("37"); //white + FF_LOGO_COLOR_TITLE("37"); //white + FF_LOGO_RETURN +} + static const FFlogo* getLogoBSD(void) { FF_LOGO_INIT @@ -2035,7 +2105,12 @@ GetLogoMethod* ffLogoBuiltinGetAll(void) getLogoArtix, getLogoArtixSmall, getLogoArtix2Small, + getLogoArseLinux, + getLogoArya, getLogoAsahi, + getLogoAster, + getLogoAsteroidOS, + getLogoAstOS, getLogoBedrock, getLogoBSD, getLogoCachyOS, From 897d1e7a11fa9565a4c55a42d8b1c702fe8ca609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 2 Aug 2023 21:18:17 +0800 Subject: [PATCH 413/493] Windows (Terminal): don't detect wsl as terminal --- src/detection/terminalshell/terminalshell_windows.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index aa38e0075..0bd65e578 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -305,6 +305,7 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "nu") || ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "powershell") || ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "powershell_ise") || + ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "wsl") || // running inside wsl ffStrbufStartsWithIgnCaseS(&result->terminalPrettyName, "ConEmuC") // wrapper process of ConEmu ) { //We are nested shell From 34e2af4c4b7f04cfc28f0b50a457c97d154aa051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 3 Aug 2023 10:29:50 +0800 Subject: [PATCH 414/493] Logo: refactor logo initial code --- README.md | 2 +- src/logo/builtin.c | 3886 +++++++++++++++++++------------------------- src/logo/logo.c | 56 +- src/logo/logo.h | 14 +- src/logo/option.h | 1 + 5 files changed, 1689 insertions(+), 2270 deletions(-) diff --git a/README.md b/README.md index 3ff4717ef..53b9751a2 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos -See files in +See files in ##### Package managers ``` diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 94798cfda..792f88122 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1,2229 +1,1663 @@ #include "logo.h" #include "logo_builtin.h" -#define FF_LOGO_INIT static FFlogo logo; static bool init = false; if(init) return &logo; init = true; -// The names of small logo must end with `_small` or `-small` -#define FF_LOGO_INIT_SMALL FF_LOGO_INIT logo.small = true; -#define FF_LOGO_NAMES(...) static const char* names[] = (const char*[]) { __VA_ARGS__, NULL }; logo.names = names; -#define FF_LOGO_LINES(x) logo.data = x; -#define FF_LOGO_COLORS(...) static const char* colors[] = (const char*[]) { __VA_ARGS__, NULL }; logo.builtinColors = colors; -#define FF_LOGO_COLOR_KEYS(x) logo.colorKeys = x; -#define FF_LOGO_COLOR_TITLE(x) logo.colorTitle = x; -#define FF_LOGO_RETURN return &logo; - -const FFlogo* ffLogoBuiltinGetUnknown(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("unknown", "question mark", "?") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UNKNOWN) - FF_LOGO_COLORS("") - FF_LOGO_COLOR_KEYS("") - FF_LOGO_COLOR_TITLE("") - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAIX(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("aix") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AIX) - FF_LOGO_COLORS( - "32", // green - "37" // yellow - ) - FF_LOGO_COLOR_KEYS("32"); // green - FF_LOGO_COLOR_TITLE("37"); // yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAlmaLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("almalinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALMALINUX) - FF_LOGO_COLORS( - "31", // red - "1;33", // yellow - "34", // blue - "1;32", // light green - "36" // cyan - ) - FF_LOGO_COLOR_KEYS("1;33"); //yellow - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAlpine(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("alpine", "alpinelinux", "alpine-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAlpineSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("alpine_small", "alpine-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAlpine2Small(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("alpine2_small", "alpine-linux2-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALPINE2_SMALL) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAlter(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Alter") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ALTER) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAmazon(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Amazon") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AMAZON) - FF_LOGO_COLORS( - "33", //yellow - "37" //white - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAmogOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("AmogOS") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AMOGOS) - FF_LOGO_COLORS( - "37", //white - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAnarchy(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Anarchy") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANARCHY) - FF_LOGO_COLORS( - "37", //white - "34" //blue - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAndroid(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("android") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANDROID) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAndroidSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("android-small", "android_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANDROID_SMALL) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAntergos(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Antergos") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANTERGOS) - FF_LOGO_COLORS( - "34", //blue - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAntix(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("antiX") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ANTIX) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAoscOsRetro(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Aosc OS/Retro", "aoscosretro") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAoscOsRetro_small(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Aosc OS/Retro_small", "aoscosretro_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO_SMALL) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAoscOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Aosc OS", "aoscos") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_AOSCOS) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAperture(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Aperture") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_APERTURE) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoApricity(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Apricity") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_APRICITY) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchBox(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ArchBox") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHBOX) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchcraft(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Archcraft") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHCRAFT) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchcraft2(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Archcraft2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHCRAFT2) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArch(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("arch", "archlinux", "arch-linux", "archmerge") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCH) - FF_LOGO_COLORS( - "36", //cyan - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("arch_small", "archlinux_small", "arch-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCH_SMALL) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchlabs(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ARCHlabs") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHLABS) - FF_LOGO_COLORS( - "36", //cyan - "31" //red - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArchStrike(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ArchStrike") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCHSTRIKE) - FF_LOGO_COLORS( - "36", //cyan - "30" //black - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArtix(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("artix", "artixlinux", "artix-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArtixSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("artix_small", "artixlinux_small", "artix-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX_SMALL) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArtix2Small(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("artix2_small", "artixlinux2_small", "artix-linux2-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARTIX2_SMALL) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArcoLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("arco", "arcolinux", "arco-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCO) - FF_LOGO_COLORS( - "34", //blue - "32" //green - ) - FF_LOGO_COLOR_KEYS("34"); //green - FF_LOGO_COLOR_TITLE("34"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArcoLinuxSmall(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("arco_small", "arcolinux_small", "arco-linux_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARCO_SMALL) - FF_LOGO_COLORS( - "34", //blue - "32" //green - ) - FF_LOGO_COLOR_KEYS("34"); //green - FF_LOGO_COLOR_TITLE("34"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArseLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("arse", "arselinux", "arse-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARSELINUX) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoArya(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Arya") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ARYA) - FF_LOGO_COLORS( - "32", //green - "31" //red - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAsahi(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("asahi", "asahi-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASAHI) - FF_LOGO_COLORS( - "33", //yellow - "32", //green - "31", //red - "38", //cyan - "37", //magenta - "36", //cyan - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAster(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("aster") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTER) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAsteroidOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("AsteroidOS") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTEROIDOS) - FF_LOGO_COLORS( - "38;5;160", - "38;5;208", - "38;5;202", - "38;5;214" - ) - FF_LOGO_COLOR_KEYS("38;5;160"); - FF_LOGO_COLOR_TITLE("38;5;208"); - FF_LOGO_RETURN -} - -static const FFlogo* getLogoAstOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("astOS") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ASTOS) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("bsd") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_BSD) - FF_LOGO_COLORS( - "31", - "37", - "34", - "33", - "36" - ) - FF_LOGO_COLOR_KEYS("31"); - FF_LOGO_COLOR_TITLE("37"); - FF_LOGO_RETURN -} - -static const FFlogo* getLogoBedrock(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("bedrock", "bedrocklinux", "bedrock-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_BEDROCK) - FF_LOGO_COLORS( - "90", //grey - "37" //white - ) - FF_LOGO_COLOR_KEYS("90"); //grey - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCachyOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("cachy", "cachyos", "cachy-linux", "cachyos-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CACHYOS) - FF_LOGO_COLORS( - "36", //cyan - "32", //green - "30" //black - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCachyOSSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - - -static const FFlogo* getLogoCelOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("cel", "celos", "cel-linux", "celos-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CELOS) - FF_LOGO_COLORS( - "35", //magenta - "30" //black - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCentOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("cent", "centos", "cent-linux", "centos-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CENTOS) - FF_LOGO_COLORS( - "33", //yellow - "32", //green - "34", //blue - "35", //magenta - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCentOSSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL) - FF_LOGO_COLORS( - "33", //yellow - "32", //green - "34", //blue - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCRUX(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("crux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CRUX) - FF_LOGO_COLORS( - "34", //blue - "35", //magenta - "37" //white - ) - FF_LOGO_COLOR_KEYS("35"); - FF_LOGO_COLOR_TITLE("34"); - FF_LOGO_RETURN -} - -static const FFlogo* getLogoCrystalLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("crystal", "Crystal", "crystal-linux", "Crystal-Linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_CRYSTAL) - FF_LOGO_COLORS( - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoDebian(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("debian", "debian-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEBIAN) - FF_LOGO_COLORS( - "31", //red - "37" //white - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoDebianSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("debian_small", "debian-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoDevuan(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("devuan", "devuan-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEVUAN) - FF_LOGO_COLORS( - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoDevuanSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("devuan_small", "devuan-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL) - FF_LOGO_COLORS( - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoElementary(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("elementary") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ELEMENTARY) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoElementarySmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("elementary_small", "elementary-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoDeepin(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("deepin", "deepin-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_DEEPIN) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoEndeavour(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ENDEAVOUR) - FF_LOGO_COLORS( - "35", //magenta - "31", //red - "34" //blue - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoEnso(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("enso", "uqc") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ENSO) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoExherbo(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("exherbo", "exherbo-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_EXHERBO) - FF_LOGO_COLORS( - "34", //blue - "37", //white - "31" //red - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoFedora(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("fedora", "fedora-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoFedoraSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("fedora_small", "fedora-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoFedoraOld(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FEDORA_OLD) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoFreeBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("freebsd", "HardenedBSD") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FREEBSD) - FF_LOGO_COLORS( - "37", //white - "31" //red - ) - FF_LOGO_COLOR_KEYS("31") //red - FF_LOGO_COLOR_TITLE("31") //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoFreeBSDSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("freebsd_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_FREEBSD_SMALL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31") //red - FF_LOGO_COLOR_TITLE("31") //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGaruda(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("garuda", "garuda-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGarudaDragon() -{ - FF_LOGO_INIT - FF_LOGO_NAMES("garudadragon", "garuda-dragon", "garuda-linux-dragon") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA_DRAGON) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGarudaSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("garuda_small", "garudalinux_small", "garuda-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGentoo(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("gentoo", "gentoo-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GENTOO) - FF_LOGO_COLORS( - "35", //magenta - "37" //white - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGentooSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("gentoo_small", "gentoo-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL) - FF_LOGO_COLORS( - "35", //magenta - "37" //white - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGhostBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ghostbsd") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GHOSTBSD) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGnome(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Gnome") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GNOME) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoGNU(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("GNU") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_GNU) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoHaiku(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Haiku") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_HAIKU) - FF_LOGO_COLORS( - "31", //red - "33", //yellow - "37", //white - "32" //green - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoHaikuSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("Haiku-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoKDENeon(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("kde", "kde-neon", "neon") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KDE) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoKISSLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("kiss", "kiss-linux", "kisslinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KISS) - FF_LOGO_COLORS( - "35", //magenta - "37", //white - "34" //blue - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoKubuntu(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_KUBUNTU) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoLangitKetujuh(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("langitketujuh", "l7") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LANGITKETUJUH) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("linux", "linux-generic") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LINUX) - FF_LOGO_COLORS( - "37", //white - "30", //black - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoLinuxSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("linux_small", "linux-generic_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LINUX_SMALL) - FF_LOGO_COLORS( - "30", //black - "37", //white - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoLMDE(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("LMDE") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_LMDE) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMacOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("macos", "mac", "apple", "darwin", "osx") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS) - FF_LOGO_COLORS( - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMacOSSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("macos_small", "mac_small", "apple_small", "darwin_small", "osx_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS_SMALL) - FF_LOGO_COLORS( - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMacOS2(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("macos2", "mac2", "apple2", "darwin2", "osx2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS2) - FF_LOGO_COLORS( - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMacOS2Small(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("macos2_small", "mac2_small", "apple2_small", "darwin2_small", "osx2_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL) - FF_LOGO_COLORS( - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMandriva(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("mandriva", "mandrake") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANDRIVA) - FF_LOGO_COLORS( - "34", //blue - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoManjaro(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("manjaro", "manjaro-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANJARO) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoManjaroSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("manjaro_small", "manjaro-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MANJARO_SMALL) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMinix(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("minix") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINIX) - FF_LOGO_COLORS( - "31", //red - "37", //white - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMint(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("mint", "linuxmint", "mint-linux", "linux-mint") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMintSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("mint_small", "linuxmint_small", "mint-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT_SMALL) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMintOld(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MINT_OLD) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMsys2(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("msys2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MSYS2) - FF_LOGO_COLORS( - "35", //magenta - "37", //white - "31" //red - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoWindows11(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Windows 11", "Windows Server 2022") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_11) - FF_LOGO_COLORS( - "34", //blue - "34", //blue - "34", //blue - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoWindows11Small(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("Windows 11_small", "Windows 11-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoWindows8(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_8) - FF_LOGO_COLORS( - "36", //cyan - "36", //cyan - "36", //cyan - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("33"); //yellow - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoWindows(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS) - FF_LOGO_COLORS( - "31", //red - "32", //green - "34", //blue - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoWindows95(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("Windows 95", "Windows 9x") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_WINDOWS_95) - FF_LOGO_COLORS( - "36", //cyan - "34", //blue - "33", //yellow - "32", //green - "31", //red - "30" //black - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNixOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS) - FF_LOGO_COLORS( - "34", //blue - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNixOsOld(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS_OLD) - FF_LOGO_COLORS( - "34", //blue - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNixOsSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMX(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("mx"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MX) - FF_LOGO_COLORS( - "37" // white - ) - FF_LOGO_COLOR_KEYS("34"); // blue - FF_LOGO_COLOR_TITLE("36"); // cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoMXSmall(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("mx_small", "mx-small"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_MX_SMALL) - FF_LOGO_COLORS( - "37" // white - ) - FF_LOGO_COLOR_KEYS("34"); // blue - FF_LOGO_COLOR_TITLE("36"); // cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNetBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("netbsd"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NETBSD) - FF_LOGO_COLORS( - "35", // blue - "37" // white - ) - FF_LOGO_COLOR_KEYS("35"); // blue - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNobara(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("nobara", "nobara-linux"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NOBARA) - FF_LOGO_COLORS( - "37" // white - ) - FF_LOGO_COLOR_KEYS("37"); // white - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoNomadBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("nomadbsd"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_NOMADBSD) - FF_LOGO_COLORS( - "34" // blue - ) - FF_LOGO_COLOR_KEYS("34"); // blue - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenKylin(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("openkylin", "open-kylin"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENKYLIN) - FF_LOGO_COLORS( - "32", // cyan - "37" // white - ) - FF_LOGO_COLOR_KEYS("32"); // cyan - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenBSD(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("openbsd"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENBSD) - FF_LOGO_COLORS( - "33", // blue - "37", // white - "36", // yellow - "31" // red - ) - FF_LOGO_COLOR_KEYS("33"); // blue - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenBSDSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("openbsd_small", "openbsd-small"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL) - FF_LOGO_COLORS( - "33", // blue - "37" // white - ) - FF_LOGO_COLOR_KEYS("33"); // blue - FF_LOGO_COLOR_TITLE("37"); // white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenSuse(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("suse", "opensuse", "open_suse", "open-suse", "suse-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenSuseSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("suse_small", "opensuse_small", "open_suse_small", "open-suse_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenSuseLeap(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenSuseTumbleweed(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenSuseTumbleweed2(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("opensuse_tumbleweed2") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2) - FF_LOGO_COLORS( - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenMandriva(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("openmandriva", "open-mandriva", "open_mandriva") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENMANDRIVA) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOpenWrt(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("openwrt") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_OPENWRT) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOracle(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("oracle", "oracle linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORACLE) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOrchid(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("orchid") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORCHID) - FF_LOGO_COLORS( - "37", //white - "35", //magenta - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoOrchidSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("orchid_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ORCHID_SMALL) - FF_LOGO_COLORS( - "37", //white - "35", //magenta - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoParabola(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("parabola", "parabola-gnulinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PARABOLA) - FF_LOGO_COLORS( - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoParabolaSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("parabola_small", "parabola-gnulinux_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PARABOLA_SMALL) - FF_LOGO_COLORS( - "35" //magenta - ) - FF_LOGO_COLOR_KEYS("35"); //magenta - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoPop(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("pop", "popos", "pop_os", "pop-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_POP) - FF_LOGO_COLORS( - "36", //cyan - "37" //white - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} - -static const FFlogo* getLogoPopSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("pop_small", "popos_small", "pop_os_small", "pop-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_POP_SMALL) - FF_LOGO_COLORS( - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("36"); //cyan - FF_LOGO_COLOR_TITLE("36"); //cyan - FF_LOGO_RETURN -} -static const FFlogo* getLogoRaspbian(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("raspbian", "raspi", "raspberrypi", "raspberrypios", "pios") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RASPBIAN) - FF_LOGO_COLORS( - "31", //red - "32" //green - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRaspbianSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL) - FF_LOGO_COLORS( - "31", //red - "32" //green - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoReborn(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REBORN) - FF_LOGO_COLORS( - "34", //blue - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRebornSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REBORN_SMALL) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRedHatEnterpriseLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("rhel", "redhat", "redhat-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_RHEL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRedstarOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_REDSTAR) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRockyLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("rocky", "rocky-linux", "rockylinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ROCKY) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoRosaLinux(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("rosa", "rosa-linux", "rosalinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ROSA) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoProxmox(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("proxmox") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_PROXMOX) - FF_LOGO_COLORS( - "37", //blue - "38;5;202" - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("38;5;202"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSlackware(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("slackware", "slackware-linux", "slackwarelinux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SLACKWARE) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34") //blue - FF_LOGO_COLOR_TITLE("34") //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSlackwareSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SLACKWARE_SMALL) - FF_LOGO_COLOR_KEYS("33"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSolaris(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("solaris") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLARIS) - FF_LOGO_COLORS( - "33" //green - ) - FF_LOGO_COLOR_KEYS("33"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSolarisSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("solaris-small", "solaris_small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL) - FF_LOGO_COLORS( - "33" //green - ) - FF_LOGO_COLOR_KEYS("33"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSolus(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("solus", "solus-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_SOLUS) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoSteamOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("steamos") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_STEAMOS) - FF_LOGO_COLORS( - "34", //blue - "37" //white - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntu(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu", "ubuntu-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU) - FF_LOGO_COLORS( - "31", //red - "37" //white - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuBudgie(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu-budgie") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_BUDGIE) - FF_LOGO_COLORS( - "34", //blue - "37", //white - "31" //red - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuGnome(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu-gnome") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME) - FF_LOGO_COLORS( - "34", //blue - "35", //magenta - "37", //white - "36" //cyan - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("35"); //magenta - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuKylin(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu kylin", "ubuntu-kylin") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_KYLIN) - FF_LOGO_COLORS( - "31", //red - "37", //white - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuMate(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu mate", "ubuntu-mate") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_MATE) - FF_LOGO_COLORS( - "32", //green - "37" //white - ) - FF_LOGO_COLOR_KEYS("32"); //green - FF_LOGO_COLOR_TITLE("37"); //white - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuOld(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("ubuntu_old", "ubuntu-linux_old") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_OLD) - FF_LOGO_COLORS( - "31", //red - "37" //white - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntuSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("ubuntu_small", "ubuntu-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU_SMALL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUbuntu2Small(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("ubuntu2_small", "ubuntu2-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("31"); //red - FF_LOGO_COLOR_TITLE("31"); //red - FF_LOGO_RETURN -} - -static const FFlogo* getLogoUOS(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("UOS") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_UOS) - FF_LOGO_COLORS( - "31" //red - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("33"); //yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoVanilla(void) -{ - - FF_LOGO_INIT - FF_LOGO_NAMES("vanilla", "vanilla-os", "vanilla-linux"); - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VANILLA) - FF_LOGO_COLORS( - "33" //yellow - ) - FF_LOGO_COLOR_KEYS("33"); // yellow - FF_LOGO_COLOR_TITLE("33"); // yellow - FF_LOGO_RETURN -} - -static const FFlogo* getLogoVoid(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("void", "void-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VOID) - FF_LOGO_COLORS( - "32", //green - "30" //black - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoVoidSmall(void) -{ - FF_LOGO_INIT_SMALL - FF_LOGO_NAMES("void_small", "void-linux-small") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_VOID_SMALL) - FF_LOGO_COLORS( - "32" //green - ) - FF_LOGO_COLOR_KEYS("37"); //white - FF_LOGO_COLOR_TITLE("32"); //green - FF_LOGO_RETURN -} - -static const FFlogo* getLogoZorin(void) -{ - FF_LOGO_INIT - FF_LOGO_NAMES("zorin", "zorin-linux", "zorinos", "zorinos-linux") - FF_LOGO_LINES(FASTFETCH_DATATEXT_LOGO_ZORIN) - FF_LOGO_COLORS( - "34" //blue - ) - FF_LOGO_COLOR_KEYS("34"); //blue - FF_LOGO_COLOR_TITLE("34"); //blue - FF_LOGO_RETURN -} - -GetLogoMethod* ffLogoBuiltinGetAll(void) -{ - static GetLogoMethod logoMethods[] = { - ffLogoBuiltinGetUnknown, - getLogoAIX, - getLogoAlmaLinux, - getLogoAlpine, - getLogoAlpineSmall, - getLogoAlpine2Small, - getLogoAlter, - getLogoAmazon, - getLogoAmogOS, - getLogoAnarchy, - getLogoAndroid, - getLogoAndroidSmall, - getLogoAntergos, - getLogoAntix, - getLogoAoscOsRetro, - getLogoAoscOsRetro_small, - getLogoAoscOS, - getLogoAperture, - getLogoApricity, - getLogoArchBox, - getLogoArchcraft, - getLogoArchcraft2, - getLogoArch, - getLogoArchSmall, - getLogoArchlabs, - getLogoArchStrike, - getLogoArcoLinux, - getLogoArcoLinuxSmall, - getLogoArtix, - getLogoArtixSmall, - getLogoArtix2Small, - getLogoArseLinux, - getLogoArya, - getLogoAsahi, - getLogoAster, - getLogoAsteroidOS, - getLogoAstOS, - getLogoBedrock, - getLogoBSD, - getLogoCachyOS, - getLogoCachyOSSmall, - getLogoCelOS, - getLogoCentOS, - getLogoCentOSSmall, - getLogoCRUX, - getLogoCrystalLinux, - getLogoElementary, - getLogoElementarySmall, - getLogoDebian, - getLogoDebianSmall, - getLogoDevuan, - getLogoDevuanSmall, - getLogoDeepin, - getLogoEndeavour, - getLogoEnso, - getLogoExherbo, - getLogoFedora, - getLogoFedoraSmall, - getLogoFedoraOld, - getLogoFreeBSD, - getLogoFreeBSDSmall, - getLogoGaruda, - getLogoGarudaDragon, - getLogoGarudaSmall, - getLogoGentoo, - getLogoGentooSmall, - getLogoGhostBSD, - getLogoGnome, - getLogoGNU, - getLogoHaiku, - getLogoHaikuSmall, - getLogoKDENeon, - getLogoKISSLinux, - getLogoKubuntu, - getLogoLangitKetujuh, - getLogoLinux, - getLogoLinuxSmall, - getLogoLMDE, - getLogoMacOS, - getLogoMacOSSmall, - getLogoMacOS2, - getLogoMacOS2Small, - getLogoMandriva, - getLogoManjaro, - getLogoManjaroSmall, - getLogoMinix, - getLogoMint, - getLogoMintSmall, - getLogoMintOld, - getLogoMsys2, - getLogoWindows11, - getLogoWindows11Small, - getLogoWindows8, - getLogoWindows, - getLogoWindows95, - getLogoNixOS, - getLogoNixOsOld, - getLogoNixOsSmall, - getLogoNomadBSD, - getLogoMX, - getLogoMXSmall, - getLogoNetBSD, - getLogoNobara, - getLogoOpenBSD, - getLogoOpenBSDSmall, - getLogoOpenKylin, - getLogoOpenSuse, - getLogoOpenSuseSmall, - getLogoOpenSuseLeap, - getLogoOpenSuseTumbleweed, - getLogoOpenSuseTumbleweed2, - getLogoOpenMandriva, - getLogoOpenWrt, - getLogoOrchid, - getLogoOrchidSmall, - getLogoOracle, - getLogoPop, - getLogoPopSmall, - getLogoParabola, - getLogoParabolaSmall, - getLogoProxmox, - getLogoRaspbian, - getLogoRaspbianSmall, - getLogoReborn, - getLogoRebornSmall, - getLogoRedHatEnterpriseLinux, - getLogoRedstarOS, - getLogoRockyLinux, - getLogoRosaLinux, - getLogoSolaris, - getLogoSolarisSmall, - getLogoSlackware, - getLogoSlackwareSmall, - getLogoSolus, - getLogoSteamOS, - getLogoUbuntu, - getLogoUbuntuBudgie, - getLogoUbuntuGnome, - getLogoUbuntuKylin, - getLogoUbuntuMate, - getLogoUbuntuOld, - getLogoUbuntuSmall, - getLogoUbuntu2Small, - getLogoUOS, - getLogoVanilla, - getLogoVoid, - getLogoVoidSmall, - getLogoZorin, - NULL - }; - - return logoMethods; -} +const FFlogo ffLogoBuiltins[] = { + // Unknown + { + .names = {"unknown", "question mark", "?"}, + .lines = FASTFETCH_DATATEXT_LOGO_UNKNOWN, + .colors = { + "37", //white + }, + .colorKeys = "", + .colorTitle = "", + }, + // AIX + { + .names = {"aix"}, + .lines = FASTFETCH_DATATEXT_LOGO_AIX, + .colors = { + "32", // green + "37" // white + }, + .colorKeys = "32", // green + .colorTitle = "37", // white + }, + // AlmaLinux + { + .names = {"almalinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ALMALINUX, + .colors = { + "31", // red + "1;33", // yellow + "34", // blue + "1;32", // light green + "36" // cyan + }, + .colorKeys = "1;33", //yellow + .colorTitle = "31", //red + }, + // Alpine + { + .names = {"alpine", "alpinelinux", "alpine-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ALPINE, + .colors = { + "34" //blue + }, + .colorKeys = "35", //magenta + .colorTitle = "34", //blue + }, + // AlpineSmall + { + .names = {"alpine_small", "alpine-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "35", //magenta + .colorTitle = "34", //blue + }, + // Alpine2Small + { + .names = {"alpine2_small", "alpine-linux2-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ALPINE2_SMALL, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "35", //magenta + .colorTitle = "34", //blue + }, + // Alter + { + .names = {"Alter"}, + .lines = FASTFETCH_DATATEXT_LOGO_ALTER, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // Amazon + { + .names = {"Amazon"}, + .lines = FASTFETCH_DATATEXT_LOGO_AMAZON, + .colors = { + "33", //yellow + "37" //white + }, + .colorKeys = "33", //yellow + .colorTitle = "37", //white + }, + // AmogOS + { + .names = {"AmogOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_AMOGOS, + .colors = { + "37", //white + "36" //cyan + }, + .colorKeys = "37", //white + .colorTitle = "36", //cyan + }, + // Anarchy + { + .names = {"Anarchy"}, + .lines = FASTFETCH_DATATEXT_LOGO_ANARCHY, + .colors = { + "37", //white + "34" //blue + }, + .colorKeys = "37", //white + .colorTitle = "34", //blue + }, + // Android + { + .names = {"android"}, + .lines = FASTFETCH_DATATEXT_LOGO_ANDROID, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // AndroidSmall + { + .names = {"android-small", "android_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ANDROID_SMALL, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // Antergos + { + .names = {"Antergos"}, + .lines = FASTFETCH_DATATEXT_LOGO_ANTERGOS, + .colors = { + "34", //blue + "36" //cyan + }, + .colorKeys = "34", //blue + .colorTitle = "36", //cyan + }, + // Antix + { + .names = {"antiX"}, + .lines = FASTFETCH_DATATEXT_LOGO_ANTIX, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "37", //white + }, + // AoscOsRetro + { + .names = {"Aosc OS/Retro", "aoscosretro"}, + .lines = FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // AoscOsRetro_small + { + .names = {"Aosc OS/Retro_small", "aoscosretro_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO_SMALL, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // AoscOS + { + .names = {"Aosc OS", "aoscos"}, + .lines = FASTFETCH_DATATEXT_LOGO_AOSCOS, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // Aperture + { + .names = {"Aperture"}, + .lines = FASTFETCH_DATATEXT_LOGO_APERTURE, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "37", //white + }, + // Apricity + { + .names = {"Apricity"}, + .lines = FASTFETCH_DATATEXT_LOGO_APRICITY, + .colors = { + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // ArchBox + { + .names = {"ArchBox"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCHBOX, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "37", //white + }, + // Archcraft + { + .names = {"Archcraft"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCHCRAFT, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "31", //red + }, + // Archcraft2 + { + .names = {"Archcraft2"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCHCRAFT2, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "31", //red + }, + // Arch + { + .names = {"arch", "archlinux", "arch-linux", "archmerge"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCH, + .colors = { + "36", //cyan + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // ArchSmall + { + .names = {"arch_small", "archlinux_small", "arch-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ARCH_SMALL, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // Archlabs + { + .names = {"ARCHlabs"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCHLABS, + .colors = { + "36", //cyan + "31" //red + }, + .colorKeys = "36", //cyan + .colorTitle = "31", //red + }, + // ArchStrike + { + .names = {"ArchStrike"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCHSTRIKE, + .colors = { + "36", //cyan + "30" //black + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // Artix + { + .names = {"artix", "artixlinux", "artix-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARTIX, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // ArtixSmall + { + .names = {"artix_small", "artixlinux_small", "artix-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ARTIX_SMALL, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // Artix2Small + { + .names = {"artix2_small", "artixlinux2_small", "artix-linux2-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ARTIX2_SMALL, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // ArcoLinux + { + .names = {"arco", "arcolinux", "arco-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCO, + .colors = { + "34", //blue + "32" //green + }, + .colorKeys = "34", //green + .colorTitle = "34", //green + }, + // ArcoLinuxSmall + { + .names = {"arco_small", "arcolinux_small", "arco-linux_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ARCO_SMALL, + .colors = { + "34", //blue + "32" //green + }, + .colorKeys = "34", //green + .colorTitle = "34", //green + }, + // ArseLinux + { + .names = {"arse", "arselinux", "arse-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARSELINUX, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //green + .colorTitle = "37", //white + }, + // Arya + { + .names = {"Arya"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARYA, + .colors = { + "32", //green + "31" //red + }, + .colorKeys = "32", //green + .colorTitle = "31", //red + }, + // Asahi + { + .names = {"asahi", "asahi-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ASAHI, + .colors = { + "33", //yellow + "32", //green + "31", //red + "38", //cyan + "37", //magenta + "36", //cyan + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "32", //green + }, + // Aster + { + .names = {"aster"}, + .lines = FASTFETCH_DATATEXT_LOGO_ASTER, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // AsteroidOS + { + .names = {"AsteroidOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_ASTEROIDOS, + .colors = { + "38;5;160", + "38;5;208", + "38;5;202", + "38;5;214" + }, + .colorKeys = "38;5;160", + .colorTitle = "38;5;208", + }, + // AstOS + { + .names = {"astOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_ASTOS, + .colors = { + "37" //white + }, + .colorKeys = "37", //white + .colorTitle = "37", //white + }, + // BSD + { + .names = {"bsd"}, + .lines = FASTFETCH_DATATEXT_LOGO_BSD, + .colors = { + "31", + "37", + "34", + "33", + "36" + }, + .colorKeys = "31", + .colorTitle = "37", + }, + // Bedrock + { + .names = {"bedrock", "bedrocklinux", "bedrock-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_BEDROCK, + .colors = { + "90", //grey + "37" //white + }, + .colorKeys = "90", //grey + .colorTitle = "37", //white + }, + // CachyOS + { + .names = {"cachy", "cachyos", "cachy-linux", "cachyos-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS, + .colors = { + "36", //cyan + "32", //green + "30" //black + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // CachyOSSmall + { + .names = {"cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // CelOS + { + .names = {"cel", "celos", "cel-linux", "celos-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CELOS, + .colors = { + "35", //magenta + "30" //black + }, + .colorKeys = "36", //cyan + .colorTitle = "34", //blue + }, + // CentOS + { + .names = {"cent", "centos", "cent-linux", "centos-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CENTOS, + .colors = { + "33", //yellow + "32", //green + "34", //blue + "35", //magenta + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "33", //yellow + }, + // CentOSSmall + { + .names = {"cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL, + .colors = { + "33", //yellow + "32", //green + "34", //blue + "35" //magenta + }, + .colorKeys = "32", //green + .colorTitle = "33", //yellow + }, + // CRUX + { + .names = {"crux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CRUX, + .colors = { + "34", //blue + "35", //magenta + "37" //white + }, + .colorKeys = "35", + .colorTitle = "34", + }, + // CrystalLinux + { + .names = {"crystal", "Crystal", "crystal-linux", "Crystal-Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CRYSTAL, + .colors = { + "35" //magenta + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // Debian + { + .names = {"debian", "debian-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN, + .colors = { + "31", //red + "37" //white + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // DebianSmall + { + .names = {"debian_small", "debian-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // Devuan + { + .names = {"devuan", "devuan-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN, + .colors = { + "35" //magenta + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // DevuanSmall + { + .names = {"devuan_small", "devuan-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL, + .colors = { + "35" //magenta + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // Elementary + { + .names = {"elementary"}, + .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY, + .colors = { + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // ElementarySmall + { + .names = {"elementary_small", "elementary-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL, + .colors = { + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // Deepin + { + .names = {"deepin", "deepin-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_DEEPIN, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // Endeavour + { + .names = {"endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ENDEAVOUR, + .colors = { + "35", //magenta + "31", //red + "34" //blue + }, + .colorKeys = "35", //magenta + .colorTitle = "31", //red + }, + // Enso + { + .names = {"enso", "uqc"}, + .lines = FASTFETCH_DATATEXT_LOGO_ENSO, + .colors = { + "37" //white + }, + .colorKeys = "37", //white + .colorTitle = "37", //white + }, + // Exherbo + { + .names = {"exherbo", "exherbo-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_EXHERBO, + .colors = { + "34", //blue + "37", //white + "31" //red + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // Fedora + { + .names = {"fedora", "fedora-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_FEDORA, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // FedoraSmall + { + .names = {"fedora_small", "fedora-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // FedoraOld + { + .names = {"fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_OLD, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // FreeBSD + { + .names = {"freebsd", "HardenedBSD"}, + .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD, + .colors = { + "37", //white + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // FreeBSDSmall + { + .names = {"freebsd_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD_SMALL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // Garuda + { + .names = {"garuda", "garuda-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_GARUDA, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // GarudaDragon + { + .names = {"garudadragon", "garuda-dragon", "garuda-linux-dragon"}, + .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_DRAGON, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // GarudaSmall + { + .names = {"garuda_small", "garudalinux_small", "garuda-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // Gentoo + { + .names = {"gentoo", "gentoo-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_GENTOO, + .colors = { + "35", //magenta + "37" //white + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // GentooSmall + { + .names = {"gentoo_small", "gentoo-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL, + .colors = { + "35", //magenta + "37" //white + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // GhostBSD + { + .names = {"ghostbsd"}, + .lines = FASTFETCH_DATATEXT_LOGO_GHOSTBSD, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "31", //red + }, + // Gnome + { + .names = {"Gnome"}, + .lines = FASTFETCH_DATATEXT_LOGO_GNOME, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "31", //red + }, + // GNU + { + .names = {"GNU"}, + .lines = FASTFETCH_DATATEXT_LOGO_GNU, + .colors = { + "37" //white + }, + .colorKeys = "37", //white + .colorTitle = "31", //red + }, + // Haiku + { + .names = {"Haiku"}, + .lines = FASTFETCH_DATATEXT_LOGO_HAIKU, + .colors = { + "31", //red + "33", //yellow + "37", //white + "32" //green + }, + .colorKeys = "31", //red + .colorTitle = "33", //yellow + }, + // HaikuSmall + { + .names = {"Haiku-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "33", //yellow + }, + // KDENeon + { + .names = {"kde", "kde-neon", "neon"}, + .lines = FASTFETCH_DATATEXT_LOGO_KDE, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // KISSLinux + { + .names = {"kiss", "kiss-linux", "kisslinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_KISS, + .colors = { + "35", //magenta + "37", //white + "34" //blue + }, + .colorKeys = "35", //magenta + .colorTitle = "34", //blue + }, + // Kubuntu + { + .names = {"kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma"}, + .lines = FASTFETCH_DATATEXT_LOGO_KUBUNTU, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // LangitKetujuh + { + .names = {"langitketujuh", "l7"}, + .lines = FASTFETCH_DATATEXT_LOGO_LANGITKETUJUH, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // Linux + { + .names = {"linux", "linux-generic"}, + .lines = FASTFETCH_DATATEXT_LOGO_LINUX, + .colors = { + "37", //white + "30", //black + "33" //yellow + }, + .colorKeys = "37", //white + .colorTitle = "37", //white + }, + // LinuxSmall + { + .names = {"linux_small", "linux-generic_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_LINUX_SMALL, + .colors = { + "30", //black + "37", //white + "33" //yellow + }, + .colorKeys = "37", //white + .colorTitle = "37", //white + }, + // LMDE + { + .names = {"LMDE"}, + .lines = FASTFETCH_DATATEXT_LOGO_LMDE, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "37", //white + }, + // MacOS + { + .names = {"macos", "mac", "apple", "darwin", "osx"}, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS, + .colors = { + "32", //green + "33", //yellow + "31", //red + "35", //magenta + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "32", //green + }, + // MacOSSmall + { + .names = {"macos_small", "mac_small", "apple_small", "darwin_small", "osx_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, + .colors = { + "32", //green + "33", //yellow + "31", //red + "35", //magenta + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "32", //green + }, + // MacOS2 + { + .names = {"macos2", "mac2", "apple2", "darwin2", "osx2"}, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS2, + .colors = { + "32", //green + "33", //yellow + "31", //red + "35", //magenta + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "32", //green + }, + // MacOS2Small + { + .names = {"macos2_small", "mac2_small", "apple2_small", "darwin2_small", "osx2_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL, + .colors = { + "32", //green + "33", //yellow + "31", //red + "35", //magenta + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "32", //green + }, + // Mandriva + { + .names = {"mandriva", "mandrake"}, + .lines = FASTFETCH_DATATEXT_LOGO_MANDRIVA, + .colors = { + "34", //blue + "33" //yellow + }, + .colorKeys = "34", //blue + .colorTitle = "33", //yellow + }, + // Manjaro + { + .names = {"manjaro", "manjaro-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_MANJARO, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // ManjaroSmall + { + .names = {"manjaro_small", "manjaro-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MANJARO_SMALL, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // Minix + { + .names = {"minix"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINIX, + .colors = { + "31", //red + "37", //white + "33" //yellow + }, + .colorKeys = "31", //red + .colorTitle = "33", //yellow + }, + // Mint + { + .names = {"mint", "linuxmint", "mint-linux", "linux-mint"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINT, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // MintSmall + { + .names = {"mint_small", "linuxmint_small", "mint-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // MintOld + { + .names = {"mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // Msys2 + { + .names = {"msys2"}, + .lines = FASTFETCH_DATATEXT_LOGO_MSYS2, + .colors = { + "35", //magenta + "37", //white + "31" //red + }, + .colorKeys = "35", //magenta + .colorTitle = "31", //red + }, + // Windows11 + { + .names = {"Windows 11", "Windows Server 2022"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11, + .colors = { + "34", //blue + "34", //blue + "34", //blue + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "36", //cyan + }, + // Windows11Small + { + .names = {"Windows 11_small", "Windows 11-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL, + .colors = { + "34" //blue + }, + .colorKeys = "33", //yellow + .colorTitle = "36", //cyan + }, + // Windows8 + { + .names = {"Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_8, + .colors = { + "36", //cyan + "36", //cyan + "36", //cyan + "36" //cyan + }, + .colorKeys = "33", //yellow + .colorTitle = "37", //white + }, + // Windows + { + .names = {"Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS, + .colors = { + "31", //red + "32", //green + "34", //blue + "33" //yellow + }, + .colorKeys = "34", //blue + .colorTitle = "32", //green + }, + // Windows95 + { + .names = {"Windows 95", "Windows 9x"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_95, + .colors = { + "36", //cyan + "34", //blue + "33", //yellow + "32", //green + "31", //red + "30" //black + }, + .colorKeys = "36", //cyan + .colorTitle = "34", //blue + }, + // NixOS + { + .names = {"nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_NIXOS, + .colors = { + "34", //blue + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "34", //blue + }, + // NixOsOld + { + .names = {"nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_OLD, + .colors = { + "34", //blue + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "34", //blue + }, + // NixOsSmall + { + .names = {"nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // MX + { + .names = {"mx"}, + .lines = FASTFETCH_DATATEXT_LOGO_MX, + .colors = { + "37" // white + }, + .colorKeys = "34", // blue + .colorTitle = "36", // cyan + }, + // MXSmall + { + .names = {"mx_small", "mx-small"}, + .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, + .colors = { + "37" // white + }, + .colorKeys = "34", // blue + .colorTitle = "36", // cyan + }, + // NetBSD + { + .names = {"netbsd"}, + .lines = FASTFETCH_DATATEXT_LOGO_NETBSD, + .colors = { + "35", // blue + "37" // white + }, + .colorKeys = "35", // blue + .colorTitle = "37", // white + }, + // Nobara + { + .names = {"nobara", "nobara-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_NOBARA, + .colors = { + "37" // white + }, + .colorKeys = "37", // white + .colorTitle = "37", // white + }, + // NomadBSD + { + .names = {"nomadbsd"}, + .lines = FASTFETCH_DATATEXT_LOGO_NOMADBSD, + .colors = { + "34" // blue + }, + .colorKeys = "34", // blue + .colorTitle = "37", // white + }, + // OpenKylin + { + .names = {"openkylin", "open-kylin"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENKYLIN, + .colors = { + "32", // cyan + "37" // white + }, + .colorKeys = "32", // cyan + .colorTitle = "37", // white + }, + // OpenBSD + { + .names = {"openbsd"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENBSD, + .colors = { + "33", // blue + "37", // white + "36", // yellow + "31" // red + }, + .colorKeys = "33", // blue + .colorTitle = "37", // white + }, + // OpenBSDSmall + { + .names = {"openbsd_small", "openbsd-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL, + .colors = { + "33", // blue + "37" // white + }, + .colorKeys = "33", // blue + .colorTitle = "37", // white + }, + // OpenSuse + { + .names = {"suse", "opensuse", "open_suse", "open-suse", "suse-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // OpenSuseSmall + { + .names = {"suse_small", "opensuse_small", "open_suse_small", "open-suse_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // OpenSuseLeap + { + .names = {"opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP, + .colors = { + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // OpenSuseTumbleweed + { + .names = {"opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED, + .colors = { + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // OpenSuseTumbleweed2 + { + .names = {"opensuse_tumbleweed2"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2, + .colors = { + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // OpenMandriva + { + .names = {"openmandriva", "open-mandriva", "open_mandriva"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENMANDRIVA, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // OpenWrt + { + .names = {"openwrt"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENWRT, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // Oracle + { + .names = {"oracle", "oracle linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ORACLE, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "37", //white + }, + // Orchid + { + .names = {"orchid"}, + .lines = FASTFETCH_DATATEXT_LOGO_ORCHID, + .colors = { + "37", //white + "35", //magenta + "35" //magenta + }, + .colorKeys = "37", //white + .colorTitle = "35", //magenta + }, + // OrchidSmall + { + .names = {"orchid_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_ORCHID_SMALL, + .colors = { + "37", //white + "35", //magenta + "35" //magenta + }, + .colorKeys = "37", //white + .colorTitle = "35", //magenta + }, + // Parabola + { + .names = {"parabola", "parabola-gnulinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_PARABOLA, + .colors = { + "35" //magenta + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // ParabolaSmall + { + .names = {"parabola_small", "parabola-gnulinux_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_PARABOLA_SMALL, + .colors = { + "35" //magenta + }, + .colorKeys = "35", //magenta + .colorTitle = "35", //magenta + }, + // Pop + { + .names = {"pop", "popos", "pop_os", "pop-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_POP, + .colors = { + "36", //cyan + "37" //white + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, + // PopSmall + { + .names = {"pop_small", "popos_small", "pop_os_small", "pop-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_POP_SMALL, + .colors = { + "36" //cyan + }, + .colorKeys = "36", //cyan + .colorTitle = "36", //cyan + }, // Raspbian + { + .names = {"raspbian", "raspi", "raspberrypi", "raspberrypios", "pios"}, + .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN, + .colors = { + "31", //red + "32" //green + }, + .colorKeys = "31", //red + .colorTitle = "32", //green + }, + // RaspbianSmall + { + .names = {"raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL, + .colors = { + "31", //red + "32" //green + }, + .colorKeys = "31", //red + .colorTitle = "32", //green + }, + // Reborn + { + .names = {"reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_REBORN, + .colors = { + "34", //blue + "36" //cyan + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // RebornSmall + { + .names = {"reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_REBORN_SMALL, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // RedHatEnterpriseLinux + { + .names = {"rhel", "redhat", "redhat-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_RHEL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // RedstarOS + { + .names = {"redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_REDSTAR, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // RockyLinux + { + .names = {"rocky", "rocky-linux", "rockylinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ROCKY, + .colors = { + "32" //green + }, + .colorKeys = "32", //green + .colorTitle = "32", //green + }, + // RosaLinux + { + .names = {"rosa", "rosa-linux", "rosalinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ROSA, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // Proxmox + { + .names = {"proxmox"}, + .lines = FASTFETCH_DATATEXT_LOGO_PROXMOX, + .colors = { + "37", //blue + "38;5;202" + }, + .colorKeys = "37", //white + .colorTitle = "38;5;202", //white + }, + // Slackware + { + .names = {"slackware", "slackware-linux", "slackwarelinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // SlackwareSmall + { + .names = {"slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE_SMALL, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // Solaris + { + .names = {"solaris", "sunos"}, + .lines = FASTFETCH_DATATEXT_LOGO_SOLARIS, + .colors = { + "33" //green + }, + .colorKeys = "33", //green + .colorTitle = "37", //white + }, + // SolarisSmall + { + .names = {"solaris-small", "solaris_small", "sunos-small", "sunos_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL, + .colors = { + "33" //green + }, + .colorKeys = "33", //green + .colorTitle = "37", //white + }, + // Solus + { + .names = {"solus", "solus-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_SOLUS, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // SteamOS + { + .names = {"steamos"}, + .lines = FASTFETCH_DATATEXT_LOGO_STEAMOS, + .colors = { + "34", //blue + "37" //white + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, + // Ubuntu + { + .names = {"ubuntu", "ubuntu-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU, + .colors = { + "31", //red + "37" //white + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // UbuntuBudgie + { + .names = {"ubuntu-budgie"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_BUDGIE, + .colors = { + "34", //blue + "37", //white + "31" //red + }, + .colorKeys = "34", //blue + .colorTitle = "37", //white + }, + // UbuntuGnome + { + .names = {"ubuntu-gnome"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME, + .colors = { + "34", //blue + "35", //magenta + "37", //white + "36" //cyan + }, + .colorKeys = "34", //blue + .colorTitle = "35", //magenta + }, + // UbuntuKylin + { + .names = {"ubuntu kylin", "ubuntu-kylin"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_KYLIN, + .colors = { + "31", //red + "37", //white + "33" //yellow + }, + .colorKeys = "31", //red + .colorTitle = "37", //white + }, + // UbuntuMate + { + .names = {"ubuntu mate", "ubuntu-mate"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_MATE, + .colors = { + "32", //green + "37" //white + }, + .colorKeys = "32", //green + .colorTitle = "37", //white + }, + // UbuntuOld + { + .names = {"ubuntu_old", "ubuntu-linux_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_OLD, + .colors = { + "31", //red + "37" //white + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // UbuntuSmall + { + .names = {"ubuntu_small", "ubuntu-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_SMALL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // Ubuntu2Small + { + .names = {"ubuntu2_small", "ubuntu2-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL, + .colors = { + "31" //red + }, + .colorKeys = "31", //red + .colorTitle = "31", //red + }, + // UOS + { + .names = {"UOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_UOS, + .colors = { + "31" //red + }, + .colorKeys = "37", //white + .colorTitle = "33", //yellow + }, + // Vanilla + { + .names = {"vanilla", "vanilla-os", "vanilla-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_VANILLA, + .colors = { + "33" //yellow + }, + .colorKeys = "33", // yellow + .colorTitle = "33", // yellow + }, + // Void + { + .names = {"void", "void-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_VOID, + .colors = { + "32", //green + "30" //black + }, + .colorKeys = "37", //white + .colorTitle = "32", //green + }, + // VoidSmall + { + .names = {"void_small", "void-linux-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_VOID_SMALL, + .colors = { + "32" //green + }, + .colorKeys = "37", //white + .colorTitle = "32", //green + }, + // Zorin + { + .names = {"zorin", "zorin-linux", "zorinos", "zorinos-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ZORIN, + .colors = { + "34" //blue + }, + .colorKeys = "34", //blue + .colorTitle = "34", //blue + }, +}; + +const uint32_t ffLogoBuiltinLength = sizeof(ffLogoBuiltins) / sizeof(ffLogoBuiltins[0]); diff --git a/src/logo/logo.c b/src/logo/logo.c index 449901856..35bb616c6 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -187,8 +187,11 @@ static void logoApplyColors(const FFlogo* logo) static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) { - for(const char** logoName = logo->names; *logoName != NULL; ++logoName) - { + for( + const char* const* logoName = logo->names; + *logoName != NULL && logoName <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; + ++logoName + ) { if(small) { uint32_t logoNameLength = (uint32_t) (strlen(*logoName) - strlen("_small")); @@ -206,10 +209,8 @@ static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) if (name->length == 0) return NULL; - for(GetLogoMethod* methods = ffLogoBuiltinGetAll(); *methods; ++methods) + for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) { - const FFlogo* logo = (*methods)(); - switch (size) { case FF_LOGO_SIZE_NORMAL: @@ -253,7 +254,7 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) if(logo != NULL) return logo; - return ffLogoBuiltinGetUnknown(); + return &ffLogoBuiltins[0]; // Unknown } static inline void logoApplyColorsDetected(void) @@ -267,14 +268,14 @@ static void logoPrintStruct(const FFlogo* logo) FFLogoOptions* options = &instance.config.logo; - const char** colors = logo->builtinColors; + const char* const* colors = logo->colors; for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) { if(options->colors[i].length == 0) ffStrbufAppendS(&options->colors[i], *colors); } - ffLogoPrintChars(logo->data, true); + ffLogoPrintChars(logo->lines, true); } static void logoPrintNone(void) @@ -499,13 +500,11 @@ void ffLogoPrintRemaining(void) void ffLogoBuiltinPrint(void) { - GetLogoMethod* methods = ffLogoBuiltinGetAll(); FFLogoOptions* options = &instance.config.logo; - while(*methods != NULL) + for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) { - const FFlogo* logo = (*methods)(); - printf("\033[%sm%s:\033[0m\n", logo->builtinColors[0], logo->names[0]); + printf("\033[%sm%s:\033[0m\n", logo->colors[0], logo->names[0]); logoPrintStruct(logo); ffLogoPrintRemaining(); @@ -515,43 +514,30 @@ void ffLogoBuiltinPrint(void) for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) ffStrbufClear(&options->colors[i]); - puts("\n"); - ++methods; + putchar('\n'); } } void ffLogoBuiltinList(void) { - GetLogoMethod* methods = ffLogoBuiltinGetAll(); - - uint32_t counter = 0; - - while(*methods != NULL) + for(uint32_t counter = 0; counter < ffLogoBuiltinLength; ++counter) { - const FFlogo* logo = (*methods)(); - const char** names = logo->names; - + const FFlogo* logo = &ffLogoBuiltins[counter]; printf("%u)%s ", counter, counter < 10 ? " " : ""); - ++counter; - while(*names != NULL) - { + for( + const char* const* names = logo->names; + *names != NULL && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; + ++names + ) printf("\"%s\" ", *names); - ++names; - } putchar('\n'); - ++methods; } } void ffLogoBuiltinListAutocompletion(void) { - GetLogoMethod* methods = ffLogoBuiltinGetAll(); - - while(*methods != NULL) - { - printf("%s\n", (*methods)()->names[0]); - ++methods; - } + for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) + printf("%s\n", logo->names[0]); } diff --git a/src/logo/logo.h b/src/logo/logo.h index 6bbfa7cff..f80c6e79c 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -7,22 +7,20 @@ typedef struct FFlogo { - const char* data; - const char** names; //Null terminated - const char** builtinColors; //Null terminated + const char* lines; + const char* names[FASTFETCH_LOGO_MAX_NAMES]; + const char* colors[FASTFETCH_LOGO_MAX_COLORS]; const char* colorKeys; const char* colorTitle; - bool small; + bool small; // The names of small logo must end with `_small` or `-small` } FFlogo; -typedef const FFlogo*(*GetLogoMethod)(); - //logo.c void ffLogoPrintChars(const char* data, bool doColorReplacement); //builtin.c -const FFlogo* ffLogoBuiltinGetUnknown(); -GetLogoMethod* ffLogoBuiltinGetAll(); +extern const FFlogo ffLogoBuiltins[]; +extern const uint32_t ffLogoBuiltinLength; //image/image.c bool ffLogoPrintImageIfExists(FFLogoType type, bool printError); diff --git a/src/logo/option.h b/src/logo/option.h index d31ca53f4..e1073db37 100644 --- a/src/logo/option.h +++ b/src/logo/option.h @@ -2,6 +2,7 @@ #include "util/FFstrbuf.h" +#define FASTFETCH_LOGO_MAX_NAMES 9 #define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) typedef enum FFLogoType From 7d347a9b46ad36f95b809b581a0be8710e74d513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 3 Aug 2023 14:30:53 +0800 Subject: [PATCH 415/493] Logo (Builtin): use meaningful macros instead of raw color codes --- doc/json_schema.json | 6 +- src/common/color.h | 55 ++ src/common/option.c | 31 +- src/logo/builtin.c | 1165 +++++++++++++++++++++--------------------- 4 files changed, 664 insertions(+), 593 deletions(-) create mode 100644 src/common/color.h diff --git a/doc/json_schema.json b/doc/json_schema.json index 6e92ac2ea..7d5e1465b 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -3,7 +3,11 @@ "$defs": { "colors": { "type": "string", - "enum": ["reset_", "bright_", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] + "enum": [ + "reset_", "bright_", "dim_", + "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default", + "bright_black", "bright_red", "bright_green", "bright_yellow", "bright_blue", "bright_magenta", "bright_cyan", "bright_white" + ] }, "key": { "title": "Key of the module", diff --git a/src/common/color.h b/src/common/color.h new file mode 100644 index 000000000..7f8c539cc --- /dev/null +++ b/src/common/color.h @@ -0,0 +1,55 @@ +#pragma once + +#define FF_COLOR_MODE_RESET "0;" +#define FF_COLOR_MODE_BOLD "1;" +#define FF_COLOR_MODE_DIM "2;" +#define FF_COLOR_MODE_ITALIC "3;" +#define FF_COLOR_MODE_UNDERLINE "4;" +#define FF_COLOR_MODE_BLINK "5;" +#define FF_COLOR_MODE_INVERSE "7;" +#define FF_COLOR_MODE_HIDDEN "8;" +#define FF_COLOR_MODE_STRIKETHROUGH "9;" + +#define FF_COLOR_FG_BLACK "30" +#define FF_COLOR_FG_RED "31" +#define FF_COLOR_FG_GREEN "32" +#define FF_COLOR_FG_YELLOW "33" +#define FF_COLOR_FG_BLUE "34" +#define FF_COLOR_FG_MAGENTA "35" +#define FF_COLOR_FG_CYAN "36" +#define FF_COLOR_FG_WHITE "37" +#define FF_COLOR_FG_DEFAULT "39" + +#define FF_COLOR_FG_LIGHT_BLACK "90" +#define FF_COLOR_FG_LIGHT_RED "91" +#define FF_COLOR_FG_LIGHT_GREEN "92" +#define FF_COLOR_FG_LIGHT_YELLOW "93" +#define FF_COLOR_FG_LIGHT_BLUE "94" +#define FF_COLOR_FG_LIGHT_MAGENTA "95" +#define FF_COLOR_FG_LIGHT_CYAN "96" +#define FF_COLOR_FG_LIGHT_WHITE "97" + +#define FF_COLOR_BG_BLACK "40" +#define FF_COLOR_BG_RED "41" +#define FF_COLOR_BG_GREEN "42" +#define FF_COLOR_BG_YELLOW "43" +#define FF_COLOR_BG_BLUE "44" +#define FF_COLOR_BG_MAGENTA "45" +#define FF_COLOR_BG_CYAN "46" +#define FF_COLOR_BG_WHITE "47" +#define FF_COLOR_BG_DEFAULT "49" + +#define FF_COLOR_BG_LIGHT_BLACK "100" +#define FF_COLOR_BG_LIGHT_RED "101" +#define FF_COLOR_BG_LIGHT_GREEN "102" +#define FF_COLOR_BG_LIGHT_YELLOW "103" +#define FF_COLOR_BG_LIGHT_BLUE "104" +#define FF_COLOR_BG_LIGHT_MAGENTA "105" +#define FF_COLOR_BG_LIGHT_CYAN "106" +#define FF_COLOR_BG_LIGHT_WHITE "107" + +#define FF_COLOR_FG_256 "38;5;" +#define FF_COLOR_BG_256 "48;5;" + +#define FF_COLOR_FG_RGB "38;2;" +#define FF_COLOR_BG_RGB "48;2;" diff --git a/src/common/option.c b/src/common/option.c index 86a3b7363..faae31619 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -1,4 +1,5 @@ #include "common/option.h" +#include "common/color.h" #include "util/stringUtils.h" // Return start position of the inner key if the argument key belongs to the module specified, NULL otherwise @@ -138,16 +139,26 @@ void ffOptionParseColor(const char* value, FFstrbuf* buffer) #define FF_APPEND_COLOR_CODE_COND(prefix, code) \ if(strncasecmp(value, #prefix, strlen(#prefix)) == 0) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); } - FF_APPEND_COLOR_CODE_COND(reset_, "0;") - else FF_APPEND_COLOR_CODE_COND(bright_, "1;") - else FF_APPEND_COLOR_CODE_COND(black, "30") - else FF_APPEND_COLOR_CODE_COND(red, "31") - else FF_APPEND_COLOR_CODE_COND(green, "32") - else FF_APPEND_COLOR_CODE_COND(yellow, "33") - else FF_APPEND_COLOR_CODE_COND(blue, "34") - else FF_APPEND_COLOR_CODE_COND(magenta, "35") - else FF_APPEND_COLOR_CODE_COND(cyan, "36") - else FF_APPEND_COLOR_CODE_COND(white, "37") + FF_APPEND_COLOR_CODE_COND(reset_, FF_COLOR_MODE_RESET) + else FF_APPEND_COLOR_CODE_COND(bright_, FF_COLOR_MODE_BOLD) + else FF_APPEND_COLOR_CODE_COND(dim_, FF_COLOR_MODE_DIM) + else FF_APPEND_COLOR_CODE_COND(black, FF_COLOR_FG_BLACK) + else FF_APPEND_COLOR_CODE_COND(red, FF_COLOR_FG_RED) + else FF_APPEND_COLOR_CODE_COND(green, FF_COLOR_FG_GREEN) + else FF_APPEND_COLOR_CODE_COND(yellow, FF_COLOR_FG_YELLOW) + else FF_APPEND_COLOR_CODE_COND(blue, FF_COLOR_FG_BLUE) + else FF_APPEND_COLOR_CODE_COND(magenta, FF_COLOR_FG_MAGENTA) + else FF_APPEND_COLOR_CODE_COND(cyan, FF_COLOR_FG_CYAN) + else FF_APPEND_COLOR_CODE_COND(white, FF_COLOR_FG_WHITE) + else FF_APPEND_COLOR_CODE_COND(default, FF_COLOR_FG_DEFAULT) + else FF_APPEND_COLOR_CODE_COND(light_black, FF_COLOR_FG_LIGHT_BLACK) + else FF_APPEND_COLOR_CODE_COND(light_red, FF_COLOR_FG_LIGHT_RED) + else FF_APPEND_COLOR_CODE_COND(light_green, FF_COLOR_FG_LIGHT_GREEN) + else FF_APPEND_COLOR_CODE_COND(light_yellow, FF_COLOR_FG_LIGHT_YELLOW) + else FF_APPEND_COLOR_CODE_COND(light_blue, FF_COLOR_FG_LIGHT_BLUE) + else FF_APPEND_COLOR_CODE_COND(light_magenta, FF_COLOR_FG_LIGHT_MAGENTA) + else FF_APPEND_COLOR_CODE_COND(light_cyan, FF_COLOR_FG_LIGHT_CYAN) + else FF_APPEND_COLOR_CODE_COND(light_white, FF_COLOR_FG_LIGHT_WHITE) else { ffStrbufAppendC(buffer, *value); diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 792f88122..6f12d2177 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1,5 +1,6 @@ #include "logo.h" #include "logo_builtin.h" +#include "common/color.h" const FFlogo ffLogoBuiltins[] = { // Unknown @@ -7,7 +8,7 @@ const FFlogo ffLogoBuiltins[] = { .names = {"unknown", "question mark", "?"}, .lines = FASTFETCH_DATATEXT_LOGO_UNKNOWN, .colors = { - "37", //white + FF_COLOR_FG_WHITE, }, .colorKeys = "", .colorTitle = "", @@ -17,35 +18,35 @@ const FFlogo ffLogoBuiltins[] = { .names = {"aix"}, .lines = FASTFETCH_DATATEXT_LOGO_AIX, .colors = { - "32", // green - "37" // white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", // green - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, }, // AlmaLinux { .names = {"almalinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ALMALINUX, .colors = { - "31", // red - "1;33", // yellow - "34", // blue - "1;32", // light green - "36" // cyan + FF_COLOR_FG_RED, + FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, + FF_COLOR_MODE_BOLD FF_COLOR_FG_GREEN, + FF_COLOR_FG_CYAN, }, - .colorKeys = "1;33", //yellow - .colorTitle = "31", //red + .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_RED, }, // Alpine { .names = {"alpine", "alpinelinux", "alpine-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ALPINE, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "35", //magenta - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, }, // AlpineSmall { @@ -53,11 +54,11 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", //magenta - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, }, // Alpine2Small { @@ -65,65 +66,65 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ALPINE2_SMALL, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", //magenta - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, }, // Alter { .names = {"Alter"}, .lines = FASTFETCH_DATATEXT_LOGO_ALTER, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // Amazon { .names = {"Amazon"}, .lines = FASTFETCH_DATATEXT_LOGO_AMAZON, .colors = { - "33", //yellow - "37" //white + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, }, - .colorKeys = "33", //yellow - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // AmogOS { .names = {"AmogOS"}, .lines = FASTFETCH_DATATEXT_LOGO_AMOGOS, .colors = { - "37", //white - "36" //cyan + FF_COLOR_FG_WHITE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "37", //white - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_CYAN, }, // Anarchy { .names = {"Anarchy"}, .lines = FASTFETCH_DATATEXT_LOGO_ANARCHY, .colors = { - "37", //white - "34" //blue + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, }, - .colorKeys = "37", //white - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_BLUE, }, // Android { .names = {"android"}, .lines = FASTFETCH_DATATEXT_LOGO_ANDROID, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // AndroidSmall { @@ -131,125 +132,125 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ANDROID_SMALL, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // Antergos { .names = {"Antergos"}, .lines = FASTFETCH_DATATEXT_LOGO_ANTERGOS, .colors = { - "34", //blue - "36" //cyan + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "34", //blue - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, }, // Antix { .names = {"antiX"}, .lines = FASTFETCH_DATATEXT_LOGO_ANTIX, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, }, // AoscOsRetro { .names = {"Aosc OS/Retro", "aoscosretro"}, .lines = FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // AoscOsRetro_small { .names = {"Aosc OS/Retro_small", "aoscosretro_small"}, .lines = FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO_SMALL, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // AoscOS { .names = {"Aosc OS", "aoscos"}, .lines = FASTFETCH_DATATEXT_LOGO_AOSCOS, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Aperture { .names = {"Aperture"}, .lines = FASTFETCH_DATATEXT_LOGO_APERTURE, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_WHITE, }, // Apricity { .names = {"Apricity"}, .lines = FASTFETCH_DATATEXT_LOGO_APRICITY, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // ArchBox { .names = {"ArchBox"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCHBOX, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, }, // Archcraft { .names = {"Archcraft"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCHCRAFT, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_RED, }, // Archcraft2 { .names = {"Archcraft2"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCHCRAFT2, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_RED, }, // Arch { .names = {"arch", "archlinux", "arch-linux", "archmerge"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCH, .colors = { - "36", //cyan - "36" //cyan + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // ArchSmall { @@ -257,42 +258,42 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ARCH_SMALL, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // Archlabs { .names = {"ARCHlabs"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCHLABS, .colors = { - "36", //cyan - "31" //red + FF_COLOR_FG_CYAN, + FF_COLOR_FG_RED, }, - .colorKeys = "36", //cyan - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_RED, }, // ArchStrike { .names = {"ArchStrike"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCHSTRIKE, .colors = { - "36", //cyan - "30" //black + FF_COLOR_FG_CYAN, + FF_COLOR_FG_BLACK, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // Artix { .names = {"artix", "artixlinux", "artix-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ARTIX, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // ArtixSmall { @@ -300,10 +301,10 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ARTIX_SMALL, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // Artix2Small { @@ -311,21 +312,21 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ARTIX2_SMALL, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // ArcoLinux { .names = {"arco", "arcolinux", "arco-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ARCO, .colors = { - "34", //blue - "32" //green + FF_COLOR_FG_BLUE, + FF_COLOR_FG_GREEN, }, - .colorKeys = "34", //green - .colorTitle = "34", //green + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // ArcoLinuxSmall { @@ -333,119 +334,119 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ARCO_SMALL, .colors = { - "34", //blue - "32" //green + FF_COLOR_FG_BLUE, + FF_COLOR_FG_GREEN, }, - .colorKeys = "34", //green - .colorTitle = "34", //green + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // ArseLinux { .names = {"arse", "arselinux", "arse-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ARSELINUX, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Arya { .names = {"Arya"}, .lines = FASTFETCH_DATATEXT_LOGO_ARYA, .colors = { - "32", //green - "31" //red + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, }, - .colorKeys = "32", //green - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_RED, }, // Asahi { .names = {"asahi", "asahi-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ASAHI, .colors = { - "33", //yellow - "32", //green - "31", //red + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, "38", //cyan - "37", //magenta - "36", //cyan - "34" //blue + FF_COLOR_FG_WHITE, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, }, // Aster { .names = {"aster"}, .lines = FASTFETCH_DATATEXT_LOGO_ASTER, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // AsteroidOS { .names = {"AsteroidOS"}, .lines = FASTFETCH_DATATEXT_LOGO_ASTEROIDOS, .colors = { - "38;5;160", - "38;5;208", - "38;5;202", - "38;5;214" + FF_COLOR_FG_256 "160", + FF_COLOR_FG_256 "208", + FF_COLOR_FG_256 "202", + FF_COLOR_FG_256 "214" }, - .colorKeys = "38;5;160", - .colorTitle = "38;5;208", + .colorKeys = FF_COLOR_FG_256 "160", + .colorTitle = FF_COLOR_FG_256 "208", }, // AstOS { .names = {"astOS"}, .lines = FASTFETCH_DATATEXT_LOGO_ASTOS, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "37", //white - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, }, // BSD { .names = {"bsd"}, .lines = FASTFETCH_DATATEXT_LOGO_BSD, .colors = { - "31", - "37", - "34", - "33", - "36" + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_CYAN, }, - .colorKeys = "31", - .colorTitle = "37", + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, }, // Bedrock { .names = {"bedrock", "bedrocklinux", "bedrock-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_BEDROCK, .colors = { - "90", //grey - "37" //white + FF_COLOR_FG_LIGHT_BLACK, //grey + FF_COLOR_FG_WHITE, }, - .colorKeys = "90", //grey - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, //grey + .colorTitle = FF_COLOR_FG_WHITE, }, // CachyOS { .names = {"cachy", "cachyos", "cachy-linux", "cachyos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS, .colors = { - "36", //cyan - "32", //green - "30" //black + FF_COLOR_FG_CYAN, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLACK, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // CachyOSSmall { @@ -453,35 +454,35 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // CelOS { .names = {"cel", "celos", "cel-linux", "celos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CELOS, .colors = { - "35", //magenta - "30" //black + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLACK, }, - .colorKeys = "36", //cyan - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, }, // CentOS { .names = {"cent", "centos", "cent-linux", "centos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CENTOS, .colors = { - "33", //yellow - "32", //green - "34", //blue - "35", //magenta - "37" //white + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, }, // CentOSSmall { @@ -489,46 +490,46 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL, .colors = { - "33", //yellow - "32", //green - "34", //blue - "35" //magenta + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "32", //green - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, }, // CRUX { .names = {"crux"}, .lines = FASTFETCH_DATATEXT_LOGO_CRUX, .colors = { - "34", //blue - "35", //magenta - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", - .colorTitle = "34", + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, }, // CrystalLinux { .names = {"crystal", "Crystal", "crystal-linux", "Crystal-Linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CRYSTAL, .colors = { - "35" //magenta + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // Debian { .names = {"debian", "debian-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN, .colors = { - "31", //red - "37" //white + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // DebianSmall { @@ -536,20 +537,20 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // Devuan { .names = {"devuan", "devuan-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN, .colors = { - "35" //magenta + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // DevuanSmall { @@ -557,20 +558,20 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL, .colors = { - "35" //magenta + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // Elementary { .names = {"elementary"}, .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // ElementarySmall { @@ -578,65 +579,65 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Deepin { .names = {"deepin", "deepin-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_DEEPIN, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // Endeavour { .names = {"endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ENDEAVOUR, .colors = { - "35", //magenta - "31", //red - "34" //blue + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLUE, }, - .colorKeys = "35", //magenta - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_RED, }, // Enso { .names = {"enso", "uqc"}, .lines = FASTFETCH_DATATEXT_LOGO_ENSO, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "37", //white - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Exherbo { .names = {"exherbo", "exherbo-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_EXHERBO, .colors = { - "34", //blue - "37", //white - "31" //red + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // Fedora { .names = {"fedora", "fedora-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // FedoraSmall { @@ -644,32 +645,32 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // FedoraOld { .names = {"fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old"}, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_OLD, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // FreeBSD { .names = {"freebsd", "HardenedBSD"}, .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD, .colors = { - "37", //white - "31" //red + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // FreeBSDSmall { @@ -677,30 +678,30 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD_SMALL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // Garuda { .names = {"garuda", "garuda-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // GarudaDragon { .names = {"garudadragon", "garuda-dragon", "garuda-linux-dragon"}, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_DRAGON, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // GarudaSmall { @@ -708,21 +709,21 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // Gentoo { .names = {"gentoo", "gentoo-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_GENTOO, .colors = { - "35", //magenta - "37" //white + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // GentooSmall { @@ -730,54 +731,54 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL, .colors = { - "35", //magenta - "37" //white + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // GhostBSD { .names = {"ghostbsd"}, .lines = FASTFETCH_DATATEXT_LOGO_GHOSTBSD, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_RED, }, // Gnome { .names = {"Gnome"}, .lines = FASTFETCH_DATATEXT_LOGO_GNOME, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_RED, }, // GNU { .names = {"GNU"}, .lines = FASTFETCH_DATATEXT_LOGO_GNU, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "37", //white - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_RED, }, // Haiku { .names = {"Haiku"}, .lines = FASTFETCH_DATATEXT_LOGO_HAIKU, .colors = { - "31", //red - "33", //yellow - "37", //white - "32" //green + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_GREEN, }, - .colorKeys = "31", //red - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, }, // HaikuSmall { @@ -785,66 +786,66 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, }, // KDENeon { .names = {"kde", "kde-neon", "neon"}, .lines = FASTFETCH_DATATEXT_LOGO_KDE, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // KISSLinux { .names = {"kiss", "kiss-linux", "kisslinux"}, .lines = FASTFETCH_DATATEXT_LOGO_KISS, .colors = { - "35", //magenta - "37", //white - "34" //blue + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, }, - .colorKeys = "35", //magenta - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, }, // Kubuntu { .names = {"kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma"}, .lines = FASTFETCH_DATATEXT_LOGO_KUBUNTU, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // LangitKetujuh { .names = {"langitketujuh", "l7"}, .lines = FASTFETCH_DATATEXT_LOGO_LANGITKETUJUH, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // Linux { .names = {"linux", "linux-generic"}, .lines = FASTFETCH_DATATEXT_LOGO_LINUX, .colors = { - "37", //white - "30", //black - "33" //yellow + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLACK, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "37", //white - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, }, // LinuxSmall { @@ -852,37 +853,37 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_LINUX_SMALL, .colors = { - "30", //black - "37", //white - "33" //yellow + FF_COLOR_FG_BLACK, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "37", //white - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, }, // LMDE { .names = {"LMDE"}, .lines = FASTFETCH_DATATEXT_LOGO_LMDE, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, }, // MacOS { .names = {"macos", "mac", "apple", "darwin", "osx"}, .lines = FASTFETCH_DATATEXT_LOGO_MACOS, .colors = { - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, }, // MacOSSmall { @@ -890,28 +891,28 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, .colors = { - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, }, // MacOS2 { .names = {"macos2", "mac2", "apple2", "darwin2", "osx2"}, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2, .colors = { - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, }, // MacOS2Small { @@ -919,35 +920,35 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL, .colors = { - "32", //green - "33", //yellow - "31", //red - "35", //magenta - "34" //blue + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, }, // Mandriva { .names = {"mandriva", "mandrake"}, .lines = FASTFETCH_DATATEXT_LOGO_MANDRIVA, .colors = { - "34", //blue - "33" //yellow + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "34", //blue - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_YELLOW, }, // Manjaro { .names = {"manjaro", "manjaro-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_MANJARO, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // ManjaroSmall { @@ -955,33 +956,33 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MANJARO_SMALL, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // Minix { .names = {"minix"}, .lines = FASTFETCH_DATATEXT_LOGO_MINIX, .colors = { - "31", //red - "37", //white - "33" //yellow + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "31", //red - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, }, // Mint { .names = {"mint", "linuxmint", "mint-linux", "linux-mint"}, .lines = FASTFETCH_DATATEXT_LOGO_MINT, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // MintSmall { @@ -989,47 +990,47 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // MintOld { .names = {"mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old"}, .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // Msys2 { .names = {"msys2"}, .lines = FASTFETCH_DATATEXT_LOGO_MSYS2, .colors = { - "35", //magenta - "37", //white - "31" //red + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, }, - .colorKeys = "35", //magenta - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_RED, }, // Windows11 { .names = {"Windows 11", "Windows Server 2022"}, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11, .colors = { - "34", //blue - "34", //blue - "34", //blue - "34" //blue + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_CYAN, }, // Windows11Small { @@ -1037,73 +1038,73 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "33", //yellow - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_CYAN, }, // Windows8 { .names = {"Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019"}, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_8, .colors = { - "36", //cyan - "36", //cyan - "36", //cyan - "36" //cyan + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, }, - .colorKeys = "33", //yellow - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // Windows { .names = {"Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2"}, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS, .colors = { - "31", //red - "32", //green - "34", //blue - "33" //yellow + FF_COLOR_FG_RED, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "34", //blue - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_GREEN, }, // Windows95 { .names = {"Windows 95", "Windows 9x"}, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_95, .colors = { - "36", //cyan - "34", //blue - "33", //yellow - "32", //green - "31", //red - "30" //black + FF_COLOR_FG_CYAN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLACK, }, - .colorKeys = "36", //cyan - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, }, // NixOS { .names = {"nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"}, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS, .colors = { - "34", //blue - "36" //cyan + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, }, // NixOsOld { .names = {"nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old"}, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_OLD, .colors = { - "34", //blue - "36" //cyan + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, }, // NixOsSmall { @@ -1111,85 +1112,85 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // MX { .names = {"mx"}, .lines = FASTFETCH_DATATEXT_LOGO_MX, .colors = { - "37" // white + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", // blue - .colorTitle = "36", // cyan + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, }, // MXSmall { .names = {"mx_small", "mx-small"}, .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, .colors = { - "37" // white + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", // blue - .colorTitle = "36", // cyan + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, }, // NetBSD { .names = {"netbsd"}, .lines = FASTFETCH_DATATEXT_LOGO_NETBSD, .colors = { - "35", // blue - "37" // white + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, }, - .colorKeys = "35", // blue - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_WHITE, }, // Nobara { .names = {"nobara", "nobara-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_NOBARA, .colors = { - "37" // white + FF_COLOR_FG_WHITE, }, - .colorKeys = "37", // white - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, }, // NomadBSD { .names = {"nomadbsd"}, .lines = FASTFETCH_DATATEXT_LOGO_NOMADBSD, .colors = { - "34" // blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", // blue - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // OpenKylin { .names = {"openkylin", "open-kylin"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENKYLIN, .colors = { - "32", // cyan - "37" // white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", // cyan - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, }, // OpenBSD { .names = {"openbsd"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENBSD, .colors = { - "33", // blue - "37", // white - "36", // yellow - "31" // red + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_RED, }, - .colorKeys = "33", // blue - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // OpenBSDSmall { @@ -1197,22 +1198,22 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL, .colors = { - "33", // blue - "37" // white + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, }, - .colorKeys = "33", // blue - .colorTitle = "37", // white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // OpenSuse { .names = {"suse", "opensuse", "open_suse", "open-suse", "suse-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // OpenSuseSmall { @@ -1220,82 +1221,82 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // OpenSuseLeap { .names = {"opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // OpenSuseTumbleweed { .names = {"opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // OpenSuseTumbleweed2 { .names = {"opensuse_tumbleweed2"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2, .colors = { - "37" //white + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // OpenMandriva { .names = {"openmandriva", "open-mandriva", "open_mandriva"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENMANDRIVA, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // OpenWrt { .names = {"openwrt"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENWRT, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Oracle { .names = {"oracle", "oracle linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ORACLE, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, }, // Orchid { .names = {"orchid"}, .lines = FASTFETCH_DATATEXT_LOGO_ORCHID, .colors = { - "37", //white - "35", //magenta - "35" //magenta + FF_COLOR_FG_WHITE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "37", //white - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // OrchidSmall { @@ -1303,22 +1304,22 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ORCHID_SMALL, .colors = { - "37", //white - "35", //magenta - "35" //magenta + FF_COLOR_FG_WHITE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "37", //white - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // Parabola { .names = {"parabola", "parabola-gnulinux"}, .lines = FASTFETCH_DATATEXT_LOGO_PARABOLA, .colors = { - "35" //magenta + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // ParabolaSmall { @@ -1326,21 +1327,21 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_PARABOLA_SMALL, .colors = { - "35" //magenta + FF_COLOR_FG_MAGENTA, }, - .colorKeys = "35", //magenta - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // Pop { .names = {"pop", "popos", "pop_os", "pop-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_POP, .colors = { - "36", //cyan - "37" //white + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // PopSmall { @@ -1348,20 +1349,20 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_POP_SMALL, .colors = { - "36" //cyan + FF_COLOR_FG_CYAN, }, - .colorKeys = "36", //cyan - .colorTitle = "36", //cyan + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, }, // Raspbian { .names = {"raspbian", "raspi", "raspberrypi", "raspberrypios", "pios"}, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN, .colors = { - "31", //red - "32" //green + FF_COLOR_FG_RED, + FF_COLOR_FG_GREEN, }, - .colorKeys = "31", //red - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_GREEN, }, // RaspbianSmall { @@ -1369,22 +1370,22 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL, .colors = { - "31", //red - "32" //green + FF_COLOR_FG_RED, + FF_COLOR_FG_GREEN, }, - .colorKeys = "31", //red - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_GREEN, }, // Reborn { .names = {"reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_REBORN, .colors = { - "34", //blue - "36" //cyan + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // RebornSmall { @@ -1392,72 +1393,72 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_REBORN_SMALL, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // RedHatEnterpriseLinux { .names = {"rhel", "redhat", "redhat-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_RHEL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // RedstarOS { .names = {"redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_REDSTAR, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // RockyLinux { .names = {"rocky", "rocky-linux", "rockylinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ROCKY, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "32", //green - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, }, // RosaLinux { .names = {"rosa", "rosa-linux", "rosalinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ROSA, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // Proxmox { .names = {"proxmox"}, .lines = FASTFETCH_DATATEXT_LOGO_PROXMOX, .colors = { - "37", //blue - "38;5;202" + FF_COLOR_FG_WHITE, + FF_COLOR_FG_256 "202" }, - .colorKeys = "37", //white - .colorTitle = "38;5;202", //white + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_256 "202", }, // Slackware { .names = {"slackware", "slackware-linux", "slackwarelinux"}, .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // SlackwareSmall { @@ -1465,21 +1466,21 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE_SMALL, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // Solaris { .names = {"solaris", "sunos"}, .lines = FASTFETCH_DATATEXT_LOGO_SOLARIS, .colors = { - "33" //green + FF_COLOR_FG_YELLOW, }, - .colorKeys = "33", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // SolarisSmall { @@ -1487,102 +1488,102 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL, .colors = { - "33" //green + FF_COLOR_FG_YELLOW, }, - .colorKeys = "33", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, }, // Solus { .names = {"solus", "solus-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_SOLUS, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // SteamOS { .names = {"steamos"}, .lines = FASTFETCH_DATATEXT_LOGO_STEAMOS, .colors = { - "34", //blue - "37" //white + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, // Ubuntu { .names = {"ubuntu", "ubuntu-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU, .colors = { - "31", //red - "37" //white + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // UbuntuBudgie { .names = {"ubuntu-budgie"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_BUDGIE, .colors = { - "34", //blue - "37", //white - "31" //red + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, }, - .colorKeys = "34", //blue - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, }, // UbuntuGnome { .names = {"ubuntu-gnome"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME, .colors = { - "34", //blue - "35", //magenta - "37", //white - "36" //cyan + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_CYAN, }, - .colorKeys = "34", //blue - .colorTitle = "35", //magenta + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_MAGENTA, }, // UbuntuKylin { .names = {"ubuntu kylin", "ubuntu-kylin"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_KYLIN, .colors = { - "31", //red - "37", //white - "33" //yellow + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, }, - .colorKeys = "31", //red - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, }, // UbuntuMate { .names = {"ubuntu mate", "ubuntu-mate"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_MATE, .colors = { - "32", //green - "37" //white + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, }, - .colorKeys = "32", //green - .colorTitle = "37", //white + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, }, // UbuntuOld { .names = {"ubuntu_old", "ubuntu-linux_old"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_OLD, .colors = { - "31", //red - "37" //white + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // UbuntuSmall { @@ -1590,10 +1591,10 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_SMALL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // Ubuntu2Small { @@ -1601,41 +1602,41 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "31", //red - .colorTitle = "31", //red + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, }, // UOS { .names = {"UOS"}, .lines = FASTFETCH_DATATEXT_LOGO_UOS, .colors = { - "31" //red + FF_COLOR_FG_RED, }, - .colorKeys = "37", //white - .colorTitle = "33", //yellow + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_YELLOW, }, // Vanilla { .names = {"vanilla", "vanilla-os", "vanilla-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_VANILLA, .colors = { - "33" //yellow + FF_COLOR_FG_YELLOW, }, - .colorKeys = "33", // yellow - .colorTitle = "33", // yellow + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_YELLOW, }, // Void { .names = {"void", "void-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_VOID, .colors = { - "32", //green - "30" //black + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLACK, }, - .colorKeys = "37", //white - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_GREEN, }, // VoidSmall { @@ -1643,20 +1644,20 @@ const FFlogo ffLogoBuiltins[] = { .small = true, .lines = FASTFETCH_DATATEXT_LOGO_VOID_SMALL, .colors = { - "32" //green + FF_COLOR_FG_GREEN, }, - .colorKeys = "37", //white - .colorTitle = "32", //green + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_GREEN, }, // Zorin { .names = {"zorin", "zorin-linux", "zorinos", "zorinos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ZORIN, .colors = { - "34" //blue + FF_COLOR_FG_BLUE, }, - .colorKeys = "34", //blue - .colorTitle = "34", //blue + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, }, }; From f65959506647c0eb5fe15ca04d55d7a5af546ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 3 Aug 2023 15:32:16 +0800 Subject: [PATCH 416/493] Logo (Builtin): more 170 left, sigh --- src/logo/ascii/astra_linux.txt | 22 ++ src/logo/ascii/athena.txt | 24 ++ src/logo/ascii/biglinux.txt | 19 ++ src/logo/ascii/bitrig.txt | 17 ++ src/logo/ascii/blackarch.txt | 21 ++ src/logo/ascii/blackpanther.txt | 23 ++ src/logo/ascii/blag.txt | 17 ++ src/logo/ascii/blankon.txt | 17 ++ src/logo/ascii/bluelight.txt | 19 ++ src/logo/ascii/bodhi.txt | 18 ++ src/logo/ascii/bonsai.txt | 16 ++ src/logo/ascii/bunsenlabs.txt | 20 ++ src/logo/ascii/calculate.txt | 20 ++ src/logo/ascii/calinixos.txt | 25 ++ src/logo/ascii/calinixos_small.txt | 15 ++ src/logo/ascii/carbs.txt | 18 ++ src/logo/ascii/cbl_mariner.txt | 18 ++ src/logo/ascii/center.txt | 13 + src/logo/ascii/chakra.txt | 18 ++ src/logo/ascii/chaletos.txt | 20 ++ src/logo/ascii/chapeau.txt | 18 ++ src/logo/ascii/chonkysealos.txt | 21 ++ src/logo/ascii/chrom.txt | 18 ++ src/logo/ascii/cleanjaro.txt | 12 + src/logo/ascii/cleanjaro_small.txt | 7 + src/logo/ascii/clear_linux.txt | 20 ++ src/logo/ascii/clearos.txt | 20 ++ src/logo/ascii/clover.txt | 20 ++ src/logo/ascii/cobalt.txt | 16 ++ src/logo/ascii/condres.txt | 17 ++ src/logo/ascii/container_linux.txt | 20 ++ src/logo/ascii/crux_small.txt | 7 + src/logo/ascii/cucumber.txt | 20 ++ src/logo/ascii/cutefishos.txt | 9 + src/logo/ascii/cuteos.txt | 14 + src/logo/builtin.c | 420 +++++++++++++++++++++++++++-- 36 files changed, 1023 insertions(+), 16 deletions(-) create mode 100644 src/logo/ascii/astra_linux.txt create mode 100644 src/logo/ascii/athena.txt create mode 100644 src/logo/ascii/biglinux.txt create mode 100644 src/logo/ascii/bitrig.txt create mode 100644 src/logo/ascii/blackarch.txt create mode 100644 src/logo/ascii/blackpanther.txt create mode 100644 src/logo/ascii/blag.txt create mode 100644 src/logo/ascii/blankon.txt create mode 100644 src/logo/ascii/bluelight.txt create mode 100644 src/logo/ascii/bodhi.txt create mode 100644 src/logo/ascii/bonsai.txt create mode 100644 src/logo/ascii/bunsenlabs.txt create mode 100644 src/logo/ascii/calculate.txt create mode 100644 src/logo/ascii/calinixos.txt create mode 100644 src/logo/ascii/calinixos_small.txt create mode 100644 src/logo/ascii/carbs.txt create mode 100644 src/logo/ascii/cbl_mariner.txt create mode 100644 src/logo/ascii/center.txt create mode 100644 src/logo/ascii/chakra.txt create mode 100644 src/logo/ascii/chaletos.txt create mode 100644 src/logo/ascii/chapeau.txt create mode 100644 src/logo/ascii/chonkysealos.txt create mode 100644 src/logo/ascii/chrom.txt create mode 100644 src/logo/ascii/cleanjaro.txt create mode 100644 src/logo/ascii/cleanjaro_small.txt create mode 100644 src/logo/ascii/clear_linux.txt create mode 100644 src/logo/ascii/clearos.txt create mode 100644 src/logo/ascii/clover.txt create mode 100644 src/logo/ascii/cobalt.txt create mode 100644 src/logo/ascii/condres.txt create mode 100644 src/logo/ascii/container_linux.txt create mode 100644 src/logo/ascii/crux_small.txt create mode 100644 src/logo/ascii/cucumber.txt create mode 100644 src/logo/ascii/cutefishos.txt create mode 100644 src/logo/ascii/cuteos.txt diff --git a/src/logo/ascii/astra_linux.txt b/src/logo/ascii/astra_linux.txt new file mode 100644 index 000000000..97b7bc686 --- /dev/null +++ b/src/logo/ascii/astra_linux.txt @@ -0,0 +1,22 @@ + AA + AaaA + Aa${c2}/\\${c1}aA +${c1} Aa${c2}/${c1}aa${c2}\\${c1}aA +${c1} Aa${c2}/${c1}aAAa${c2}\\${c1}aA +${c1} aA${c2}/${c1}aaAAaa${c2}\\${c1}Aa +${c1} aA${c2}/${c1}aaAAAAaa${c2}\\${c1}Aa +${c1} aaaaaaAAAAa${c2}/${c1}aaAAAAAAaa${c2}\\${c1}aAAAAaaaaa +${c1}aAAa${c2}-----${c1}aaaaaAAAAAAAAAAaaaaa${c2}-----${c1}aAAa +${c1} aAA${c2}\ ${c1}aAAAAAAAAAAAAAAAAAAAAAAa${c2} /${c1}AAa +${c1} aAa${c2}\\${c1}aAAA${c2}\\${c1}AAAA${c2}\\${c1}AAAA${c2}\\${c1}AAA${c2}\\${c1}AAa${c2}/${c1}aAa +${c1} aAa${c2}\\${c1}aA${c2}\\\\${c1}AAA${c2}\\\\${c1}AAA${c2}\\\\${c1}AA${c2}\\\\/${c1}aAa +${c1} aAA${c2}\\${c1}aA${c2}\\\\${c1}AAA${c2}\\\\${c1}AAA${c2}\\\\${c1}Aa${c2}/${c1}AAa +${c1} aA${c2}\\${c1}aA${c2}\\\\${c1}AAA${c2}\\\\${c1}AAA${c2}\\\\/${c1}Aa +${c1} aA${c2}/${c1}AA${c2}\\\\\\${c1}AA${c2}\\\\\\${c1}AA${c2}\\\\\\${c1}Aa +${c1} aA${c2}/\\${c1}AAa${c2}\\\\\\${c1}Aa${c2}\\\\\\${c1}Aa${c2}\\\\\\${c1}Aa +${c1} aA${c2}/\\\\${c1}AAa${c2}\\\\/\\${c1}a${c2}\\\\\\${c1}Aa${c2}\\\\${c1}Aa +${c1} aA${c2}/${c1}a${c2}\\\\\\${c1}Aa${c2}\\/${c1}AA${c2}\\\\\\\\\\${c1}Aa${c2}\\\\${c1}Aa +${c1} aA${c2}/${c1}aA${c2}\\\\/${c1}aAa aAa${c2}\\\\\\${c1}Aa${c2}\\${c1}Aa +${c1} aA${c2}/\\${c1}A${c2}\\/${c1}Aa aA${c2}\\\\${c1}A${c2}\\\\${c1}Aa +${c1} A${c2}|/${c1}aaAa aAaa${c2}\\|${c1}A +${c1} aAaa aaAa diff --git a/src/logo/ascii/athena.txt b/src/logo/ascii/athena.txt new file mode 100644 index 000000000..1cbd3145b --- /dev/null +++ b/src/logo/ascii/athena.txt @@ -0,0 +1,24 @@ +${c1} . .. +${c1} :####: ####. +${c1} .################ +${c1} :################## +${c1}.###################. +${c1}######## ####### +${c1}####### ${c2}####${c1} ##### +${c1}:#######. #### +${c1} ######### ${c2}#${c1} ## # +${c1} ####### ${c2}##${c1} #### +${c1}######## ${c2}####${c1} ####### +${c1}######## ${c2}#####${c1} ######## +${c1}######## ${c2}#######${c1} ####### +${c1} ####### ${c2}########${c1} ####### +${c1} ######## ${c2}#########${c1} ###### +${c1} ######## ${c2}#########${c1} ##### +${c1} ####### ${c2}#########${c1} #### +${c1} ####### ${c2}#########${c1} ## +${c1} ####### ${c2}########${c1} ## +${c1} ###### ${c2}########${c1} # +${c1} ### ${c2}#######${c1} +${c1} ${c2}######${c1} +${c1} ${c2}####${c1} +${c1} ${c2}##${c1} diff --git a/src/logo/ascii/biglinux.txt b/src/logo/ascii/biglinux.txt new file mode 100644 index 000000000..3570e8588 --- /dev/null +++ b/src/logo/ascii/biglinux.txt @@ -0,0 +1,19 @@ + ... + :OWMMMNd. + :NMMMMMMMMWc + okkl. kMMMMMW0xdOWMl + : xMMMMMW. kMMMMNc lW. + :x NMMMMMO ,MMMM0. 'l + Xx "lkk" kMMMX .okx, +${c2}.MX .cc;. .xXKx. KMMM: .OMMMMMl +:MM' 'KMMMMWK: 0MMMMk xMMM. lWMMMMMMM' +cMMN:;xMMMMk::MMO oMMMMX .XMM. .KMMMWOOMMMd +'MMMMMMMMN, NMMx OMMMMl .kM0OMMMMk. ;MMd + xMMMMMMd .MMMW :NMMMd .ckKKx' KMc + dWMNd. oMMMN lkNMX, oM. + ;. ;MMMMx "MM:. cO +${c3} .X. oMMMMW. l. + dMk:..;xWMMMMW, + kMMMMMMMMMMX. + :XMMMMMMK: + ':MM:" Made in Brazil diff --git a/src/logo/ascii/bitrig.txt b/src/logo/ascii/bitrig.txt new file mode 100644 index 000000000..c360216ff --- /dev/null +++ b/src/logo/ascii/bitrig.txt @@ -0,0 +1,17 @@ + `hMMMMN+ + -MMo-dMd` + oMN- oMN` + yMd /NM: + .mMmyyhMMs + :NMMMhsmMh + +MNhNNoyMm- + hMd.-hMNMN: + mMmsssmMMMo + .MMdyyhNMMMd + oMN.`/dMddMN` + yMm/hNm+./MM/ +.dMMMmo.``.NMo +:NMMMNmmmmmMMh +/MN/-------oNN: +hMd. .dMh +sm/ /ms diff --git a/src/logo/ascii/blackarch.txt b/src/logo/ascii/blackarch.txt new file mode 100644 index 000000000..d8dd4afc4 --- /dev/null +++ b/src/logo/ascii/blackarch.txt @@ -0,0 +1,21 @@ +${c3} 00 + 11 + ====${c1} + .${c3}//${c1} + `o${c3}//${c1}: + `+o${c3}//${c1}o: + `+oo${c3}//${c1}oo: + -+oo${c3}//${c1}oo+: + `/:-:+${c3}//${c1}ooo+: + `/+++++${c3}//${c1}+++++: + `/++++++${c3}//${c1}++++++: + `/+++o${c2}ooo${c3}//${c2}ooo${c1}oooo/` +${c2} ${c1}./${c2}ooosssso${c3}//${c2}osssssso${c1}+` +${c2} .oossssso-`${c3}//${c1}`/ossssss+` + -osssssso. ${c3}//${c1} :ssssssso. + :osssssss/ ${c3}//${c1} osssso+++. + /ossssssss/ ${c3}//${c1} +ssssooo/- + `/ossssso+/:- ${c3}//${c1} -:/+osssso+- + `+sso+:-` ${c3}//${c1} `.-/+oso: + `++:. ${c3}//${c1} `-/+/ + .` ${c3}/${c1} `/ diff --git a/src/logo/ascii/blackpanther.txt b/src/logo/ascii/blackpanther.txt new file mode 100644 index 000000000..e14329fb6 --- /dev/null +++ b/src/logo/ascii/blackpanther.txt @@ -0,0 +1,23 @@ +${c3} ........ + .,»╔╗╗╬▄▄╫█▀▓▄▄╬╗╗g≈,. + ,j╗╬╣▓▓███████▌;»╙▀▀▀▀█▄▄╗j, + .≈╗╬▓██▀▀▀▀▀╠╙░░»»;:`${c2}``>${c1}▄ ${c3}▐ ▓╫╗⌂, + .j╬▓█▀▒░░░░░░░░░»»»;:```` ╙▀█▌╬░, + ;╗▓█▄▄███████▀░░»»»»;```` ╓▄▄█▄▄φ ██▌Ñ>. + .j╣█████▀▀░░░░░░░░»»╓▄▄¿``▄███████/▄████▓╬U. + .j╣▓██▀ÜÑ╦╦░░░░░░▐█@▄████⌐▐███████████████▓╬H. + «╫▓█▀░ÑÑ╩╦░░░░░░░░▀██████M"▀███████████████▓╫░ + :]╣█▌ÑÑÑÑ▄▄██▀░░░░»»██████████████████████████Ñ~ + »╫▓█╫ÑÑ▄███▀░░░░░»»▐██████████████████████████▌░ + `j╣█▌Ñ╬████░░░░░░░»»▐████████████████████████▌▐█U` + `/╫█▌▄███▌░░░░░░░»»»;▀██████████████▀████████w▐█░` + ;╟█▌███▌░░░░░░░▄▄»»;:`▀▀████████▀Ü▄████████▌ ▐▌>` + `]▓████░░░░░░░░██⌂;:````╓▄▄µp╓▄▄██████████▀ ,█M` + "╠╣██▌░░░░░░░»██▌;```` ╙▀██████████████M █▀" + "╟╣█░░░░░░░░»███⌂``` ▐▀████████▀░ █▌░` + "╩█▄░░░░░░»»▀███ `` └└` ,█▀"` + `░▀█▄░░░»»»»████@ .▄█Ü` + `╙▀█▄@»»»;`▀███▌¿ ,▄▀Ñ"` + `"╨▀█▄▄▄░`▐█████▄, ,▄▄▀▀░` + `"╙╩▀▀▀▀████████▓▌▌▌▀▀▀╨"`` + ``""░╚╨╝╝╝╝╨╨░""`` diff --git a/src/logo/ascii/blag.txt b/src/logo/ascii/blag.txt new file mode 100644 index 000000000..1275cf657 --- /dev/null +++ b/src/logo/ascii/blag.txt @@ -0,0 +1,17 @@ + d + ,MK: + xMMMX: + .NMMMMMX; + lMMMMMMMM0clodkO0KXWW: + KMMMMMMMMMMMMMMMMMMX' + .;d0NMMMMMMMMMMMMMMMMMMK. + .;dONMMMMMMMMMMMMMMMMMMMMMMx +'dKMMMMMMMMMMMMMMMMMMMMMMMMl + .:xKWMMMMMMMMMMMMMMMMMMM0. + .:xNMMMMMMMMMMMMMMMMMK. + lMMMMMMMMMMMMMMMMMMK. + ,MMMMMMMMWkOXWMMMMMM0 + .NMMMMMNd. `':ldko + OMMMK: + oWk, + ;: diff --git a/src/logo/ascii/blankon.txt b/src/logo/ascii/blankon.txt new file mode 100644 index 000000000..43bbd7865 --- /dev/null +++ b/src/logo/ascii/blankon.txt @@ -0,0 +1,17 @@ +${c2} `./ohdNMMMMNmho+.` ${c1} .+oo:` +${c2} -smMMMMMMMMMMMMMMMMmy-` ${c1}`yyyyy+ +${c2} `:dMMMMMMMMMMMMMMMMMMMMMMd/` ${c1}`yyyyys +${c2} .hMMMMMMMNmhso/++symNMMMMMMMh- ${c1}`yyyyys +${c2} -mMMMMMMms-` -omMMMMMMN-${c1}.yyyyys +${c2}.mMMMMMMy. .yMMMMMMm:${c1}yyyyys +${c2}sMMMMMMy `sMMMMMMh${c1}yyyyys +${c2}NMMMMMN: .NMMMMMN${c1}yyyyys +${c2}MMMMMMm. NMMMMMN${c1}yyyyys +${c2}hMMMMMM+ /MMMMMMN${c1}yyyyys +${c2}:NMMMMMN: :mMMMMMM+${c1}yyyyys +${c2} oMMMMMMNs- .sNMMMMMMs.${c1}yyyyys +${c2} +MMMMMMMNho:.` `.:ohNMMMMMMNo ${c1}`yyyyys +${c2} -hMMMMMMMMNNNmmNNNMMMMMMMMh- ${c1}`yyyyys +${c2} :yNMMMMMMMMMMMMMMMMMMNy:` ${c1}`yyyyys +${c2} .:sdNMMMMMMMMMMNds/. ${c1}`yyyyyo +${c2} `.:/++++/:.` ${c1}:oys+. diff --git a/src/logo/ascii/bluelight.txt b/src/logo/ascii/bluelight.txt new file mode 100644 index 000000000..05eba637c --- /dev/null +++ b/src/logo/ascii/bluelight.txt @@ -0,0 +1,19 @@ + oMMNMMMMMMMMMMMMMMMMMMMMMM + oMMMMMMMMMMMMMMMMMMMMMMMMM + oMMMMMMMMMMMMMMMMMMMMMMMMM + oMMMMMMMMMMMMMMMMMMMMMMMMM + -+++++++++++++++++++++++mM${c2} + ```````````````````````..${c1}dM${c2} + ```````````````````````....${c1}dM${c2} + ```````````````````````......${c1}dM${c2} + ```````````````````````........${c1}dM${c2} + ```````````````````````..........${c1}dM${c2} + ```````````````````````............${c1}dM${c2} +.::::::::::::::::::::::-..............${c1}dM${c2} + `-+yyyyyyyyyyyyyyyyyyyo............${c1}+mMM${c2} + -+yyyyyyyyyyyyyyyyo..........${c1}+mMMMM${c2} + ./syyyyyyyyyyyyo........${c1}+mMMMMMM${c2} + ./oyyyyyyyyyo......${c1}+mMMMMMMMM${c2} + omdyyyyyyo....${c1}+mMMMMMMMMMM${c2} + ${c1}oMMM${c2}mdhyyo..${c1}+mMMMMMMMMMMMM + oNNNNNNm${c2}dso${c1}mMMMMMMMMMMMMMM diff --git a/src/logo/ascii/bodhi.txt b/src/logo/ascii/bodhi.txt new file mode 100644 index 000000000..6b49f9b3e --- /dev/null +++ b/src/logo/ascii/bodhi.txt @@ -0,0 +1,18 @@ +${c1}| ${c2},,mmKKKKKKKKWm,, + ${c1}' ${c2},aKKP${c1}LL**********|L*${c2}TKp, + ${c1}t ${c2}aKP${c1}L**``` ```**L${c2}*Kp + IX${c1}EL${c3}L,wwww, ${c1}``*||${c2}Kp + ,#P${c1}L|${c3}KKKpPP@IPPTKmw, ${c1}`*||${c2}K + ,K${c1}LL*${c3}{KKKKKKPPb$KPhpKKPKp ${c1}`||${c2}K + #${c1}PL ${c3}!KKKKKKPhKPPP$KKEhKKKKp ${c1}`||${c2}K +!H${c1}L* ${c3}1KKKKKKKphKbPKKKKKK$KKp ${c1}`|I${c2}W +$$$${c1}bL ${c3}KKKKKKKKBQKhKbKKKKKKKK ${c1}|I${c2}N +$$$${c1}bL ${c3}!KKKKKKKKKKNKKKKKKKPP` ${c1}|I${c2}b +TH${c1}L* ${c3}TKKKKKK##KKKN@KKKK^ ${c1}|I${c2}M + K@${c1}L ${c3}*KKKKKKKKKKKEKE5 ${c1}||${c2}K + `NL${c1}L ${c3}`KKKKKKKKKK"```|L ${c1}||${c2}#P + `K@${c1}LL ${c3}`"**"` ${c1}'. :||${c2}#P + Yp${c1}LL ${c1}' |L${c2}$M` + `Tp${c1}pLL, ,|||${c2}p'L + "Kpp${c1}LL++,., ,,|||$$$${c2}#K* ${c1}'. + ${c2}`"MKWpppppppp#KM"` ${c1}`h, diff --git a/src/logo/ascii/bonsai.txt b/src/logo/ascii/bonsai.txt new file mode 100644 index 000000000..4dbc8d5ea --- /dev/null +++ b/src/logo/ascii/bonsai.txt @@ -0,0 +1,16 @@ +${c2} ,####, + ${c2}#######, ${c2},#####, + ${c2}#####',# ${c2}'###### + ${c2}''###'${c3}';,,,'${c2}###' + ${c3} ,; '''' + ${c3} ;;; ${c2},#####, + ${c3} ;;;' ,,;${c2};;### + ${c3} ';;;;''${c2}'####' + ${c3} ;;; + ${c3} ,.;;';'',,, + ${c3} ' ' +${c1} # + # O + ##, ,##,',##, ,## ,#, , + # # # # #''# #,, # # # + '#' '##' # # ,,# '##;, # diff --git a/src/logo/ascii/bunsenlabs.txt b/src/logo/ascii/bunsenlabs.txt new file mode 100644 index 000000000..218c417f8 --- /dev/null +++ b/src/logo/ascii/bunsenlabs.txt @@ -0,0 +1,20 @@ + `++ + -yMMs + `yMMMMN` + -NMMMMMMm. + :MMMMMMMMMN- + .NMMMMMMMMMMM/ + yMMMMMMMMMMMMM/ +`MMMMMMNMMMMMMMN. +-MMMMN+ /mMMMMMMy +-MMMm` `dMMMMMM +`MMN. .NMMMMM. + hMy yMMMMM` + -Mo +MMMMN + /o +MMMMs + +MMMN` + hMMM: + `NMM/ + +MN: + mh. + -/ diff --git a/src/logo/ascii/calculate.txt b/src/logo/ascii/calculate.txt new file mode 100644 index 000000000..86f4974d7 --- /dev/null +++ b/src/logo/ascii/calculate.txt @@ -0,0 +1,20 @@ + ...... + ,,+++++++,. + .,,,....,,,${c2}+**+,,.${c1} + ............,${c2}++++,,,${c1} + ............... + ......,,,........ + .....+*#####+,,,*+. + .....,*###############,..,,,,,,.. + ......,*#################*..,,,,,..,,,.. + .,,....*####################+***+,,,,...,++, + .,,..,..*#####################*, + ,+,.+*..*#######################. + ,+,,+*+..,########################* +.,++++++. ..+##**###################+ +..... ..+##***#################*. + .,.*#*****##############*. + ..,,*********#####****+. + ${c2}.,++*****+++${c1}*****************${c2}+++++,.${c1} + ${c2},++++++**+++++${c1}***********${c2}+++++++++,${c1} + ${c2}.,,,,++++,.. .,,,,,.....,+++,.,,${c1} diff --git a/src/logo/ascii/calinixos.txt b/src/logo/ascii/calinixos.txt new file mode 100644 index 000000000..85475c52b --- /dev/null +++ b/src/logo/ascii/calinixos.txt @@ -0,0 +1,25 @@ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⠤⠔⠒⠒⠋⠉⠉⠉⠉⠓⠒⠒⠦⠤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠒⠉⣁⣠⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣤⣄⣈⠙⠲⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠴⠋⢁⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⡈⠑⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⢀⠞⠁⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠋⠉⠁⠀⠀⠀⠀⠈⠉⠙⠛⠿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠈⢢⡀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⡰⠃⣠⣾⣿⣿⣿⣿⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⢿⡿⠁⠀⠀⠀⠀⠀⠀⠙⣄⠀⠀⠀⠀ +⠀⠀⠀⡼⠁⣴⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢆⠀⠀⠀ +⠀⠀⡼⠀⣼⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣆⠀⠀ +⠀⣰⠁⣸⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠉⠻⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄⠀ +⢀⡇⢠⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⢿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀ +⢸⠀⣸⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄ +⣼⠀⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ +⡇⠀⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢛⣿⣿⣿⣿⣿⣿⣿⡦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ +⢻⠀⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ +⢸⡀⢹⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠃ +⠀⣇⠘⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠀ +⠀⠸⡄⢹⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠃⠀ +⠀⠀⢳⡀⢻⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠏⠀⠀ +⠀⠀⠀⠳⡀⠻⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣷⣄⡀⠀⠀⠀⠀⢠⠏⠀⠀⠀ +⠀⠀⠀⠀⠙⣄⠙⢿⣿⣿⣿⣿⣿⣿⣷⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣾⣿⣿⣿⣿⣿⣦⡀⠀⡰⠃⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠈⠢⡈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣄⣀⡀⠀⠀⠀⠀⢀⣀⣠⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⣠⠞⠁⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠈⠢⡈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣡⠞⠁⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⢤⡈⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⣁⠴⠊⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⢄⣉⠙⠛⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠛⠋⣉⡤⠖⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠓⠒⠢⠤⠤⠤⠤⠤⠤⠤⠤⠖⠒⠋⠉⠀ diff --git a/src/logo/ascii/calinixos_small.txt b/src/logo/ascii/calinixos_small.txt new file mode 100644 index 000000000..801e45fd7 --- /dev/null +++ b/src/logo/ascii/calinixos_small.txt @@ -0,0 +1,15 @@ +⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠐⣂⣈⣩⣭⣭⣍⣀⣐⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⡀⠔⣨⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣅⠢⡀⠀⠀⠀⠀⠀ +⠀⠀⠀⠠⢊⣴⣾⣿⣿⣿⣿⠿⠟⠛⠛⠛⠛⠻⠿⣿⣿⣿⣿⠃⠀⠠⡀⠀⠀⠀ +⠀⠀⡐⢡⣾⣿⣿⣿⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠁⠀⠀⠀⠈⢆⠀⠀ +⠀⡘⢰⣿⣿⣿⡟⠁⠀⠀⢀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢂⠀ +⢠⢠⣿⣿⣿⡟⠀⠀⠀⠀⠀⠙⠿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡀ +⡄⢸⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁ +⡇⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣹⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀ +⠃⢸⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⡀ +⠘⡘⣿⣿⣿⣧⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠁ +⠀⠡⠸⣿⣿⣿⣧⡀⠀⠀⠀⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⢀⠆⠀ +⠀⠀⠡⡘⢿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⣷⣦⡀⢀⠊⠀⠀ +⠀⠀⠀⠈⠊⡻⢿⣿⣿⣿⣿⣶⣤⣤⣤⣤⣤⣤⣶⣿⣿⣿⣿⡿⢟⠕⠁⠀⠀⠀ +⠀⠀⠀⠀⠀⠈⠢⢙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⡩⠐⠁⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠈⠐⠂⠭⠉⠙⣛⣛⠋⠉⠭⠐⠂⠁⠀⠀⠀⠀ diff --git a/src/logo/ascii/carbs.txt b/src/logo/ascii/carbs.txt new file mode 100644 index 000000000..71fdface7 --- /dev/null +++ b/src/logo/ascii/carbs.txt @@ -0,0 +1,18 @@ + .......... + ..,;:ccccccc:;'.. + ..,clllc:;;;;;:cllc,. + .,cllc,... ..';;'. + .;lol;.. .. + .,lol;. + .coo:. + .'lol,. + .,lol,. + .,lol,. + 'col;. + .:ooc'. + .'col:. + .'cllc'.. .''. + ..:lolc,'.......',cll,. + ..;cllllccccclllc;'. + ...',;;;;;;,,... + ..... diff --git a/src/logo/ascii/cbl_mariner.txt b/src/logo/ascii/cbl_mariner.txt new file mode 100644 index 000000000..26e8fdcdb --- /dev/null +++ b/src/logo/ascii/cbl_mariner.txt @@ -0,0 +1,18 @@ + . + :- . + :==. .=: + :===: -==: + :-===: .====: + :-====- -=====: + -====== :=======: + -======. .=========: + -======: -==========. + -======- -===========. + :======- :===========. + :=======. .-==========. + :=======: -==========. + :=======- :==========. + :=======- .-========- +:--------. :========- + ..:::--=========- + ..::---================-=- diff --git a/src/logo/ascii/center.txt b/src/logo/ascii/center.txt new file mode 100644 index 000000000..1b9b3199a --- /dev/null +++ b/src/logo/ascii/center.txt @@ -0,0 +1,13 @@ + . + o, + . d, . + ';' ..d;.. .cl' + .:; 'oldO,.oo. + ..,:,xKXxoo;'. + ,;;;;;ldxkONMMMXxkxc;;;;;. + .....':oddXWMNOxlcl:...... + .:dlxk0c;:. . + :d:.,xcld,.,:. + ;l, .l; ';' + .o; + l, diff --git a/src/logo/ascii/chakra.txt b/src/logo/ascii/chakra.txt new file mode 100644 index 000000000..284117e3a --- /dev/null +++ b/src/logo/ascii/chakra.txt @@ -0,0 +1,18 @@ + _ _ _ "kkkkkkkk. + ,kkkkkkkk., 'kkkkkkkkk, + ,kkkkkkkkkkkk., 'kkkkkkkkk. + ,kkkkkkkkkkkkkkkk,'kkkkkkkk, + ,kkkkkkkkkkkkkkkkkkk'kkkkkkk. + "''"''',;::,,"''kkk''kkkkk; __ + ,kkkkkkkkkk, "k''kkkkk' ,kkkk + ,kkkkkkk' ., ' .: 'kkkk',kkkkkk + ,kkkkkkkk'.k' , ,kkkk;kkkkkkkkk + ,kkkkkkkk';kk 'k "'k',kkkkkkkkkkkk +.kkkkkkkkk.kkkk.'kkkkkkkkkkkkkkkkkk' +;kkkkkkkk''kkkkkk;'kkkkkkkkkkkkk'' +'kkkkkkk; 'kkkkkkkk.,""''"''"" + ''kkkk; 'kkkkkkkkkk., + ';' 'kkkkkkkkkkkk., + ';kkkkkkkkkk' + ';kkkkkk' + "''" diff --git a/src/logo/ascii/chaletos.txt b/src/logo/ascii/chaletos.txt new file mode 100644 index 000000000..d1e405c7f --- /dev/null +++ b/src/logo/ascii/chaletos.txt @@ -0,0 +1,20 @@ + `.//+osso+/:`` + `/sdNNmhyssssydmNNdo:` + :hNmy+-` .-+hNNs- + /mMh/` `+:` `+dMd: + .hMd- -sNNMNo. /yyy /mMs` + -NM+ `/dMd/--omNh::dMM `yMd` + .NN+ .sNNs:/dMNy:/hNmo/s yMd` + hMs `/hNd+-smMMMMMMd+:omNy- `dMo +:NM. .omMy:/hNMMMMMMMMMMNy:/hMd+` :Md` +/Md` `sm+.omMMMMMMMMMMMMMMMMd/-sm+ .MN: +/Md` MMMMMMMMMMMMMMMMMMMN .MN: +:NN. MMMMMMm....--NMMMMMN -Mm. +`dMo MMMMMMd mMMMMMN hMs + -MN: MMMMMMd mMMMMMN oMm` + :NM: MMMMMMd mMMMMMN +Mm- + -mMy. mmmmmmh dmmmmmh -hMh. + oNNs- :yMm/ + .+mMdo:` `:smMd/` + -ohNNmhsoo++osshmNNh+. + `./+syyhhyys+:`` diff --git a/src/logo/ascii/chapeau.txt b/src/logo/ascii/chapeau.txt new file mode 100644 index 000000000..0fa328cfc --- /dev/null +++ b/src/logo/ascii/chapeau.txt @@ -0,0 +1,18 @@ + .-/-. + ////////. + ////////${c2}y+${c1}//. + ////////${c2}mMN${c1}/////. + ////////${c2}mMN+${c1}////////. + ////////////////////////. + /////////+${c2}shhddhyo${c1}+////////. + ////////${c2}ymMNmdhhdmNNdo${c1}///////. +///////+${c2}mMms${c1}////////${c2}hNMh${c1}///////. +///////${c2}NMm+${c1}//////////${c2}sMMh${c1}/////// +//////${c2}oMMNmmmmmmmmmmmmMMm${c1}/////// +//////${c2}+MMmssssssssssssss+${c1}/////// +`//////${c2}yMMy${c1}//////////////////// + `//////${c2}smMNhso++oydNm${c1}//////// + `///////${c2}ohmNMMMNNdy+${c1}/////// + `//////////${c2}++${c1}////////// + `////////////////. + -////////- diff --git a/src/logo/ascii/chonkysealos.txt b/src/logo/ascii/chonkysealos.txt new file mode 100644 index 000000000..5d9096bce --- /dev/null +++ b/src/logo/ascii/chonkysealos.txt @@ -0,0 +1,21 @@ + .-/-. + .:-=++****++=-:. + .:=+*##%%%%%%%%%%##*+=:. + :=*#%%%%%%%%%%%%%%%%%%%%#*=: + :=*#%%%%%%%%%%%%%%%%%%%%%%%%#*=. + -+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%#+- + =+#%%%%@@@@@@@%%%%%%%@@@@@@@%%%%%#+= + =+#@%%%%*+=-==*%%%%%%%#+====*%%%%%@#+= +:+*%%%%@* +@%%%@# -@%%%%%*+: +=+#%%%%%%#+====*###%%##*=--=+*%%%%%%%#+= ++*%%%%%%%@@##%%%%*=::=#%%%##%@%%%%%%%%*+ ++*%%%%%%%@**@%%%%%@==@%%%%%@+#%%%%%%%%*+ +=+#%%%%%%@#*@%%%%%%**%%%%%@%+%%%%%%%%#+= +:+*%%%%%%%@#*####**###*####*%@%%%%%%%*+: + =+#@%%%%%%@%%%%%%%@@%%%%%%%%%%%%%%@#+= + =+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#+= + -+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%*+- + .=*#%%%%%%%%%%%%%%%%%%%%%%%%#*=. + :=*##%%%%%%%%%%%%%%%%%%##*=: + .:=+*##%%%%%%%%%%##*+=:. + .:-=++****++=-:. diff --git a/src/logo/ascii/chrom.txt b/src/logo/ascii/chrom.txt new file mode 100644 index 000000000..951bf1906 --- /dev/null +++ b/src/logo/ascii/chrom.txt @@ -0,0 +1,18 @@ +${c2} .,:loool:,. + .,coooooooooooooc,. + .,lllllllllllllllllllll,. + ;ccccccccccccccccccccccccc; +${c1} '${c2}ccccccccccccccccccccccccccccc. +${c1} ,oo${c2}c::::::::okO${c5}000${c3}0OOkkkkkkkkkkk: +${c1}.ooool${c2};;;;:x${c5}K0${c4}kxxxxxk${c5}0X${c3}K0000000000. +${c1}:oooool${c2};,;O${c5}K${c4}ddddddddddd${c5}KX${c3}000000000d +${c1}lllllool${c2};l${c5}N${c4}dllllllllllld${c5}N${c3}K000000000 +${c1}lllllllll${c2}o${c5}M${c4}dccccccccccco${c5}W${c3}K000000000 +${c1};cllllllllX${c5}X${c4}c:::::::::c${c5}0X${c3}000000000d +${c1}.ccccllllllO${c5}Nk${c4}c;,,,;cx${c5}KK${c3}0000000000. +${c1} .cccccclllllxOO${c5}OOO${c1}Okx${c3}O0000000000; +${c1} .:ccccccccllllllllo${c3}O0000000OOO, +${c1} ,:ccccccccclllcd${c3}0000OOOOOOl. +${c1} '::ccccccccc${c3}dOOOOOOOkx:. +${c1} ..,::cccc${c3}xOOOkkko;. +${c1} ..,:${c3}dOkxl:. diff --git a/src/logo/ascii/cleanjaro.txt b/src/logo/ascii/cleanjaro.txt new file mode 100644 index 000000000..8c2dbe94f --- /dev/null +++ b/src/logo/ascii/cleanjaro.txt @@ -0,0 +1,12 @@ +███████▌ ████████████████ +███████▌ ████████████████ +███████▌ ████████████████ +███████▌ +███████▌ +███████▌ +███████▌ +███████▌ +█████████████████████████ +█████████████████████████ +█████████████████████████ +▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ diff --git a/src/logo/ascii/cleanjaro_small.txt b/src/logo/ascii/cleanjaro_small.txt new file mode 100644 index 000000000..9de37e3a7 --- /dev/null +++ b/src/logo/ascii/cleanjaro_small.txt @@ -0,0 +1,7 @@ +█████ ██████████ +█████ ██████████ +█████ +█████ +█████ +████████████████ +████████████████ diff --git a/src/logo/ascii/clear_linux.txt b/src/logo/ascii/clear_linux.txt new file mode 100644 index 000000000..7d427ed3d --- /dev/null +++ b/src/logo/ascii/clear_linux.txt @@ -0,0 +1,20 @@ + BBB + BBBBBBBBB + BBBBBBBBBBBBBBB + BBBBBBBBBBBBBBBBBBBB + BBBBBBBBBBB BBB + BBBBBBBB${c2}YYYYY +${c1} BBBBBBBB${c2}YYYYYY +${c1} BBBBBBBB${c2}YYYYYYY +${c1} BBBBBBBBB${c2}YYYYY${c3}W +${c4} GG${c1}BBBBBBBY${c2}YYYY${c3}WWW +${c4} GGG${c1}BBBBBBB${c2}YY${c3}WWWWWWWW +${c4} GGGGGG${c1}BBBBBB${c3}WWWWWWWW +${c4} GGGGGGGG${c1}BBBB${c3}WWWWWWWW +${c4}GGGGGGGGGGG${c1}BBB${c3}WWWWWWW +${c4}GGGGGGGGGGGGG${c1}B${c3}WWWWWW +${c4}GGGGGGGG${c3}WWWWWWWWWWW +${c4}GG${c3}WWWWWWWWWWWWWWWW + WWWWWWWWWWWWWWWW + WWWWWWWWWW + WWW diff --git a/src/logo/ascii/clearos.txt b/src/logo/ascii/clearos.txt new file mode 100644 index 000000000..7b5252da1 --- /dev/null +++ b/src/logo/ascii/clearos.txt @@ -0,0 +1,20 @@ + `.--::::::--.` + .-:////////////////:-. + `-////////////////////////-` + -////////////////////////////- + `//////////////-..-//////////////` + ./////////////: ://///////////. + `//////:..-////: :////-..-//////` + ://////` -///:.``.:///-` ://///: +`///////:. -////////-` `:///////` +.//:--////:. -////-` `:////--://. +./: .////:. --` `:////- :/. +`//-` .////:. `:////- `-//` + :///-` .////:. `:////- `-///: + `/////-` -///: :///- `-/////` + `//////- `///: :///` .//////` + `:////: `///: :///` -////:` + .://: `///: :///` -//:. + .:: `///: :///` -:. + `///: :///` + `... ...` diff --git a/src/logo/ascii/clover.txt b/src/logo/ascii/clover.txt new file mode 100644 index 000000000..bf64adb49 --- /dev/null +++ b/src/logo/ascii/clover.txt @@ -0,0 +1,20 @@ + `omo``omo` + `oNMMMNNMMMNo` + `oNMMMMMMMMMMMMNo` + oNMMMMMMMMMMMMMMMMNo + `sNMMMMMMMMMMMMMMNs` + `omo` `sNMMMMMMMMMMNs` `omo` + `oNMMMNo` `sNMMMMMMNs` `oNMMMNo` + `oNMMMMMMMNo` `oNMMNs` `oNMMMMMMMNo` +oNMMMMMMMMMMMNo` `sy` `oNMMMMMMMMMMMNo +`sNMMMMMMMMMMMMNo.${c2}oNNs${c1}.oNMMMMMMMMMMMMNs` +`oNMMMMMMMMMMMMNs.${c2}oNNs${c1}.oNMMMMMMMMMMMMNo` +oNMMMMMMMMMMMNs` `sy` `oNMMMMMMMMMMMNo + `oNMMMMMMMNs` `oNMMNo` `oNMMMMMMMNs` + `oNMMMNs` `sNMMMMMMNs` `oNMMMNs` + `oNs` `sNMMMMMMMMMMNs` `oNs` + `sNMMMMMMMMMMMMMMNs` + +NMMMMMMMMMMMMMMMMNo + `oNMMMMMMMMMMMMNo` + `oNMMMNNMMMNs` + `omo``oNs` diff --git a/src/logo/ascii/cobalt.txt b/src/logo/ascii/cobalt.txt new file mode 100644 index 000000000..6780a3880 --- /dev/null +++ b/src/logo/ascii/cobalt.txt @@ -0,0 +1,16 @@ +${c1} /// +${c1} ,////////////// +${c1} /////////////////////////////// +${c1} ///////////////${c5}***********${c1}////// + ////${c5}***********************${c1}///// + /////${c5}***********************${c1}//// + //////${c5},,,,,,,,,,,,,,,,,,,,,,${c1}/// + //////${c5},,,,,,,,,,,,,,,,,,,,,,,,,${c1}///// + /////${c5},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c1}///// +${c4} *****${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}***** + ******${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}***** + *******${c3},,,,,,,,,,,,,,,,,,,,,,,,,${c4}****** + *******${c3}......................${c4}******* + ******${c3}....${c4}*********************** + **************************** + ***** diff --git a/src/logo/ascii/condres.txt b/src/logo/ascii/condres.txt new file mode 100644 index 000000000..c14c19eee --- /dev/null +++ b/src/logo/ascii/condres.txt @@ -0,0 +1,17 @@ +${c1}syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+${c3}.+. +${c1}`oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+${c3}:++. +${c2}/o${c1}+oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/${c3}oo++. +${c2}/y+${c1}syyyyyyyyyyyyyyyyyyyyyyyyyyyyy${c3}+ooo++. +${c2}/hy+${c1}oyyyhhhhhhhhhhhhhhyyyyyyyyy${c3}+oo+++++. +${c2}/hhh+${c1}shhhhhdddddhhhhhhhyyyyyyy${c3}+oo++++++. +${c2}/hhdd+${c1}oddddddddddddhhhhhyyyys${c3}+oo+++++++. +${c2}/hhddd+${c1}odmmmdddddddhhhhyyyy${c3}+ooo++++++++. +${c2}/hhdddmo${c1}odmmmdddddhhhhhyyy${c3}+oooo++++++++. +${c2}/hdddmmms${c1}/dmdddddhhhhyyys${c3}+oooo+++++++++. +${c2}/hddddmmmy${c1}/hdddhhhhyyyyo${c3}+oooo++++++++++: +${c2}/hhdddmmmmy${c1}:yhhhhyyyyy+${c3}+oooo+++++++++++: +${c2}/hhddddddddy${c1}-syyyyyys+${c3}ooooo++++++++++++: +${c2}/hhhddddddddy${c1}-+yyyy+${c3}/ooooo+++++++++++++: +${c2}/hhhhhdddddhhy${c1}./yo:${c3}+oooooo+++++++++++++/ +${c2}/hhhhhhhhhhhhhy${c1}:-.${c3}+sooooo+++++++++++///: +${c2}:sssssssssssso++${c1}${c3}`:/:--------.```````` diff --git a/src/logo/ascii/container_linux.txt b/src/logo/ascii/container_linux.txt new file mode 100644 index 000000000..e1f81b9d1 --- /dev/null +++ b/src/logo/ascii/container_linux.txt @@ -0,0 +1,20 @@ + ..... + .';:cccccccc:;'. + ':ccccclc${c3}lllllllll${c1}cc:. + .;cccccccc${c3}lllllllllllllll${c1}c, + ;clllccccc${c3}llllllllllllllllll${c1}c, + .cllclccccc${c3}lllll${c2}lll${c3}llllllllllll${c1}c: + ccclclcccc${c3}cllll${c2}kWMMNKk${c3}llllllllll${c1}c: + :ccclclcccc${c3}llll${c2}oWMMMMMMWO${c3}lllllllll${c1}c, +.ccllllllccc${c3}clll${c2}OMMMMMMMMM0${c3}lllllllll${c1}c +.lllllclcccc${c3}llll${c2}KMMMMMMMMMMo${c3}llllllll${c1}c. +.lllllllcccc${c3}clll${c2}KMMMMMMMMN0${c3}lllllllll${c1}c. +.cclllllcccc${c3}lllld${c2}xkkxxdo${c3}llllllllllc${c1}lc + :cccllllllcccc${c3}lllccllllcclccc${c1}cccccc; + .ccclllllllcccccccc${c3}lll${c1}ccccclccccccc + .cllllllllllclcccclccclccllllcllc + :cllllllllccclcllllllllllllcc; + .cccccccccccccclcccccccccc:. + .;cccclccccccllllllccc,. + .';ccccclllccc:;.. + ..... diff --git a/src/logo/ascii/crux_small.txt b/src/logo/ascii/crux_small.txt new file mode 100644 index 000000000..d332133db --- /dev/null +++ b/src/logo/ascii/crux_small.txt @@ -0,0 +1,7 @@ + ___ + (${c3}.· ${c1}| + (${c2}<> ${c1}| + / ${c3}__ ${c1}\\ + ( ${c3}/ \\ ${c1}/| +${c2}_${c1}/\\ ${c3}__)${c1}/${c2}_${c1}) +${c2}\/${c1}-____${c2}\/ diff --git a/src/logo/ascii/cucumber.txt b/src/logo/ascii/cucumber.txt new file mode 100644 index 000000000..24bd1a834 --- /dev/null +++ b/src/logo/ascii/cucumber.txt @@ -0,0 +1,20 @@ + `.-://++++++//:-.` + `:/+//${c2}::--------${c1}:://+/:` + -++/:${c2}----..........----${c1}:/++- + .++:${c2}---...........-......---${c1}:++. + /+:${c2}---....-::/:/--//:::-....---${c1}:+/ + `++:${c2}--.....:---::/--/::---:.....--${c1}:++` + /+:${c2}--.....--.--::::-/::--.--.....--${c1}:+/ +-o:${c2}--.......-:::://--/:::::-.......--${c1}:o- +/+:${c2}--...-:-::---:::..:::---:--:-...--${c1}:+/ +o/:${c2}-...-:.:.-/:::......::/:.--.:-...-${c1}:/o +o/${c2}--...::-:/::/:-......-::::::-/-...-${c1}:/o +/+:${c2}--..-/:/:::--:::..:::--::////-..--${c1}:+/ +-o:${c2}--...----::/:::/--/:::::-----...--${c1}:o- + /+:${c2}--....://:::.:/--/:.::://:....--${c1}:+/ + `++:${c2}--...-:::.--.:..:.--.:/:-...--${c1}:++` + /+:${c2}---....----:-..-:----....---${c1}:+/ + .++:${c2}---..................---${c1}:++. + -/+/:${c2}----..........----${c1}:/+/- + `:/+//${c2}::--------:::${c1}/+/:` + `.-://++++++//:-.` diff --git a/src/logo/ascii/cutefishos.txt b/src/logo/ascii/cutefishos.txt new file mode 100644 index 000000000..3cf5a3e4e --- /dev/null +++ b/src/logo/ascii/cutefishos.txt @@ -0,0 +1,9 @@ + ___ww___ +_ _wwMMM@M^^^^MMMMww_ +M0w_ _wMMM~~ ~~MMm_ + ~MMy _ww0M~ ~MMy + ~MMMM~ o "MM +${c3} jw0M~~MMMw_ _wMM' +wMM~ ~~MMmw__ __w0M~ +~ ~~MM0MmwwwwwwwwwMMM~ + ~~~~^^~~~ diff --git a/src/logo/ascii/cuteos.txt b/src/logo/ascii/cuteos.txt new file mode 100644 index 000000000..482791c9d --- /dev/null +++ b/src/logo/ascii/cuteos.txt @@ -0,0 +1,14 @@ + ${c3}1ua${c2} + ${c3}MMM1ua${c2} + ${c1}MM${c2}EE ${c3} MMMMM1uazE${c2} +${c1}MM ${c2}EEEE ${c3}M1MM1uazzEn ${c2}EEEE MME + EEEEE ${c3}MMM uazEno ${c2}EEEE + EEEEE${c1}MMMMMMEno~; ${c2}EE E${c2} + EE ${c1}MMMMMMMM~;;E ${c2}MMMMM M ${c2} + E ${c1}MMMMMMMMM ${c2} E E ${c2} + ${c1}MMMMMMMMMMM + ${c1}MMMMMMMMM ${c2}EE ${c1} + MM1MMMM ${c2}EEE ${c1} + MMMMM + MMM + M diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 6f12d2177..81fd9d449 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -411,6 +411,141 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_WHITE, }, + // Astra + { + .names = {"Astra", "Astra Linux", "astralinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ASTRA_LINUX, + .colors = { + FF_COLOR_MODE_BOLD FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Athena + { + .names = {"Athena"}, + .lines = FASTFETCH_DATATEXT_LOGO_ATHENA, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Bedrock + { + .names = {"bedrock", "bedrocklinux", "bedrock-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_BEDROCK, + .colors = { + FF_COLOR_FG_LIGHT_BLACK, //grey + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, //grey + .colorTitle = FF_COLOR_FG_WHITE, + }, + // BigLinux + { + .names = {"BigLinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_BIGLINUX, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // Bitrig + { + .names = {"Bitrig"}, + .lines = FASTFETCH_DATATEXT_LOGO_BITRIG, + .colors = { + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // BlackArch + { + .names = {"Blackarch"}, + .lines = FASTFETCH_DATATEXT_LOGO_BLACKARCH, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_LIGHT_RED, + FF_COLOR_FG_BLACK, + }, + .colorKeys = FF_COLOR_FG_LIGHT_RED, + .colorTitle = FF_COLOR_FG_RED, + }, + // BlackPanther + { + .names = {"BlackPanther"}, + .lines = FASTFETCH_DATATEXT_LOGO_BLACKPANTHER, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_LIGHT_BLUE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // BLAG + { + .names = {"BLAG"}, + .lines = FASTFETCH_DATATEXT_LOGO_BLAG, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // BlankOn + { + .names = {"BlankOn"}, + .lines = FASTFETCH_DATATEXT_LOGO_BLANKON, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // BlueLight + { + .names = {"BlueLight"}, + .lines = FASTFETCH_DATATEXT_LOGO_BLUELIGHT, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // Bodhi + { + .names = {"Bodhi"}, + .lines = FASTFETCH_DATATEXT_LOGO_BODHI, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_LIGHT_YELLOW, + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // Bonsai + { + .names = {"bonsai"}, + .lines = FASTFETCH_DATATEXT_LOGO_BONSAI, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // BSD { .names = {"bsd"}, @@ -425,15 +560,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_WHITE, }, - // Bedrock + // BunsenLabs { - .names = {"bedrock", "bedrocklinux", "bedrock-linux"}, - .lines = FASTFETCH_DATATEXT_LOGO_BEDROCK, + .names = {"BunsenLabs"}, + .lines = FASTFETCH_DATATEXT_LOGO_BUNSENLABS, .colors = { - FF_COLOR_FG_LIGHT_BLACK, //grey FF_COLOR_FG_WHITE, }, - .colorKeys = FF_COLOR_FG_LIGHT_BLACK, //grey + .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_WHITE, }, // CachyOS @@ -459,6 +593,57 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_CYAN, }, + // Calculate + { + .names = {"Calculate"}, + .lines = FASTFETCH_DATATEXT_LOGO_CALCULATE, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // CalinixOS + { + .names = {"calinix", "calinixos"}, + .lines = FASTFETCH_DATATEXT_LOGO_CALINIXOS, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // CalinixOSSmall + { + .names = {"calinix_small", "calinixos_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_CALINIXOS_SMALL, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // Carbs + { + .names = {"Carbs"}, + .lines = FASTFETCH_DATATEXT_LOGO_CARBS, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // CBL-Mariner + { + .names = {"CBL-Mariner"}, + .lines = FASTFETCH_DATATEXT_LOGO_CBL_MARINER, + .colors = { + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, + }, // CelOS { .names = {"cel", "celos", "cel-linux", "celos-linux"}, @@ -470,6 +655,16 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_BLUE, }, + // Center + { + .names = {"Center"}, + .lines = FASTFETCH_DATATEXT_LOGO_CENTER, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // CentOS { .names = {"cent", "centos", "cent-linux", "centos-linux"}, @@ -498,9 +693,156 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_YELLOW, }, + // Chakra + { + .names = {"Chakra"}, + .lines = FASTFETCH_DATATEXT_LOGO_CHAKRA, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, + // ChaletOS + { + .names = {"ChaletOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CHALETOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Chapeau + { + .names = {"Chapeau"}, + .lines = FASTFETCH_DATATEXT_LOGO_CHAPEAU, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // ChonkySealOS + { + .names = {"ChonkySealOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CHONKYSEALOS, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Chrom + { + .names = {"Chrom", "ChromeOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CHROM, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_RED, + }, + // Cleanjaro + { + .names = {"Cleanjaro"}, + .lines = FASTFETCH_DATATEXT_LOGO_CLEANJARO, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // CleanjaroSmall + { + .names = {"cleanjaro_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_CLEANJARO_SMALL, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // ClearLinux + { + .names = {"Clear Linux", "clearlinux", "Clear Linux OS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CLEAR_LINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // ClearOS + { + .names = {"ClearOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CLEAROS, + .colors = { + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // Clover + { + .names = {"Clover"}, + .lines = FASTFETCH_DATATEXT_LOGO_CLOVER, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // Cobalt + { + .names = {"Cobalt"}, + .lines = FASTFETCH_DATATEXT_LOGO_COBALT, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLACK, + FF_COLOR_FG_LIGHT_BLUE, + FF_COLOR_FG_BLACK, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // Condres + { + .names = {"Condres"}, + .lines = FASTFETCH_DATATEXT_LOGO_CONDRES, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_CYAN + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // ContainerLinux + { + .names = {"Container Linux by CoreOS", "ContainerLinux", "Container Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_CONTAINER_LINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // CRUX { - .names = {"crux"}, + .names = {"CRUX"}, .lines = FASTFETCH_DATATEXT_LOGO_CRUX, .colors = { FF_COLOR_FG_BLUE, @@ -510,6 +852,19 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_BLUE, }, + // CRUXSmall + { + .names = {"CRUX_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_CRUX_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_BLUE, + }, // CrystalLinux { .names = {"crystal", "Crystal", "crystal-linux", "Crystal-Linux"}, @@ -520,6 +875,39 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // Cucumber + { + .names = {"Cucumber", "CucumberOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CUCUMBER, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // CutefishOS + { + .names = {"CutefishOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CUTEFISHOS, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + }, + }, + // CuteOS + { + .names = {"CuteOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CUTEOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_256 "57", + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, // Debian { .names = {"debian", "debian-linux"}, @@ -542,6 +930,16 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // Deepin + { + .names = {"Deepin", "deepin-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_DEEPIN, + .colors = { + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // Devuan { .names = {"devuan", "devuan-linux"}, @@ -584,16 +982,6 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, - // Deepin - { - .names = {"deepin", "deepin-linux"}, - .lines = FASTFETCH_DATATEXT_LOGO_DEEPIN, - .colors = { - FF_COLOR_FG_GREEN, - }, - .colorKeys = FF_COLOR_FG_GREEN, - .colorTitle = FF_COLOR_FG_GREEN, - }, // Endeavour { .names = {"endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, From 26bb2dc9984a16de28e9bc54fad544ac9fd9d608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 3 Aug 2023 16:30:56 +0800 Subject: [PATCH 417/493] Logo: more 146 left --- src/logo/ascii/cyberos.txt | 15 ++ src/logo/ascii/dahlia.txt | 17 ++ src/logo/ascii/darkos.txt | 20 +++ src/logo/ascii/desaos.txt | 16 ++ src/logo/ascii/devuan.txt | 22 +-- src/logo/ascii/dietpi.txt | 19 +++ src/logo/ascii/dracos.txt | 13 ++ src/logo/ascii/dragonfly.txt | 15 ++ src/logo/ascii/dragonfly_old.txt | 17 ++ src/logo/ascii/dragonfly_small.txt | 7 + src/logo/ascii/drauger.txt | 16 ++ src/logo/ascii/droidian.txt | 15 ++ src/logo/ascii/elive.txt | 17 ++ src/logo/ascii/encryptos.txt | 13 ++ src/logo/ascii/endless.txt | 20 +++ src/logo/ascii/eurolinux.txt | 18 ++ src/logo/ascii/exodia_predator.txt | 24 +++ src/logo/ascii/femboyos.txt | 20 +++ src/logo/ascii/feren.txt | 16 ++ src/logo/ascii/finnix.txt | 17 ++ src/logo/ascii/floflis.txt | 19 +++ src/logo/ascii/freemint.txt | 15 ++ src/logo/ascii/frugalware.txt | 23 +++ src/logo/ascii/funtoo.txt | 10 ++ src/logo/builtin.c | 253 +++++++++++++++++++++++++++++ 25 files changed, 646 insertions(+), 11 deletions(-) create mode 100644 src/logo/ascii/cyberos.txt create mode 100644 src/logo/ascii/dahlia.txt create mode 100644 src/logo/ascii/darkos.txt create mode 100644 src/logo/ascii/desaos.txt create mode 100644 src/logo/ascii/dietpi.txt create mode 100644 src/logo/ascii/dracos.txt create mode 100644 src/logo/ascii/dragonfly.txt create mode 100644 src/logo/ascii/dragonfly_old.txt create mode 100644 src/logo/ascii/dragonfly_small.txt create mode 100644 src/logo/ascii/drauger.txt create mode 100644 src/logo/ascii/droidian.txt create mode 100644 src/logo/ascii/elive.txt create mode 100644 src/logo/ascii/encryptos.txt create mode 100644 src/logo/ascii/endless.txt create mode 100644 src/logo/ascii/eurolinux.txt create mode 100644 src/logo/ascii/exodia_predator.txt create mode 100644 src/logo/ascii/femboyos.txt create mode 100644 src/logo/ascii/feren.txt create mode 100644 src/logo/ascii/finnix.txt create mode 100644 src/logo/ascii/floflis.txt create mode 100644 src/logo/ascii/freemint.txt create mode 100644 src/logo/ascii/frugalware.txt create mode 100644 src/logo/ascii/funtoo.txt diff --git a/src/logo/ascii/cyberos.txt b/src/logo/ascii/cyberos.txt new file mode 100644 index 000000000..ebdb1c6f7 --- /dev/null +++ b/src/logo/ascii/cyberos.txt @@ -0,0 +1,15 @@ +${c3} !M$EEEEEEEEEEEP + .MMMMM000000Nr. + ${c3}&MMMMMM${c2}MMMMMMMMMMMMM9 + ${c3}~MMM${c1}MMMM${c2}MMMMMMMMMMMMC + ${c1}" ${c3}M${c1}MMMMMMM${c2}MMMMMMMMMMs + ${c1}iM${c2}MMM&&${c1}MMMMMMMM${c2}MMMMMMMM\\ + ${c1}BMMM${c2}MMMMM${c1}MMMMMMM${c2}MMMMMM${c3}" + ${c1}9MMMMM${c2}MMMMMMM${c1}MMMM${c2}MMMM${c3}MMMf- + ${c2}sMMMMMMMM${c1}MM${c2}M${c3}MMMMMMMMM3_ + ${c2}+ffffffff${c1}P${c3}MMMMMMMMMMMM0 + ${c2}CMMMMMMMMMMM + }MMMMMMMMM + ~MMMMMMM + "RMMMM + .PMB diff --git a/src/logo/ascii/dahlia.txt b/src/logo/ascii/dahlia.txt new file mode 100644 index 000000000..d3d058803 --- /dev/null +++ b/src/logo/ascii/dahlia.txt @@ -0,0 +1,17 @@ + .#. + *%@@@%* + .,,,,,(&@@@@@@@&/,,,,,. + ,#@@@@@@@@@@@@@@@@@@@@@#. + ,#@@@@@@@&#///#&@@@@@@@#. + ,/%&@@@@@%/, .,(%@@@@@&#/. + *#&@@@@@@#,. .*#@@@@@@&#, + .&@@@@@@@@@( .(@@@@@@@@@&&. +#@@@@@@@@@@( )@@@@@@@@@@@# + °@@@@@@@@@@( .(@@@@@@@@@@@° + *%@@@@@@@(. ,#@@@@@@@%* + ,(&@@@@@@%*. ./%@@@@@@%(, + ,#@@@@@@@&(***(&@@@@@@@#. + ,#@@@@@@@@@@@@@@@@@@@@@#. + ,*****#&@@@@@@@&(*****, + ,/%@@@%/. + ,#, diff --git a/src/logo/ascii/darkos.txt b/src/logo/ascii/darkos.txt new file mode 100644 index 000000000..8ff29fab7 --- /dev/null +++ b/src/logo/ascii/darkos.txt @@ -0,0 +1,20 @@ +${c3}⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⠋⡆⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c5}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡆⢀⣤⢛⠛⣠⣿⠀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c6}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⣿⠟⣡⠊⣠⣾⣿⠃⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c2}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣯⣿⠀⠊⣤⣿⣿⣿⠃⣴⣧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡟⣠⣶⣿⣿⣿⢋⣤⠿⠛⠉⢁⣭⣽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c4} ⠀⠀⠀⠀⠀⠀ ⠀⣠⠖⡭⢉⣿⣯⣿⣯⣿⣿⣿⣟⣧⠛⢉⣤⣶⣾⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c5}⠀⠀⠀⠀⠀⠀⠀⠀⣴⣫⠓⢱⣯⣿⢿⠋⠛⢛⠟⠯⠶⢟⣿⣯⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c2}⠀⠀⠀⠀⠀⠀⢀⡮⢁⣴⣿⣿⣿⠖⣠⠐⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠛⠛⠛⢿⣶⣄⠀⠀⠀⠀⠀⠀⠀ +${c3}⠀⠀⠀⠀⢀⣤⣷⣿⣿⠿⢛⣭⠒⠉⠀⠀⠀⣀⣀⣄⣤⣤⣴⣶⣶⣶⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀ +${c1}⠀⢀⣶⠏⠟⠝⠉⢀⣤⣿⣿⣶⣾⣿⣿⣿⣿⣿⣿⣟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c6}⢴⣯⣤⣶⣿⣿⣿⣿⣿⡿⣿⣯⠉⠉⠉⠉⠀⠀⠀⠈⣿⡀⣟⣿⣿⢿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c5}⠀⠀⠀⠉⠛⣿⣧⠀⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠃⣿⣿⣯⣿⣦⡀⠀⠉⠻⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c3}⠀⠀⠀⠀⠀⠀⠉⢿⣮⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⣯⠉⠉⠛⢿⣿⣷⣄⠀⠈⢻⣆⠀⠀⠀⠀⠀⠀⠀⠀ +${c2}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠢⠀⠀⠀⠀⠀⠀⠀⢀⢡⠃⣾⣿⣿⣦⠀⠀⠀⠙⢿⣿⣤⠀⠙⣄⠀⠀⠀⠀⠀⠀⠀ +${c6}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢋⡟⢠⣿⣿⣿⠋⢿⣄⠀⠀⠀⠈⡄⠙⣶⣈⡄⠀⠀⠀⠀⠀⠀ +${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠚⢲⣿⠀⣾⣿⣿⠁⠀⠀⠉⢷⡀⠀⠀⣇⠀⠀⠈⠻⡀⠀⠀⠀⠀⠀ +${c4}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⣀⣿⡏⠀⣿⡿⠀⠀⠀⠀⠀⠀⠙⣦⠀⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c3}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠿⣧⣾⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣮⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +${c5}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠀⠀⠀⠀⠀⠀ diff --git a/src/logo/ascii/desaos.txt b/src/logo/ascii/desaos.txt new file mode 100644 index 000000000..8259b116e --- /dev/null +++ b/src/logo/ascii/desaos.txt @@ -0,0 +1,16 @@ +███████████████████████ +███████████████████████ +███████████████████████ +███████████████████████ +████████ ███████ +████████ ███████ +████████ ███████ +████████ ███████ +████████ ███████ +████████ ███████ +████████ ███████ +██████████████████████████████ +██████████████████████████████ +████████████████████████ +████████████████████████ +████████████████████████ diff --git a/src/logo/ascii/devuan.txt b/src/logo/ascii/devuan.txt index d400acec8..2ecd8d749 100644 --- a/src/logo/ascii/devuan.txt +++ b/src/logo/ascii/devuan.txt @@ -1,15 +1,15 @@ ..,,;;;::;,.. `':ddd;:,. `'dPPd:,. - `:b$$b`. - 'P$$$d` - .$$$$$` - ;$$$$$P - .:P$$$$$$` - .,:b$$$$$$$;' - .,:dP$$$$$$$$b:' - .,:;db$$$$$$$$$$Pd'` - ,db$$$$$$$$$$$$$$b:'` -:$$$$$$$$$$$$b:'` - `$$$$$bd:''` + `:b$$$$b`. + 'P$$$$$d` + .$$$$$$$$$` + ;$$$$$$$$$P + .:P$$$$$$$$$$$$` + .,:b$$$$$$$$$$$$$;' + .,:dP$$$$$$$$$$$$$$$$b:' + .,:;db$$$$$$$$$$$$$$$$$$$$Pd'` + ,db$$$$$$$$$$$$$$$$$$$$$$$$$$$$b:'` +:$$$$$$$$$$$$$$$$$$$$$$$$b:'` + `$$$$$$$$$bd:''` `'''` diff --git a/src/logo/ascii/dietpi.txt b/src/logo/ascii/dietpi.txt new file mode 100644 index 000000000..7e2b10d9b --- /dev/null +++ b/src/logo/ascii/dietpi.txt @@ -0,0 +1,19 @@ + :=+******+- -+******+=: + =#-::-::::-=#:-#=-::::-::-#= + :%-::--==-::-%%-::-==--::-%: + +#-:::::=+++${c2}@@${c1}+++=-::::-#= + :#+-::::=%${c2}@@@@@${c1}=::::-+#: + =@%##%${c2}@@@@@@@@${c1}%##%@= +${c2} .#@@@@@@@@@@@@@@@@@@@@#. + %@@@@@@@@@@@@@@@@@@@@@@% + -@@@@@@@@@@@@@@@@@@@@@@@@: +.#@@@@@@@@@@%%%%%@@@@@@@@@@@#. +#@@@${c1}+-=*#%${c2}%%%%%%%%%${c1}%%#+--#${c2}@@@# +%@@%${c1}*. .:${c2}=*%%%%*${c1}=: .#${c2}@@@% +:%@@@${c1}#+=-:${c2}:-*%%%%+::${c1}:-=+%${c2}@@@%: + :@@@@%@%%%%@${c1}#${c2}#${c1}#${c2}%@%%%%@%@@@@. + +@@@@@@@@@${c1}%${c2}=*+${c1}%${c2}@%@@@@@@@@+ + #@@@@@@@@@@@@@@@@@@@@@@# + -#@@@@@@@@@@@@@@@@@@#- + -*%@@@@@@@@@@%*- + .+%@@@@%+. diff --git a/src/logo/ascii/dracos.txt b/src/logo/ascii/dracos.txt new file mode 100644 index 000000000..e8d59dd02 --- /dev/null +++ b/src/logo/ascii/dracos.txt @@ -0,0 +1,13 @@ + `-:/- + -os: + -os/` + :sy+-` + `/yyyy+. + `+yyyyo- + `/yyyys: +`:osssoooo++- +yyyyyy/` + ./yyyyyyo yo`:syyyy+. + -oyyy+ +- :yyyyyo- + `:sy: `. `/yyyyys: + ./o/.` .oyyso+oo:` + :+oo+//::::///:-.` `.` diff --git a/src/logo/ascii/dragonfly.txt b/src/logo/ascii/dragonfly.txt new file mode 100644 index 000000000..7ccc14bc3 --- /dev/null +++ b/src/logo/ascii/dragonfly.txt @@ -0,0 +1,15 @@ +${c2},--, ${c1}| ${c2},--, +${c2}| `-, ${c1},^, ${c2},-' | +${c2} `, `-, ${c3}(/ \) ${c2},-' ,' +${c2} `-, `-,${c1}/ \${c2},-' ,-' +${c2} `------${c1}( )${c2}------' +${c2} ,----------${c1}( )${c2}----------, +${c2} | _,-${c1}( )${c2}-,_ | +${c2} `-,__,-' ${c1}\ /${c2} `-,__,-' +${c1} | | + | | + | | + | | + | | + | | + `|' diff --git a/src/logo/ascii/dragonfly_old.txt b/src/logo/ascii/dragonfly_old.txt new file mode 100644 index 000000000..66609ffb5 --- /dev/null +++ b/src/logo/ascii/dragonfly_old.txt @@ -0,0 +1,17 @@ + .-. + ${c3} ()${c1}I${c3}() + ${c1} "==.__:-:__.==" + "==.__/~|~\__.==" + "==._( Y )_.==" + ${c2}.-'~~""~=--...,__${c1}\/|\/${c2}__,...--=~""~~'-. +( ..=${c1}\\=${c1}/${c2}=.. ) + `'-. ,.-"`;${c1}/=\\${c2};"-.,_ .-'` + `~"-=-~` .-~` ${c1}|=|${c2} `~-. `~-=-"~` + .-~` /${c1}|=|${c2}\ `~-. + .~` / ${c1}|=|${c2} \ `~. + .-~` .' ${c1}|=|${c2} `. `~-. + (` _,.-="` ${c1} |=|${c2} `"=-.,_ `) + `~"~"` ${c1} |=|${c2} `"~"~` + ${c1} /=\\ + \\=/ + ^ diff --git a/src/logo/ascii/dragonfly_small.txt b/src/logo/ascii/dragonfly_small.txt new file mode 100644 index 000000000..a20c040c8 --- /dev/null +++ b/src/logo/ascii/dragonfly_small.txt @@ -0,0 +1,7 @@ +${c2} ,${c1}_${c2}, +('-_${c1}|${c2}_-') + >--${c1}|${c2}--< +(_-'${c1}|${c2}'-_) + ${c1}| + | + | diff --git a/src/logo/ascii/drauger.txt b/src/logo/ascii/drauger.txt new file mode 100644 index 000000000..72ae4ffe5 --- /dev/null +++ b/src/logo/ascii/drauger.txt @@ -0,0 +1,16 @@ + -``- + `:+``+:` + `/++``++/. + .++/. ./++. + :++/` `/++: + `/++: :++/` + ./+/- -/+/. + -++/. ./++- + :++:` `:++: + `/++- -++/` + ./++. ./+/. + -++/` `/++- + :++:` `:++: + `/++- -++/` +.:-.`..............................`.-:. +`.-/++++++++++++++++++++++++++++++++/-.` diff --git a/src/logo/ascii/droidian.txt b/src/logo/ascii/droidian.txt new file mode 100644 index 000000000..bc1eace63 --- /dev/null +++ b/src/logo/ascii/droidian.txt @@ -0,0 +1,15 @@ +${c2} _,met$$$$$$$$$$gg. + ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P. + ,$$$$P' `$$$$$$. +',$$$$P ,ggs. `$$$$b: +`d$$$$' ,$$P"' ${c1}.${c2} $$$$$$ + $$$$P d$$' ${c1},${c2} $$$$P + $$$$: $$$$. ${c1}-${c2} ,d$$$$' + $$$$; Y$$b._ _,d$$P' + Y$$$$. ${c1}`.${c2}`"Y$$$$$$$$P"' +${c2} `$$$$b ${c1}"-.__ +${c2} `Y$$$$ + `Y$$$$. + `$$$$b. + `Y$$$$b. + `"Y$$b._ diff --git a/src/logo/ascii/elive.txt b/src/logo/ascii/elive.txt new file mode 100644 index 000000000..4727cd863 --- /dev/null +++ b/src/logo/ascii/elive.txt @@ -0,0 +1,17 @@ + *@${c2},,&(%%%..%*. + ${c1}(@${c2}&%/##############((/${c1}*, + ${c2}@${c1}@&${c2}#########${c1}*..../${c2}########%${c1}*.. + ${c2}@${c1}&${c2}#%%%%%. ${c3},.${c1},${c2}%%%%%%. + /%${c2}(%%%%. ${c1}(${c2}%%%%#. + /${c1}*${c2}%%##,. .,%%###, + ,####. ,${c1}*${c2}#%${c1}#${c3}/,(/ ${c2}/${c1}#${c2}###, +((###/ ,,##########${c1}(${c3}/(# ${c2}%####, +%#(((${c1}. .${c1}./${c2}((((((((((((((${c1}(${c2}#/${c3}*.. ${c3}*.${c2}(((${c1}/ +${c2}%#///${c1}. ${c3}***${c2}.*///////////// +${c3}#${c2}#////* ${c3}***${c2}.*/////. + ${c3}(${c2}(***** ${c3}*** + ${c2},*****.. + ..${c1}*${c2}*****.. *${c1}%${c2}/****. + .,,*******,${c3},,../##(${c2}%&${c1}&${c2}#******${c1},${c2}. + ,*${c1},${c2},,,,,,,,,,,,,,,,,,,${c1},${c2}.. + *//${c1}/,,${c2},,,,,,,${c1},..${c2} diff --git a/src/logo/ascii/encryptos.txt b/src/logo/ascii/encryptos.txt new file mode 100644 index 000000000..4f86a291c --- /dev/null +++ b/src/logo/ascii/encryptos.txt @@ -0,0 +1,13 @@ + ******* + *** **. + ** ** + ** ** + + ***************** +,,,,,,,,,,,,,,,,*** +,,,,,,, ,,,,,,, +,,,,,,, ,,,,,,, +,,,,,,, ,,,,,,, +,,,,,,, ,,,,,,, +,,,,,,,,,,,,,,,,,,, + ,,,,,,,,,,,,. diff --git a/src/logo/ascii/endless.txt b/src/logo/ascii/endless.txt new file mode 100644 index 000000000..7dcf052ec --- /dev/null +++ b/src/logo/ascii/endless.txt @@ -0,0 +1,20 @@ + `:+yhmNMMMMNmhy+:` + -odMMNhso//////oshNMMdo- + /dMMh+. .+hMMd/ + /mMNo` `oNMm: + `yMMo` `oMMy` + `dMN- -NMd` + hMN. .NMh +/MM/ -os` /MM/ +dMm `smNmmhs/- `:sNMd+ `` mMd +MMy oMd--:+yMMMMMNo.:ohmMMMNy` yMM +MMy -NNyyhmMNh+oNMMMMMy:. dMo yMM +dMm `/++/-``/yNNh+/sdNMNddMm- mMd +/MM/ `dNy: `-::- /MM/ + hMN. .NMh + `dMN- -NMd` + `yMMo` `oMMy` + /mMNo` `oNMm/ + /dMMh+. .+hMMd/ + -odMMNhso//////oshNMMdo- + `:+yhmNMMMMNmhy+:` diff --git a/src/logo/ascii/eurolinux.txt b/src/logo/ascii/eurolinux.txt new file mode 100644 index 000000000..b379eba1c --- /dev/null +++ b/src/logo/ascii/eurolinux.txt @@ -0,0 +1,18 @@ + __ + -wwwWWWWWWWWWwww- + -WWWWWWWWWWWWWWWWWWw- + \WWWWWWWWWWWWWWWWWWW- + _Ww `WWWWWWWWWWWWWWWWWWWw + -W${c2}E${c1}Www -WWWWWWWWW- +_WW${c2}U${c1}WWWW- _WWWWWWWW +_WW${c2}R${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW- +wWW${c2}O${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW +WWW${c2}L${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWw +WWW${c2}I${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWww- +wWW${c2}N${c1}WWWWw + WW${c2}U${c1}WWWWWWw + wW${c2}X${c1}WWWWWWWWww + wWWWWWWWWWWWWWWWw + wWWWWWWWWWWWWWWWw + WWWWWWWWWWWWWw + wWWWWWWWw diff --git a/src/logo/ascii/exodia_predator.txt b/src/logo/ascii/exodia_predator.txt new file mode 100644 index 000000000..67456ce2a --- /dev/null +++ b/src/logo/ascii/exodia_predator.txt @@ -0,0 +1,24 @@ +- : ++: :+ +++. .++ ++++ : . +++ ++++= .+ + =+++ +++++- ++ += -++++ +++++++- -++ ++- -++++++ +++++++++: .+++ +++. :++++++++ +++++++++++: ++++ ++++ :++++++++++ ++++++++++++==++++ ++++=++++++=+++++ ++++++.:++++++++++ ++++++++++:.+++++ ++++++. .+++++++++ +++++++++. .+++++ ++++++: ++++++++ ++++++++ :+++++ +++++++- =+++++++ +++++++= -++++++ + :+++++= =+++++++ +++++++= =+++++: + :+++= =+++++++ +++++++= =+++: + -+= =+++++++ +++++++= ++- + : =++++++- -++++++= : + =++++- -++++= + =++= =++= + =++ ++= + =+. .+= + =- -= + : : diff --git a/src/logo/ascii/femboyos.txt b/src/logo/ascii/femboyos.txt new file mode 100644 index 000000000..20f0306ed --- /dev/null +++ b/src/logo/ascii/femboyos.txt @@ -0,0 +1,20 @@ +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMWKkxkKWMMMMMMMMMMMMMMMMMMMMWKkxkKWMM +MMMMXo. .;xKWMMMMMMMMMMMMMMMMMMXo. .oXMM +MMWXx,..'..oXMMMMMMMMMMMMMMMMWKx, .lXMM +MMNo. .cOc.,xKWMMMMMMMMMMMMWXx;.....cXMM +MMXl..;kKl. .oXMMMMMMMMMMWKx;..,ok:.'o0W +WKx,.cKWNk;..lXMMMMMMMMWKx;..,o0NXl. .oN +No. .lXMMWKc.,dKWMMMMMMNo..;d0NWMNx,..lX +Nk:,:kNMMMNk:,ckNMMMMMMNxcxXWMMMMMN0ockN +MWNNNWMMMMMWNNNWMMMMMMMMWWWMMMMMMMMMWWWM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMNXKXNWMMMMMMMMMMMWNKOKWMMMMMMMMMM +MMMMMMWKdccxXMMMMMMMMMMW0o'.oXMMMMMMMMMM +MMMMMMMNO:.'o0NKkkkkkOXXo. .lXMMMMMMMMMM +MMMMMMMMNx,..;o;. .:o,..;kNMMMMMMMMMM +MMMMMMMMMNO: ... .cKWMMMMMMMMMMM +MMMMMMMMMMNx,. .;dk:. .;kNMMMMMMMMMMMM +MMMMMMMMMMMN0ocxXWNkl:,:xXWMMMMMMMMMMMMM +MMMMMMMMMMMMMWNWMMMWWNNNWMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM diff --git a/src/logo/ascii/feren.txt b/src/logo/ascii/feren.txt new file mode 100644 index 000000000..186dd7df8 --- /dev/null +++ b/src/logo/ascii/feren.txt @@ -0,0 +1,16 @@ + `----------` + :+ooooooooo+. +-o+oooooooooo+- +..`/+++++++++++/...````````````````` + .++++++++++++++++++++++++++/////- + ++++++++++++++++++++++++++++++++//:` + -++++++++++++++++++++++++++++++/-` + ++++++++++++++++++++++++++++:. + -++++++++++++++++++++++++/. + +++++++++++++++++++++/-` + -++++++++++++++++++//-` + .:+++++++++++++//////- + .:++++++++//////////- + `-++++++---:::://///. + `.:///+++. ` + `......... diff --git a/src/logo/ascii/finnix.txt b/src/logo/ascii/finnix.txt new file mode 100644 index 000000000..9f18eac78 --- /dev/null +++ b/src/logo/ascii/finnix.txt @@ -0,0 +1,17 @@ + ,,:;;;;:,, + ,;*%S########S%*;, + ;?#################S?: + :%######################?: + +##########################; + +############################; + :#############.**,#############, + *###########+ +###########+ + ?########## ${c3}Finnix${c1} ##########* + *###########, ,###########+ + :#############%..%#############, + *############################+ + *##########################+ + ;S######################%: + ,+%##################%; + :+?S##########S?+: + ,:;++++;:, diff --git a/src/logo/ascii/floflis.txt b/src/logo/ascii/floflis.txt new file mode 100644 index 000000000..7d5020518 --- /dev/null +++ b/src/logo/ascii/floflis.txt @@ -0,0 +1,19 @@ + ,▄▄▄▌▓▓███▓▓▌▄▄▄, + ,▄▒▓███████████████████▓▄▄ + ▄▓███████████████████████████▌ + ▓███████████████████████████████ + , ╙▓████████████████████████████▀ ▄ + ╓█▓▄ ╙▀▓████████████████████▀▀` ,▄██▓ + ╓█████▌▄, '▀▀▀▀▓▓▓▓▓▓▀▀Å╙` ▄▄▓█████▌ + ██████████▓▌▄ , ▄▓███████████▄ +╢████████████▓ ║████▓▓███▌ ╣█████████████▓ +▓█████████████ ▐█████████▀ ▓██████████████ +▓█████████████ ▐█████████▄ ███████████████ +▀████████████▌ ║█████████▌ ▀█████████████▌ + ████████████M ▓██████████ ▐█████████████⌐ + ▀██████████▌ ▐███████████▌ ▀███████████▌ + ╙▓█████▓ ▓██████████████▄ ▀███████▀ + ╝▓██▀ ╓▓████████████████▓ ▀▓██▀ + ,▄████████████████████▌, + ╝▀████████████████████▓▀' + `╙▀▀▓▓███████▓▀▀╩' diff --git a/src/logo/ascii/freemint.txt b/src/logo/ascii/freemint.txt new file mode 100644 index 000000000..bc2842dbe --- /dev/null +++ b/src/logo/ascii/freemint.txt @@ -0,0 +1,15 @@ + ## + ## ######### + #### ## + #### #### ## +#### #### ## ## + #### #### ## ## + #### #### ## ## ## + #### ###### + ###### ## ## #### + #### ################ + #### ## #### + ## #### ###### + ## ## #### #### + ## ## ## ## ## #### + #### ## ## ## diff --git a/src/logo/ascii/frugalware.txt b/src/logo/ascii/frugalware.txt new file mode 100644 index 000000000..7b760d3d6 --- /dev/null +++ b/src/logo/ascii/frugalware.txt @@ -0,0 +1,23 @@ + `++/::-.` + /o+++++++++/::-.` + `o+++++++++++++++o++/::-.` + /+++++++++++++++++++++++oo++/:-.`` + .o+ooooooooooooooooooosssssssso++oo++/:-` + ++osoooooooooooosssssssssssssyyo+++++++o: + -o+ssoooooooooooosssssssssssssyyo+++++++s` + o++ssoooooo++++++++++++++sssyyyyo++++++o: + :o++ssoooooo${c2}/-------------${c1}+syyyyyo+++++oo + `o+++ssoooooo${c2}/-----${c1}+++++ooosyyyyyyo++++os: + /o+++ssoooooo${c2}/-----${c1}ooooooosyyyyyyyo+oooss + .o++++ssooooos${c2}/------------${c1}syyyyyyhsosssy- + ++++++ssooooss${c2}/-----${c1}+++++ooyyhhhhhdssssso + -s+++++syssssss${c2}/-----${c1}yyhhhhhhhhhhhddssssy. + sooooooyhyyyyyh${c2}/-----${c1}hhhhhhhhhhhddddyssy+ + :yooooooyhyyyhhhyyyyyyhhhhhhhhhhdddddyssy` + yoooooooyhyyhhhhhhhhhhhhhhhhhhhddddddysy/ +-ysooooooydhhhhhhhhhhhddddddddddddddddssy + .-:/+osssyyyysyyyyyyyyyyyyyyyyyyyyyyssy: + ``.-/+oosysssssssssssssssssssssss + ``.:/+osyysssssssssssssh. + `-:/+osyyssssyo + .-:+++` diff --git a/src/logo/ascii/funtoo.txt b/src/logo/ascii/funtoo.txt new file mode 100644 index 000000000..ad7a2e6e8 --- /dev/null +++ b/src/logo/ascii/funtoo.txt @@ -0,0 +1,10 @@ + .dKXXd . + :XXl;:. .OXo +.'OXO'' .''''''''''''''''''''':XNd..'oco.lco, +xXXXXXX, cXXXNNNXXXXNNXXXXXXXXNNNNKOOK; d0O .k + kXX xXo KNNN0 KNN. 'xXNo :c; 'cc. + kXX xNo KNNN0 KNN. :xxxx. 'NNo + kXX xNo loooc KNN. oNNNN. 'NNo + kXX xN0:. KNN' oNNNX' ,XNk + kXX xNNXNNNNNNNNXNNNNNNNNXNNOxXNX0Xl + ... ......................... .;cc;. diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 81fd9d449..3bdbba069 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -908,6 +908,42 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_CYAN, }, + // CyberOS + { + .names = {"CyberOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_CYBEROS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_256 "57", + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // dahlia + { + .names = {"dahlia"}, + .lines = FASTFETCH_DATATEXT_LOGO_DAHLIA, + .colors = { + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // DarkOS + { + .names = {"DarkOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_DARKOS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_CYAN, + }, // Debian { .names = {"debian", "debian-linux"}, @@ -940,6 +976,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // DesaOS + { + .names = {"DesaOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_DESAOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Devuan { .names = {"devuan", "devuan-linux"}, @@ -961,6 +1008,85 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // DietPi + { + .names = {"DietPi"}, + .lines = FASTFETCH_DATATEXT_LOGO_DIETPI, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLACK, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // DracOS + { + .names = {"DracOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_DRACOS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // DragonFly + { + .names = {"DragonFly", "DragonFly-BSD"}, + .lines = FASTFETCH_DATATEXT_LOGO_DRAGONFLY, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // DragonFlySmall + { + .names = {"DragonFly_small", "DragonFly-BSD_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_DRAGONFLY_SMALL, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // DragonFlyOld + { + .names = {"DragonFly_old", "DragonFly-BSD_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_DRAGONFLY_OLD, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Drauger + { + .names = {"Drauger"}, + .lines = FASTFETCH_DATATEXT_LOGO_DRAUGER, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Droidian + { + .names = {"Droidian"}, + .lines = FASTFETCH_DATATEXT_LOGO_DROIDIAN, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_LIGHT_GREEN, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_LIGHT_GREEN, + }, // Elementary { .names = {"elementary"}, @@ -982,6 +1108,28 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // Elive + { + .names = {"Elive"}, + .lines = FASTFETCH_DATATEXT_LOGO_ELIVE, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_LIGHT_CYAN, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // EncryptOS + { + .names = {"EncryptOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_ENCRYPTOS, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_GREEN, + }, // Endeavour { .names = {"endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, @@ -994,6 +1142,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_RED, }, + // Endless + { + .names = {"Endless"}, + .lines = FASTFETCH_DATATEXT_LOGO_ENDLESS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Enso { .names = {"enso", "uqc"}, @@ -1004,6 +1163,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_WHITE, }, + // EuroLinux + { + .names = {"EuroLinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_EUROLINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Exherbo { .names = {"exherbo", "exherbo-linux"}, @@ -1016,6 +1186,16 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // ExodiaPredator + { + .names = {"Exodia Predator", "exodia-predator", "Exodia Predator OS"}, + .lines = FASTFETCH_DATATEXT_LOGO_EXODIA_PREDATOR, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, // Fedora { .names = {"fedora", "fedora-linux"}, @@ -1049,6 +1229,47 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // FemboyOS + { + .names = {"FemboyOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_FEMBOYOS, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Feren + { + .names = {"Feren"}, + .lines = FASTFETCH_DATATEXT_LOGO_FEREN, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Finnix + { + .names = {"Finnix"}, + .lines = FASTFETCH_DATATEXT_LOGO_FINNIX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Floflis + { + .names = {"Floflis"}, + .lines = FASTFETCH_DATATEXT_LOGO_FLOFLIS, + .colors = { + FF_COLOR_FG_LIGHT_CYAN, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, // FreeBSD { .names = {"freebsd", "HardenedBSD"}, @@ -1071,6 +1292,38 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // FreeMiNT + { + .names = {"FreeMiNT"}, + .lines = FASTFETCH_DATATEXT_LOGO_FREEMINT, + .colors = { + FF_COLOR_FG_WHITE + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Frugalware + { + .names = {"Frugalware", "frugalware-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_FRUGALWARE, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Funtoo + { + .names = {"Funtoo"}, + .lines = FASTFETCH_DATATEXT_LOGO_FUNTOO, + .colors = { + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Garuda { .names = {"garuda", "garuda-linux"}, From fa13906e47e69eac0deb6f1b883737c99fafde7d Mon Sep 17 00:00:00 2001 From: b1n4ry Date: Thu, 3 Aug 2023 14:38:48 +0300 Subject: [PATCH 418/493] Fix typo in config_user.txt ...weather to hide... -> ...whether to hide... --- src/data/config_user.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 29152b3d8..594b3e99d 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -271,7 +271,7 @@ #--opengl-library auto # GPU hide options -# Sets weather to hide certain gpu types +# Sets whether to hide certain gpu types # Must be either true or false # Default is false. #--gpu-hide-integrated From 1d1dc56ec1c9e475f83330652d948fac0816312f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 10:31:30 +0800 Subject: [PATCH 419/493] Logo (Builtin): more 81 left --- src/logo/ascii/galliumos.txt | 19 + src/logo/ascii/glaucus.txt | 12 + src/logo/ascii/gnewsense.txt | 12 + src/logo/ascii/gobolinux.txt | 6 + src/logo/ascii/grapheneos.txt | 23 + src/logo/ascii/grombyang.txt | 18 + src/logo/ascii/guix.txt | 10 + src/logo/ascii/guix_small.txt | 7 + src/logo/ascii/hamonikr.txt | 23 + src/logo/ascii/hardclanz.txt | 19 + src/logo/ascii/hash.txt | 13 + src/logo/ascii/huayra.txt | 17 + src/logo/ascii/hybrid.txt | 16 + src/logo/ascii/hydroos.txt | 8 + src/logo/ascii/hyperbola.txt | 16 + src/logo/ascii/hyperbola_small.txt | 7 + src/logo/ascii/iglunix.txt | 12 + src/logo/ascii/instantos.txt | 20 + src/logo/ascii/irix.txt | 19 + src/logo/ascii/itc.txt | 10 + src/logo/ascii/januslinux.txt | 24 + src/logo/ascii/kaisen.txt | 17 + src/logo/ascii/kali.txt | 21 + src/logo/ascii/kali_small.txt | 16 + src/logo/ascii/kaos.txt | 16 + src/logo/ascii/kibojoe.txt | 13 + src/logo/ascii/kogaion.txt | 20 + src/logo/ascii/korora.txt | 16 + src/logo/ascii/krassos.txt | 19 + src/logo/ascii/kslinux.txt | 11 + src/logo/ascii/laxeros.txt | 20 + src/logo/ascii/lede.txt | 9 + src/logo/ascii/libreelec.txt | 20 + src/logo/ascii/linspire.txt | 12 + src/logo/ascii/linuxlite.txt | 20 + src/logo/ascii/linuxlite_small.txt | 7 + src/logo/ascii/live_raizo.txt | 20 + src/logo/ascii/lunar.txt | 13 + src/logo/ascii/mageia.txt | 19 + src/logo/ascii/mageia_small.txt | 7 + src/logo/ascii/magpieos.txt | 20 + src/logo/ascii/massos.txt | 18 + src/logo/ascii/matuusos.txt | 20 + src/logo/ascii/maui.txt | 20 + src/logo/ascii/meowix.txt | 10 + src/logo/ascii/mer.txt | 27 ++ src/logo/ascii/miracle_linux.txt | 16 + src/logo/ascii/namib.txt | 20 + src/logo/ascii/nekos.txt | 23 + src/logo/ascii/neptune.txt | 17 + src/logo/ascii/netrunner.txt | 20 + src/logo/ascii/nitrux.txt | 18 + src/logo/ascii/nixos_small.txt | 4 +- src/logo/ascii/nurunner.txt | 19 + src/logo/ascii/nutyx.txt | 23 + src/logo/ascii/obarun.txt | 19 + src/logo/ascii/obrevenge.txt | 18 + src/logo/ascii/omnios.txt | 8 + src/logo/ascii/openeuler.txt | 23 + src/logo/ascii/openindiana.txt | 16 + src/logo/ascii/openmamba.txt | 21 + src/logo/ascii/openstage.txt | 17 + src/logo/ascii/opnsense.txt | 20 + src/logo/ascii/os_elbrus.txt | 14 + src/logo/ascii/osmc.txt | 20 + src/logo/builtin.c | 681 ++++++++++++++++++++++++++++- src/logo/logo.c | 4 +- 67 files changed, 1738 insertions(+), 5 deletions(-) create mode 100644 src/logo/ascii/galliumos.txt create mode 100644 src/logo/ascii/glaucus.txt create mode 100644 src/logo/ascii/gnewsense.txt create mode 100644 src/logo/ascii/gobolinux.txt create mode 100644 src/logo/ascii/grapheneos.txt create mode 100644 src/logo/ascii/grombyang.txt create mode 100644 src/logo/ascii/guix.txt create mode 100644 src/logo/ascii/guix_small.txt create mode 100644 src/logo/ascii/hamonikr.txt create mode 100644 src/logo/ascii/hardclanz.txt create mode 100644 src/logo/ascii/hash.txt create mode 100644 src/logo/ascii/huayra.txt create mode 100644 src/logo/ascii/hybrid.txt create mode 100644 src/logo/ascii/hydroos.txt create mode 100644 src/logo/ascii/hyperbola.txt create mode 100644 src/logo/ascii/hyperbola_small.txt create mode 100644 src/logo/ascii/iglunix.txt create mode 100644 src/logo/ascii/instantos.txt create mode 100644 src/logo/ascii/irix.txt create mode 100644 src/logo/ascii/itc.txt create mode 100644 src/logo/ascii/januslinux.txt create mode 100644 src/logo/ascii/kaisen.txt create mode 100644 src/logo/ascii/kali.txt create mode 100644 src/logo/ascii/kali_small.txt create mode 100644 src/logo/ascii/kaos.txt create mode 100644 src/logo/ascii/kibojoe.txt create mode 100644 src/logo/ascii/kogaion.txt create mode 100644 src/logo/ascii/korora.txt create mode 100644 src/logo/ascii/krassos.txt create mode 100644 src/logo/ascii/kslinux.txt create mode 100644 src/logo/ascii/laxeros.txt create mode 100644 src/logo/ascii/lede.txt create mode 100644 src/logo/ascii/libreelec.txt create mode 100644 src/logo/ascii/linspire.txt create mode 100644 src/logo/ascii/linuxlite.txt create mode 100644 src/logo/ascii/linuxlite_small.txt create mode 100644 src/logo/ascii/live_raizo.txt create mode 100644 src/logo/ascii/lunar.txt create mode 100644 src/logo/ascii/mageia.txt create mode 100644 src/logo/ascii/mageia_small.txt create mode 100644 src/logo/ascii/magpieos.txt create mode 100644 src/logo/ascii/massos.txt create mode 100644 src/logo/ascii/matuusos.txt create mode 100644 src/logo/ascii/maui.txt create mode 100644 src/logo/ascii/meowix.txt create mode 100644 src/logo/ascii/mer.txt create mode 100644 src/logo/ascii/miracle_linux.txt create mode 100644 src/logo/ascii/namib.txt create mode 100644 src/logo/ascii/nekos.txt create mode 100644 src/logo/ascii/neptune.txt create mode 100644 src/logo/ascii/netrunner.txt create mode 100644 src/logo/ascii/nitrux.txt create mode 100644 src/logo/ascii/nurunner.txt create mode 100644 src/logo/ascii/nutyx.txt create mode 100644 src/logo/ascii/obarun.txt create mode 100644 src/logo/ascii/obrevenge.txt create mode 100644 src/logo/ascii/omnios.txt create mode 100644 src/logo/ascii/openeuler.txt create mode 100644 src/logo/ascii/openindiana.txt create mode 100644 src/logo/ascii/openmamba.txt create mode 100644 src/logo/ascii/openstage.txt create mode 100644 src/logo/ascii/opnsense.txt create mode 100644 src/logo/ascii/os_elbrus.txt create mode 100644 src/logo/ascii/osmc.txt diff --git a/src/logo/ascii/galliumos.txt b/src/logo/ascii/galliumos.txt new file mode 100644 index 000000000..fdc4b71cf --- /dev/null +++ b/src/logo/ascii/galliumos.txt @@ -0,0 +1,19 @@ +sooooooooooooooooooooooooooooooooooooo+: +yyooooooooooooooooooooooooooooooooo+/::: +yyysoooooooooooooooooooooooooooo+/:::::: +yyyyyoooooooooooooooooooooooo+/::::::::: +yyyyyysoooooooooooooooooo++/:::::::::::: +yyyyyyysoooooooooooooo++/::::::::::::::: +yyyyyyyyysoooooo${c2}sydddys${c1}+/::::::::::::::: +yyyyyyyyyysooo${c2}smMMMMMMMNd${c1}+:::::::::::::: +yyyyyyyyyyyyo${c2}sMMMMMMMMMMMN${c1}/::::::::::::: +yyyyyyyyyyyyy${c2}dMMMMMMMMMMMM${c1}o//::::::::::: +yyyyyyyyyyyyy${c2}hMMMMMMMMMMMm${c1}--//:::::::::: +yyyyyyyyyyyyyy${c2}hmMMMMMMMNy${c1}:..-://:::::::: +yyyyyyyyyyyyyyy${c2}yyhhyys+:${c1}......://::::::: +yyyyyyyyyyyyyyys+:--...........-///::::: +yyyyyyyyyyyys+:--................://:::: +yyyyyyyyyo+:-.....................-//::: +yyyyyyo+:-..........................://: +yyyo+:-..............................-// +o/:-...................................: diff --git a/src/logo/ascii/glaucus.txt b/src/logo/ascii/glaucus.txt new file mode 100644 index 000000000..6878951e9 --- /dev/null +++ b/src/logo/ascii/glaucus.txt @@ -0,0 +1,12 @@ + ,, ,d88P + ,d8P ,ad8888* + ,888P d88888* ,,ad8888P* + d d888P a88888P* ,ad8888888* + .d8 d8888: d888888* ,d888888P* + .888; 88888b d8888888b8888888P + d8888J888888a88888888888888P* ,d + 88888888888888888888888888P ,,d8* + 888888888888888888888888888888888* + *8888888888888888888888888888888* + Y888888888P* `*``*888888888888* + *^888^* *Y888P** diff --git a/src/logo/ascii/gnewsense.txt b/src/logo/ascii/gnewsense.txt new file mode 100644 index 000000000..d6a43f5df --- /dev/null +++ b/src/logo/ascii/gnewsense.txt @@ -0,0 +1,12 @@ + ..,,,,.. + .oocchhhhhhhhhhccoo. + .ochhlllllllc hhhhhh ollllllhhco. + ochlllllllllll hhhllllllhhh lllllllllllhco + .cllllllllllllll hlllllo +hllh llllllllllllllc. +ollllllllllhco'' hlllllo +hllh ``ochllllllllllo +hllllllllc' hllllllllllllh `cllllllllh +ollllllh +llllllllllll+ hllllllo + `cllllh. ohllllllho .hllllc' + ochllc. ++++ .cllhco + `+occooo+. .+ooocco+' + `+oo++++ ++++oo+' diff --git a/src/logo/ascii/gobolinux.txt b/src/logo/ascii/gobolinux.txt new file mode 100644 index 000000000..a8583004a --- /dev/null +++ b/src/logo/ascii/gobolinux.txt @@ -0,0 +1,6 @@ + _____ _ + / ____| | | +| | __ ___ | |__ ___ +| | |_ |/ _ \| '_ \ / _ \ +| |__| | (_) | |_) | (_) | + \_____|\___/|_.__/ \___/ diff --git a/src/logo/ascii/grapheneos.txt b/src/logo/ascii/grapheneos.txt new file mode 100644 index 000000000..c1b8152e8 --- /dev/null +++ b/src/logo/ascii/grapheneos.txt @@ -0,0 +1,23 @@ + B? + G~ + G~& + G!^:^?# + &^.:::.J + &PG& #G5JJ7~^~?JY5B& #PG + B5JJPGJ77YG5JYP# && &B5JYPGJ7?YG5JYP# + &Y..::.:P& &?..::.:G + #!::::? B~::::J + B~J# B!?# + !P 75 + !P 75 + !5 7Y + &Y~:^!P &J~:^!P + P..::.:B Y..::.:# + #PYJJ~^^!JJYP# &B5YJ?~^^!JJYG# + &YYG# && #PYJ5G5??JGGYJ5G& && #PYP + B^.::..7& + J::::^G + #Y^G& + B~ + G! + # diff --git a/src/logo/ascii/grombyang.txt b/src/logo/ascii/grombyang.txt new file mode 100644 index 000000000..6bbfa08bc --- /dev/null +++ b/src/logo/ascii/grombyang.txt @@ -0,0 +1,18 @@ + eeeeeeeeeeee + eeeeeeeeeeeeeeeee + eeeeeeeeeeeeeeeeeeeeeee + eeeee ${c2}.o+ ${c1}eeee + eeee ${c2}`ooo/ ${c1}eeee + eeee ${c2}`+oooo: ${c1}eeee +eee ${c2}`+oooooo: ${c1}eee +eee ${c2}-+oooooo+: ${c1}eee +ee ${c2}`/:oooooooo+: ${c1}ee +ee ${c2}`/+ +++ +: ${c1}ee +ee ${c2}+o+\ ${c1}ee +eee ${c2}+o+\ ${c1}eee +eee ${c2}// \\ooo/ \\\ ${c1}eee + eee ${c2}//++++oooo++++\\\ ${c1}eee + eeee ${c2}::::++oooo+::::: ${c1}eeee + eeeee ${c3}Grombyang OS ${c1} eeee + eeeeeeeeeeeeeeeeeeeeeee + eeeeeeeeeeeeeeeee diff --git a/src/logo/ascii/guix.txt b/src/logo/ascii/guix.txt new file mode 100644 index 000000000..64b7a9972 --- /dev/null +++ b/src/logo/ascii/guix.txt @@ -0,0 +1,10 @@ + .. `. + `--..```..` `..```..--` + .-:///-:::. `-:::///:-. + ````.:::` `:::.```` + -//:` -::- + ://: -::- + `///- .:::` + -+++-:::. + :+/:::- + `-....` diff --git a/src/logo/ascii/guix_small.txt b/src/logo/ascii/guix_small.txt new file mode 100644 index 000000000..ee48c0021 --- /dev/null +++ b/src/logo/ascii/guix_small.txt @@ -0,0 +1,7 @@ +|.__ __.| +|__ \\ / __| + \\ \\ / / + \\ \\ / / + \\ \\ / / + \\ \\/ / + \\__/ diff --git a/src/logo/ascii/hamonikr.txt b/src/logo/ascii/hamonikr.txt new file mode 100644 index 000000000..c2f38f432 --- /dev/null +++ b/src/logo/ascii/hamonikr.txt @@ -0,0 +1,23 @@ + cO0Ox. + .ldddddddo. + .lddddddddddo + 'lddddddddddddc + ,oddddddddddddd; + 'ldddddddddddddo. + .oddddddddddddddc. + ,dddddddddddddddo. + ,ccoooooooocoddooo: + ,cooooooooooooooooop ${c3} c000x. +${c1}.cooooooooooooooopcllll${c3} .cddddddo. +${c1}coooooooooooooop' .qlll.${c3} .ddoooooooo; +${c1}cooooooooooc; ${c3}'qlllp. .ddoooooooooo; +${c1}.cooooooc; ${c3}'lllbc...coooooooooooo; +${c1} .cooc' ${c3}.llllcoooooooooooooo. + .coooooooooooooop: + .coooooooooooooop' + .cooooooooooooop. + .cooooooooooooop. + .coooooooooooop. + .cooooooooooop. + .cooooooooop. + .cooooop' diff --git a/src/logo/ascii/hardclanz.txt b/src/logo/ascii/hardclanz.txt new file mode 100644 index 000000000..19766d953 --- /dev/null +++ b/src/logo/ascii/hardclanz.txt @@ -0,0 +1,19 @@ +${c1} ........::::.... + ::################::.. + :########################:. + :######**###################: + :###${c2}&&&&^${c1}############ ${c2}&${c1}#######: + :#${c2}&&&&&${c1}.:##############:${c2}^&o${c1}`:###: + :#${c2}&&&&${c1}.:#################:.${c2}&&&${c1}`###: + :##${c2}&^${c1}:######################:${c2}^&&${c1}::##: + :#############################:${c2}&${c1}:##:: + :##########${c2}@@${c1}###########${c2}@@${c1}#####:.###: +:#########${c2}@@${c3}o${c2}@@${c1}#########${c2}@@${c3}o${c2}@@${c1}########: +:#######:${c2}@@${c3}o${c5}0${c3}o${c2}@@@@${c1}###${c2}@@@@${c3}o${c5}0${c3}o${c2}@@${c1}######: : + :######:${c2}@@@${c3}o${c2}@@@@@@${c1}V${c2}@@@@@@${c3}o${c2}@@@${c1}######: + :#####:${c2}@@@@@@@@@@@@@@@@@@@${c1}:####; + :####:.${c2}@@@@@@@@@@@@@@@@${c1}:#####: + `:####:.${c2}@@@@@@@@@@@@@@${c1}:#####: + ``:##:.${c2}@@@@@@@@@@@@${c1}^## # : + : ## ${c2}\@@@;@@@/ ${c1}:: # : + ${c2} VVV diff --git a/src/logo/ascii/hash.txt b/src/logo/ascii/hash.txt new file mode 100644 index 000000000..1ddaf1758 --- /dev/null +++ b/src/logo/ascii/hash.txt @@ -0,0 +1,13 @@ + + ###### + + ### ###### ### + ##### ###### ##### + ###### ###### ###### + +####### '"###### '"######## +####### ###### ######## +####### ###### ######## + + ###### '"###### '"###### + ##### ###### ##### + ### ###### ### + ~ ###### ~ diff --git a/src/logo/ascii/huayra.txt b/src/logo/ascii/huayra.txt new file mode 100644 index 000000000..5cca3f880 --- /dev/null +++ b/src/logo/ascii/huayra.txt @@ -0,0 +1,17 @@ +${c2} ` + . . ` + `` - . . + `.` -` `. - `` .` + ..`-`-` + - / .` ``` + .--.+--`+:- :/.` .-``.` + -+/so::h:.d-`./:`.` + :hNhyMomy:os-...-. ```` + .dhsshNmNhoo+:-``.``` + ${c1}`ohy:-${c2}NMds+::-.`` + ````${c1}.hNN+`${c2}mMNho/:-....```` + ````` `../dmNhoo+/:..`` + ```` .dh++o/:....` +.+s/` `/s-.-.:.`` ```` +::` `::`..` + .` `.. + `` diff --git a/src/logo/ascii/hybrid.txt b/src/logo/ascii/hybrid.txt new file mode 100644 index 000000000..bc0d06444 --- /dev/null +++ b/src/logo/ascii/hybrid.txt @@ -0,0 +1,16 @@ +${c1} / ${c2}# +${c1}////& ${c2}##### +${c1}///// ${c2}###### +${c1}///// ////////// ${c2}###### +${c1}///// //////////////////// ${c2}###### +${c1}////////////////////////// ${c2}###### +${c1}///////// /// ${c2}###### +${c1}/////// / ${c2}###### +${c1}////// ${c2}###### +${c1}///// ${c2}###### +${c1}///// ${c2}###### +${c1}///// ${c2}###### +${c1}///// ${c2}###### +${c1}///// ${c2}###### +${c1}///// ${c2}######### +${c1}////& ${c2}######## diff --git a/src/logo/ascii/hydroos.txt b/src/logo/ascii/hydroos.txt new file mode 100644 index 000000000..df5bbe4a5 --- /dev/null +++ b/src/logo/ascii/hydroos.txt @@ -0,0 +1,8 @@ + _ _ _ ____ _____ +| | | | | | / __ \ / ____| +| |__| |_ _ __| |_ __ ___ | | | | (___ +| __ | | | |/ _` | '__/ _ \| | | |\___ \ +| | | | |_| | (_| | | | (_) | |__| |____) | +|_| |_|\__, |\__,_|_| \___/ \____/|_____/ + __/ | + |___/ diff --git a/src/logo/ascii/hyperbola.txt b/src/logo/ascii/hyperbola.txt new file mode 100644 index 000000000..396a7a195 --- /dev/null +++ b/src/logo/ascii/hyperbola.txt @@ -0,0 +1,16 @@ + WW + KX W + WO0W NX0O + NOO0NW WNXK0OOKW + W0OOOOOOOOOOOOKN + N0OOOOOOO0KXW + WNXXXNW + NXK00000KN + WNK0OOOOOOOOOO0W + NK0OOOOOOOOOOOOOO0W + X0OOOOOOO00KK00OOOOOK + X0OOOO0KNWW WX0OO0W + X0OO0XNW KOOW + N00KNW KOW + NKXN W0W +WW W diff --git a/src/logo/ascii/hyperbola_small.txt b/src/logo/ascii/hyperbola_small.txt new file mode 100644 index 000000000..b3adf7d9e --- /dev/null +++ b/src/logo/ascii/hyperbola_small.txt @@ -0,0 +1,7 @@ + |`__.`/ + \____/ + .--. + / \\ + / ___ \\ + / .` `.\\ +/.` `.\\ diff --git a/src/logo/ascii/iglunix.txt b/src/logo/ascii/iglunix.txt new file mode 100644 index 000000000..a36537a3b --- /dev/null +++ b/src/logo/ascii/iglunix.txt @@ -0,0 +1,12 @@ + | + | | + | +| ________ +| /\ | \ + / \ | \ | + / \ \ | +/ \________\ +\ / / + \ / / + \ / / + \/________/ diff --git a/src/logo/ascii/instantos.txt b/src/logo/ascii/instantos.txt new file mode 100644 index 000000000..150b520c3 --- /dev/null +++ b/src/logo/ascii/instantos.txt @@ -0,0 +1,20 @@ + 'cx0XWWMMWNKOd:'. + .;kNMMMMMMMMMMMMMWNKd' + 'kNMMMMMMWNNNWMMMMMMMMXo. +,0MMMMMW0o;'..,:dKWMMMMMWx. +OMMMMMXl. .xNMMMMMNo +WMMMMNl .kWWMMMMO' +MMMMMX; oNWMMMMK, +NMMMMWo .OWMMMMMK, +kWMMMMNd. ,kWMMMMMMK, +'kWMMMMWXxl:;;:okNMMMMMMMMK, + .oXMMMMMMMWWWMMMMMMMMMMMMK, + 'oKWMMMMMMMMMMMMMMMMMMMK, + .;lxOKXXXXXXXXXXXXXXXO;...... + ................,d0000000kd:. + .kMMMMMMMMMW0; + .kMMMMMMMMMMMX + .xMMMMMMMMMMMW + cXMMMMMMMMMM0 + :0WMMMMMMNx, + .o0NMWNOc. diff --git a/src/logo/ascii/irix.txt b/src/logo/ascii/irix.txt new file mode 100644 index 000000000..ae9329bb4 --- /dev/null +++ b/src/logo/ascii/irix.txt @@ -0,0 +1,19 @@ + ./ohmNd/ +dNmho/- + `:+ydNMMMMMMMM.-MMMMMMMMMdyo:. + `hMMMMMMNhs/sMMM-:MMM+/shNMMMMMMh` + -NMMMMMmo-` /MMM-/MMM- `-omMMMMMN. + `.`-+hNMMMMMNhyMMM-/MMMshmMMMMMmy+...` ++mMNds:-:sdNMMMMMMMyyMMMMMMMNdo:.:sdMMm+ +dMMMMMMmy+.-/ymNMMMMMMMMNmy/-.+hmMMMMMMd +oMMMMmMMMMNds:.+MMMmmMMN/.-odNMMMMmMMMM+ +.MMMM-/ymMMMMMmNMMy..hMMNmMMMMMmy/-MMMM. + hMMM/ `/dMMMMMMMN////NMMMMMMMd/. /MMMh + /MMMdhmMMMmyyMMMMMMMMMMMMhymMMMmhdMMM: + `mMMMMNho//sdMMMMM//NMMMMms//ohNMMMMd + `/so/:+ymMMMNMMMM` mMMMMMMMmh+::+o/` + `yNMMNho-yMMMM` NMMMm.+hNMMNh` + -MMMMd: oMMMM. NMMMh :hMMMM- + -yNMMMmooMMMM- NMMMyomMMMNy- + .omMMMMMMMM-`NMMMMMMMmo. + `:hMMMMMM. NMMMMMh/` + .odNm+ /dNms. diff --git a/src/logo/ascii/itc.txt b/src/logo/ascii/itc.txt new file mode 100644 index 000000000..f27c4c3c2 --- /dev/null +++ b/src/logo/ascii/itc.txt @@ -0,0 +1,10 @@ +${c1}....................-==============+... +${c1}....................-==============:... +${c1}...:===========-....-==============:... +${c1}...-===========:....-==============-... +${c1}....*==========+........-::********-... +${c1}....*===========+.:*====**==*+-.-...... +${c1}....:============*+-..--:+**====*---... +${c1}......::--........................::... +${c1}..+-:+-.+::*:+::+:-++::++-.:-.*.:++:++. +${c1}..:-:-++++:-::--:+::-::.:++-++:++--:-:. diff --git a/src/logo/ascii/januslinux.txt b/src/logo/ascii/januslinux.txt new file mode 100644 index 000000000..e81cc69a4 --- /dev/null +++ b/src/logo/ascii/januslinux.txt @@ -0,0 +1,24 @@ + 'l: + loooooo + loooo coooool + looooooooooooooooooool + looooooooooooooooo + lool cooo + coooooooloooooooo + clooooo ;lood cloooo + :loooocooo cloo loooo + loooo :ooooool loooo +looo cooooo cooooo +looooooooooooo ;loooooo ${c2}looooooc +${c1}looooooooo loo cloooooool ${c2}looooc +${c1} cooo cooooooooooo ${c2}looolooooool +${c1} cooo: ${c2}coooooooooooooooooool + loooooooooooolc: loooc; + cooo: loooooooooooc + ;oool looooooo: + coool olc, + looooc ,, + coooooc loc + :oooool, coool:, looool:, + looool: ooooooooooooooo: + cooolc .ooooooooooool diff --git a/src/logo/ascii/kaisen.txt b/src/logo/ascii/kaisen.txt new file mode 100644 index 000000000..be9cd0894 --- /dev/null +++ b/src/logo/ascii/kaisen.txt @@ -0,0 +1,17 @@ + `:+oyyho. + `+:`sdddddd/ + `+` :ho oyo++ohds-` + .ho :dd. .: `sddddddhhyso+/- + ody.ddd-:yd- +hysssyhddddddddho` + yddddddhddd` ` `--` -+hddddddh. + hddy-+dddddy+ohh/..+sddddy/:::+ys + :ddd/sdddddddddd- oddddddd ` + `yddddddddddddddd/ /ddddddd/ +:. :ydddddddddddddddddo..sddddddy/` +odhdddddddo- `ddddh+-``....-+hdddddds. +-ddddddhd: /dddo -ydddddddhdddddddd- + /hdy:o - `:sddds .`./hdddddddddddddo + `/- `+hddyosy+ :dddddddy-.-od/ + :sydds -hddddddd` / + .+shd- `:ohddddddddd` + `:+ooooooooooooo: diff --git a/src/logo/ascii/kali.txt b/src/logo/ascii/kali.txt new file mode 100644 index 000000000..84176a04b --- /dev/null +++ b/src/logo/ascii/kali.txt @@ -0,0 +1,21 @@ +.............. + ..,;:ccc,. + ......''';lxO. +.....''''..........,:ld; + .';;;:::;,,.x, + ..'''. 0Xxoc:,. ... + .... ,ONkc;,;cokOdc',. + . OMo ':${c2}dd${c1}o. + dMc :OO; + 0M. .:o. + ;Wd + ;XO, + ,d0Odlc;,.. + ..',;:cdOOd::,. + .:d;.':;. + 'd, .' + ;l .. + .o + c + .' + . diff --git a/src/logo/ascii/kali_small.txt b/src/logo/ascii/kali_small.txt new file mode 100644 index 000000000..c8a468cea --- /dev/null +++ b/src/logo/ascii/kali_small.txt @@ -0,0 +1,16 @@ + -#. # + @### + -###### + @######### +=##. .##### +## ## ## +## ## # +## @### +##. ### + ##% ##- + -##% -* + :*##+ + :*#* + -# + @ + : diff --git a/src/logo/ascii/kaos.txt b/src/logo/ascii/kaos.txt new file mode 100644 index 000000000..8648a71c1 --- /dev/null +++ b/src/logo/ascii/kaos.txt @@ -0,0 +1,16 @@ + .. + ..... ..OSSAAAAAAA.. + .KKKKSS. .SSAAAAAAAAAAA. +.KKKKKSO. .SAAAAAAAAAA... +KKKKKKS. .OAAAAAAAA. +KKKKKKS. .OAAAAAA. +KKKKKKS. .SSAA.. +.KKKKKS..OAAAAAAAAAAAA........ + DKKKKO.=AA=========A===AASSSO.. + AKKKS.==========AASSSSAAAAAASS. + .=KKO..========ASS.....SSSSASSSS. + .KK. .ASS..O.. =SSSSAOSS: + .OK. .ASSSSSSSO...=A.SSA. + .K ..SSSASSSS.. ..SSA. + .SSS.AAKAKSSKA. + .SSS....S.. diff --git a/src/logo/ascii/kibojoe.txt b/src/logo/ascii/kibojoe.txt new file mode 100644 index 000000000..5e8cf510f --- /dev/null +++ b/src/logo/ascii/kibojoe.txt @@ -0,0 +1,13 @@ +${c3} ./+oooooo+/. + -/+ooooo+/:.` + ${c1}`${c3}yyyo${c2}+++/++${c3}osss${c1}. + ${c1}+NMN${c3}yssssssssssss${c1}. + ${c1}.dMMMMN${c3}sssssssssssy${c1}Ns` + +MMMMMMMm${c3}sssssssssssh${c1}MNo` + `hMMMMMNNNMd${c3}sssssssssssd${c1}MMN/ + .${c3}syyyssssssy${c1}NNmmmmd${c3}sssss${c1}hMMMMd: + -NMmh${c3}yssssssssyhhhhyssyh${c1}mMMMMMMMy` + -NMMMMMNN${c3}mdhyyyyyyyhdm${c1}NMMMMMMMMMMMN+ +`NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd. +ods+/:-----://+oyydmNMMMMMMMMMMMMMMMMMN- +` .-:+osyhhdmmNNNmdo diff --git a/src/logo/ascii/kogaion.txt b/src/logo/ascii/kogaion.txt new file mode 100644 index 000000000..1a305e06b --- /dev/null +++ b/src/logo/ascii/kogaion.txt @@ -0,0 +1,20 @@ + ;; ,; + ;;; ,;; + ,;;;; ;;;; + ,;;;;;;;; ;;;; + ;;;;;;;;;;; ;;;;; + ,;;;;;;;;;;;; ';;;;;, + ;;;;;;;;;;;;;;, ';;;;;;; + ;;;;;;;;;;;;;;;;;, ';;;;; +; ';;;;;;;;;;;;;;;;;;, ;;; +;;;, ';;;;;;;;;;;;;;;;;;;,;; +;;;;;, ';;;;;;;;;;;;;;;;;;, +;;;;;;;;, ';;;;;;;;;;;;;;;;, +;;;;;;;;;;;;, ';;;;;;;;;;;;;; +';;;;;;;;;;;;; ';;;;;;;;;;;;; + ';;;;;;;;;;;;;, ';;;;;;;;;;; + ';;;;;;;;;;;;; ;;;;;;;;;; + ';;;;;;;;;;;; ;;;;;;;; + ';;;;;;;; ;;;;;; + ';;;;; ;;;; + ';;; ;; diff --git a/src/logo/ascii/korora.txt b/src/logo/ascii/korora.txt new file mode 100644 index 000000000..709289afd --- /dev/null +++ b/src/logo/ascii/korora.txt @@ -0,0 +1,16 @@ +${c2} ____________ + _add55555555554${c1}: + _w?'${c1}``````````'${c2})k${c1}: + _Z'${c1}`${c2} ]k${c1}: + m(${c1}`${c2} )k${c1}: + _.ss${c1}`${c2}m[${c1}`${c2}, ]e${c1}: + .uY"^`${c1}`${c2}Xc${c1}`${c2}?Ss. d(${c1}` + jF'${c1}`${c2} `@. ${c1}`${c2}Sc .jr${c1}` + jr${c1}`${c2} `?n_ ${c1}`${c2}$; _a2"${c1}` +.m${c1}:${c2} `~M${c1}`${c2}1k${c1}`${c2}5?!`${c1}` +:#${c1}:${c2} ${c1}`${c2})e${c1}``` +:m${c1}:${c2} ,#'${c1}` +:#${c1}:${c2} .s2'${c1}` +:m,________.aa7^${c1}` +:#baaaaaaas!J'${c1}` + ``````````` diff --git a/src/logo/ascii/krassos.txt b/src/logo/ascii/krassos.txt new file mode 100644 index 000000000..aa3bdcaa3 --- /dev/null +++ b/src/logo/ascii/krassos.txt @@ -0,0 +1,19 @@ + ${c2}**@@@@@@@@@@@* + ${c2},@@@@%${c1}(((((((((((((${c2}%@@@@, + ${c2}#@@&${c1}(((((((((((((((((((((((${c2}&@@% + ${c2}@@&${c1}(((((((((((((((((((((((((((((${c2}@@@ + ${c2}@@&${c1}(((((((((((((((((((((((((((((((((${c2}&@@ + ${c2}.@@${c1}(((((((((((((((((((((((((((((((((((((${c2}@@. + ${c2}@@${c1}(((((((((((((((((((((((((((((((((((((((${c2}@@ + ${c2}@@#${c1}(((((((((((((((((((((((((((((${c2}%@@@@@@@#${c1}(#${c2}@@ + ${c2}.@@${c1}((((((((((((((((${c2}#%@@@@@@@@@&%#${c1}((((${c2}%@&${c1}((((${c2}@@. + ${c2}.@@${c1}(((((((/(${c2}&@@@@@@%${c1}(/((((((((((((((${c2}@@/${c1}(((((${c2}@@. + ${c2}.@@${c1}(///////////////////////////////${c2}@${c1}(///////${c2}@@ + ${c2}%@#${c1}/////////////////////////////(${c2}#${c1}////////${c2}%@% + ${c2} @@${c1}(///////////////////////////${c2}%${c1}/////////(${c2}@@ + ${c2}@@#${c1}***********************************${c2}%@@ + ${c2}*@@${c1}********************************${c2}/@@/ + ${c2},@@#${c1}***************************${c2}%@@* + ${c2}@@@&${c1}********************${c2}/@@@@ + ${c2}&@@@@&${c1}(//***//(${c2}&@@@@& + ${c2}**@@@@@@@@@@@* diff --git a/src/logo/ascii/kslinux.txt b/src/logo/ascii/kslinux.txt new file mode 100644 index 000000000..c2246410b --- /dev/null +++ b/src/logo/ascii/kslinux.txt @@ -0,0 +1,11 @@ +K K U U RRRR ooo +K K U U R R o o +KKK U U RRRR o o +K K U U R R o o +K K UUU R R ooo + +${c2} SSS AAA W W AAA +S A A W W A A + SSS AAAAA W W W AAAAA + S A A WW WW A A + SSS A A W W A A diff --git a/src/logo/ascii/laxeros.txt b/src/logo/ascii/laxeros.txt new file mode 100644 index 000000000..38d24c8f0 --- /dev/null +++ b/src/logo/ascii/laxeros.txt @@ -0,0 +1,20 @@ + /. + `://:- + `//////: + .////////:` + -//////////:` + -/////////////` + :///////////////. + `://////.```-//////- + `://///:` .//////- + `//////: `//////: + .//////- `://///:` + -//////- `://///:` + -//////. ://////` + ://////` -//////. + `/////:` ./////: + .-::-` .:::-` + +.:://////////////////////////////////::. +//////////////////////////////////////// +.:////////////////////////////////////:. diff --git a/src/logo/ascii/lede.txt b/src/logo/ascii/lede.txt new file mode 100644 index 000000000..459ae94ec --- /dev/null +++ b/src/logo/ascii/lede.txt @@ -0,0 +1,9 @@ + _________ + / /\ + / LE / \ + / DE / \ +/________/ LE \ +\ \ DE / + \ LE \ / + \ DE \ / + \________\/ diff --git a/src/logo/ascii/libreelec.txt b/src/logo/ascii/libreelec.txt new file mode 100644 index 000000000..9a6534e3f --- /dev/null +++ b/src/logo/ascii/libreelec.txt @@ -0,0 +1,20 @@ +${c1} :+ooo/. ${c2}./ooo+: +${c1} :+ooooooo/. ${c2}./ooooooo+: +${c1} :+ooooooooooo:${c2}:ooooooooooo+: +${c1} :+ooooooooooo+- ${c2}-+ooooooooooo+: +${c1} :+ooooooooooo+- ${c3}-- ${c2}-+ooooooooooo+: +${c1}.+ooooooooooo+- ${c3}:+oo+: ${c2}-+ooooooooooo+- +${c1}-+ooooooooo+- ${c3}:+oooooo+: ${c2}-+oooooooooo- +${c1} :+ooooo+- ${c3}:+oooooooooo+: ${c2}-+oooooo: +${c1} :+o+- ${c3}:+oooooooooooooo+: ${c2}-+oo: +${c4} ./ ${c3}:oooooooooooooooooo: ${c5}/. +${c4} ./oo+: ${c3}-+oooooooooooooo+- ${c5}:+oo/. +${c4} ./oooooo+: ${c3}-+oooooooooo+- ${c5}:+oooooo/. +${c4}-oooooooooo+: ${c3}-+oooooo+- ${c5}:+oooooooooo- +${c4}.+ooooooooooo+: ${c3}-+oo+- ${c5}:+ooooooooooo+. +${c4} -+ooooooooooo+: ${c3}.. ${c5}:+ooooooooooo+- +${c4} -+ooooooooooo+: ${c5}:+ooooooooooo+- +${c4} -+oooooooooo+:${c5}:+oooooooooo+- +${c4} -+oooooo+: ${c5}:+oooooo+- +${c4} -+oo+: ${c5}:+oo+- +${c4} .. ${c5}.. diff --git a/src/logo/ascii/linspire.txt b/src/logo/ascii/linspire.txt new file mode 100644 index 000000000..3b8fbd450 --- /dev/null +++ b/src/logo/ascii/linspire.txt @@ -0,0 +1,12 @@ +${c2} __^ +${c2} __/ \\ +${c2} MMy dMy __/ \\ +${c2} dMMy MMy ${c1}MM${c2} \\ +${c2} MMMy ,, ${c1}dMMMMn ${c2}\\ +${c2} dMMy dMM dMMMMMMy ${c1}dMM MM dMMMMMy dMM MM.nMMM dMMMMMM +${c1}MMM ${c2}MMy MMy MMy ${c1}dMM MMy MMy MMy MMy dy dMy +${c1}MMM ${c2}dMM dMM MMy ${c1}dMMMMy dMM dMM dMM dMM dMMMMMMM +${c2} dMMy MMy MMy MMy ${c1}dMMy MM MMy MMy MMy dMM +${c2}dMMy dMM dMM dMM ${c1}dMM MMy dMMMMMy dMM dMM MMy MM +${c2}MMMMMMMMMM MMy MMy MMy ${c1}dMMMyyy MMy MMy MMy dMMMMMMy +${c2} ${c1}dy diff --git a/src/logo/ascii/linuxlite.txt b/src/logo/ascii/linuxlite.txt new file mode 100644 index 000000000..c6a398b8d --- /dev/null +++ b/src/logo/ascii/linuxlite.txt @@ -0,0 +1,20 @@ + ,xXc + .l0MMMMMO + .kNMMMMMWMMMN, + KMMMMMMKMMMMMMo + 'MMMMMMNKMMMMMM: + kMMMMMMOMMMMMMO + .MMMMMMX0MMMMMW. + oMMMMMMxWMMMMM: + WMMMMMNkMMMMMO +:MMMMMMOXMMMMW +.0MMMMMxMMMMM; +:;cKMMWxMMMMO +'MMWMMXOMMMMl + kMMMMKOMMMMMX: + .WMMMMKOWMMM0c + lMMMMMWO0MNd:' + oollXMKXoxl;. + ':. .: .' + .. + . diff --git a/src/logo/ascii/linuxlite_small.txt b/src/logo/ascii/linuxlite_small.txt new file mode 100644 index 000000000..6fd817d4d --- /dev/null +++ b/src/logo/ascii/linuxlite_small.txt @@ -0,0 +1,7 @@ +${c1} /\\ + / \\ + / ${c2}/ ${c1}/ +> ${c2}/ ${c1}/ +\\ ${c2}\\ ${c1}\\ + \\_${c2}\\${c1}_\\ +${c2} \\ diff --git a/src/logo/ascii/live_raizo.txt b/src/logo/ascii/live_raizo.txt new file mode 100644 index 000000000..ebc079feb --- /dev/null +++ b/src/logo/ascii/live_raizo.txt @@ -0,0 +1,20 @@ + `......` + -+shmNMMMMMMNmhs/. + :smMMMMMmmhyyhmmMMMMMmo- + -hMMMMd+:. `----` .:odMMMMh- + `hMMMN+. .odNMMMMMMNdo. .yMMMMs` + hMMMd. -dMMMMmdhhdNMMMNh` .mMMMh +oMMMm` :MMMNs.:sddy:-sMMMN- `NMMM+ +mMMMs dMMMo sMMMMMMd yMMMd sMMMm +----` .---` oNMMMMMh `---. .---- + .sMMy: + /MM/ + +dMMms. + hMMMMMMN + `dMMMMMMm: + .+ss+sMNysMMoomMd+ss+. + +MMMMMMN` +MM/ hMMMMMNs + sMMMMMMm-hNMMMd-hMMMMMMd + :yddh+`hMMMMMMN :yddy/` + .hMMMMd: + `..` diff --git a/src/logo/ascii/lunar.txt b/src/logo/ascii/lunar.txt new file mode 100644 index 000000000..dd4373e83 --- /dev/null +++ b/src/logo/ascii/lunar.txt @@ -0,0 +1,13 @@ +`-. `-. + -ohys/-` `:+shy/` + -omNNdyo/` :+shmNNy/` + ${c3} - + /mMmo + hMMMN` + .NMMs + ${c1} -:+oooo+//: ${c3}/MN${c1}. -///oooo+/-` + /:.` ${c3}/${c1} `.:/` +${c3} __ + | | _ _ ___ ___ ___ + | |__| | | | .'| _| + |_____|___|_|_|__,|_| diff --git a/src/logo/ascii/mageia.txt b/src/logo/ascii/mageia.txt new file mode 100644 index 000000000..cd2566deb --- /dev/null +++ b/src/logo/ascii/mageia.txt @@ -0,0 +1,19 @@ + .°°. + °° .°°. + .°°°. °° + . . + °°° .°°°. + .°°°. '___' +${c2} .${c1}'___' ${c2} . + :dkxc;'. ..,cxkd; + .dkk. kkkkkkkkkk .kkd. +.dkk. ';cloolc;. .kkd +ckk. .kk; +xO: cOd +xO: lOd +lOO. .OO: +.k00. .00x + .k00; ;00O. + .lO0Kc;,,,,,,;c0KOc. + ;d00KKKKKK00d; + .,KKKK,. diff --git a/src/logo/ascii/mageia_small.txt b/src/logo/ascii/mageia_small.txt new file mode 100644 index 000000000..84bf0dc4c --- /dev/null +++ b/src/logo/ascii/mageia_small.txt @@ -0,0 +1,7 @@ + * + * + ** +${c2} /\\__/\\ +/ \\ +\\ / + \\____/ diff --git a/src/logo/ascii/magpieos.txt b/src/logo/ascii/magpieos.txt new file mode 100644 index 000000000..20da68650 --- /dev/null +++ b/src/logo/ascii/magpieos.txt @@ -0,0 +1,20 @@ + ;00000 :000Ol + .x00kk00: O0kk00k; + l00: :00. o0k :O0k. + .k0k. x${c2}d$dddd${c1}k' .d00; + k0k. ${c2}.dddddl ${c1}o00, + o00. ${c2}':cc:. ${c1}d0O +.00l ,00. +l00. d0x +k0O .:k0o +O0k ;dO0000d. +k0O .O0O${c2}xxxxk${c1}00: +o00. k0O${c2}dddddd${c1}occ +'00l x0O${c2}dddddo${c3};..${c1} + x00. .x00${c2}kxxd${c3}:..${c1} + .O0x .:oxxx${c4}Okl.${c1} + .x0d ${c4},xx,${c1} + .:o. ${c4}.xd ckd${c1} + .. ${c4}dxl .xx; + :xxolldxd' + ;oxdl. diff --git a/src/logo/ascii/massos.txt b/src/logo/ascii/massos.txt new file mode 100644 index 000000000..5cc4e796f --- /dev/null +++ b/src/logo/ascii/massos.txt @@ -0,0 +1,18 @@ +-+++/+++osyyhdmNNMMMMNdy/ +/MMMMMMMMMMMMMMMMMMMMMMMMm. +/MMMMMMMMMMMMMMMMMMMMMMMMMm +/MMMMMMMMMMMMMMMMMMMMMMMMMM: +:ddddddddhddddddddhdddddddd/ +/NNNNNNNm:NNNNNNNN-NNNNNNNNo +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +/MMMMMMMN:MMMMMMMM-MMMMMMMMs +:MMMMMMMN:MMMMMMMM-MMMMMMMMs + dMMMMMMN:MMMMMMMM-MMMMMMMMs + `yNMMMMN:MMMMMMMM-MMMMMMMMs + `:+oss.ssssssss.ssssssss/ diff --git a/src/logo/ascii/matuusos.txt b/src/logo/ascii/matuusos.txt new file mode 100644 index 000000000..bf7505dae --- /dev/null +++ b/src/logo/ascii/matuusos.txt @@ -0,0 +1,20 @@ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░▒▓▓████▓▒▒░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░▒▓████████████▓░░░░░░░░░░░░░░ +░░░░░░░░░░░░▓████████████████▒░░░░░░░░░░░░ +░░░░░░░░░░░▓██████████████████▒░░░░░░░░░░░ +░░░░░░░░░░▓████▒▓███████▓▓█████░░░░░░░░░░░ +░░░░░░░░░░██████▓░▓████▒░██████▓░░░░░░░░░░ +░░░░░░░░░▒███████▓░▒▓▒░░████████░░░░░░░░░░ +░░░░░░░░░▒█████████▒░░░█████████░░░░░░░░░░ +░░░░░░░░░░██████████▓▒██████████░░░░░░░░░░ +░░░░░░░░░░▓████████████████████▒░░░░░░░░░░ +░░░░░░░░░░░███████████████████▓░░░░░░░░░░░ +░░░░░░░░░░░░█████████████████▓░░░░░░░░░░░░ +░░░░░░░░░░░░░▓██████████████▒░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░▒▓████████▓░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ +░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ diff --git a/src/logo/ascii/maui.txt b/src/logo/ascii/maui.txt new file mode 100644 index 000000000..650371f48 --- /dev/null +++ b/src/logo/ascii/maui.txt @@ -0,0 +1,20 @@ + `.-://////:--` + .:/oooooooooooooooo+:. + `:+ooooooooooooooooooooooo:` + `:oooooooooooooooooooooooooooo/` + ..```-oooooo/-`` `:oooooo+:.` `-- + :. +oo+-` /ooo/` -/ + -o. `o+- +o/` -o: +`oo` ::` :o/ `+. .+o` /oo. +/o+ . -+oo- ` /oo/ `ooo/ ++o- /ooo+` .+ooo. :ooo+ +++ .+oooo: -oooo+ `oooo+ +:. .oooooo` :ooooo- :oooo: +` .oooooo: :ooooo+ `ooo+-` + .+oooooo` -oooooo: `o/- + +oooooo: .ooooooo. + /ooooooo` /ooooooo/ .. + `:oooooooo/:::/ooooooooo+:--:/:` + `:+oooooooooooooooooooooo+:` + .:+oooooooooooooooo+:. + `.-://////:-.` diff --git a/src/logo/ascii/meowix.txt b/src/logo/ascii/meowix.txt new file mode 100644 index 000000000..73682942a --- /dev/null +++ b/src/logo/ascii/meowix.txt @@ -0,0 +1,10 @@ +${c1} #${c2}% ${c3}&${c4}* +${c1} ##${c2}%% ${c3}&&${c4}** +${c1} ## ${c2}%% ${c3}&& ${c4}** +${c1} ## ${c2}%% ${c3}&& ${c4}** +${c1} ## ${c2}%% ${c3}&& ${c4}** +${c1} ## ${c2}%% ${c3}&& ${c4}** +${c1} ## ${c2}%%${c3}&& ${c4}** +${c1} ## ${c2}%% ${c4}** +${c1} ## ${c4}** +${c1}## ${c4}** diff --git a/src/logo/ascii/mer.txt b/src/logo/ascii/mer.txt new file mode 100644 index 000000000..11cdca1c4 --- /dev/null +++ b/src/logo/ascii/mer.txt @@ -0,0 +1,27 @@ + dMs + .-` + `y`-o+` + ``NMMy + .--`:++. + .hNNNNs + /MMMMMN + `ommmd/ +/ + ```` +/ + `:+sssso/-` + .-::. `-::-` `smNMNmdmNMNd/ .://-` +.ymNMNNdmNMMNm+` -dMMh:.....+dMMs `sNNMMNo +dMN+::NMMy::hMM+ mMMo `ohhy/ `dMM+ yMMy::- +MMm yMM- :MMs NMN` `:::::--sMMh dMM` +MMm yMM- -MMs mMM+ `ymmdsymMMMs dMM` +NNd sNN- -NNs -mMNs-.--..:dMMh` dNN +--- .--` `--. .smMMmdddmMNdo` .-- + ./ohddds+:` + +h- `.:-. + ./`.dMMMN+ + +MMMMMd + `+dmmy- + ``` .+` + .dMNo-y. + `hmm/ + .:` + dMs diff --git a/src/logo/ascii/miracle_linux.txt b/src/logo/ascii/miracle_linux.txt new file mode 100644 index 000000000..f7d021977 --- /dev/null +++ b/src/logo/ascii/miracle_linux.txt @@ -0,0 +1,16 @@ + ,A + .### + .#' .#### .#. + r##: :#### ####. + +###; :#### ######C + :####: #### ,######".#. +.# :####. :### #####'.#####. +##: `####. ### ###'.########+. +#### `####::## ##'.#######+' + ####+.`###i## #',####:' + `+###MI`##### 'l###:' + `+####+`### ;#E' + `+###:## #' + `:### ' + '## + '; diff --git a/src/logo/ascii/namib.txt b/src/logo/ascii/namib.txt new file mode 100644 index 000000000..ee4ff6ba8 --- /dev/null +++ b/src/logo/ascii/namib.txt @@ -0,0 +1,20 @@ + .:+shysyhhhhysyhs+:. + -/yyys syyy/- + -shy yhs- + -yhs shy- + +hy yh+ + +ds sd+ +/ys so sy/ +sh smMMNdyo hs +yo ymMMMMNNMMNho oy +N ydMMMNNMMMMMMMMMmy N +N shmMMMMNNMMMMMMMMMMMMMNy N +yo ooshmNMMMNNNNMMMMMMMMMMMMMMMMMms oy +sd yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy ds +/ys sy/ + +ds sd+ + +hy yh+ + -yhs shy- + -shy yhs- + -/yyys syyy/- + .:+shysyhyhhysyhs+:. diff --git a/src/logo/ascii/nekos.txt b/src/logo/ascii/nekos.txt new file mode 100644 index 000000000..8dfeb3c3e --- /dev/null +++ b/src/logo/ascii/nekos.txt @@ -0,0 +1,23 @@ + @@@@@ + @@@@@@@@@. + @@@@@@@@ @@@ + @@@@@@@@@@@ @@. + @@@@@@@@@@@@@ . + @@@@@@@@@@@@@@@@@ , + @@@@@@@@@@@@@@@@@@@ + @@@@@${c2}///${c1}@@@@@@@${c2}///${c1}@@@ + @@@@${c2}/***${c1}@@@@@@@${c2}**//${c1}@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@ + @@@/ /@@@@@@@@@/ /@@@ + @@@@@@ @@@${c3}██${c1}@@@@ @@@@@@ + @@@@@@/ /@${c2}██${c3}██${c2}██${c1}@@/ /@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@ + ##########%%%% + ##########%% %% + @ @@@#######@@%%% + @@@ @@@@####@@@@ % + @@@ @@@@@@@#@@@@@@@ + @@@ @@@@@@@@@@@@@@@ + @@@@ @@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/logo/ascii/neptune.txt b/src/logo/ascii/neptune.txt new file mode 100644 index 000000000..b88d03169 --- /dev/null +++ b/src/logo/ascii/neptune.txt @@ -0,0 +1,17 @@ + ./+sydddddddys/-. + .+ymNNdyooo/:+oooymNNmy/` + `/hNNh/.` `-+dNNy:` + /mMd/. .++.:oy/ .+mMd- + `sMN/ oMMmdy+. `oNNo + `hMd. `/ymy/. :NMo + oMN- `/dMd: /MM- +`mMy -dMN+` mMs +.MMo -NMM/ yMs + dMh mMMMo:` `NMo + /MM/ /ymMMMm- sMN. + +Mm: .hMMd` oMN/ + +mNs. `yNd/` -dMm- + .yMNs: `/.` `/yNNo` + .odNNy+-` .:ohNNd/. + -+ymNNmdyyyyyyydmNNmy+. + `-//sssssss//. diff --git a/src/logo/ascii/netrunner.txt b/src/logo/ascii/netrunner.txt new file mode 100644 index 000000000..abbaef9bd --- /dev/null +++ b/src/logo/ascii/netrunner.txt @@ -0,0 +1,20 @@ + .:oydmMMMMMMmdyo:` + -smMMMMMMMMMMMMMMMMMMds- + +mMMMMMMMMMMMMMMMMMMMMMMMMd+ + /mMMMMMMMMMMMMMMMMMMMMMMMMMMMMm/ + `hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy` + .mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd` + dMMMMMMMMMMMMMMMMMMMMMMNdhmMMMMMMMMMMh ++MMMMMMMMMMMMMNmhyo+/-. -MMMMMMMMMMMM/ +mMMMMMMMMd+:.` `mMMMMMMMMMMMMd +MMMMMMMMMMMdy/. yMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMNh+` +MMMMMMMMMMMMMMM +mMMMMMMMMMMMMMMMMMs -NMMMMMMMMMMMMMMd ++MMMMMMMMMMMMMMMMMN. `mMMMMMMMMMMMMMMM/ + dMMMMMMMMMMMMMMMMMy hMMMMMMMMMMMMMMMh + `dMMMMMMMMMMMMMMMMM-+MMMMMMMMMMMMMMMd` + `hMMMMMMMMMMMMMMMMmMMMMMMMMMMMMMMMy + /mMMMMMMMMMMMMMMMMMMMMMMMMMMMMm: + +dMMMMMMMMMMMMMMMMMMMMMMMMd/ + -odMMMMMMMMMMMMMMMMMMdo- + `:+ydmNMMMMNmhy+-` diff --git a/src/logo/ascii/nitrux.txt b/src/logo/ascii/nitrux.txt new file mode 100644 index 000000000..c27c02356 --- /dev/null +++ b/src/logo/ascii/nitrux.txt @@ -0,0 +1,18 @@ +`:/. +`/yo +`/yo +`/yo .+:. +`/yo .sys+:.` +`/yo `-/sys+:.` +`/yo ./sss+:.` +`/yo .:oss+:-` +`/yo ./o///:-` +`/yo `.-:///////:` +`/yo `.://///++//-`` +`/yo `.-:////++++/-` +`/yo `-://///++o+/-` +`/yo `-/+o+++ooo+/-` +`/s+:+oooossso/.` +`//+sssssso:. +`+syyyy+:` +:+s+- diff --git a/src/logo/ascii/nixos_small.txt b/src/logo/ascii/nixos_small.txt index b7b3367dd..be1b628a3 100644 --- a/src/logo/ascii/nixos_small.txt +++ b/src/logo/ascii/nixos_small.txt @@ -1,7 +1,7 @@ -$1 \\ \\ // + \\ \\ // ==\\__\\/ // // \\// ==// //== //\\___// // /\\ \\== - // \\ \\ \ No newline at end of file + // \\ \\ diff --git a/src/logo/ascii/nurunner.txt b/src/logo/ascii/nurunner.txt new file mode 100644 index 000000000..a4fa6c524 --- /dev/null +++ b/src/logo/ascii/nurunner.txt @@ -0,0 +1,19 @@ + ,xc + ;00cxXl + ;K0, .xNo. + :KO' .lXx. + cXk. ;xl cXk. + cXk. ;k:.,xo. cXk. + .lXx. :x::0MNl,dd. :KO, + .xNx. cx;:KMMMMMNo'dx. ;KK; + .dNl. cd,cXMMMMMMMMMWd,ox' 'OK: +;WK. 'K,.KMMMMMMMMMMMMMWc.Kx lMO + 'OK: 'dl'xWMMMMMMMMMM0::x: 'OK: + .kNo .xo'xWMMMMMM0;:O: ;KK; + .dXd. .do,oNMMO;ck: ;00, + oNd. .dx,;'cO; ;K0, + oNx. okk; ;K0, + lXx. :KO' + cKk' cXk. + ;00:lXx. + ,kd. diff --git a/src/logo/ascii/nutyx.txt b/src/logo/ascii/nutyx.txt new file mode 100644 index 000000000..6adc33fa7 --- /dev/null +++ b/src/logo/ascii/nutyx.txt @@ -0,0 +1,23 @@ + . + . + ... + ... + .... .........--. + ..-++-----....--++++++---. + .-++++++-. .-++++++++++++-----.. + .--... .++..-+++--.....-++++++++++--.. + . .-+-. .**- .... ..-+----.. + .+++. .*+. + -++-----. + .+++++- ++. .*+. .....-+++-----. + -+++-++. .+. .-+***++***++--++++. . + -+-. -- -. -*- ...... ..--. +.-. .+- . -+. +. .+- +. + -- -- + -+----. .- + -++-.+. . + .++. -- + +. ----. + . .+. .. + - . + . diff --git a/src/logo/ascii/obarun.txt b/src/logo/ascii/obarun.txt new file mode 100644 index 000000000..2e57389d4 --- /dev/null +++ b/src/logo/ascii/obarun.txt @@ -0,0 +1,19 @@ + ,;::::; + ;cooolc;, + ,coool; + ,loool, + loooo; + :ooool + cooooc ,:ccc; + looooc :oooooool + cooooo ;oooooooooo, + :ooooo; :ooooooooooo + oooooo oooooooooooc +:oooooo :ooooooooool +loooooo ;oooooooool +looooooc .coooooooc +cooooooo: ,;co; +,ooooooool; ,:loc + cooooooooooooloooooc + ;ooooooooooooool; + ;looooooolc; diff --git a/src/logo/ascii/obrevenge.txt b/src/logo/ascii/obrevenge.txt new file mode 100644 index 000000000..d561ad217 --- /dev/null +++ b/src/logo/ascii/obrevenge.txt @@ -0,0 +1,18 @@ + __ __ + _@@@@ @@@g_ + _@@@@@@ @@@@@@ + _@@@@@@M W@@@@@@_ + j@@@@P ^W@@@@ + @@@@L____ _____Q@@@@ +Q@@@@@@@@@@j@@@@@@@@@@ +@@@@@ T@j@ T@@@@@ +@@@@@ ___Q@J@ _@@@@@ +@@@@@fMMM@@j@jggg@@@@@@ +@@@@@ j@j@^MW@P @@@@ +Q@@@@@ggg@@f@ @@@@@@L +^@@@@WWMMP ^ Q@@@@ + @@@@@_ _@@@@l + W@@@@@g_____g@@@@@P + @@@@@@@@@@@@@@@@l + ^W@@@@@@@@@@@P + ^TMMMMTll diff --git a/src/logo/ascii/omnios.txt b/src/logo/ascii/omnios.txt new file mode 100644 index 000000000..6852c5d9c --- /dev/null +++ b/src/logo/ascii/omnios.txt @@ -0,0 +1,8 @@ + ____ __ __ _ _ _ + / __ \ | \/ || \ | || | +| | | || || \| || | +| |__| || |\/| || , `${c2}_${c1}||${c2}_${c1}| ${c2}____${c1} + \____/ |_| |_||_|\${c2}/ __ \ / ___| + | | | ||(__ + ${c3}community${c2} | |__| | ___)| + ${c3}edition${c2} \____/ |____/ diff --git a/src/logo/ascii/openeuler.txt b/src/logo/ascii/openeuler.txt new file mode 100644 index 000000000..38ec0c009 --- /dev/null +++ b/src/logo/ascii/openeuler.txt @@ -0,0 +1,23 @@ + `.cc.` + ``.cccccccc..` + `.cccccccccccccccc.` + ``.cccccccccccccccccccccc.`` + `..cccccccccccccccccccccccccccc..` +`.ccccccccccccccc${c2}/++/${c1}ccccccccccccccccc.` +.ccccccccccccccc${c2}mNMMNdo+oso+${c1}ccccccccccc. +.cccccccccc${c2}/++odms+//+mMMMMm/:+syso/${c1}cccc +.ccccccccc${c2}yNNMMMs:::/::+o+/:${c1}c${c2}dMMMMMm${c1}cccc +.ccccccc${c2}:+NmdyyhNNmNNNd:${c1}ccccc${c1}${c2}:oyyyo:${c1}cccc +.ccc${c2}:ohdmMs:${c1}cccc${c2}+mNMNmy${c1}ccccccccccccccccc +.cc${c2}/NMMMMMo////:${c1}c${c2}:///:${c1}cccccccccccccccccc +.cc${c2}:syysyNMNNNMNy${c1}ccccccccccccccccccccccc +.cccccccc${c2}+MMMMMNy${c1}c${c2}:/+++/${c1}cccccccccccccccc +.ccccccccc${c2}ohhhs/${c1}c${c2}omMMMMNh${c1}ccccccccccccccc +.ccccccccccccccc${c2}:MMMMMMMM/${c1}cccccccccccccc +.cccccccccccccccc${c2}sNNNNNd+${c1}cccccccccccccc. +`..cccccccccccccccc${c2}/+/:${c1}cccccccccccccc..` + ``.cccccccccccccccccccccccccccc.`` + `.cccccccccccccccccccccc.` + ``.cccccccccccccc.`` + `.cccccccc.` + `....` diff --git a/src/logo/ascii/openindiana.txt b/src/logo/ascii/openindiana.txt new file mode 100644 index 000000000..c76d8f7ba --- /dev/null +++ b/src/logo/ascii/openindiana.txt @@ -0,0 +1,16 @@ +${c2} .sy/ + .yh+ + + ${c1}-+syyyo+- ${c2} /+. + ${c1}+ddo/---/sdh/ ${c2} ym- + ${c1}`hm+ `sms${c2} ym-```````.-. + ${c1}sm+ sm/ ${c2} ym- +s + ${c1}hm. /mo ${c2} ym- /h + ${c1}omo ym: ${c2} ym- `os` + ${c1}smo` .ym+ ${c2} ym- .os- + `` ${c1}:ymy+///oyms- ${c2} ym- .+s+. + ..` ${c1}`:+oo+/-` ${c2} -//oyo- + -:` .:oys/. ++- `./oyys/. +h+` `.-:+oyyyo/-` +`/ossssysso+/-.` diff --git a/src/logo/ascii/openmamba.txt b/src/logo/ascii/openmamba.txt new file mode 100644 index 000000000..61bca9fbc --- /dev/null +++ b/src/logo/ascii/openmamba.txt @@ -0,0 +1,21 @@ + ````` + .-/+ooooooooo+/:-` + ./ooooooooooooooooooo+:. + -+oooooooooooooooooooooooo+- + .+ooooooooo+/:---::/+ooooooooo+. + :oooooooo/-` `-/oo${c2}s´${c1}oooo.${c2}s´${c1} + :ooooooo/` `${c2}sNds${c1}ooo${c2}sNds${c1} + -ooooooo- ${c2}:dmy${c1}ooo${c2}:dmy${c1} + +oooooo: :oooooo- +.ooooooo .://:` +:oooooo+ ./+o+:` +-ooooooo` `oooooo+ +`ooooooo: /oooooo+ + -ooooooo: :ooooooo. + :ooooooo+. .+ooooooo: + :oooooooo+-` `-+oooooooo: + .+ooooooooo+/::::://oooooooooo+. + -+oooooooooooooooooooooooo+- + .:ooooooooooooooooooo+:. + `-:/ooooooooo+/:.` + `````` diff --git a/src/logo/ascii/openstage.txt b/src/logo/ascii/openstage.txt new file mode 100644 index 000000000..b113be856 --- /dev/null +++ b/src/logo/ascii/openstage.txt @@ -0,0 +1,17 @@ + /(/ + .(((((((, + /(((((((((/ + .(((((/,/(((((, + *(((((* ,(((((/ + (((((* .*/(( + *((((/ (//(/* + /((((* ((((((((((, + . /((((* (((((((((((((. + ((. *((((/ ,(((((((( + ,(((/ (((((/ ** ,((((((* + /(((((. .(((((/ //(((* *(((((/ + .(((((, ((/ .(((((/. .(((((, + /((((* ,(((((((/ ,((((( + /(((((((((((((((((((/. /(((((((((/ + /(((((((((((((((((, /(((((((((((/ + */(((((//*. */((/(/(/* diff --git a/src/logo/ascii/opnsense.txt b/src/logo/ascii/opnsense.txt new file mode 100644 index 000000000..4e62c7e89 --- /dev/null +++ b/src/logo/ascii/opnsense.txt @@ -0,0 +1,20 @@ + .''''''''''''''''''''''''''''''''''' + oocc:::::::::::::::::::::::::::::::cox + ;00; o0O + .,:' .;;;;;;;;;;;;;;;;;;;;;;;;;; ;:, + .',;;cxOOOOOOOOOOOOOOOOOOOOOOOkd:;;,.. + .,cll:' ':llc,. + ,;;:okxdxd: :dxdxko:;;, + .xxxx0XNNK0O. .O0KNNX0xxxx. + ,${c2}cc:${c1},. .,${c2}:cc${c1}, + ........;${c2}ccc:${c1};. .;${c2}:ccc${c1};........ + ${c2}ccccccccccccccc ccccccccccccccc${c1} + ........;${c2}ccc:${c1};. .;${c2}:ccc${c1};........ + ,${c2}cc:${c1},. .,${c2}:cc${c1}, + .xxxx0XNNK0O. .O0KNNX0xxxx. + ,;;:okxdxd: :dxdxko:;;, + .,cll:' ':llc,. + .,,;,ckOOOOOOOOOOOOOOOOOOOOOOOOx;,;,'. + .:l' ........................... ;:; + lOk' cdd + ;lccccccccccccccccccccccccccccccccccc:. diff --git a/src/logo/ascii/os_elbrus.txt b/src/logo/ascii/os_elbrus.txt new file mode 100644 index 000000000..b70cac89c --- /dev/null +++ b/src/logo/ascii/os_elbrus.txt @@ -0,0 +1,14 @@ +▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ +██▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀██ +██ ██ +██ ███████ ███████ ██ +██ ██ ██ ██ ██ ██ +██ ██ ██ ██ ██ ██ +██ ██ ██ ██ ██ ██ +██ ██ ██ ██ ██ ██ +██ ██ ███████ ███████ +██ ██ ██ +██ ██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██ +██ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀██ +██ ██ +███████████████████████████ diff --git a/src/logo/ascii/osmc.txt b/src/logo/ascii/osmc.txt new file mode 100644 index 000000000..a7d8868db --- /dev/null +++ b/src/logo/ascii/osmc.txt @@ -0,0 +1,20 @@ + -+shdmNNNNmdhs+- + .+hMNho/:..``..:/ohNMh+. + :hMdo. .odMh: + -dMy- -yMd- + sMd- -dMs + hMy +. .+ yMh + yMy dMs. .sMd yMy +:Mm dMNMs` `sMNMd `mM: +yM+ dM//mNs``sNm//Md +My +mM- dM: +NNNN+ :Md -Mm +mM- dM: `oNN+ :Md -Mm +yM+ dM/+NNo` :Md +My +:Mm` dMMNs` :Md `mM: + yMy dMs` -ms yMy + hMy +. yMh + sMd- -dMs + -dMy- -yMd- + :hMdo. .odMh: + .+hMNho/:..``..:/ohNMh+. + -+shdmNNNNmdhs+- diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 3bdbba069..860526fdb 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1324,6 +1324,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_WHITE, }, + // GalliumOS + { + .names = {"GalliumOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_GALLIUMOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Garuda { .names = {"garuda", "garuda-linux"}, @@ -1388,6 +1399,26 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_RED, }, + // Glaucus + { + .names = {"Glaucus"}, + .lines = FASTFETCH_DATATEXT_LOGO_GLAUCUS, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, + // gNewSense + { + .names = {"gNewSense"}, + .lines = FASTFETCH_DATATEXT_LOGO_GNEWSENSE, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, + }, // Gnome { .names = {"Gnome"}, @@ -1408,6 +1439,58 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_RED, }, + // GoboLinux + { + .names = {"GoboLinux", "Gobo"}, + .lines = FASTFETCH_DATATEXT_LOGO_GOBOLINUX, + .colors = { + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_MAGENTA, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, + // GrapheneOS + { + .names = {"GrapheneOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_GRAPHENEOS, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // Grombyang + { + .names = {"Grombyang"}, + .lines = FASTFETCH_DATATEXT_LOGO_GROMBYANG, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // Guix + { + .names = {"Guix"}, + .lines = FASTFETCH_DATATEXT_LOGO_GUIX, + .colors = { + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // GuixSmall + { + .names = {"Guix_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_GUIX_SMALL, + .colors = { + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Haiku { .names = {"Haiku"}, @@ -1432,6 +1515,189 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_YELLOW, }, + // HamoniKR + { + .names = {"HamoniKR"}, + .lines = FASTFETCH_DATATEXT_LOGO_HAMONIKR, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_256 "99" + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // HarDClanZ + { + .names = {"HarDClanZ"}, + .lines = FASTFETCH_DATATEXT_LOGO_HARDCLANZ, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Hash + { + .names = {"Hash"}, + .lines = FASTFETCH_DATATEXT_LOGO_HASH, + .colors = { + FF_COLOR_FG_256 "123", + }, + .colorKeys = FF_COLOR_FG_256 "123", + .colorTitle = FF_COLOR_FG_256 "123", + }, + // Huayra + { + .names = {"Huayra"}, + .lines = FASTFETCH_DATATEXT_LOGO_HUAYRA, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // Hybrid + { + .names = {"Hybrid"}, + .lines = FASTFETCH_DATATEXT_LOGO_HYBRID, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, + }, + // HydroOS + { + .names = {"HydroOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_HYDROOS, + .colors = { + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // Hyperbola + { + .names = {"Hyperbola"}, + .lines = FASTFETCH_DATATEXT_LOGO_HYPERBOLA, + .colors = { + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // HyperbolaSmall + { + .names = {"Hyperbola_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_HYPERBOLA_SMALL, + .colors = { + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Iglunix + { + .names = {"Iglunix", "Iglu"}, + .lines = FASTFETCH_DATATEXT_LOGO_IGLUNIX, + .colors = { + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // InstantOS + { + .names = {"InstantOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_INSTANTOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // IRIX + { + .names = {"IRIX"}, + .lines = FASTFETCH_DATATEXT_LOGO_IRIX, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Itc + { + .names = {"Itc"}, + .lines = FASTFETCH_DATATEXT_LOGO_ITC, + .colors = { + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_RED, + }, + // januslinux + { + .names = {"januslinux", "janus", "Ataraxia Linux", "Ataraxia"}, + .lines = FASTFETCH_DATATEXT_LOGO_JANUSLINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, + // Kaisen + { + .names = {"Kaisen"}, + .lines = FASTFETCH_DATATEXT_LOGO_KAISEN, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Kali + { + .names = {"Kali", "Kalilinux", "Kali-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_KALI, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // KaliSmall + { + .names = {"Kali_small", "Kalilinux_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_KALI_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // KaOS + { + .names = {"KaOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_KAOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // KDENeon { .names = {"kde", "kde-neon", "neon"}, @@ -1442,6 +1708,18 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // Kibojoe + { + .names = {"Kibojoe"}, + .lines = FASTFETCH_DATATEXT_LOGO_KIBOJOE, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_WHITE, + }, // KISSLinux { .names = {"kiss", "kiss-linux", "kisslinux"}, @@ -1454,6 +1732,50 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_BLUE, }, + // Kogaion + { + .names = {"Kogaion"}, + .lines = FASTFETCH_DATATEXT_LOGO_KOGAION, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Korora + { + .names = {"Korora"}, + .lines = FASTFETCH_DATATEXT_LOGO_KORORA, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // KrassOS + { + .names = {"KrassOS", "Krass"}, + .lines = FASTFETCH_DATATEXT_LOGO_KRASSOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // KSLinux + { + .names = {"KSLinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_KSLINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Kubuntu { .names = {"kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma"}, @@ -1476,6 +1798,53 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // Laxeros + { + .names = {"Laxeros"}, + .lines = FASTFETCH_DATATEXT_LOGO_LAXEROS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // LEDE + { + .names = {"LEDE"}, + .lines = FASTFETCH_DATATEXT_LOGO_LEDE, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // LibreELEC + { + .names = {"LibreELEC"}, + .lines = FASTFETCH_DATATEXT_LOGO_LIBREELEC, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // Linspire + { + .names = {"Linspire", "Freespire", "Lindows"}, + .lines = FASTFETCH_DATATEXT_LOGO_LINSPIRE, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_GREEN, + }, // Linux { .names = {"linux", "linux-generic"}, @@ -1501,6 +1870,39 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_WHITE, }, + // LinuxLight + { + .names = {"LinuxLite", "Linux Lite", "linux_lite"}, + .lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // LinuxLightSmall + { + .names = {"LinuxLite_small", "Linux Lite_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE_SMALL, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Live_Raizo + { + .names = {"Live Raizo", "Live_Raizo"}, + .lines = FASTFETCH_DATATEXT_LOGO_LIVE_RAIZO, + .colors = { + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, // LMDE { .names = {"LMDE"}, @@ -1512,6 +1914,18 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_WHITE, }, + // Lunar + { + .names = {"Lunar"}, + .lines = FASTFETCH_DATATEXT_LOGO_LUNAR, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // MacOS { .names = {"macos", "mac", "apple", "darwin", "osx"}, @@ -1570,6 +1984,41 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_GREEN, }, + // Mageia + { + .names = {"Mageia"}, + .lines = FASTFETCH_DATATEXT_LOGO_MAGEIA, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // MageiaSmall + { + .names = {"Mageia_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_MAGEIA_SMALL, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // MagpieOS + { + .names = {"MagpieOS", "Magpie"}, + .lines = FASTFETCH_DATATEXT_LOGO_MAGPIEOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_RED, + }, // Mandriva { .names = {"mandriva", "mandrake"}, @@ -1614,6 +2063,60 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_YELLOW, }, + // MassOS + { + .names = {"massos", "mass"}, + .lines = FASTFETCH_DATATEXT_LOGO_MASSOS, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // MatuusOS + { + .names = {"MatuusOS", "Matuus"}, + .lines = FASTFETCH_DATATEXT_LOGO_MATUUSOS, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_RED, + }, + // MaUI + { + .names = {"MaUI"}, + .lines = FASTFETCH_DATATEXT_LOGO_MAUI, + .colors = { + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Meowix + { + .names = {"Meowix"}, + .lines = FASTFETCH_DATATEXT_LOGO_MEOWIX, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, + }, + // Mer + { + .names = {"Mer"}, + .lines = FASTFETCH_DATATEXT_LOGO_MER, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Mint { .names = {"mint", "linuxmint", "mint-linux", "linux-mint"}, @@ -1648,6 +2151,16 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // MiracleLinux + { + .names = {"MIRACLE LINUX", "miracle_linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_MIRACLE_LINUX, + .colors = { + FF_COLOR_FG_256 "29", + }, + .colorKeys = FF_COLOR_FG_256 "29", + .colorTitle = FF_COLOR_FG_WHITE, + }, // Msys2 { .names = {"msys2"}, @@ -1660,6 +2173,52 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_RED, }, + // Namib + { + .names = {"Namib"}, + .lines = FASTFETCH_DATATEXT_LOGO_NAMIB, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // Nekos + { + .names = {"Nekos"}, + .lines = FASTFETCH_DATATEXT_LOGO_NEKOS, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + }, + // Neptune + { + .names = {"Neptune"}, + .lines = FASTFETCH_DATATEXT_LOGO_NEPTUNE, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_WHITE, + }, + }, + // NetRunner + { + .names = {"NetRunner"}, + .lines = FASTFETCH_DATATEXT_LOGO_NETRUNNER, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Nitrux + { + .names = {"Nitrux"}, + .lines = FASTFETCH_DATATEXT_LOGO_NITRUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, // Windows11 { .names = {"Windows 11", "Windows Server 2022"}, @@ -1727,7 +2286,7 @@ const FFlogo ffLogoBuiltins[] = { }, // NixOS { - .names = {"nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"}, + .names = {"NixOS", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"}, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS, .colors = { FF_COLOR_FG_BLUE, @@ -1736,6 +2295,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_BLUE, }, + // NixOS_small + { + .names = {"NixOS_small", "nix_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, + }, // NixOsOld { .names = {"nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old"}, @@ -1809,6 +2379,52 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // Nurunner + { + .names = {"Nurunner"}, + .lines = FASTFETCH_DATATEXT_LOGO_NURUNNER, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // NuTyX + { + .names = {"NuTyX"}, + .lines = FASTFETCH_DATATEXT_LOGO_NUTYX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_RED, + }, + }, + // Obarun + { + .names = {"Obarun"}, + .lines = FASTFETCH_DATATEXT_LOGO_OBARUN, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // OBRevenge + { + .names = {"OBRevenge"}, + .lines = FASTFETCH_DATATEXT_LOGO_OBREVENGE, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // OmniOS + { + .names = {"OmniOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_OMNIOS, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_LIGHT_BLACK, + } + }, // OpenKylin { .names = {"openkylin", "open-kylin"}, @@ -1845,6 +2461,42 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_WHITE, }, + // OpenEuler + { + .names = {"OpenEuler"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENEULER, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // OpenIndiana + { + .names = {"OpenIndiana"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENINDIANA, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // OpenMamba + { + .names = {"OpenMamba"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENMAMBA, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_GREEN, + }, + }, + // OpenStage + { + .names = {"OpenStage"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSTAGE, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + }, // OpenSuse { .names = {"suse", "opensuse", "open_suse", "open-suse", "suse-linux"}, @@ -1917,6 +2569,15 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // OPNsense + { + .names = {"OPNsense"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPNSENSE, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_256 "202", + }, + }, // Oracle { .names = {"oracle", "oracle linux"}, @@ -1952,6 +2613,24 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // OS_Elbrus + { + .names = {"OS Elbrus"}, + .lines = FASTFETCH_DATATEXT_LOGO_OS_ELBRUS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // OSMC + { + .names = {"OSMC", "Open Source Media Center"}, + .lines = FASTFETCH_DATATEXT_LOGO_OSMC, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, // Parabola { .names = {"parabola", "parabola-gnulinux"}, diff --git a/src/logo/logo.c b/src/logo/logo.c index 35bb616c6..025f78420 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -179,10 +179,10 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) static void logoApplyColors(const FFlogo* logo) { if(instance.config.colorKeys.length == 0) - ffStrbufAppendS(&instance.config.colorKeys, logo->colorKeys); + ffStrbufAppendS(&instance.config.colorKeys, logo->colorKeys ? logo->colorKeys : logo->colors[0]); if(instance.config.colorTitle.length == 0) - ffStrbufAppendS(&instance.config.colorTitle, logo->colorTitle); + ffStrbufAppendS(&instance.config.colorTitle, logo->colorTitle ? logo->colorTitle : logo->colors[1]); } static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) From f42fb5365f9913761cac6206f42688cb177681f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 14:35:39 +0800 Subject: [PATCH 420/493] Logo (Builtin): more --- README.md | 6 +- src/detection/os/os_linux.c | 27 + src/logo/ascii/pacbsd.txt | 24 + src/logo/ascii/parch.txt | 19 + src/logo/ascii/pardus.txt | 18 + src/logo/ascii/parrot.txt | 24 + src/logo/ascii/parsix.txt | 21 + src/logo/ascii/pcbsd.txt | 27 + src/logo/ascii/pclinuxos.txt | 19 + src/logo/ascii/pearos.txt | 21 + src/logo/ascii/pengwin.txt | 15 + src/logo/ascii/pentoo.txt | 20 + src/logo/ascii/peppermint.txt | 21 + src/logo/ascii/phyos.txt | 18 + src/logo/ascii/pisi.txt | 19 + src/logo/ascii/pnm_linux.txt | 19 + src/logo/ascii/porteus.txt | 23 + src/logo/ascii/postmarketos.txt | 18 + src/logo/ascii/postmarketos_small.txt | 9 + src/logo/ascii/puffos.txt | 12 + src/logo/ascii/puppy.txt | 18 + src/logo/ascii/pureos.txt | 12 + src/logo/ascii/pureos_small.txt | 6 + src/logo/ascii/q4os.txt | 19 + src/logo/ascii/qubes.txt | 21 + src/logo/ascii/qubyt.txt | 15 + src/logo/ascii/quibian.txt | 18 + src/logo/ascii/radix.txt | 18 + src/logo/ascii/ravynos.txt | 20 + src/logo/ascii/redcore.txt | 16 + src/logo/ascii/redstar.txt | 4 +- src/logo/ascii/refracted_devuan.txt | 18 + src/logo/ascii/regata.txt | 20 + src/logo/ascii/regolith.txt | 18 + src/logo/ascii/rhaymos.txt | 14 + src/logo/ascii/rhel_old.txt | 16 + src/logo/ascii/rocky_small.txt | 12 + src/logo/ascii/sabayon.txt | 18 + src/logo/ascii/sabotage.txt | 11 + src/logo/ascii/sailfish.txt | 13 + src/logo/ascii/salentos.txt | 20 + src/logo/ascii/salientos.txt | 20 + src/logo/ascii/sambabox.txt | 19 + src/logo/ascii/sasanqua.txt | 18 + src/logo/ascii/scientific.txt | 20 + src/logo/ascii/semc.txt | 9 + src/logo/ascii/septor.txt | 20 + src/logo/ascii/serene.txt | 20 + src/logo/ascii/sharklinux.txt | 15 + src/logo/ascii/shastraos.txt | 19 + src/logo/ascii/siduction.txt | 20 + src/logo/ascii/skiffos.txt | 9 + src/logo/ascii/slitaz.txt | 17 + src/logo/ascii/smartos.txt | 17 + src/logo/ascii/soda.txt | 15 + src/logo/ascii/source_mage.txt | 21 + src/logo/ascii/sparky.txt | 20 + src/logo/ascii/star.txt | 19 + src/logo/ascii/stock_linux.txt | 19 + src/logo/ascii/sulin.txt | 20 + src/logo/ascii/swagarch.txt | 15 + src/logo/ascii/t2.txt | 6 + src/logo/ascii/tails.txt | 19 + src/logo/ascii/tearch.txt | 21 + src/logo/ascii/torizoncore.txt | 29 + src/logo/ascii/trisquel.txt | 17 + src/logo/ascii/twister.txt | 23 + src/logo/ascii/ubuntu2_old.txt | 18 + src/logo/ascii/ubuntu_cinnamon.txt | 20 + src/logo/ascii/ubuntu_studio.txt | 20 + src/logo/ascii/ubuntu_sway.txt | 20 + src/logo/ascii/ubuntu_touch.txt | 7 + src/logo/ascii/ultramarine.txt | 20 + src/logo/ascii/univalent.txt | 18 + src/logo/ascii/univention.txt | 20 + src/logo/ascii/urukos.txt | 20 + src/logo/ascii/uwuntu.txt | 20 + src/logo/ascii/venom.txt | 15 + src/logo/ascii/vnux.txt | 20 + src/logo/ascii/vzlinux.txt | 20 + src/logo/ascii/wii_linux_ngx.txt | 16 + src/logo/ascii/xferience.txt | 19 + src/logo/ascii/yiffos.txt | 19 + src/logo/builtin.c | 769 +++++++++++++++++++++++++- 84 files changed, 2227 insertions(+), 8 deletions(-) create mode 100644 src/logo/ascii/pacbsd.txt create mode 100644 src/logo/ascii/parch.txt create mode 100644 src/logo/ascii/pardus.txt create mode 100644 src/logo/ascii/parrot.txt create mode 100644 src/logo/ascii/parsix.txt create mode 100644 src/logo/ascii/pcbsd.txt create mode 100644 src/logo/ascii/pclinuxos.txt create mode 100644 src/logo/ascii/pearos.txt create mode 100644 src/logo/ascii/pengwin.txt create mode 100644 src/logo/ascii/pentoo.txt create mode 100644 src/logo/ascii/peppermint.txt create mode 100644 src/logo/ascii/phyos.txt create mode 100644 src/logo/ascii/pisi.txt create mode 100644 src/logo/ascii/pnm_linux.txt create mode 100644 src/logo/ascii/porteus.txt create mode 100644 src/logo/ascii/postmarketos.txt create mode 100644 src/logo/ascii/postmarketos_small.txt create mode 100644 src/logo/ascii/puffos.txt create mode 100644 src/logo/ascii/puppy.txt create mode 100644 src/logo/ascii/pureos.txt create mode 100644 src/logo/ascii/pureos_small.txt create mode 100644 src/logo/ascii/q4os.txt create mode 100644 src/logo/ascii/qubes.txt create mode 100644 src/logo/ascii/qubyt.txt create mode 100644 src/logo/ascii/quibian.txt create mode 100644 src/logo/ascii/radix.txt create mode 100644 src/logo/ascii/ravynos.txt create mode 100644 src/logo/ascii/redcore.txt create mode 100644 src/logo/ascii/refracted_devuan.txt create mode 100644 src/logo/ascii/regata.txt create mode 100644 src/logo/ascii/regolith.txt create mode 100644 src/logo/ascii/rhaymos.txt create mode 100644 src/logo/ascii/rhel_old.txt create mode 100644 src/logo/ascii/rocky_small.txt create mode 100644 src/logo/ascii/sabayon.txt create mode 100644 src/logo/ascii/sabotage.txt create mode 100644 src/logo/ascii/sailfish.txt create mode 100644 src/logo/ascii/salentos.txt create mode 100644 src/logo/ascii/salientos.txt create mode 100644 src/logo/ascii/sambabox.txt create mode 100644 src/logo/ascii/sasanqua.txt create mode 100644 src/logo/ascii/scientific.txt create mode 100644 src/logo/ascii/semc.txt create mode 100644 src/logo/ascii/septor.txt create mode 100644 src/logo/ascii/serene.txt create mode 100644 src/logo/ascii/sharklinux.txt create mode 100644 src/logo/ascii/shastraos.txt create mode 100644 src/logo/ascii/siduction.txt create mode 100644 src/logo/ascii/skiffos.txt create mode 100644 src/logo/ascii/slitaz.txt create mode 100644 src/logo/ascii/smartos.txt create mode 100644 src/logo/ascii/soda.txt create mode 100644 src/logo/ascii/source_mage.txt create mode 100644 src/logo/ascii/sparky.txt create mode 100644 src/logo/ascii/star.txt create mode 100644 src/logo/ascii/stock_linux.txt create mode 100644 src/logo/ascii/sulin.txt create mode 100644 src/logo/ascii/swagarch.txt create mode 100644 src/logo/ascii/t2.txt create mode 100644 src/logo/ascii/tails.txt create mode 100644 src/logo/ascii/tearch.txt create mode 100644 src/logo/ascii/torizoncore.txt create mode 100644 src/logo/ascii/trisquel.txt create mode 100644 src/logo/ascii/twister.txt create mode 100644 src/logo/ascii/ubuntu2_old.txt create mode 100644 src/logo/ascii/ubuntu_cinnamon.txt create mode 100644 src/logo/ascii/ubuntu_studio.txt create mode 100644 src/logo/ascii/ubuntu_sway.txt create mode 100644 src/logo/ascii/ubuntu_touch.txt create mode 100644 src/logo/ascii/ultramarine.txt create mode 100644 src/logo/ascii/univalent.txt create mode 100644 src/logo/ascii/univention.txt create mode 100644 src/logo/ascii/urukos.txt create mode 100644 src/logo/ascii/uwuntu.txt create mode 100644 src/logo/ascii/venom.txt create mode 100644 src/logo/ascii/vnux.txt create mode 100644 src/logo/ascii/vzlinux.txt create mode 100644 src/logo/ascii/wii_linux_ngx.txt create mode 100644 src/logo/ascii/xferience.txt create mode 100644 src/logo/ascii/yiffos.txt diff --git a/README.md b/README.md index 53b9751a2..aa4cf591e 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,11 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos -See files in +``` +Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin +``` + +Run `fastfetch --print-logos` to print them ##### Package managers ``` diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index eb37a5bad..338a1fcfb 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -75,6 +75,15 @@ static void getUbuntuFlavour(FFOSResult* result) return; } + if(strstr(xdgConfigDirs, "cinnamon") != NULL) + { + ffStrbufSetS(&result->name, "Ubuntu Cinnamon"); + ffStrbufSetS(&result->prettyName, "Ubuntu Cinnamon"); + ffStrbufSetS(&result->id, "ubuntu-cinnamon"); + ffStrbufSetS(&result->idLike, "ubuntu"); + return; + } + if(strstr(xdgConfigDirs, "mate") != NULL) { ffStrbufSetS(&result->name, "Ubuntu MATE"); @@ -92,6 +101,24 @@ static void getUbuntuFlavour(FFOSResult* result) ffStrbufSetS(&result->idLike, "ubuntu"); return; } + + if(strstr(xdgConfigDirs, "sway") != NULL) + { + ffStrbufSetS(&result->name, "Ubuntu Sway"); + ffStrbufSetS(&result->prettyName, "Ubuntu Sway"); + ffStrbufSetS(&result->id, "ubuntu-sway"); + ffStrbufSetS(&result->idLike, "ubuntu"); + return; + } + + if(strstr(xdgConfigDirs, "touch") != NULL) + { + ffStrbufSetS(&result->name, "Ubuntu Touch"); + ffStrbufSetS(&result->prettyName, "Ubuntu Touch"); + ffStrbufSetS(&result->id, "ubuntu-touch"); + ffStrbufSetS(&result->idLike, "ubuntu"); + return; + } } static void detectOS(FFOSResult* os) diff --git a/src/logo/ascii/pacbsd.txt b/src/logo/ascii/pacbsd.txt new file mode 100644 index 000000000..0909bf35f --- /dev/null +++ b/src/logo/ascii/pacbsd.txt @@ -0,0 +1,24 @@ + :+sMs. + `:ddNMd- -o--` + -sMMMMh: `+N+`` + yMMMMMs` .....-/-... `mNh/ + yMMMMMmh+-`:sdmmmmmmMmmmmddy+-``./ddNMMm + yNMMNMMMMNdyyNNMMMMMMMMMMMMMMMhyshNmMMMm + :yMMMMMMMMMNdooNMMMMMMMMMMMMMMMMNmy:mMMd + +MMMMMMMMMmy:sNMMMMMMMMMMMMMMMMMMMmshs- + :hNMMMMMMN+-+MMMMMMMMMMMMMMMMMMMMMMMs. + .omysmNNhy/+yNMMMMMMMMMMNMMMMMMMMMNdNNy- + /hMM:::::/hNMMMMMMMMMMMm/-yNMMMMMMN.mMNh` +.hMMMMdhdMMMMMMMMMMMMMMmo `sMMMMMMN mMMm- +:dMMMMMMMMMMMMMMMMMMMMMdo+ oMMMMMMN`smMNo` +/dMMMMMMMMMMMMMMMMMMMMMNd/` :yMMMMMN:-hMMM. +:dMMMMMMMMMMMMMMMMMMMMMNh` oMMMMMMNo/dMNN` +:hMMMMMMMMMMMMMMMMMMMMMMNs--sMMMMMMMNNmy++` + sNMMMMMMMMMMMMMMMMMMMMMMMmmNMMMMMMNho::o. + :yMMMMMMMMMMMMMNho+sydNNNNNNNmysso/` -// + /dMMMMMMMMMMMMMs- ````````..`` + .oMMMMMMMMMMMMNs` ./y:` + +dNMMNMMMMMMMmy` ``./ys. + `/hMMMMMMMMMMMNo-`` `.+yy+-` + `-/hmNMNMMMMMMmmddddhhy/-` + `-+oooyMMMdsoo+/:. diff --git a/src/logo/ascii/parch.txt b/src/logo/ascii/parch.txt new file mode 100644 index 000000000..566954cab --- /dev/null +++ b/src/logo/ascii/parch.txt @@ -0,0 +1,19 @@ + +s;;:o- + s/sssso+/-'+\\ + +/ssssss/` + /ssssssss/ + \\ 'sssssss: + `o+;ssssssso\\ + /sssssssssssss\\+ + ;ssssssssssssssss: + :sssssssssssssssssso; + /ssssssssssssssssssssss + `+ssssssssssssssssssssso\\ + so+'+ssssssssssssssss+'` + '` +osssssoooooosssss++oo\\ + /sssssssooooooosssssssso + `osssssssssoooossssssssso: + \\sssssssssssssssssssss; + `+osssssssssssssss:/' + `\\osssssssssso;+' + `\\+;so:+-` diff --git a/src/logo/ascii/pardus.txt b/src/logo/ascii/pardus.txt new file mode 100644 index 000000000..5305949e0 --- /dev/null +++ b/src/logo/ascii/pardus.txt @@ -0,0 +1,18 @@ + .smNdy+- `.:/osyyso+:.` -+ydmNs. +/Md- -/ymMdmNNdhso/::/oshdNNmdMmy/. :dM/ +mN. oMdyy- -y `-dMo .Nm +.mN+` sMy hN+ -: yMs `+Nm. + `yMMddMs.dy `+` sMddMMy` + +MMMo .` . oMMM+ + `NM/ `````.` `.````` +MN` + yM+ `.-:yhomy ymohy:-.` +My + yM: yo oy :My + +Ms .N` `N. +h sM+ + `MN - -::::::- : :o:+`NM` + yM/ sh -dMMMMd- ho +y+My + .dNhsohMh-//: /mm/ ://-yMyoshNd` + `-ommNMm+:/. oo ./:+mMNmmo:` + `/o+.-somNh- :yy: -hNmos-.+o/` + ./` .s/`s+sMdd+``+ddMs+s`/s. `/. + : -y. -hNmddmNy. .y- : + -+ `..` +- diff --git a/src/logo/ascii/parrot.txt b/src/logo/ascii/parrot.txt new file mode 100644 index 000000000..d1f0d1ea7 --- /dev/null +++ b/src/logo/ascii/parrot.txt @@ -0,0 +1,24 @@ + `:oho/-` +`mMMMMMMMMMMMNmmdhy- + dMMMMMMMMMMMMMMMMMMs` + +MMsohNMMMMMMMMMMMMMm/ + .My .+dMMMMMMMMMMMMMh. + + :NMMMMMMMMMMMMNo + `yMMMMMMMMMMMMMm: + /NMMMMMMMMMMMMMy` + .hMMMMMMMMMMMMMN+ + ``-NMMMMMMMMMd- + /MMMMMMMMMMMs` + mMMMMMMMsyNMN/ + +MMMMMMMo :sNh. + `NMMMMMMm -o/ + oMMMMMMM. + `NMMMMMM+ + +MMd/NMh + mMm -mN` + /MM `h: + dM` . + :M- + d: + -+ + - diff --git a/src/logo/ascii/parsix.txt b/src/logo/ascii/parsix.txt new file mode 100644 index 000000000..2753a461a --- /dev/null +++ b/src/logo/ascii/parsix.txt @@ -0,0 +1,21 @@ + ${c2}-/+/:. + ${c2}.syssssys. + ${c1}.--. ${c2}ssssssssso${c1} ..--. + :++++++: ${c2}+ssssssss+${c1} ./++/+++: + /+++++++++.${c2}.yssooooy`${c1}-+///////o- + /++++++++++.${c2}+soooos:${c1}:+////////+- + :+++++////o-${c2}oooooo-${c1}+/////////- + `-/++//++-${c4}.-----.-${c1}:+/////:- + ${c3}-://::--${c1}-:/:${c4}.--.````.--.${c1}:::-${c3}--::::::. +${c3}-/:::::::://:${c4}.:-` `-:${c3}`:/:::::::--/- +${c3}/::::::::::/-${c4}--. .-.${c3}-/://///::::/ +${c3}-/:::::::::/:${c4}`:-. .-:${c3}`:///////////- + `${c3}-::::--${c1}.-://.${c4}---....---${c1}`:+/:-${c3}--::::-` + ${c1}-/+///+o/-${c4}.----.${c1}.:oo+++o+. + ${c1}-+/////+++o:${c2}syyyyy.${c1}o+++++++++: + ${c1}.+////+++++-${c2}+sssssy+${c1}.++++++++++\ + ${c1}.+:/++++++.${c2}.yssssssy-${c1}`+++++++++: + ${c1}:/+++++- ${c2}+sssssssss ${c1}-++++++- + ${c1}`--` ${c2}+sssssssso ${c1}`--` + ${c2}+sssssy+` + ${c2}`.::-` diff --git a/src/logo/ascii/pcbsd.txt b/src/logo/ascii/pcbsd.txt new file mode 100644 index 000000000..4641cbc69 --- /dev/null +++ b/src/logo/ascii/pcbsd.txt @@ -0,0 +1,27 @@ + .. + s. + +y + yN + -MN `. + :NMs `m + .yMMm` `No + `-/+++sdMMMNs+-`+Ms + `:oo+-` .yMMMMy` `-+oNMh + -oo- +NMMMM/ oMMh- + .s+` ` oMMMMM/ - oMMMhy. + +s`- :: :MMMMMd -o `mMMMy`s+ + y+ h .Ny+oNMMMMMN/ sh+NMMMMo +y + s+ .ds -NMMMMMMMMMMNdhdNMMMMMMh` +s +-h .NM` `hMMMMMMMMMMMMMMNMMNy: h- +y- hMN` hMMmMMMMMMMMMNsdMNs. -y +m` mMMy` oMMNoNMMMMMMo` sMMMo `m +m` :NMMMdyydMMMMo+MdMMMs sMMMd` `m +h- `+ymMMMMMMMM--M+hMMN/ +MMMMy -h +:y `.sMMMMM/ oMM+.yMMNddNMMMMMm y: + y: `s dMMN- .MMMM/ :MMMMMMMMMMh :y + `h: `mdmMMM/ yMMMMs sMMMMMMMMN- :h` + so -NMMMN /mmd+ `dMMMMMMMm- os + :y: `yMMM` `+NMMMMMMNo`:y: + /s+`.omy /NMMMMMNh/.+s: + .+oo:-. /mdhs+::oo+. + -/o+++++++++++/- diff --git a/src/logo/ascii/pclinuxos.txt b/src/logo/ascii/pclinuxos.txt new file mode 100644 index 000000000..64172a3a6 --- /dev/null +++ b/src/logo/ascii/pclinuxos.txt @@ -0,0 +1,19 @@ + mhhhyyyyhhhdN + dyssyhhhhhhhhhhhssyhN + Nysyhhyo/:-.....-/oyhhhssd + Nsshhy+. `/shhysm + dohhy/ -shhsy + dohhs` /hhys +N+hho ${c2}+ssssss+- .+syhys+ ${c1}/hhsy +ohhh` ${c2}ymmo++hmm+`smmy/::+y` ${c1}shh+ ++hho ${c2}ymm- /mmy+mms ${c1}:hhod +/hh+ ${c2}ymmhhdmmh.smm/ ${c1}.hhsh ++hhs ${c2}ymm+::-` /mmy` ` ${c1}/hh+m +yyhh- ${c2}ymm- /dmdyosyd` ${c1}`yhh+ + ohhy` ${c2}://` -/+++/- ${c1}ohhom + N+hhy- `shhoh + sshho. `+hhyom + dsyhhs/. `:ohhhoy + dysyhhhso///://+syhhhssh + dhyssyhhhhhhyssyyhN + mddhdhdmN diff --git a/src/logo/ascii/pearos.txt b/src/logo/ascii/pearos.txt new file mode 100644 index 000000000..bf151de5f --- /dev/null +++ b/src/logo/ascii/pearos.txt @@ -0,0 +1,21 @@ + .+yh + sMMMo + sMMN+ + +o: +$2 ./oyyys+. + :dMMMMMMMMMm/ + :MMMMMMMMMMMMMy + yMMMMMMMMMMMMMN +$3 mMMMMMMMMMMMMs` + yMMMMMMMMMMMMo + -mMMMMMMMMMMMMM` + oMMMMMMMMMMMMMMM` +$4 oMMMMMMMMMMMMMMMMy + .MMMMMMMMMMMMMMMMMMy` + +MMMMMMMMMMMMMMMMMMMMy/` + /MMMMMMMMMMMMMMMMMMMMMMMNds +$5 `mMMMMMMMMMMMMMMMMMMMMMMMM/ + .mMMMMMMMMMMMMMMMMMMMMMM+ + `oNMMMMMMMMMMMMMMMMMMd- + `+hMMMMMMMMMMMMMms- + -/osyhhyso:. diff --git a/src/logo/ascii/pengwin.txt b/src/logo/ascii/pengwin.txt new file mode 100644 index 000000000..4306068e3 --- /dev/null +++ b/src/logo/ascii/pengwin.txt @@ -0,0 +1,15 @@ +${c3} ...` +${c3} `-///:-` +${c3} .+${c2}ssys${c3}/ +${c3} +${c2}yyyyy${c3}o ${c2} +${c2} -yyyyyy: +${c2} `.:/+ooo+/:` -yyyyyy+ +${c2} `:oyyyyyys+:-.`syyyyyy: +${c2} .syyyyyyo-` .oyyyyyyo +${c2}`syyyyyy `-+yyyyyyy/` +${c2}/yyyyyy+ -/osyyyyyyo/. +${c2}+yyyyyy- `.-:::-.` +${c2}.yyyyyy- +${c3} :${c2}yyyyy${c3}o +${c3} .+${c2}ooo${c3}+ +${c3} `.::/:. diff --git a/src/logo/ascii/pentoo.txt b/src/logo/ascii/pentoo.txt new file mode 100644 index 000000000..c3c763ea1 --- /dev/null +++ b/src/logo/ascii/pentoo.txt @@ -0,0 +1,20 @@ +${c2} `:oydNNMMMMNNdyo:` + :yNMMMMMMMMMMMMMMMMNy: + :dMMMMMMMMMMMMMMMMMMMMMMd: + oMMMMMMMho/-....-/ohMMMMMMMo + oMMMMMMy. .yMMMMMMo + .MMMMMMo oMMMMMM. + +MMMMMm mMMMMM+ + oMMMMMh hMMMMMo + //hMMMMMm//${c1}`${c2} ${c1}`${c2}////mMMMMMh// +MMMMMMMMMMM${c1}/${c2} ${c1}/o/`${c2} ${c1}.${c2}smMMMMMMMMMMM +MMMMMMMMMMm ${c1}`NMN:${c2} ${c1}.${c2}yMMMMMMMMMM +MMMMMMMMMMMh${c1}:.${c2} dMMMMMMMMM +MMMMMMMMMMMMMy${c1}.${c2} ${c1}-${c2}NMMMMMMMMM +MMMMMMMMMMMd:${c1}`${c2} ${c1}-${c2}yNMMMMMMMMMM +MMMMMMMMMMh${c1}`${c2} ${c1}./${c2}hNMMMMMMMMMMMM +MMMMMMMMMM${c1}s${c2} ${c1}.:${c2}ymMMMMMMMMMMMMMMM +MMMMMMMMMMN${c1}s:..-/${c2}ohNMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM diff --git a/src/logo/ascii/peppermint.txt b/src/logo/ascii/peppermint.txt new file mode 100644 index 000000000..85f25fdc2 --- /dev/null +++ b/src/logo/ascii/peppermint.txt @@ -0,0 +1,21 @@ +${c1} PPPPPPPPPPPPPP +${c1} PPPP${c2}MMMMMMM${c1}PPPPPPPPPPP +${c1} PPPP${c2}MMMMMMMMMM${c1}PPPPPPPP${c2}MM${c1}PP +${c1} PPPPPPPP${c2}MMMMMMM${c1}PPPPPPPP${c2}MMMMM${c1}PP +${c1} PPPPPPPPPPPP${c2}MMMMMM${c1}PPPPPPP${c2}MMMMMMM${c1}PP +${c1} PPPPPPPPPPPP${c2}MMMMMMM${c1}PPPP${c2}M${c1}P${c2}MMMMMMMMM${c1}PP +${c1} PP${c2}MMMM${c1}PPPPPPPPPP${c2}MMM${c1}PPPPP${c2}MMMMMMM${c1}P${c2}MM${c1}PPPP +${c1} P${c2}MMMMMMMMMM${c1}PPPPPP${c2}MM${c1}PPPPP${c2}MMMMMM${c1}PPPPPPPP +${c1}P${c2}MMMMMMMMMMMM${c1}PPPPP${c2}MM${c1}PP${c2}M${c1}P${c2}MM${c1}P${c2}MM${c1}PPPPPPPPPPP +${c1}P${c2}MMMMMMMMMMMMMMMM${c1}PP${c2}M${c1}P${c2}MMM${c1}PPPPPPPPPPPPPPPP +${c1}P${c2}MMM${c1}PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP${c2}MMMMM${c1}P +${c1}PPPPPPPPPPPPPPPP${c2}MMM${c1}P${c2}M${c1}P${c2}MMMMMMMMMMMMMMMM${c1}PP +${c1}PPPPPPPPPPP${c2}MM${c1}P${c2}MM${c1}PPPP${c2}MM${c1}PPPPP${c2}MMMMMMMMMMM${c1}PP +${c1} PPPPPPPP${c2}MMMMMM${c1}PPPPP${c2}MM${c1}PPPPPP${c2}MMMMMMMMM${c1}PP +${c1} PPPP${c2}MM${c1}P${c2}MMMMMMM${c1}PPPPPP${c2}MM${c1}PPPPPPPPPP${c2}MMMM${c1}PP +${c1} PP${c2}MMMMMMMMM${c1}P${c2}M${c1}PPPP${c2}MMMMMM${c1}PPPPPPPPPPPPP +${c1} PP${c2}MMMMMMM${c1}PPPPPPP${c2}MMMMMM${c1}PPPPPPPPPPPP +${c1} PP${c2}MMMM${c1}PPPPPPPPP${c2}MMMMMMM${c1}PPPPPPPP +${c1} PP${c2}MM${c1}PPPPPPPP${c2}MMMMMMMMMM${c1}PPPP +${c1} PPPPPPPPPP${c2}MMMMMMMM${c1}PPPP +${c1} PPPPPPPPPPPPPP diff --git a/src/logo/ascii/phyos.txt b/src/logo/ascii/phyos.txt new file mode 100644 index 000000000..4bd8feaff --- /dev/null +++ b/src/logo/ascii/phyos.txt @@ -0,0 +1,18 @@ + ' +.^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.^^^^^. + :777777777777777777777777777777^~7777: + .~~~~~~~~~~~~~~~~~~~~~^~7777!:!777!. + ~7!!!!!!!!!!!!!!!!!^:!777~^!777~ + ^77777!!!!!!!!!7!^^7777^^7777^ + ^7777~.~~~~^. .~7777^~7777: + :!777~^!777~. !777!:~777!: + .!777!:~777!:~77~:!777!. + ~777!^~7777:^~^!777~ + ^7777^^7777^^7777^ + :7777~^!7777777: + .!777!:!7777!. + .~777!:~77~. + ~7777^~~ + ^7777. + :77: + .. diff --git a/src/logo/ascii/pisi.txt b/src/logo/ascii/pisi.txt new file mode 100644 index 000000000..5fee6715a --- /dev/null +++ b/src/logo/ascii/pisi.txt @@ -0,0 +1,19 @@ + \Fv/!- `:?lzC +${c1} Q!::=zFx! ${c2}`;v6WBCicl;` ${c1},vCC\!::#. +${c1} ,%:::,'` ${c2}+#%@@FQ@@. ,cF%i${c1}``-',::a? +${c1} +m:,'```${c2}}3,/@@Q\@@ "af-${c1} `-'"7f + =o'.` ${c2}/m' :Q@:Qg ,kl${c1} `.|o + :k` '${c2}$+ 'Narm >d,${c1} ii + #`${c2}!p. `C , 'd+${c1} %' +${c2} !0m `6Kv + =a m+ + !A !\L|: :|L\! $: + .8` Q''%Q#' '#Q%''Q `0- + :6 E|.6QQu uQQ6.|E p: + i{ \jts9? ?9stj\ u\ + |a` -''. `e> + ,m+ ${c1}'^ !`${c2}s@@@@a${c1}'"`+`${c2} >e' + !3|${c1}`|=>>r- ${c2}'U%:${c1} '>>>=:`\3! + 'xopE| ${c2}`'${c1} `ledoz- + `;=>>+`${c2}`^llci/|==|/iclc;`${c1}'>>>>: + `^`+~ ${c2}````${c1} !!-^ diff --git a/src/logo/ascii/pnm_linux.txt b/src/logo/ascii/pnm_linux.txt new file mode 100644 index 000000000..3c3f3842e --- /dev/null +++ b/src/logo/ascii/pnm_linux.txt @@ -0,0 +1,19 @@ + ``.---..` `--` + ``.---........-:.${c2}-::`${c1} + ${c2}./::-${c1}........${c2}--::.````${c1} + ${c2}.:://:::${c1}----${c2}::::-..${c1} + ..${c2}--:::::--::::++-${c1}.` + ${c2}`-:-`${c1} .-ohy+::${c2}-:::${c1}/sdmdd:.${c2} `-:- + .-:::${c1}...${c3}sNNmds$y${c1}o/+${c3}sy+NN$m${c1}d+.`${c2}-:::-. + `.-:-${c1}./${c3}dN${c1}()${c3}yyooosd${c1}()${c3}$m${c1}dy${c2}-.::-.`${c1} + ${c2}`.${c1}-...-${c3}+hNdyyyyyydmy${c1}:......${c2}`${c1} + ``..--.....-${c3}yNNm${c4}hssssh${c3}mmdo${c1}.........``` +`-:://:.....${c3}hNNNNN${c4}mddm${c3}NNNmds${c1}.....//::--` + ```.:-...${c3}oNNNNNNNNNNNNNNmd/${c1}...:-.``` + .....${c3}hNNNNNNNNNNNNNNmds${c1}....` + --...${c3}hNNNNNNNNNNNNNNmdo${c1}..... + .:...${c3}/NNNNNNNNNNNNNNdd${c1}:....` + `-...${c3}+mNNNNNNNNNNNmh${c1}:...-. + ${c4}.:+o+/:-${c1}:+oo+///++o+/:-${c4}:/+ooo/:. + ${c4}+oo/:o- +oooooso.` + ${c4}.` ` `/ .-//- diff --git a/src/logo/ascii/porteus.txt b/src/logo/ascii/porteus.txt new file mode 100644 index 000000000..bc2cac4be --- /dev/null +++ b/src/logo/ascii/porteus.txt @@ -0,0 +1,23 @@ + `.-:::-.` + -+ydmNNNNNNNmdy+- + .+dNmdhs+//////+shdmdo. + .smmy+-` ./sdy: + `omdo. `.-/+osssso+/-` `+dy. + `yms. `:shmNmdhsoo++osyyo-``oh. + hm/ .odNmds/.` ``.....:::-+s +/m: `+dNmy:` `./oyhhhhyyooo++so +ys `yNmy- .+hmmho:-.` ``` +s: yNm+` .smNd+. +`` /Nm: +dNd+` + yN+ `smNy. + dm oNNy` + hy -mNm. + +y oNNo + `y` sNN: + `: +NN: + ` .mNo + /mm` + /my` + .sy` + .+: + ` diff --git a/src/logo/ascii/postmarketos.txt b/src/logo/ascii/postmarketos.txt new file mode 100644 index 000000000..82e995bd7 --- /dev/null +++ b/src/logo/ascii/postmarketos.txt @@ -0,0 +1,18 @@ + /\\ + / \\ + / \\ + / \\ + / \\ + / \\ + \\ \\ + /\\ \\____ \\ + / \\____ \\ \\ + / / \\ \\ + / / \\ ___\\ + / / \\ / ____ + / / \\/ / \\ + / / __________/ \\ + / \\ \\ \\ + / \\ \\ \\ + / / / \\ +/___________/ /____________________\\ diff --git a/src/logo/ascii/postmarketos_small.txt b/src/logo/ascii/postmarketos_small.txt new file mode 100644 index 000000000..0515ff07e --- /dev/null +++ b/src/logo/ascii/postmarketos_small.txt @@ -0,0 +1,9 @@ + /\\ + / \\ + / \\ + \\__ \\ + /\\__ \\ _\\ + / / \\/ __ + / / ____/ \\ + / \\ \\ \\ +/_____/ /________\\ diff --git a/src/logo/ascii/puffos.txt b/src/logo/ascii/puffos.txt new file mode 100644 index 000000000..46fde3a73 --- /dev/null +++ b/src/logo/ascii/puffos.txt @@ -0,0 +1,12 @@ + _,..._,m, + ,/' '""; + / ". + ,'mmmMMMMmm. \ + _/-"^^^^^"""%#%mm, ; + ,m,_,' "###) ;, +(###% \#/ ;##mm. + ^#/ __ ___ ; (######) + ; //.\\ //.\\ ; \####/ + _; (#\"// \\"/#) ; ,/ +@##\ \##/ = `"=" ,;mm/ +`\##>.____,...,____,<####@ diff --git a/src/logo/ascii/puppy.txt b/src/logo/ascii/puppy.txt new file mode 100644 index 000000000..d650845dc --- /dev/null +++ b/src/logo/ascii/puppy.txt @@ -0,0 +1,18 @@ + `-/osyyyysosyhhhhhyys+- + -ohmNNmh+/hMMMMMMMMNNNNd+dMMMMNM+ + yMMMMNNmmddo/NMMMNNNNNNNNNo+NNNNNy +.NNNNNNmmmddds:MMNNNNNNNNNNNh:mNNN/ +-NNNdyyyhdmmmd`dNNNNNmmmmNNmdd/os/ +.Nm+shddyooo+/smNNNNmmmmNh. :mmd. + NNNNy:` ./hmmmmmmmNNNN: hNMh + NMN- -++- +NNNNNNNNNNm+..-sMMMM- +.MMo oNNNNo hNNNNNNNNmhdNNNMMMMM+ +.MMs /NNNN/ dNmhs+:-` yMMMMMMMM+ + mMM+ .. `sNN+. hMMMMhhMMM- + +MMMmo:...:sNMMMMMms:` hMMMMm.hMMy + yMMMMMMMMMMMNdMMMMMM::/+o+//dMMd` + sMMMMMMMMMMN+:oyyo:sMMMNNMMMNy` + :mMMMMMMMMMMMmddNMMMMMMMMmh/ + /dMMMMMMMMMMMMMMMMMMNdy/` + .+hNMMMMMMMMMNmdhs/. + .:/+ooo+/:-. diff --git a/src/logo/ascii/pureos.txt b/src/logo/ascii/pureos.txt new file mode 100644 index 000000000..38aad933e --- /dev/null +++ b/src/logo/ascii/pureos.txt @@ -0,0 +1,12 @@ +dmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmd +dNm//////////////////////////////////mNd +dNd dNd +dNd dNd +dNd dNd +dNd dNd +dNd dNd +dNd dNd +dNd dNd +dNd dNd +dNm//////////////////////////////////mNd +dmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmd diff --git a/src/logo/ascii/pureos_small.txt b/src/logo/ascii/pureos_small.txt new file mode 100644 index 000000000..a53b1d8f4 --- /dev/null +++ b/src/logo/ascii/pureos_small.txt @@ -0,0 +1,6 @@ + _____________ +| _________ | +| | | | +| | | | +| |_________| | +|_____________| diff --git a/src/logo/ascii/q4os.txt b/src/logo/ascii/q4os.txt new file mode 100644 index 000000000..a696636e7 --- /dev/null +++ b/src/logo/ascii/q4os.txt @@ -0,0 +1,19 @@ + .:***** :=====. + .:******** :========. + .*********** :===========. + .:************ :============- + .************** :============== + :*************** :=============== + :**************. :=============== +.*************: .=============. +*************. .============: + +${c1}:############. ${c2}:==: +${c1}:##############. ${c2}:======: + ${c1}:################ ${c2}.==========: + ${c1}:############### ${c2}.===========: + ${c1}:############## ${c2}.===========: + ${c1}:############# ${c2}.=========: + ${c1}:########### ${c2}.=====: + ${c1}.######### ${c2}.=: + ${c1}.##### diff --git a/src/logo/ascii/qubes.txt b/src/logo/ascii/qubes.txt new file mode 100644 index 000000000..0b4085405 --- /dev/null +++ b/src/logo/ascii/qubes.txt @@ -0,0 +1,21 @@ + `..--..` + `.----------.` + `..----------------..` + `.------------------------.`` + `..-------------....-------------..` +.::----------..`` ``..----------:+: +:////:----..` `..---:/ossso +:///////:` `/osssssso +:///////: /ssssssso +:///////: /ssssssso +:///////: /ssssssso +:///////: /ssssssso +:///////: /ssssssso +:////////-` .:sssssssso +:///////////-.` `-/osssssssssso +`//////////////:-```.:+ssssssssssssso- + .-://////////////sssssssssssssso/-` + `.:///////////sssssssssssssso:. + .-:///////ssssssssssssssssss/` + `.:////ssss+/+ssssssssssss. + `--//- `-/osssso/. diff --git a/src/logo/ascii/qubyt.txt b/src/logo/ascii/qubyt.txt new file mode 100644 index 000000000..a0a52d53b --- /dev/null +++ b/src/logo/ascii/qubyt.txt @@ -0,0 +1,15 @@ +${c1} ########################${c2}(${c3}ooo +${c1} ########################${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo +${c1}###${c2}(${c3}ooo ${c1}##${c3}o ${c2}((((${c3}ooo +${c1}###${c2}(${c3}ooo o${c2}((${c1}### ${c3}oooooo +${c1}###${c2}(${c3}ooo oo${c2}((${c1}###${c3}o +${c1}###${c2}(${c3}ooo ooo${c2}((${c1}### +${c1}################${c2}(${c3}oo oo${c2}((((${c3}o +${c2}(((((((((((((((((${c3}ooo ooooo + oooooooooooooooooo o diff --git a/src/logo/ascii/quibian.txt b/src/logo/ascii/quibian.txt new file mode 100644 index 000000000..46541787a --- /dev/null +++ b/src/logo/ascii/quibian.txt @@ -0,0 +1,18 @@ + `.--::::::::--.` + `.-:::-..`` ``..-::-.` + .::::-` .${c2}+${c1}:`` `.-::.` + .::::.` -::::::-` `.::. + `-:::-` -:::::::::--..`` .::` + `::::- .${c2}oy${c1}:::::::---.```.: `::` + -:::: `.-:::::::::::-.``` `:: +.::::.`-:::::::::::::. `:. +-::::.::::::::::::::: -: +::::::::::::::::::::` `: +:::::::::::::::::::- `: +::::::::::::::::::: -- +.:::::::::::::::::` `:` +`::::::::::::::::: -` + .:::::::::::::::- -` + `::::::::::::::- `.` + .::::::::::::- `` + `.--:::::-. diff --git a/src/logo/ascii/radix.txt b/src/logo/ascii/radix.txt new file mode 100644 index 000000000..96d6ea6ce --- /dev/null +++ b/src/logo/ascii/radix.txt @@ -0,0 +1,18 @@ + .:oyhdmNo + `/yhyoosdms` + -o+/ohmmho- + ..`.:/:-` + `.--:::-.``${c2} + .+ydNMMMMMMNmhs:` +`omMMMMMMMMMMMMMMNh- +oNMMMNmddhhyyhhhddmy. +mMMMMNmmddhhysoo+/:-` +yMMMMMMMMMMMMMMMMNNh. +-dmmmmmNNMMMMMMMMMMs` + -+oossyhmMMMMMMMMd- + `sNMMMMMMMMMMMMMm: + `yMMMMMMNmdhhhh: + `sNMMMMMNmmho. + `+mMMMMMMMy. + .yNMMMm+` + `:yd+. diff --git a/src/logo/ascii/ravynos.txt b/src/logo/ascii/ravynos.txt new file mode 100644 index 000000000..a53a5733a --- /dev/null +++ b/src/logo/ascii/ravynos.txt @@ -0,0 +1,20 @@ + ..oooo.. + .o$$$$$$$$$$$$$$$$$$$$$$$$$$$$o. + od$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$o + o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$o + .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$. + d$$$$$$$$$$$$$$$$$********$$$$$$$$$$$$$$$$$$$$$$$$$$$$$b + d$$$$$$$$$$$$$* °****?$$$$$$$$$$$$$$$$b + $$$$$$$$$$$$* °$$$$$$$$$$$$$ + d$$$$** .oo$$$$$$$$$$$$$$$$b + *° o$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P + *$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$P + $$$$$$$$$$$$$$$$$$$$$$$$$P + $$$$$$$$$$$$$$$$$$$$$$$$P + ?$$$$$$$$$$$$$$$$$$$$* + $$$$$$$$$$$$$*° + d$$$$$$$$*° + ° diff --git a/src/logo/ascii/redcore.txt b/src/logo/ascii/redcore.txt new file mode 100644 index 000000000..a226b918d --- /dev/null +++ b/src/logo/ascii/redcore.txt @@ -0,0 +1,16 @@ + RRRRRRRRR + RRRRRRRRRRRRR + RRRRRRRRRR RRRRR + RRRRRRRRRRRRRRRRRRRRRRRRRRR + RRRRRRR RRR RRR RRRRRRRR +RRRRR RR RRRRRRRRR +RRRR RR RRRRRRRR RR RRRRRR +RRRR R RRRRRRRRRRRRRR RR RRRRR +RRRR R RRRRRRRRRRRRRRRRRR R RRRRR +RRRR RRRRRRRRRRRRRRRRRRR R RRRR + RRR RRRRRRRRRRRRRRRRRRRR R RRRR + RRR RRRRRRRRRRRRRRRRRRRR RRRR + RR RRRRRRRRRRRRRRRRRRR RRR + RR RRRRRRRRRRRRRRRRR RRR + RR RRRRRRRRRRRRRR RR + R RRRR RR diff --git a/src/logo/ascii/redstar.txt b/src/logo/ascii/redstar.txt index de489776a..4340f5e49 100644 --- a/src/logo/ascii/redstar.txt +++ b/src/logo/ascii/redstar.txt @@ -1,4 +1,4 @@ -$1 .. + .. .oK0l :0KKKKd. .xKO0KKKKd @@ -15,4 +15,4 @@ $1 .. :lcc:'',..';::::;;;;;;;,,. :cccc::::;...';;;;;,,,,,,. ,::::::;;;,'. ..',,,,'''. - ........ ...... \ No newline at end of file + ........ ...... diff --git a/src/logo/ascii/refracted_devuan.txt b/src/logo/ascii/refracted_devuan.txt new file mode 100644 index 000000000..1ec9ff9b7 --- /dev/null +++ b/src/logo/ascii/refracted_devuan.txt @@ -0,0 +1,18 @@ + A + VW + VVW\\ + .yWWW\\ + ,;,,u,;yy;;v;uyyyyyyy ,WWWWW^ + *WWWWWWWWWWWWWWWW/ $VWWWWw , + ^*%WWWWWWVWWX $WWWW** ,yy + , "**WWW/' **' ,yy/WWW*` + &WWWWwy `*` <,ywWW%VWWW* + yWWWWWWWWWW* ., "**WW%W + ,&WWWWWM*"` ,y/ &WWWww ^* + XWWX*^ ,yWWWW09 .WWWWWWWWwy, + *` &WWWWWM WWWWWWWWWWWWWww, + (WWWWW` /#####WWW*********** + ^WWWW + VWW + Wh. + V/ diff --git a/src/logo/ascii/regata.txt b/src/logo/ascii/regata.txt new file mode 100644 index 000000000..9760d18a1 --- /dev/null +++ b/src/logo/ascii/regata.txt @@ -0,0 +1,20 @@ + ddhso+++++osydd + dho/.`hh${c2}.:/+/:.${c1}hhh`:+yd + do-hhhhhh${c2}/sssssss+`${c1}hhhhh./yd + h/`hhhhhhh${c2}-sssssssss:${c1}hhhhhhhh-yd + do`hhhhhhhhh${c2}`ossssssso.${c1}hhhhhhhhhh/d + d/hhhhhhhhhhhh${c2}`/ossso/.${c1}hhhhhhhhhhhh.h + /hhhhhhhhhhhh${c3}`-/osyso/-`${c1}hhhhhhhhhhhh.h +shh${c4}-/ooo+-${c1}hhh${c3}:syyso+osyys/`${c1}hhh${c5}`+oo`${c1}hhh/ +h${c4}`ohhhhhhho`${c3}+yyo.${c1}hhhhh${c3}.+yyo`${c5}.sssssss.${c1}h`h +s${c4}:hhhhhhhhho${c3}yys`${c1}hhhhhhh${c3}.oyy/${c5}ossssssso-${c1}hs +s${c4}.yhhhhhhhy/${c3}yys`${c1}hhhhhhh${c3}.oyy/${c5}ossssssso-${c1}hs +hh${c4}./syyys+.${c1} ${c3}+yy+.${c1}hhhhh${c3}.+yyo`${c5}.ossssso/${c1}h`h +shhh${c4}``.`${c1}hhh${c3}`/syyso++oyys/`${c1}hhh${c5}`+++-`${c1}hh:h +d/hhhhhhhhhhhh${c3}`-/osyso+-`${c1}hhhhhhhhhhhh.h + d/hhhhhhhhhhhh${c6}`/ossso/.${c1}hhhhhhhhhhhh.h + do`hhhhhhhhh${c6}`ossssssso.${c1}hhhhhhhhhh:h + h/`hhhhhhh${c6}-sssssssss:${c1}hhhhhhhh-yd + h+.hhhhhh${c6}+sssssss+${c1}hhhhhh`/yd + dho:.hhh${c6}.:+++/.${c1}hhh`-+yd + ddhso+++++osyhd diff --git a/src/logo/ascii/regolith.txt b/src/logo/ascii/regolith.txt new file mode 100644 index 000000000..50ae404fd --- /dev/null +++ b/src/logo/ascii/regolith.txt @@ -0,0 +1,18 @@ + ``....``` + `.:/++++++/::-.` + -/+++++++:.` + -++++++++:` + `/++++++++- + `/++++++++. -/+/ + /++++++++/ `` .:+++:. + -+++++++++/ ./++++:+++/-` + :+++++++++/ `+++++++/-` + :++++++++++` .-/+++++++` + `:++++++++++/``.-/++++:-:::-` ` + `:+++++++++++++++++/:.` ./` +:++/-:+++++++++/:-.. -/+. ++++++++++/::-...:/+++/-..````..-/+++. +`......``.::/+++++++++++++++++++++/. + -/+++++++++++++++++++++/. + .:/+++++++++++++++/-` + `.-:://////:-. diff --git a/src/logo/ascii/rhaymos.txt b/src/logo/ascii/rhaymos.txt new file mode 100644 index 000000000..87e0aae04 --- /dev/null +++ b/src/logo/ascii/rhaymos.txt @@ -0,0 +1,14 @@ + ### + ##### + + ####### /######## + ############# ########### + ,########### #### ####(.. + #### #### ####* ########## + #### ##### ##### (#### + #### ########### ########### + #### ######### ########## + + ################################### + ##################################### +####################################### diff --git a/src/logo/ascii/rhel_old.txt b/src/logo/ascii/rhel_old.txt new file mode 100644 index 000000000..766f87683 --- /dev/null +++ b/src/logo/ascii/rhel_old.txt @@ -0,0 +1,16 @@ + `.-..........` + `////////::.`-/. + -: ....-////////. + //:-::///////////` + `--::: `-://////////////: + //////- ``.-:///////// .` + `://////:-.` :///////::///:` + .-/////////:---/////////////: + .-://////////////////////. +${c2} yMN+`.-${c1}::///////////////-` +${c2} .-`:NMMNMs` `..-------..` + MN+/mMMMMMhoooyysshsss +MMM MMMMMMMMMMMMMMyyddMMM+ + MMMM MMMMMMMMMMMMMNdyNMMh` hyhMMM + MMMMMMMMMMMMMMMMyoNNNMMM+. MMMMMMMM + MMNMMMNNMMMMMNM+ mhsMNyyyyMNMMMMsMM diff --git a/src/logo/ascii/rocky_small.txt b/src/logo/ascii/rocky_small.txt new file mode 100644 index 000000000..beb90607b --- /dev/null +++ b/src/logo/ascii/rocky_small.txt @@ -0,0 +1,12 @@ + `-/+++++++++/-.` + `-+++++++++++++++++-` +.+++++++++++++++++++++. +-+++++++++++++++++++++++. ++++++++++++++++/-/+++++++ ++++++++++++++/. ./+++++ ++++++++++++:. ./+++ ++++++++++:` `:/:` .:/ +-++++++:` .:+++++:` + .+++-` ./+++++++++:` + `-` ./+++++++++++- + -+++++++++:-.` diff --git a/src/logo/ascii/sabayon.txt b/src/logo/ascii/sabayon.txt new file mode 100644 index 000000000..70384adff --- /dev/null +++ b/src/logo/ascii/sabayon.txt @@ -0,0 +1,18 @@ + ........... + .. .. + .. .. + .. ${c2}o ${c1}.. + .. ${c2}:W' ${c1}.. + .. ${c2}.d. ${c1}.. +:. ${c2}.KNO ${c1}.: +:. ${c2}cNNN. ${c1}.: +: ${c2}dXXX, ${c1}: +: ${c2}. dXXX, .cd, ${c1}: +: ${c2}'kc .. dKKK. ,ll;:' ${c1}: +: ${c2}.xkkxc;..dkkkc',cxkkl ${c1}: +:. ${c2}.,cdddddddddddddo:. ${c1}.: + .. ${c2}:lllllll: ${c1}.. + .. ${c2}',,,,, ${c1}.. + .. .. + .. .. + ............... diff --git a/src/logo/ascii/sabotage.txt b/src/logo/ascii/sabotage.txt new file mode 100644 index 000000000..9f3adb713 --- /dev/null +++ b/src/logo/ascii/sabotage.txt @@ -0,0 +1,11 @@ + .|'''.| | '||''|. ..|''|| + ||.. ' ||| || || .|' || + ''|||. | || ||'''|. || || +. '|| .''''|. || || '|. || +|'....|' .|. .||. .||...|' ''|...|' + +|''||''| | ..|'''.| '||''''| + || ||| .|' ' || . + || | || || .... ||''| + || .''''|. '|. || || + .||. .|. .||. ''|...'| .||.....| diff --git a/src/logo/ascii/sailfish.txt b/src/logo/ascii/sailfish.txt new file mode 100644 index 000000000..68b20ac26 --- /dev/null +++ b/src/logo/ascii/sailfish.txt @@ -0,0 +1,13 @@ + _a@b + _#b (b + _@@ @_ _, + _#^@ _#*^^*gg,aa@^^ + #- @@^ _a@^^ + @_ *g#b + ^@_ ^@_ + ^@_ @ + @(b (b + #b(b#^ + _@_#@^ + _a@a*^ +,a@*^ diff --git a/src/logo/ascii/salentos.txt b/src/logo/ascii/salentos.txt new file mode 100644 index 000000000..fe819033d --- /dev/null +++ b/src/logo/ascii/salentos.txt @@ -0,0 +1,20 @@ + ``..`` + .-:+oshdNMMMMMMNdhyo+:-.` + -oydmMMMMMMMMMMMMMMMMMMMMMMMMMMNdhs/ +${c4} +hdddm${c1}NMMMMMMMMMMMMMMMMMMMMMMMMN${c4}mdddh+` +${c2}`MMMMMN${c4}mdddddm${c1}MMMMMMMMMMMM${c4}mdddddm${c3}NMMMMM- +${c2} mMMMMMMMMMMMN${c4}ddddhyyhhddd${c3}NMMMMMMMMMMMM` +${c2} dMMMMMMMMMMMMMMMMM${c4}oo${c3}MMMMMMMMMMMMMMMMMN` +${c2} yMMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMd +${c2} +MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMy +${c2} :MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMo +${c2} .MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMM/ +${c2} `NMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMM- +${c2} mMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMN` +${c2} hMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMm +${c2} /MMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMy +${c2} .+hMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMms: +${c2} `:smMMMMMMMMM${c4}hh${c3}MMMMMMMMMNh+. +${c2} .+hMMMMMM${c4}hh${c3}MMMMMMdo: +${c2} `:smMM${c4}yy${c3}MMNy/` + ${c2}.- ${c4}`${c3}:. diff --git a/src/logo/ascii/salientos.txt b/src/logo/ascii/salientos.txt new file mode 100644 index 000000000..1fab8994e --- /dev/null +++ b/src/logo/ascii/salientos.txt @@ -0,0 +1,20 @@ + 00xxxx0 + 00xxxxxx0 + 0xxxxxxxxx 000000 + 0xxxxxxxxxx xxxxxxxxxx0 + 0xxxxxxxxxxx0 xxxxxxxxxxxxx0 + 0xxxxxxxxxxxx0 0xxxxxxxxxxxxxx0 + 0xxxxxxxxxxxxx0 0xxxxxxxxxxxxxxx0 +0xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx0 +xxxxxxxxxxxxxxxx0 0xxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx 0xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxx0 xxxxxxxxxxxxxx +0xxxxxxxxxxxxxxxxxx0 0xxxxxxxxxxxx0 + 0xxxxxxxxxxxxxxxxxx xxxxxxxxxxx0 + 0xxxxxxxxxxxxxxxxx xxxxxxxxxx0 + 0xxxxxxxxxxxxxxxx xxxxxxxxx0 + 0xxxxxxxxxxxx0 0xxxxxxx0 + 0xxxxxxx0 xxxxxx0 + 0xxx00 + x00 diff --git a/src/logo/ascii/sambabox.txt b/src/logo/ascii/sambabox.txt new file mode 100644 index 000000000..01c891875 --- /dev/null +++ b/src/logo/ascii/sambabox.txt @@ -0,0 +1,19 @@ + # + *////##### + /////////#########( + .((((((///// ,####(#((((( + /#######(((* (#(((((((((. +//((#(#(#, ((##( ,((((((// +////// #(##########( ////// +////// ((#(#(#(#(##########(///////// +/////( (((((((#########(##((((((///// +/(((#( ((((/ +####(# ((### +#########(((/////////(((((((((, (#(#( +########( /////////(((((((* ##### +####///, *////((( ((((((( +./////////// .//((((((((( + ///////////, *(/////((((* + ,/(((((((((##########/. + .((((((####### + ((##* diff --git a/src/logo/ascii/sasanqua.txt b/src/logo/ascii/sasanqua.txt new file mode 100644 index 000000000..3521c65e4 --- /dev/null +++ b/src/logo/ascii/sasanqua.txt @@ -0,0 +1,18 @@ + __,_ + _╕⌐≡µ,√* º≡, + ñ "' ░ + ╞) _, ▒ __ + _,,,_ _Ñ╜^≡µ ≡' 1µ╕º^el "%µ + ∩' K Yµ& 1l ╞) + ▒ √" ^Ü 1" `1µ + Γ ║h _¿▒∞√;, ^≡, + K ^u_ ⌐* ╙¥ ╓Ñ + ⌠ º≡u,, ║I Å + Ü _∩" ║µ_¿╝" + Yu_ ▒ ╙º≡_ ║l1µ + ║l , Y∞µ___≡ª Γl + ╓hⁿ╖I 1l Ñ ╓Ñ + Ñ ¥,___≡1l ╓Ñ ¿╕ª + Ü ╙L ¿¿∩ª ╓P + ª≡,__ *ⁿ┤ⁿÑⁿ^µ √ª + ⁿ≡,,__√╝* "ⁿⁿ*" diff --git a/src/logo/ascii/scientific.txt b/src/logo/ascii/scientific.txt new file mode 100644 index 000000000..ae236c7f8 --- /dev/null +++ b/src/logo/ascii/scientific.txt @@ -0,0 +1,20 @@ + =/;;/- + +: // + /; /; + -X H. +.//;;;:;;-, X= :+ .-;:=;:;#;. +M- ,=;;;#:, ,:#;;:=, ,@ +:# :#.=/++++/=.$= #= + ,#; #/:+/;,,/++:+/ ;+. + ,+/. ,;@+, ,#H;, ,/+, + ;+;;/= @. ${c3}.H${c2}#${c3}#X ${c1}-X :///+; + ;+=;;;.@, ${c2}.X${c3}M${c2}@$. ${c1}=X.//;=#/. + ,;: :@#= =$H: .+#- + ,#= #;-///==///-// =#, +;+ :#-;;;:;;;;-X- +: +@- .-;;;;M- =M/;;;-. -X + :;;::;;-. #- :+ ,-;;-;:== + ,X H. + ;/ #= + // +; + '////' diff --git a/src/logo/ascii/semc.txt b/src/logo/ascii/semc.txt new file mode 100644 index 000000000..6ba73edea --- /dev/null +++ b/src/logo/ascii/semc.txt @@ -0,0 +1,9 @@ + /\ + ______/ \ + / |()| ${c2}E M C +${c1} | (-- | | + \ \ | | +.----) | |__| +|_______/ / ${c3}"${c1} \ + ${c3}" + " diff --git a/src/logo/ascii/septor.txt b/src/logo/ascii/septor.txt new file mode 100644 index 000000000..47d9e8239 --- /dev/null +++ b/src/logo/ascii/septor.txt @@ -0,0 +1,20 @@ +ssssssssssssssssssssssssssssssssssssssss +ssssssssssssssssssssssssssssssssssssssss +ssssssssssssssssssssssssssssssssssssssss +ssssssssssssssssssssssssssssssssssssssss +ssssssssss${c2};okOOOOOOOOOOOOOOko;${c1}ssssssssss +sssssssss${c2}oNWWWWWWWWWWWWWWWWWWNo${c1}sssssssss +ssssssss${c2}:WWWWWWWWWWWWWWWWWWWWWW:${c1}ssssssss +ssssssss${c2}lWWWWWk${c1}ssssssssss${c2}lddddd:${c1}ssssssss +ssssssss${c2}cWWWWWNKKKKKKKKKKKKOx:${c1}ssssssssss +${c3}yy${c1}sssssss${c2}OWWWWWWWWWWWWWWWWWWWWx${c1}sssssss${c3}yy +yyyyyyyyyy${c2}:kKNNNNNNNNNNNNWWWWWW:${c3}yyyyyyyy +yyyyyyyy${c2}sccccc;${c3}yyyyyyyyyy${c2}kWWWWW:${c3}yyyyyyyy +yyyyyyyy${c2}:WWWWWWNNNNNNNNNNWWWWWW;${c3}yyyyyyyy +yyyyyyyy${c2}.dWWWWWWWWWWWWWWWWWWWNd${c3}yyyyyyyyy +yyyyyyyyyy${c2}sdO0KKKKKKKKKKKK0Od;${c3}yyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy diff --git a/src/logo/ascii/serene.txt b/src/logo/ascii/serene.txt new file mode 100644 index 000000000..fbdbcfb02 --- /dev/null +++ b/src/logo/ascii/serene.txt @@ -0,0 +1,20 @@ + __---''''''---__ + . . + : : + - _______----_- + s __----''' __---- + __h_ _-' _-' h + '-._''--.._ ; _-' y + : ''-._ '-._/ _-' : + y ':_ _--'' y + m .--'' '-._.;' m + m : : m + y '.._ '-__ y + : '--._ '''----___ : + y '--._ ''-- _ y + h '--._ : h + s __'; vs + - __..--'' - + :_..--'' : + . _ . + `''---______---''-`` diff --git a/src/logo/ascii/sharklinux.txt b/src/logo/ascii/sharklinux.txt new file mode 100644 index 000000000..d1ab28757 --- /dev/null +++ b/src/logo/ascii/sharklinux.txt @@ -0,0 +1,15 @@ + `:shd/ + `:yNMMMMs + `-smMMMMMMN. + .+dNMMMMMMMMs + .smNNMMMMMMMMm` + .sNNNNNNNMMMMMM/ + `omNNNNNNNMMMMMMm + /dNNNNNNNNMMMMMMM+ + .yNNNNNNNNNMMMMMMMN` + +mNNNNNNNNNMMMMMMMMh + .hNNNNNNNNNNMMMMMMMMMs + +mMNNNNNNNNMMMMMMMMMMMs + .hNMMNNNNMMMMMMMMMMMMMMMd + .oNNNNNNNNNNMMMMMMMMMMMMMMMo +`:+syyssoo++++ooooossssssssssso: diff --git a/src/logo/ascii/shastraos.txt b/src/logo/ascii/shastraos.txt new file mode 100644 index 000000000..c533a1a11 --- /dev/null +++ b/src/logo/ascii/shastraos.txt @@ -0,0 +1,19 @@ + ..,;;,'. + ':oo. ;o: + :o, ol + .oo ..';co: + ooo',;:looo; + .;lddl + cx .xl .c:' + dd xx xx ,d; +.xd cx. xx dd. + cx: .xo xx ,x: + 'xl xx cx' .xl + xd, xx .xd dx. + .xo:xx xx .xx + 'c xx:.'lx: + ..,;cxxxo + .';:codxxl lxo +cd. 'xo +:o, 'ld + .oc'...';lo diff --git a/src/logo/ascii/siduction.txt b/src/logo/ascii/siduction.txt new file mode 100644 index 000000000..139798e97 --- /dev/null +++ b/src/logo/ascii/siduction.txt @@ -0,0 +1,20 @@ + _aass, + jQh: =$w + QWmwawQW + )$QQQQ@( .. + _a_a. ~??^ syDY?Sa, + _mW>-<$c jWmi imm. + ]QQwayQE 4QQmgwmQQ` + ?WWQWP' -9QQQQQ@'._aas, + _a%is. .adYYs,. -"?!` aQB*~^3$c +_Qh;.nm .QWc. {QL ]QQp;..vmQ/ +"QQmmQ@ -QQQggmQP ]QQWmggmQQ( + -???" "$WQQQY` __, ?QQQQQQW! + _yZ!?q, - .yWY!!Sw, "???^ + .QQa_=qQ mQm>..vmm + $QQWQQP $QQQgmQQ@ + "???" _aa, -9WWQQWY` + _mB>~)$a -~~ + mQms_vmQ. + ]WQQQQQP + -?T??" diff --git a/src/logo/ascii/skiffos.txt b/src/logo/ascii/skiffos.txt new file mode 100644 index 000000000..11ba4cd0c --- /dev/null +++ b/src/logo/ascii/skiffos.txt @@ -0,0 +1,9 @@ +${c2} ,@@@@@@@@@@@w,_ + ${c2}====~~~,,.${c2}A@@@@@@@@@@@@@@@@@W,_ + ${c1}`||||||||||||||L{${c2}"@$@@@@@@@@B" + ${c1}`|||||||||||||||||||||L{${c2}"$D + ${c2}@@@@@@@@@@@@@@@@@@@@@${c1}_||||}==, + ${c2}*@@@@@@@@@@@@@@@@@@@@@@@@@p${c1}||||==, + ${c1}`'||LLL{{""${c2}@$B@@@@@@@@@@@@@@@p${c1}|| + ${c1}`~=|||||||||||L"${c2}$@@@@@@@@@@@ + ${c1}````'"""""""${c2}'"""""""" diff --git a/src/logo/ascii/slitaz.txt b/src/logo/ascii/slitaz.txt new file mode 100644 index 000000000..5cc394d9e --- /dev/null +++ b/src/logo/ascii/slitaz.txt @@ -0,0 +1,17 @@ + @ @( @ + @@ @@ @ @/ + @@ @@ @@ @@ + @@ %@@ @@ @@ + @@ %@@@ @@@@@. @@@@ @@ + @@@ @@@@ @@@@@@@ &@@@ @@@ + @@@@@@@ %@@@@@@@@@@@@ &@@@% @@@@@@@/ + ,@@@@@@@@@@@@@@@@@@@@@@@@@ + .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ +@@@@@@. @@@@@@@@@@@@@@@@@@@@@ /@@@@@@ +@@ @@@@@ @@@@@@@@@@@@, @@@@@ @@@ +@@ @@@@. @@@@@@@@@@@@@% #@@@@ @@. +@@ ,@@ @@@@@@@@@@@@@ @@@ @@ +@ @@. @@@@@@@@@@@@@ @@@ *@ +@ @@ @@@@@@@@@@@@ @@ @ + @ @@@@@@@@@. #@ + @ ,@@@@@ @ diff --git a/src/logo/ascii/smartos.txt b/src/logo/ascii/smartos.txt new file mode 100644 index 000000000..71db4ceab --- /dev/null +++ b/src/logo/ascii/smartos.txt @@ -0,0 +1,17 @@ +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyys oyyyyyyyyyyyyyyyy +yyyys yyyyyyyyy oyyyyyyyyyyyyyyyy +yyyys yyyyyyyyy oyyyyyyyyyyyyyyyy +yyyys yyyyyyyyy oyyyyyyyyyyyyyyyy +yyyys yyyyyyyyy oyyyyyyyyyyyyyyyy +yyyys yyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyy syyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyy syyyy +yyyyyyyyyyyyyyyy syyyyyyyyy syyyy +yyyyyyyyyyyyyyyy oyyyyyyyyy syyyy +yyyyyyyyyyyyyyyy oyyyyyyyyy syyyy +yyyyyyyyyyyyyyyy syyyyyyyyy syyyy +yyyyyyyyyyyyyyyy yyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy diff --git a/src/logo/ascii/soda.txt b/src/logo/ascii/soda.txt new file mode 100644 index 000000000..96c634f52 --- /dev/null +++ b/src/logo/ascii/soda.txt @@ -0,0 +1,15 @@ + ${c2}@&&&&${c1} *'*, + ${c2}@@@@@@@&&&${c1} ** '*, + ${c2}@@@@@@@@@@@&&&& + @&@@@@@@@@@@@@@@@&&& + ${c1}******${c2}@@@@@@@@@@@@@@@&&&& + ${c1}************${c2}@@@@@@@@@@@@@@ + ${c1}*****************${c2}@@@@@@@@@ + ${c1}**********************${c2}@@@ + @@@@@${c1}******************** + ${c2}@@@@@@@@@${c1}*************** +${c2}@@@@@@@@@@@@@@@${c1}********* +${c2}@@@@@@@@@@@@@@@@@@${c1}**** + ${c2}@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@ + @@@@@@@ diff --git a/src/logo/ascii/source_mage.txt b/src/logo/ascii/source_mage.txt new file mode 100644 index 000000000..7cd3ecd48 --- /dev/null +++ b/src/logo/ascii/source_mage.txt @@ -0,0 +1,21 @@ + :ymNMNho. +.+sdmNMMMMMMMMMMy` +.-::/yMMMMMMMMMMMm- + sMMMMMMMMMMMm/ + /NMMMMMMMMMMMMMm: + .MMMMMMMMMMMMMMMMM: + `MMMMMMMMMMMMMMMMMN. + NMMMMMMMMMMMMMMMMMd + mMMMMMMMMMMMMMMMMMMo + hhMMMMMMMMMMMMMMMMMM. + .`/MMMMMMMMMMMMMMMMMs + :mMMMMMMMMMMMMMMMN` + `sMMMMMMMMMMMMMMM+ + /NMMMMMMMMMMMMMN` + oMMMMMMMMMMMMM+ + ./sd.-hMMMMMMMMmmN` + ./+oyyyh- `MMMMMMMMMmNh + sMMMMMMMMMmmo + `NMMMMMMMMMd: + -dMMMMMMMMMo + -shmNMMms. diff --git a/src/logo/ascii/sparky.txt b/src/logo/ascii/sparky.txt new file mode 100644 index 000000000..f5448b354 --- /dev/null +++ b/src/logo/ascii/sparky.txt @@ -0,0 +1,20 @@ + . `-:-` + .o` .-///-` + `oo` .:/++:. + os+` -/+++:` ``.........``` + /ys+`./+++/-.-::::::----......`` + `syyo`++o+--::::-::/+++/-`` + -yyy+.+o+`:/:-:sdmmmmmmmmdy+-` +::-` :yyy/-oo.-+/`ymho++++++oyhdmdy/` +`/yy+-`.syyo`+o..o--h..osyhhddhs+//osyy/` + -ydhs+-oyy/.+o.-: ` ` :/::+ydhy+```-os- + .sdddy::syo--/:. `.:dy+-ohhho ./: + :yddds/:+oo+//:-`- /+ +hy+.shhy: `` + `:ydmmdysooooooo-.ss`/yss--oyyo + `./ossyyyyo+:-/oo:.osso- .oys + ``..-------::////.-oooo/ :so + `...----::::::::--.`/oooo: .o: + ``````` ++o+:` `:` + ./+/-` ` + `-:-. + `` diff --git a/src/logo/ascii/star.txt b/src/logo/ascii/star.txt new file mode 100644 index 000000000..9a60e8984 --- /dev/null +++ b/src/logo/ascii/star.txt @@ -0,0 +1,19 @@ + ./ + `yy- + `y.`y` + `` s- .y ` + +h//:..` +/ /o ``..:/so + /o``.-::/:/+ o/://::-.`+o` + :s` `. .` `s/ + .y. .s- + `y- :s` + .-//. /+:. + .:/:. .:/:. +-+o:. .:+:. +-///++///:::` .-::::///+so- + ``..o/ d-....``` + s. `/. d + h .+o-+o- h. + h -o/` `/o: s: + -s/o:` `:o/+/ + /s- -yo diff --git a/src/logo/ascii/stock_linux.txt b/src/logo/ascii/stock_linux.txt new file mode 100644 index 000000000..eaa03b47d --- /dev/null +++ b/src/logo/ascii/stock_linux.txt @@ -0,0 +1,19 @@ + #G5J5G# + &BPYJJJJJJJYPB& + &#G5JJJJJJY5YJJJJJJ5G#& + #G5YJJJJJY5G#& &#G5YJJJJJY5G# +BPYJJJJJJJ5B& &BPYJJJJJJYPB +JJJJJJJJJJY5G#& &BPYJJJJJ +JJJJJJJJJJJJJJY5G# &JJJJJ +PYJJJJJJJJJJJJJJJJYPB& GYJJJ + &BPYJJJJJJJJJJJJJJJJ5PB& &BP + #G5YJJJJJJJJJJJJJJJY5G# +PB& &BP5JJJJJJJJJJJJJJJJYPB& +JJJYG &BPYJJJJJJJJJJJJJJJJYP +JJJJJ& #G5YJJJJJJJJJJJJJJ +JJJJJYPB& &#G5YJJJJJJJJJJ +BPYJJJJJJYPB& &B5JJJJJJJYPB + #G5YJJJJJY5G#& &#G5YJJJJJY5G# + &#G5JJJJJJY5YJJJJJJ5G#& + &BPYJJJJJJJYPB& + #G5J5G# diff --git a/src/logo/ascii/sulin.txt b/src/logo/ascii/sulin.txt new file mode 100644 index 000000000..6b7fa719e --- /dev/null +++ b/src/logo/ascii/sulin.txt @@ -0,0 +1,20 @@ + /\ /\ + ( \\\\ // ) + \ \\\\ // / + \_\\\\||||//_/ + \/ _ _ \ + \/|(O)(O)| + \/ | | + ___________________\/ \ / + // // |____| + // || / \ + //| \| \ 0 0 / + // \ ) V / \____/ +// \ / ( / + \ /_________| |_/ + / /\ / | || + / / / / \ || + | | | | | || + | | | | | || + |_| |_| |_|| + \_\ \_\ \_\\ diff --git a/src/logo/ascii/swagarch.txt b/src/logo/ascii/swagarch.txt new file mode 100644 index 000000000..e3884f158 --- /dev/null +++ b/src/logo/ascii/swagarch.txt @@ -0,0 +1,15 @@ +${c2} .;ldkOKXXNNNNXXK0Oxoc,. + ,lkXMMNK0OkkxkkOKWMMMMMMMMMM; + 'K0xo ..,;:c:. `'lKMMMMM0 + .lONMMMMMM' `lNMk' +${c2} ;WMMMMMMMMMO. ${c1}....::... +${c2} OMMMMMMMMMMMMKl. ${c1}.,;;;;;ccccccc, +${c2} `0MMMMMMMMMMMMMM0: ${c1}.. .ccccccc. +${c2} 'kWMMMMMMMMMMMMMNo. ${c1}.,:' .ccccccc. +${c2} `c0MMMMMMMMMMMMMN,${c1},:c; :cccccc: +${c2} ckl. `lXMMMMMMMMMX${c1}occcc:.. ;ccccccc. +${c2}dMMMMXd, `OMMMMMMWk${c1}ccc;:''` ,ccccccc: +${c2}XMMMMMMMWKkxxOWMMMMMNo${c1}ccc; .cccccccc. +${c2} `':ldxO0KXXXXXK0Okdo${c1}cccc. :cccccccc. + :ccc:' `cccccccc:, + '' diff --git a/src/logo/ascii/t2.txt b/src/logo/ascii/t2.txt new file mode 100644 index 000000000..cbb4df7b7 --- /dev/null +++ b/src/logo/ascii/t2.txt @@ -0,0 +1,6 @@ +${c2}TTTTTTTTTT + tt ${c1}222${c2} + tt ${c1}2 2${c2} + tt ${c1}2${c2} + tt ${c1}2${c2} + tt ${c1}22222${c2} diff --git a/src/logo/ascii/tails.txt b/src/logo/ascii/tails.txt new file mode 100644 index 000000000..b4bb7936c --- /dev/null +++ b/src/logo/ascii/tails.txt @@ -0,0 +1,19 @@ + `` + ./yhNh +syy/Nshh `:o/ +N:dsNshh █ `ohNMMd +N-/+Nshh `yMMMMd +N-yhMshh yMMMMd +N-s:hshh █ yMMMMd so//. +N-oyNsyh yMMMMd d Mms. +N:hohhhd:. yMMMMd syMMM+ +Nsyh+-..+y+- yMMMMd :mMM+ ++hy- -ss/`yMMMM `+d+ + :sy/. ./yNMMMMm `` + .+ys- `:+hNMMMMMMy/` + `hNmmMMMMMMMMMMMMdo. + dMMMMMMMMMMMMMMMMMNh: + +hMMMMMMMMMMMMMMMMMmy. + -oNMMMMMMMMMMmy+.` + `:yNMMMds/.` + .//` diff --git a/src/logo/ascii/tearch.txt b/src/logo/ascii/tearch.txt new file mode 100644 index 000000000..706bb03d8 --- /dev/null +++ b/src/logo/ascii/tearch.txt @@ -0,0 +1,21 @@ + @@@@@@@@@@@@@@ + @@@@@@@@@ @@@@@@ + @@@@@ @@@@@ + @@ @@ + @% @@ + @ @ + @@@@@@@@@@@@@@@@@@@@@@@@ @@ + .@@@@@@@@@@@@/@@@@@@@@@@@@ + @@@@@@@@@@@@///@@@@@@@@@@@@ + @@@@@@@@@@@@@((((@@@@@@@@@@@@ + @@@@@@@@@@@#(((((((#@@@@@@@@@@@ + @@@@@@@@@@@#//////////@@@@@@@@@@& + @@@@@@@@@@////@@@@@////@@@@@@@@@@ + @@@@@@@@//////@@@@@/////@@@@@@@@@ + @@@@@@@//@@@@@@@@@@@@@@@//@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@ .@@@@@@@@@@@@@@@@@@@@@@@@@ @ + @@@@@@ @@@. @@@@@@@ + @@@@@@@&@@@@@@@# #@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@ diff --git a/src/logo/ascii/torizoncore.txt b/src/logo/ascii/torizoncore.txt new file mode 100644 index 000000000..4ca150f84 --- /dev/null +++ b/src/logo/ascii/torizoncore.txt @@ -0,0 +1,29 @@ +${c2} `.::-. + `-://////:-. + `:////////////:. + `.-.` `-:///////-. ` + `.://///:.` `-::-. `-://:.` + .:///////////:. `-:////////:.` + `.://///////:-` .:////////////:` + `.-/:-` `.:///:-` ${c3}`-+o/.${c2} `.://////-. `.` + `.:///////:-` `.` ${c3}`-+sssssso/.${c2} `.--. `-:///:-` +-/////////////: ${c3}`+sssssssssssso-${c2} `-://///////:-` + .-///////:.` `` ${c3}-/sssssssso/.${c2} ` .:///////////-. + .-::.` `-://:-. ${c3}-/sso/.${c2} `.:/:-. `.://///-. + `-:////////:-. ${c3}`${c2} `.:////////-. `.-. +${c1}o-${c2} -:///////////:` .:////////////:` ${c1}-o${c2} +${c1}hdho-${c2} `-://///:.` `..` `-://////:.` ${c1}-ohdh${c2} +${c1}/ydddho-${c2} `--.` `.:////:.` `-::.` ${c1}-ohdddy/${c2} + ${c1}./ydddho:`${c2} `.://////////:. ${c1}`:ohdddy/.${c2} +` ${c1}`/shddho:`${c2} `.://////////:. ${c1}`:ohddds/`${c2} ` +::-` ${c1}`/shddhs:`${c2} `.:////:.` ${c1}`:shddhs/`${c2} `-:: +:///:-` ${c1}`:shddhs/`${c2} `..` ${c1}`/shddhs:`${c2} `-:///- + `.:///:-` ${c1}`:ohddhs/`${c2} ${c1}`/shddho:`${c2} `-:///:.` + `.:///:-. ${c1}-ohdddy/.${c2} ${c1}./ydddho-${c2} .-:///-.` + `.:///:-. ${c1}-+hdddy+//+ydddh+-${c2} .-://:-. + `.-///:-. ${c1}-+yddddddy+-${c2} .-://:-. + .-://:-. ${c1}./++/.${c2} .-///:-. + .-:///:.` `.:///:-` + `-:///:.````.:///:-` + `-:////////:-` + `-::::-` diff --git a/src/logo/ascii/trisquel.txt b/src/logo/ascii/trisquel.txt new file mode 100644 index 000000000..7c1a35299 --- /dev/null +++ b/src/logo/ascii/trisquel.txt @@ -0,0 +1,17 @@ + ,o$$$$$$o. + ,o$$$$Y"""Y$$$$b + ,o$$$$$$$$$$$$o. ,$$$$' , Y$$$$b + ,o$$$$$$$$$$$$$$$$$$$$$$$$o. :$$ b Y$$$$. +,$$$$"' "Y$$$$$$$$o. 'b. ,b d$$$$$$ +$$$$' .d$$$$$$$$b '$$$$$$$$o 'Y$$$$$$Y d$$$$$$' +$$$$' q' 'b '$$$$$$$$$$o._ _.o$$$$$$$$' +.$$$$,_ _,d$$ ,$$$$$$$$$$$$$$$$$$$$$$$$${c2}$$$$$$$$Y' +${c1} '$$$$$$$$aaa$$$$$$' .$$$$$$$$$$$$${c2}$$$$$$$$$$$$$$$$' +${c1} """" ${c2}d$$$$$$$$"' + d$$$$$$' .d$$$$b. + $$$$$$$$ .$$" 'a$$. + $$$$$$$$ $$b $$$$. + '$$$$$$. '$$b,,. $$$$$$ + '$$$$$$. .$$$$' + 'a$$$$$$o._.o$$$$a' + 'a$$$$$$$$a' diff --git a/src/logo/ascii/twister.txt b/src/logo/ascii/twister.txt new file mode 100644 index 000000000..9d5417e88 --- /dev/null +++ b/src/logo/ascii/twister.txt @@ -0,0 +1,23 @@ +${c3}.......................${c4}.......${c5}.,:ccllllcc:.${c4}... +${c3}.......................${c5}.,;cldxkO0KXNNNWNNNX0x: +${c3}.................${c5}.,:ldkOOKK0OkkkkkOKWMMMMMMMNo +${c3}.............${c5},;coxO0Oxo::'${c4}.........${c5},oXMMMMMM0' +${c3}.........${c5},:ldkOOkc;'${c3}...${c4}.............${c5};OMMMMW0:${c4}. +${c3}.......${c5};ldkOxol:'${c3}......${c4}............${c5},dNMMX0''${c4}.. +${c3}....${c5};:oxkxl:'${c3}..........${c4}..........${c5},lOWWXx:.,'${c4}.. +${c3}..${c5},ldxkkd:'${c3}............${c5}.:c${c4}....${c5}':lkNMNOc,cdl'${c4}.. +${c3}.${c5};oxxkkkc'${c3}.........${c5}.:clc;'.';lkKNNKk;;ck00l${c4}... +${c5}.lxxxkkkxoooooddxkOOko'..cok0KOd':::o0NXd;'${c4}... +${c3}.${c5}:odxxkkOOOOOOOkdoi'..:ddxdoc:::od0NWW0c'${c4}..... +${c3}...${c5}':;gggggg;::''.......::::x0XWMMMNO.::'${c4}..... +${c3}..............${c5};......,;od0KNWMWNK0O:::do'${c4}..... +${c3}...............${c5}'cclgggggggxdll":::'XKoo,${c4}...... +${c3}.................${c5}',,,,,,,::::;ooNWMWOc'${c4}....... +${c3}..................${c5},:loxxxO0KXNNXK0ko:'${c4}........ +${c3}..................${c5}';::;oTcoggcoF":::'${c4}......... +${c3}..................${c5}':o,.:::::::::,p'${c4}........... +${c3}..................${c5};'ccdxkOOOdxlf'${c4}............. +${c3}.................${c5},l;;XgggggXP:'${c4}............... +${c3}................${c5};lco;::::::'${c4}.................. +${c3}..............${c5}.';ggggol'`${c4}..................... +${c3}.............${c5}':oo:''${c3}...${c4}....................... diff --git a/src/logo/ascii/ubuntu2_old.txt b/src/logo/ascii/ubuntu2_old.txt new file mode 100644 index 000000000..d44ee6cb9 --- /dev/null +++ b/src/logo/ascii/ubuntu2_old.txt @@ -0,0 +1,18 @@ + ./+o+- +${c2} yyyyy- ${c1}-yyyyyy+ +${c2} ${c2}://+//////${c1}-yyyyyyo +${c3} .++ ${c2}.:/++++++/-${c1}.+sss/` +${c3} .:++o: ${c2}/++++++++/:--:/- +${c3} o:+o+:++.${c2}`..```.-/oo+++++/ +${c3} .:+o:+o/.${c2} `+sssoo+/ +${c2} .++/+:${c3}+oo+o:`${c2} /sssooo. +${c2}/+++//+:${c3}`oo+o${c2} /::--:. +${c2}+/+o+++${c3}`o++o${c1} ++////. +${c2} .++.o+${c3}++oo+:`${c1} /dddhhh. +${c3} .+.o+oo:.${c1} `oddhhhh+ +${c3} +.++o+o`${c1}`-````.:ohdhhhhh+ +${c3} `:o+++ ${c1}`ohhhhhhhhyo++os: +${c3} .o:${c1}`.syhhhhhhh/${c3}.oo++o` +${c1} /osyyyyyyo${c3}++ooo+++/ +${c1} ````` ${c3}+oo+++o: +${c3} `oo++. diff --git a/src/logo/ascii/ubuntu_cinnamon.txt b/src/logo/ascii/ubuntu_cinnamon.txt new file mode 100644 index 000000000..b51d280cd --- /dev/null +++ b/src/logo/ascii/ubuntu_cinnamon.txt @@ -0,0 +1,20 @@ + .-/+oooooooo+/-. + `:+oooooooooooooooooo+:` + -+oooooooooooooooooooooooo+- + .ooooooooooooooooooo${c2}:ohNd${c1}oooooo. + /oooooooooooo${c2}:/+oo++:/ohNd${c1}ooooooo/ + +oooooooooo${c2}:osNdhyyhdNNh+:+${c1}oooooooo+ + /ooooooooo${c2}/dN/${c1}ooooooooo${c2}/sNNo${c1}ooooooooo/ +.ooooooooo${c2}oMd:${c1}oooooooooooo${c2}:yMy${c1}ooooooooo. ++ooooo${c2}:+o/Md${c1}oooooo${c2}:sm/${c1}oo/ooo${c2}yMo${c1}oooooooo+ +ooo${c2}:sdMdosMo${c1}ooooo${c2}oNMd${c1}//${c2}dMd+${c1}o${c2}:so${c1}ooooooooo +oooo${c2}+ymdosMo${c1}ooo${c2}+mMm${c1}+/${c2}hMMMMMh+hs${c1}ooooooooo ++oooooo${c2}:${c1}:${c2}/Nm:${c1}/${c2}hMNo${c1}:y${c2}MMMMMMMMMM+${c1}oooooooo+ +.ooooooooo${c2}/NNMNy${c1}:o${c2}NMMMMMMMMMMo${c1}ooooooooo. +/oooooooooo${c2}:yh:${c1}+m${c2}MMMMMMMMMMd/${c1}ooooooooo/ + +oooooooooo${c2}+${c1}/h${c2}mMMMMMMNds//o${c1}oooooooo+ + /oooooooooooo${c2}+:////:o/ymMd${c1}ooooooo/ + .oooooooooooooooooooo${c2}/sdh${c1}oooooo. + -+oooooooooooooooooooooooo+- + `:+oooooooooooooooooo+:` + .-/+oooooooo+/-. diff --git a/src/logo/ascii/ubuntu_studio.txt b/src/logo/ascii/ubuntu_studio.txt new file mode 100644 index 000000000..16d5c4866 --- /dev/null +++ b/src/logo/ascii/ubuntu_studio.txt @@ -0,0 +1,20 @@ + ..-::::::-.` + `.:+++++++++++${c2}ooo${c1}++:.` + ./+++++++++++++${c2}sMMMNdyo${c1}+/. + .++++++++++++++++${c2}oyhmMMMMms${c1}++. + `/+++++++++${c2}osyhddddhys${c1}+${c2}osdMMMh${c1}++/` + `+++++++++${c2}ydMMMMNNNMMMMNds${c1}+${c2}oyyo${c1}++++` + +++++++++${c2}dMMNhso${c1}++++${c2}oydNMMmo${c1}++++++++` + :+${c2}odmy${c1}+++${c2}ooysoohmNMMNmyoohMMNs${c1}+++++++: + ++${c2}dMMm${c1}+${c2}oNMd${c1}++${c2}yMMMmhhmMMNs+yMMNo${c1}+++++++ +`++${c2}NMMy${c1}+${c2}hMMd${c1}+${c2}oMMMs${c1}++++${c2}sMMN${c1}++${c2}NMMs${c1}+++++++. +`++${c2}NMMy${c1}+${c2}hMMd${c1}+${c2}oMMMo${c1}++++${c2}sMMN${c1}++${c2}mMMs${c1}+++++++. + ++${c2}dMMd${c1}+${c2}oNMm${c1}++${c2}yMMNdhhdMMMs${c1}+y${c2}MMNo${c1}+++++++ + :+${c2}odmy${c1}++${c2}oo${c1}+${c2}ss${c1}+${c2}ohNMMMMmho${c1}+${c2}yMMMs${c1}+++++++: + +++++++++${c2}hMMmhs+ooo+oshNMMms${c1}++++++++ + `++++++++${c2}oymMMMMNmmNMMMMmy+oys${c1}+++++` + `/+++++++++${c2}oyhdmmmmdhso+sdMMMs${c1}++/ + ./+++++++++++++++${c2}oyhdNMMMms${c1}++. + ./+++++++++++++${c2}hMMMNdyo${c1}+/. + `.:+++++++++++${c2}sso${c1}++:. + ..-::::::-.. diff --git a/src/logo/ascii/ubuntu_sway.txt b/src/logo/ascii/ubuntu_sway.txt new file mode 100644 index 000000000..bbc2cc4ed --- /dev/null +++ b/src/logo/ascii/ubuntu_sway.txt @@ -0,0 +1,20 @@ + .-/+oossssoo+\-. + ´:+ssssssssssssssssss+:` + -+ssssssssssssssssss${c2}yy${c1}ssss+- + .ossssssssssssssssss${c2}dMMMNyy${c1}ssso. + /sssssssssss${c2}hdmmNNmmyNMMMMh${c1}ssssss\ + +sssssssss${c2}hm${c1}ydMMMMMMMNdd${c2}ddy${c1}ssssssss+ + /ssssssss${c2}hN${c1}MM${c2}M${c1}yh${c2}hyyyyhmNM${c1}MM${c2}Nh${c1}ssssssss\ +.ssssssss${c2}dM${c1}MM${c2}Nh${c1}ssssssssss${c2}hN${c1}MM${c2}Md${c1}ssssssss. ++sss${c2}yyyyyN${c1}MM${c2}Ny${c1}ssssssssssss${c2}yN${c1}MM${c2}My${c1}sssssss+ +ossy${c2}NMMMNy${c1}MM${c2}h${c1}ssssssssssssss${c2}hm${c1}mm${c2}h${c1}ssssssso +ossy${c2}NMMMNy${c1}MM${c2}h${c1}sssssssssssssshmmmh${c1}ssssssso ++sss${c2}yyyyyN${c1}MM${c2}Ny${c1}ssssssssssss${c2}yN${c1}MM${c2}My${c1}sssssss+ +.ssssssss${c2}dM${c1}MM${c2}Nh${c1}ssssssssss${c2}hN${c1}MM${c2}Md${c1}ssssssss. + \ssssssss${c2}hN${c1}MM${c2}M${c1}yh${c2}hyyyyhdNM${c1}M${c2}MNh${c1}ssssssss/ + +sssssssss${c2}dm${c1}ydMMMMMMMMdd${c2}ddy${c1}ssssssss+ + \sssssssssss${c2}hdmNNNNmyNMMMMh${c1}ssssss/ + .ossssssssssssssssss${c2}dMMMNyy${c1}ssso. + -+sssssssssssssssss${c2}yy${c1}sss+- + `:+ssssssssssssssssss+:` + .-\+oossssoo+/-. diff --git a/src/logo/ascii/ubuntu_touch.txt b/src/logo/ascii/ubuntu_touch.txt new file mode 100644 index 000000000..4801edb08 --- /dev/null +++ b/src/logo/ascii/ubuntu_touch.txt @@ -0,0 +1,7 @@ + ############### + ## ## +## ${c2}##${c1} ${c2}##${c1} ## +## ${c2}##${c1} ${c2}#${c1} ${c2}#${c1} ${c2}##${c1} ## +## ${c2}###${c1} ## + ## ## + ############### diff --git a/src/logo/ascii/ultramarine.txt b/src/logo/ascii/ultramarine.txt new file mode 100644 index 000000000..ef4033720 --- /dev/null +++ b/src/logo/ascii/ultramarine.txt @@ -0,0 +1,20 @@ + .cd0NNNNNNNXOdc. + .:xKNNNNNNNNNNNNNNNNKd;. + ,dXNNNNNNNNNNNNNNNNNNNNNNNd, + 'ONNNNNNNNNNNNNNNNNNNNNNNNNNNNO' + .xNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNk. + .0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0. +.0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0. +dNNNNNNNNNNNNWWWWWWWWNNNNNNNNNNNNNNNNNNd +NNNNNNNNNNNNNW${c2}MMMMMMMM${c1}WWNNNNNNNNNNNNNNNN +NNNNNNNNNNNNNNW${c2}MMMMMMMMM${c1}WWNNNNNNNNNNNNNN +NNNNNNNNNNNNNNW${c2}MMMMMMMMMMMM${c1}WNNNNNNNNNNNN +NNNNNNNNNNWWW${c2}MMMMMMMMMMMMMMMM${c1}WWWNNNNNNNX +oNWWWW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WWWNNo + OW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WO + .OW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WO. + lNW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WNl + .dNW${c2}MMMMMMMMMMMMMMMMMMMMMMMM${c1}WNd. + .cKW${c2}MMMMMMMMMMMMMMMMMMMM${c1}WKc. + 'oOXWWW${c2}MMMMMMMM${c1}WWWXOl. + ;lkXNNNNNNXkl' diff --git a/src/logo/ascii/univalent.txt b/src/logo/ascii/univalent.txt new file mode 100644 index 000000000..8a398745f --- /dev/null +++ b/src/logo/ascii/univalent.txt @@ -0,0 +1,18 @@ +UUUUUUU UUUUUUU +UUUUUUU UUUUUUU +UUUUUUU A UUUUUUU +UUUUUUU A|A UUUUUUU +UUUUUUU A | A UUUUUUU +UUUUUUU A | A UUUUUUU +UUUUUUU A| | |A UUUUUUU +UUUUUUU A | | | A UUUUUUU +UUUUUUU A | | | A UUUUUUU +UUUUUUU A | | | A UUUUUUU +UUUUUUU A | | | A UUUUUUU +UUUUUUU A | | | A UUUUUUU +UUUUUUU A | | | A UUUUUUU + UUUUUUU A | | | A UUUUUUU + UUUUUUU A | | | A UUUUUUU + UUUUUUUAAAAAAAAAAAUUUUUUU + UUUUUUUUUUUUUUUUUUU + UUUUUUUUUUUUU diff --git a/src/logo/ascii/univention.txt b/src/logo/ascii/univention.txt new file mode 100644 index 000000000..0d5221dba --- /dev/null +++ b/src/logo/ascii/univention.txt @@ -0,0 +1,20 @@ + ./osssssssssssssssssssssso+- + `ohhhhhhhhhhhhhhhhhhhhhhhhhhhhy: + shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh- + `-//${c2}sssss${c1}/hhhhhhhhhhhhhh+${c2}s${c1}.hhhhhhhhh+ + .ohhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sss${c1}+hhhhhhh+ +.yhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}ssss${c1}:hhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ ++hhhhhy${c2}ssssss${c1}+yhhhhhhhhhhy/${c2}ssssss${c1}yhhhhh+ ++hhhhhh:${c2}sssssss${c1}:hhhhhhh+${c2}.ssssssss${c1}yhhhhy. ++hhhhhhh+`${c2}ssssssssssssssss${c1}hh${c2}sssss${c1}yhhho` ++hhhhhhhhhs+${c2}ssssssssssss${c1}+hh+${c2}sssss${c1}/:-` +-hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhho + :yhhhhhhhhhhhhhhhhhhhhhhhhhhhh+` + -+ossssssssssssssssssssss+:` diff --git a/src/logo/ascii/urukos.txt b/src/logo/ascii/urukos.txt new file mode 100644 index 000000000..8b42721ce --- /dev/null +++ b/src/logo/ascii/urukos.txt @@ -0,0 +1,20 @@ + ${c3}:${c4}:::::::::::::: ${c5}. + ${c3}=#${c4}*============. ${c5}:#: + ${c3}=##%${c4}+----------. ${c5}.###: + ${c3}=####. ${c5}.####: + ${c3}=####. ${c5}.####: + ${c3}=###*. .=${c4}--------. ${c5}####: + ${c3}=####. .*#+${c4}======- ${c5}####: + ${c3}=###*. .*###+${c4}====- ${c5}####: + ${c3}=###*. .*#####+${c4}==- ${c5}####: +${c3}=###*. .*#######+${c4}: ${c5}####: +${c3}=###*. .*#######+${c4}: ${c5}####: + ${c3}=###*. .*#####+${c4}==- ${c5}####: + ${c3}=###*. .*###+${c4}====- ${c5}####: + ${c3}=####. .*#+${c4}======- ${c5}####: + ${c3}=###*. .=${c4}--------. ${c5}.####: + ${c3}=####. ${c5}.####: + ${c3}=####. ${c5}.####: + ${c3}=###+${c4}--------------${c5}####: + ${c3}=#+${c4}=================-${c5}: + ${c3}:${c4}::::::::::::::::::. diff --git a/src/logo/ascii/uwuntu.txt b/src/logo/ascii/uwuntu.txt new file mode 100644 index 000000000..e5246fa73 --- /dev/null +++ b/src/logo/ascii/uwuntu.txt @@ -0,0 +1,20 @@ + && + &&&&&&&& + , *&&&&&& &&&&&&&&( + &%%%%&&&& &&&&&&&&&&&& ,&&&&& + %%${c2}%%%%&&${c1}&&& ,&&&&&&&&&&&&&, %&&&$&&&%%$%%%. + &%%%${c2}%&&&&&${c1}&&# &, &&&&&&${c2}&&&&&&&%%%${c1}%% + &%%&&${c2}&&&&${c1}&&&( &&&${c2}&&&&&&%${c1}%%% + &&&&&${c2}&&&${c1}&% *&&${c2}&&&&&${c1}&&% + &&&/ &&&&${c3}\${c1}& ,${c3}/${c1}*.** + %&&&&&&&& &&&${c3}⟩${c1}., *.${c3}⟨${c1} + %&&&&&&&& &&${c3}/${c1}.. ${c3}/ \${c1} ..${c3}\${c1}(&&&&&& + #&&&#%%%%.%%%( ${c3}\_/\_/${c1} (%%%.%%%%/ + /%%%%%%%&&* ,&&&%%%%%%& + &&&&&&&& &&&&&&&&&&& + (&&&&& &&&&&&&&&&& + ${c2}%%${c1} & &&&&&&&&&&&& &&&&&&& + ${c2}%%%${c1} #&&&&&&# &&&&&&&&& + ${c2}%%%%% %%${c1} #&&&&&( +${c2}&%. %%%${c1} + ${c2}%%%%%%% diff --git a/src/logo/ascii/venom.txt b/src/logo/ascii/venom.txt new file mode 100644 index 000000000..680c12f94 --- /dev/null +++ b/src/logo/ascii/venom.txt @@ -0,0 +1,15 @@ +::::::: ::::::: +mMMMMMMm dMMMMMMm +/MMMMMMMo +MMMMMMM/ + yMMMMMMN mMMMMMMy + NMMMMMMs oMMMMMMm + +MMMMMMN: NMMMMMM+ + hMMMMMMy sMMMMMMy + :NMMMMMM::NMMMMMN: + oMMMMMMyyMMMMMM+ + dMMMMMMMMMMMMh + /MMMMMMMMMMMN: + sMMMMMMMMMMo + mMMMMMMMMd + +MMMMMMMN: + :::::: diff --git a/src/logo/ascii/vnux.txt b/src/logo/ascii/vnux.txt new file mode 100644 index 000000000..ade7e29f2 --- /dev/null +++ b/src/logo/ascii/vnux.txt @@ -0,0 +1,20 @@ + ` + ^[XOx~. + ^_nwdbbkp0ti' + +${c2} _j>!vC1,, + ${c4},${c2} ,CY${c3}O${c2}t${c3}O${c2}1(l;" +`${c4}~-{r(1I${c2} ^${c1}/zmwJuc:${c2}I^ +'${c4}?)|${c1}U${c4}/}-${c2} ^${c3}f${c1}OCLLOw${c3}_${c2},; + ,${c4}i,``. ${c2}",${c3}k%ooW@$d"${c2}I,' + ' ;^${c3}u$$$$$$$$$$$$$$$$^<${c2}:^ + ` .>>${c3}($$$$${c5}$@@@@$$$$${c3}$nl${c2}[:: + `!}?${c3}B$$${c5}%&WMMW&%$$${c3}$1}-${c2}}": + ^?j${c3}Z$$${c5}WMMWWWWMMW$$${c3}ofc${c2};;` + <~x&${c3}$$${c5}&MWWWWWWWWp${c3}-${c5}l>[< +${c1} 'ljmwn${c2}~tk8${c5}MWWWWM8O${c2}X${c1}r${c2}+]nC${c1}[ +!JZqwwdX${c2}:^C8${c5}#MMMM@${c2}X${c1}Odpdpq0< + ^x00J(" + ^" diff --git a/src/logo/ascii/vzlinux.txt b/src/logo/ascii/vzlinux.txt new file mode 100644 index 000000000..334177f3c --- /dev/null +++ b/src/logo/ascii/vzlinux.txt @@ -0,0 +1,20 @@ + ${c1}.::::::::.${c2} +`/////` ${c1}:zzzzzzzz${c2} ://///- + VVVVVu` ${c1}-zzz`${c2} /VVVVV. + `dVVVVV ${c1}.zzz`${c2} :VVVVV: + `VVVVVo ${c1}zzz${c2} -VVVVV/ + .VVVVV\ ${c1}zzz/${c2} .VVVVV+ + -VVVVV: ${c1}zzzzzzzzz${c2} .dVVVVs + \VVVVV- ${c1}`````````${c2} VVVVVV + +VVVVV. sVVVVu` + oVVVVd` +VVVVd` + VVVVVV /VVVVV. + `uVVVVs -VVVVV- + `dVVVV+ .VVVVV/ + .VVVVV\ `dVVVV+ + -VVVVV-`uVVVVo + :VVVVVVVVVVV + \VVVVVVVVu + oVVVVVVd` + sVVVVV. + ----. diff --git a/src/logo/ascii/wii_linux_ngx.txt b/src/logo/ascii/wii_linux_ngx.txt new file mode 100644 index 000000000..daafdc208 --- /dev/null +++ b/src/logo/ascii/wii_linux_ngx.txt @@ -0,0 +1,16 @@ +''''''' `~;:` -'''''' ~kQ@@g\ ,EQ@@g/ +h@@@@@@' o@@@@@9` `@@@@@@D `@@@@@@@= @@@@@@@? +'@@@@@@X o@@@@@@@D v@@@@@@: R@@@@@@, D@@@@@@_ + t@@@@@@' _@@@@@@@@@; `Q@@@@@U ;fmo/- ;fmo/- + `Q@@@@@m d@@@@@@@@@N 7@@@@@@' + L@@@@@@' :@@@@@&@@@@@| `Q@@@@@Z :]]]]]v :]]]]]v + Q@@@@@X R@@@@Q`g@@@@Q f@@@@@Q- z@@@@@Q v@@@@@Q + r@@@@@@~ ;@@@@@/ ;@@@@@L `@@@@@@/ z@@@@@Q v@@@@@Q + d@@@@@q M@@@@# H@@@@Q ]@@@@@Q z@@@@@Q v@@@@@Q + ,@@@@@@, >@@@@@; _@@@@@c `@@@@@@> z@@@@@Q v@@@@@Q + X@@@@@U Q@@@@R Z@@@@Q`{@@@@@N z@@@@@Q v@@@@@Q + .@@@@@@S@@@@@: -@@@@@e@@@@@@: z@@@@@Q v@@@@@Q + {@@@@@@@@@@U t@@@@@@@@@@e z@@@@@Q v@@@@@Q + `Q@@@@@@@@@' `Q@@@@@@@@@- z@@@@@Q v@@@@@Q + :@@@@@@@@| ;@@@@@@@@= z@@@@@Q v@@@@@Q + '2#@@Q6: ,eQ@@QZ~ /QQQQQg \QQQQQN diff --git a/src/logo/ascii/xferience.txt b/src/logo/ascii/xferience.txt new file mode 100644 index 000000000..96b1b4e5c --- /dev/null +++ b/src/logo/ascii/xferience.txt @@ -0,0 +1,19 @@ + ``--:::::::-.` + .-/+++ooooooooo+++:-` + `-/+oooooooooooooooooo++:. + -/+oooooo/+ooooooooo+/ooo++:` + `/+oo++oo. .+oooooo+.-: +:-o+- + `/+o/. -o. :oooooo+ ```:.+oo+- +`:+oo- -/` :oooooo+ .`-`+oooo/. +.+ooo+. .` `://///+-+..oooooo+:` +-+ooo:` ``.-+oooooo+/` +-+oo/` :+oooo/. +.+oo: ..-/. . -+oo+/` +`/++- -:::++::/. -+oo+- + ./o: `:///+- `./ooo+:` + .++- `` /-` -:/+oooo+:` + .:+/:`` `-:ooooooo++- + ./+o+//:...../+oooooooo++:` + `:/++ooooooooooooo++/-` + `.-//++++++//:-.` + `````` diff --git a/src/logo/ascii/yiffos.txt b/src/logo/ascii/yiffos.txt new file mode 100644 index 000000000..6a0788929 --- /dev/null +++ b/src/logo/ascii/yiffos.txt @@ -0,0 +1,19 @@ + NK + NxKXW + WOlcoXW + 0olccloxNW + XxllllllloxOKNW + Nklllllllllllodk0XWW + N0dllllllllllllllodxOKNW + WKxlllllllllllllllllllooxOKN + WKdllllllllllllllooooooooooooo + Nxllllllllllllllloooooooooo${c2}oooo +${c1} XXNOolllllllllllloooooooooo${c2}oooooo +${c1} WX0xolllllllllllooooooooooo${c2}oooooooo +${c1}XWN0xolllllllllloooooooo${c2}ooooooooooooo +${c1} Kkdolllllllooooddddd${c2}doooooooooooddo +${c1} K00XNW${c2} WX0xdooooooddddddd + WXOxdoooooodddd + WXOxdddddddd + NX0ddd + WN0d diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 860526fdb..fb7bdc989 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2631,6 +2631,15 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // PacBSD + { + .names = {"PacBSD"}, + .lines = FASTFETCH_DATATEXT_LOGO_PACBSD, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // Parabola { .names = {"parabola", "parabola-gnulinux"}, @@ -2652,6 +2661,131 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // Parch + { + .names = {"Parch"}, + .lines = FASTFETCH_DATATEXT_LOGO_PARCH, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + }, + }, + // Pardus + { + .names = {"Pardus"}, + .lines = FASTFETCH_DATATEXT_LOGO_PARDUS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + }, + }, + // Parrot + { + .names = {"Parrot"}, + .lines = FASTFETCH_DATATEXT_LOGO_PARROT, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // Parsix + { + .names = {"Parsix"}, + .lines = FASTFETCH_DATATEXT_LOGO_PARSIX, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_LIGHT_BLACK, + }, + }, + // PCBSD + { + .names = {"PCBSD", "TrueOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PCBSD, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // PCLinuxOS + { + .names = {"PCLinuxOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PCLINUXOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // PearOS + { + .names = {"PearOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PEAROS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, + }, + }, + // Pengwin + { + .names = {"Pengwin"}, + .lines = FASTFETCH_DATATEXT_LOGO_PENGWIN, + .colors = { + FF_COLOR_FG_MAGENTA, + FF_COLOR_MODE_BOLD FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_MAGENTA, + }, + }, + // Pentoo + { + .names = {"Pentoo"}, + .lines = FASTFETCH_DATATEXT_LOGO_PENTOO, + .colors = { + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + }, + }, + // Peppermint + { + .names = {"Peppermint"}, + .lines = FASTFETCH_DATATEXT_LOGO_PEPPERMINT, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // PhyOS + { + .names = {"PhyOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PHYOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Pisi + { + .names = {"Pisi"}, + .lines = FASTFETCH_DATATEXT_LOGO_PISI, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // PNMLinux + { + .names = {"PNM Linux", "WHPNM Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_PNM_LINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_256 "202" + }, + }, // Pop { .names = {"pop", "popos", "pop_os", "pop-linux"}, @@ -2673,7 +2807,118 @@ const FFlogo ffLogoBuiltins[] = { }, .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_CYAN, - }, // Raspbian + }, + // Porteus + { + .names = {"Porteus"}, + .lines = FASTFETCH_DATATEXT_LOGO_PORTEUS, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // PostMarketOS + { + .names = {"PostMarketOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_POSTMARKETOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + }, + // PostMarketOSSmall + { + .names = {"PostMarketOS_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_POSTMARKETOS_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + }, + // PuffOS + { + .names = {"PuffOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PUFFOS, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + }, + // Puppy + { + .names = {"Puppy"}, + .lines = FASTFETCH_DATATEXT_LOGO_PUPPY, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // PureOS + { + .names = {"PureOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_PUREOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + }, + // PureOSSmall + { + .names = {"PureOS_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_PUREOS_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + }, + // Q4OS + { + .names = {"Q4OS"}, + .lines = FASTFETCH_DATATEXT_LOGO_Q4OS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_RED, + }, + }, + // Qubes + { + .names = {"Qubes"}, + .lines = FASTFETCH_DATATEXT_LOGO_QUBES, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + }, + }, + // Qubyt + { + .names = {"Qubyt"}, + .lines = FASTFETCH_DATATEXT_LOGO_QUBYT, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLACK, + }, + }, + // Quibian + { + .names = {"Quibian"}, + .lines = FASTFETCH_DATATEXT_LOGO_QUIBIAN, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + }, + // Radix + { + .names = {"Radix"}, + .lines = FASTFETCH_DATATEXT_LOGO_RADIX, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + }, + }, + // Raspbian { .names = {"raspbian", "raspi", "raspberrypi", "raspberrypios", "pios"}, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN, @@ -2696,9 +2941,18 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_GREEN, }, + // RavynOS + { + .names = {"RavynOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_RAVYNOS, + .colors = { + FF_COLOR_FG_256 "15", + FF_COLOR_FG_WHITE, + }, + }, // Reborn { - .names = {"reborn", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux"}, + .names = {"Reborn", "Reborn OS", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_REBORN, .colors = { FF_COLOR_FG_BLUE, @@ -2709,7 +2963,7 @@ const FFlogo ffLogoBuiltins[] = { }, // RebornSmall { - .names = {"reborn_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small"}, + .names = {"Reborn_small", "Reborn OS_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_REBORN_SMALL, .colors = { @@ -2718,6 +2972,15 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // RedCore + { + .names = {"RedCore"}, + .lines = FASTFETCH_DATATEXT_LOGO_REDCORE, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // RedHatEnterpriseLinux { .names = {"rhel", "redhat", "redhat-linux"}, @@ -2728,6 +2991,15 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // RedHatEnterpriseLinux_old + { + .names = {"rhel_old", "redhat_old", "redhat-linux_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_RHEL_OLD, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // RedstarOS { .names = {"redstar", "redstar-os", "redstaros", "redstaros-linux", "redstar-os-linux"}, @@ -2738,6 +3010,48 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // Refracted Devuan + { + .names = {"Refracted Devuan", "refracted-devuan"}, + .lines = FASTFETCH_DATATEXT_LOGO_REFRACTED_DEVUAN, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_LIGHT_BLACK, + }, + .colorKeys = FF_COLOR_FG_LIGHT_BLACK, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Regata + { + .names = {"Regata"}, + .lines = FASTFETCH_DATATEXT_LOGO_REGATA, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + }, + }, + // Regolith + { + .names = {"Regolith"}, + .lines = FASTFETCH_DATATEXT_LOGO_REGOLITH, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // RhaymOS + { + .names = {"RhaymOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_RHAYMOS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // RockyLinux { .names = {"rocky", "rocky-linux", "rockylinux"}, @@ -2748,6 +3062,16 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // RockyLinuxSmall + { + .names = {"rocky_small", "rocky-linux_small", "rockylinux_small"}, + .lines = FASTFETCH_DATATEXT_LOGO_ROCKY_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // RosaLinux { .names = {"rosa", "rosa-linux", "rosalinux"}, @@ -2769,13 +3093,163 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_256 "202", }, + // Sabayon + { + .names = {"Sabayon"}, + .lines = FASTFETCH_DATATEXT_LOGO_SABAYON, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Sabotage + { + .names = {"Sabotage"}, + .lines = FASTFETCH_DATATEXT_LOGO_SABOTAGE, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Sailfish + { + .names = {"Sailfish"}, + .lines = FASTFETCH_DATATEXT_LOGO_SAILFISH, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + }, + }, + // SalentOS + { + .names = {"SalentOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SALENTOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + }, + // SalientOS + { + .names = {"Salient OS", "SalientOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SALIENTOS, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // SambaBOX + { + .names = {"SambaBOX", "Profelis SambaBOX"}, + .lines = FASTFETCH_DATATEXT_LOGO_SAMBABOX, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_CYAN, + }, + }, + // Sasanqua + { + .names = {"Sasanqua"}, + .lines = FASTFETCH_DATATEXT_LOGO_SASANQUA, + .colors = { + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_RED, + }, + }, + // Scientific + { + .names = {"Scientific"}, + .lines = FASTFETCH_DATATEXT_LOGO_SCIENTIFIC, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + }, + // Semc + { + .names = {"semc"}, + .lines = FASTFETCH_DATATEXT_LOGO_SEMC, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_LIGHT_BLACK, + FF_COLOR_FG_RED, + }, + }, + // Septor + { + .names = {"Septor"}, + .lines = FASTFETCH_DATATEXT_LOGO_SEPTOR, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + }, + }, + // Serene + { + .names = {"Serene"}, + .lines = FASTFETCH_DATATEXT_LOGO_SERENE, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + }, + }, + // SharkLinux + { + .names = {"SharkLinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_SHARKLINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // ShastraOS + { + .names = {"ShastraOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SHASTRAOS, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // Siduction + { + .names = {"Siduction"}, + .lines = FASTFETCH_DATATEXT_LOGO_SIDUCTION, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + } + }, + // SkiffOS + { + .names = {"SkiffOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SKIFFOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Slitaz + { + .names = {"Slitaz"}, + .lines = FASTFETCH_DATATEXT_LOGO_SLITAZ, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_YELLOW, + }, + }, // Slackware { .names = {"slackware", "slackware-linux", "slackwarelinux"}, .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE, .colors = { FF_COLOR_FG_BLUE, - FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, }, .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, @@ -2792,6 +3266,34 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // SmartOS + { + .names = {"SmartOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SMARTOS, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // Soda + { + .names = {"Soda"}, + .lines = FASTFETCH_DATATEXT_LOGO_SODA, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // SourceMage + { + .names = {"Source Mage", "source_mage"}, + .lines = FASTFETCH_DATATEXT_LOGO_SOURCE_MAGE, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Solaris { .names = {"solaris", "sunos"}, @@ -2824,6 +3326,33 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // Sparky + { + .names = {"Sparky"}, + .lines = FASTFETCH_DATATEXT_LOGO_SPARKY, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE + }, + }, + // Star + { + .names = {"Star"}, + .lines = FASTFETCH_DATATEXT_LOGO_STAR, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_WHITE, + }, + }, + // StockLinux + { + .names = {"Stock Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_STOCK_LINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, // SteamOS { .names = {"steamos"}, @@ -2835,6 +3364,83 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // Sulin + { + .names = {"Sulin"}, + .lines = FASTFETCH_DATATEXT_LOGO_SULIN, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Swagarch + { + .names = {"Swagarch"}, + .lines = FASTFETCH_DATATEXT_LOGO_SWAGARCH, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // T2 + { + .names = {"T2"}, + .lines = FASTFETCH_DATATEXT_LOGO_T2, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_BLUE, + }, + }, + // Tails + { + .names = {"Tails"}, + .lines = FF_COLOR_FG_MAGENTA, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // TeArch + { + .names = {"TeArch"}, + .lines = FASTFETCH_DATATEXT_LOGO_TEARCH, + .colors = { + FF_COLOR_BG_256 "39", + FF_COLOR_FG_WHITE, + }, + }, + // TorizonCore + { + .names = {"TorizonCore"}, + .lines = FASTFETCH_DATATEXT_LOGO_TORIZONCORE, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLACK, + FF_COLOR_FG_MAGENTA, + }, + }, + // Trisquel + { + .names = {"Trisquel"}, + .lines = FASTFETCH_DATATEXT_LOGO_TRISQUEL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_CYAN, + }, + }, + // Twister + { + .names = {"Twister"}, + .lines = FASTFETCH_DATATEXT_LOGO_TWISTER, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + }, + }, // Ubuntu { .names = {"ubuntu", "ubuntu-linux"}, @@ -2858,9 +3464,18 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // UbuntuCinnamon + { + .names = {"ubuntu cinnamon", "ubuntu-cinnamon"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_CINNAMON, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // UbuntuGnome { - .names = {"ubuntu-gnome"}, + .names = {"ubuntu gnome", "ubuntu-gnome"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME, .colors = { FF_COLOR_FG_BLUE, @@ -2916,6 +3531,33 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // UbuntuStudio + { + .names = {"ubuntu studio", "ubuntu-studio"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_STUDIO, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // UbuntuSway + { + .names = {"ubuntu sway", "ubuntu-sway"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_SWAY, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // UbuntuTouch + { + .names = {"ubuntu touch", "ubuntu-touch"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_TOUCH, + .colors = { + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_WHITE, + }, + }, // Ubuntu2Small { .names = {"ubuntu2_small", "ubuntu2-small"}, @@ -2927,6 +3569,43 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // Ubuntu2Old + { + .names = {"ubuntu2_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU2_OLD, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + }, + // Ultramarine + { + .names = {"Ultramarine", "Ultramarine Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_ULTRAMARINE, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + }, + // Univalent + { + .names = {"Univalent"}, + .lines = FASTFETCH_DATATEXT_LOGO_UNIVALENT, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + }, + }, + // Univention + { + .names = {"Univention"}, + .lines = FASTFETCH_DATATEXT_LOGO_UNIVENTION, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // UOS { .names = {"UOS"}, @@ -2937,6 +3616,28 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_YELLOW, }, + // UrukOS + { + .names = {"UrukOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_URUKOS, + .colors = { + FF_COLOR_FG_LIGHT_BLUE, + FF_COLOR_FG_LIGHT_BLUE, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_LIGHT_BLUE, + FF_COLOR_FG_BLUE, + } + }, + // Uwuntu + { + .names = {"uwuntu"}, + .lines = FASTFETCH_DATATEXT_LOGO_UWUNTU, + .colors = { + FF_COLOR_FG_256 "225", + FF_COLOR_FG_256 "206", + FF_COLOR_FG_256 "52", + }, + }, // Vanilla { .names = {"vanilla", "vanilla-os", "vanilla-linux"}, @@ -2947,6 +3648,37 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_YELLOW, }, + // Venom + { + .names = {"Venom"}, + .lines = FASTFETCH_DATATEXT_LOGO_VENOM, + .colors = { + FF_COLOR_FG_LIGHT_BLACK, + FF_COLOR_FG_BLUE, + }, + }, + // Vnux + { + .names = {"Vnux"}, + .lines = FASTFETCH_DATATEXT_LOGO_VNUX, + .colors = { + FF_COLOR_FG_256 "11", + FF_COLOR_FG_256 "8", + FF_COLOR_FG_256 "15", + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, + // Vzlinux + { + .names = {"Vzlinux"}, + .lines = FASTFETCH_DATATEXT_LOGO_VZLINUX, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + }, // Void { .names = {"void", "void-linux"}, @@ -2969,6 +3701,33 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_GREEN, }, + // WiiLinuxNgx + { + .names = {"WiiLinuxNgx"}, + .lines = FASTFETCH_DATATEXT_LOGO_WII_LINUX_NGX, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_WHITE, + }, + }, + // Xferience + { + .names = {"Xferience"}, + .lines = FASTFETCH_DATATEXT_LOGO_XFERIENCE, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + }, + }, + // YiffOS + { + .names = {"YiffOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_YIFFOS, + .colors = { + FF_COLOR_FG_256 "93", + FF_COLOR_FG_256 "92", + }, + }, // Zorin { .names = {"zorin", "zorin-linux", "zorinos", "zorinos-linux"}, From c1b75c0e4d0c01512225d1c8b84854152ffc6867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 14:53:22 +0800 Subject: [PATCH 421/493] Doc: update changelog --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9267e211d..42fca53da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,20 +4,20 @@ This release introduces a new configuration file format: JSON config. Please ref Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. -* Remove `--shell-version` and `--terminal-version`. They are always enabled +* Remove `--shell-version` and `--terminal-version`. They are always enabled (Terminal / Shell) * Remove `--*-error-format`, which seems to be useless * Remove `--display-detect-name`. Display name is always detected, and will be printed if multiple displays are detected * Deprecate `--set` and `--set-keyless`; they may be removed in future releases. Use JSON config with Custom module instead * Remove the special handling of Command module (it can be set once in the triditional `config.conf`). Use JSON config with Command module instead -* Change `--wm-theme-*` to `--wmtheme-*`. Affect `key` and `format` -* Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` -* Module `Command` uses `/bin/sh` as the default shell on systems other than Windows +* Change `--wm-theme-*` to `--wmtheme-*`. Affect `key` and `format` (WMTheme) +* Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` (TerminalFont) +* Module `Command` uses `/bin/sh` as the default shell on systems other than Windows (Command) Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module -* Support `--colors-symbol` and `--colors-padding-left` +* Support `--colors-symbol` and `--colors-padding-left` (Colors) * Add LM (Login Manager) module. Currently requires systemd installed (thus Linux only) * Add `--wmi-timeout` option (Windows) * Add `--logo-type small` to search for small logos @@ -48,7 +48,7 @@ Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: 1. Although konsole was said to support `kitty` image protocol, it doesn't support `kitty-direct` 2. wezterm support more image formats other than `.png` (tested with `.jpg` and `.webp`) -* Add `Windows 95` and more +* Port all logos supported by neo(wo)fetch. Fastfetch now has 350 builtin logos in total. # 1.12.2 From f2b341848261375d0d7a83a5494ae6072e9a8dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 15:08:15 +0800 Subject: [PATCH 422/493] Logo (Builtin): fix `Tails` and `TeArch` --- src/logo/builtin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index fb7bdc989..08f5a6768 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -3394,7 +3394,7 @@ const FFlogo ffLogoBuiltins[] = { // Tails { .names = {"Tails"}, - .lines = FF_COLOR_FG_MAGENTA, + .lines = FASTFETCH_DATATEXT_LOGO_TAILS, .colors = { FF_COLOR_FG_BLUE, FF_COLOR_FG_WHITE, @@ -3405,7 +3405,7 @@ const FFlogo ffLogoBuiltins[] = { .names = {"TeArch"}, .lines = FASTFETCH_DATATEXT_LOGO_TEARCH, .colors = { - FF_COLOR_BG_256 "39", + FF_COLOR_FG_256 "39", FF_COLOR_FG_WHITE, }, }, From 819c78e74c4046d5917777d093556cb45edecb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 16:05:25 +0800 Subject: [PATCH 423/493] Fastfetch: add option `--bright-color` --- CHANGELOG.md | 1 + doc/json_schema.json | 5 +++++ src/common/init.c | 1 + src/common/jsonconfig.c | 2 ++ src/common/printing.c | 5 ++++- src/data/help.txt | 1 + src/fastfetch.c | 2 ++ src/fastfetch.h | 2 ++ src/logo/builtin.c | 14 +++++++------- src/logo/logo.c | 9 +++++++-- src/modules/title/title.c | 3 ++- 11 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42fca53da..403c33fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Features: * Add new option `--temperature-unit` * Better CPU and Host detection for Android (Android) * Support yakuake terminal version & font detection (Terminal, Linux) +* Add new option `--bright-color` which can be used to disable the default bright color of keys, title and ASCII logo. Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/doc/json_schema.json b/doc/json_schema.json index 7d5e1465b..92f2779ee 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -304,6 +304,11 @@ } ] }, + "brightColor": { + "title": "Set if the keys, title and ASCII logo should be printed in bright color", + "type": "boolean", + "default": true + }, "binaryPrefix": { "type": "string", "title": "Set the binary prefix to used when printing bytes", diff --git a/src/common/init.c b/src/common/init.c index 8ffadbc98..a74be3e33 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -35,6 +35,7 @@ static void defaultConfig(void) ffStrbufInit(&instance.config.colorKeys); ffStrbufInit(&instance.config.colorTitle); + instance.config.brightColor = true; ffStrbufInitStatic(&instance.config.keyValueSeparator, ": "); instance.config.processingTimeout = 1000; diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 1b91c0035..9e7f1e481 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -379,6 +379,8 @@ const char* ffParseDisplayJsonConfig(void) else return "display.color must be either a string or an object"; } + else if (ffStrEqualsIgnCase(key, "brightColor")) + config->brightColor = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "binaryPrefix")) { int value; diff --git a/src/common/printing.c b/src/common/printing.c index 538698550..1ef1a0ea6 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -12,7 +12,10 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb if(!instance.config.pipe) { - fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if(customKeyColor != NULL && customKeyColor->length > 0) ffPrintColor(customKeyColor); else diff --git a/src/data/help.txt b/src/data/help.txt index 2eb23e67f..f56ea5d5c 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -58,6 +58,7 @@ Display options: -s,--structure : Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available. --color-keys : Set the color of the keys --color-title : Set the color of the title + --bright-color : Set if the keys, title and ASCII logo should be printed in bright color. Default is true -c,--color : Set the color of both the keys and title --separator : Set the separator between key and value. Default is a colon with a space --set : Hard set the value of a key diff --git a/src/fastfetch.c b/src/fastfetch.c index 2b0ac906f..f12ffe0ca 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -906,6 +906,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) optionCheckString(key, value, &instance.config.colorTitle); ffOptionParseColor(value, &instance.config.colorTitle); } + else if(ffStrEqualsIgnCase(key, "--bright-color")) + instance.config.brightColor = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color")) { optionCheckString(key, value, &instance.config.colorKeys); diff --git a/src/fastfetch.h b/src/fastfetch.h index fde4923f1..b261654ee 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -39,6 +39,8 @@ typedef struct FFconfig FFstrbuf colorKeys; FFstrbuf colorTitle; + bool brightColor; + FFstrbuf keyValueSeparator; bool showErrors; diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 08f5a6768..5b097f3c6 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -30,12 +30,12 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_ALMALINUX, .colors = { FF_COLOR_FG_RED, - FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + FF_COLOR_FG_LIGHT_YELLOW, FF_COLOR_FG_BLUE, - FF_COLOR_MODE_BOLD FF_COLOR_FG_GREEN, + FF_COLOR_FG_LIGHT_GREEN, FF_COLOR_FG_CYAN, }, - .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_RED, }, // Alpine @@ -416,7 +416,7 @@ const FFlogo ffLogoBuiltins[] = { .names = {"Astra", "Astra Linux", "astralinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ASTRA_LINUX, .colors = { - FF_COLOR_MODE_BOLD FF_COLOR_FG_RED, + FF_COLOR_FG_LIGHT_RED, FF_COLOR_FG_WHITE, }, .colorKeys = FF_COLOR_FG_RED, @@ -1565,9 +1565,9 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_HYBRID, .colors = { FF_COLOR_FG_BLUE, - FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLUE, }, - .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + .colorKeys = FF_COLOR_FG_LIGHT_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, // HydroOS @@ -2735,7 +2735,7 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_PENGWIN, .colors = { FF_COLOR_FG_MAGENTA, - FF_COLOR_MODE_BOLD FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_LIGHT_MAGENTA, FF_COLOR_FG_MAGENTA, }, }, diff --git a/src/logo/logo.c b/src/logo/logo.c index 025f78420..343eba264 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -19,7 +19,10 @@ typedef enum FFLogoSize static void ffLogoPrintCharsRaw(const char* data, size_t length) { FFLogoOptions* options = &instance.config.logo; - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); fwrite(data, length, 1, stdout); @@ -34,7 +37,9 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) uint32_t currentlineLength = 0; - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index c9dc9b8eb..ef3d7abe4 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -10,7 +10,8 @@ static inline void printTitlePart(const FFstrbuf* content, const FFstrbuf* color { if(!instance.config.pipe) { - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); ffPrintColor(color->length > 0 ? color : &instance.config.colorTitle); } From 0c2edd4064685b4ff6b42884dd92a6f5f96c4a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 5 Aug 2023 00:29:04 +0800 Subject: [PATCH 424/493] Memory / Swap (Windows): simplify implementation --- src/detection/memory/memory_windows.c | 17 ++++++++++------- src/detection/swap/swap_windows.c | 22 +++++----------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/detection/memory/memory_windows.c b/src/detection/memory/memory_windows.c index 666d79727..b50e068c6 100644 --- a/src/detection/memory/memory_windows.c +++ b/src/detection/memory/memory_windows.c @@ -1,16 +1,19 @@ #include "memory.h" +#include +#include #include const char* ffDetectMemory(FFMemoryResult* ram) { - MEMORYSTATUSEX statex = { - .dwLength = sizeof(statex), - }; - if (!GlobalMemoryStatusEx(&statex)) - return "GlobalMemoryStatusEx() failed"; + SYSTEM_INFO sysInfo; + GetNativeSystemInfo(&sysInfo); + + SYSTEM_PERFORMANCE_INFORMATION info; + if (!NT_SUCCESS(NtQuerySystemInformation(SystemPerformanceInformation, &info, sizeof(info), NULL))) + return "NtQuerySystemInformation(SystemPerformanceInformation) failed"; + ram->bytesUsed = (uint64_t)(info.TotalCommitLimit - info.AvailablePages) * sysInfo.dwPageSize; + ram->bytesTotal = (uint64_t)info.TotalCommitLimit * sysInfo.dwPageSize; - ram->bytesTotal = statex.ullTotalPhys; - ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys; return NULL; } diff --git a/src/detection/swap/swap_windows.c b/src/detection/swap/swap_windows.c index f541f1964..0855f76e4 100644 --- a/src/detection/swap/swap_windows.c +++ b/src/detection/swap/swap_windows.c @@ -1,5 +1,4 @@ #include "swap.h" -#include "util/mallocHelper.h" #include #include @@ -10,22 +9,11 @@ const char* ffDetectSwap(FFSwapResult* swap) SYSTEM_INFO sysInfo; GetNativeSystemInfo(&sysInfo); - ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION); - SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size); - while(true) - { - NTSTATUS status = NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size); - if(status == STATUS_INFO_LENGTH_MISMATCH) - { - if(!(pstart = (SYSTEM_PAGEFILE_INFORMATION*)realloc(pstart, size))) - return "realloc(pstart, size) failed"; - } - else if(!NT_SUCCESS(status)) - return "NtQuerySystemInformation(SystemPagefileInformation, size) failed"; - break; - } - swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize; - swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize; + SYSTEM_PAGEFILE_INFORMATION info; + if (!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, &info, sizeof(info), NULL))) + return "NtQuerySystemInformation(SystemPagefileInformation) failed"; + swap->bytesUsed = (uint64_t)info.TotalUsed * sysInfo.dwPageSize; + swap->bytesTotal = (uint64_t)info.CurrentSize * sysInfo.dwPageSize; return NULL; } From a971f6d933669e25fff67d72603580a472f95148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 5 Aug 2023 11:40:23 +0800 Subject: [PATCH 425/493] Revert "Memory / Swap (Windows): simplify implementation" Doesn't work at all This reverts commit 0c2edd4064685b4ff6b42884dd92a6f5f96c4a1e. --- src/detection/memory/memory_windows.c | 17 +++++++---------- src/detection/swap/swap_windows.c | 22 +++++++++++++++++----- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/detection/memory/memory_windows.c b/src/detection/memory/memory_windows.c index b50e068c6..666d79727 100644 --- a/src/detection/memory/memory_windows.c +++ b/src/detection/memory/memory_windows.c @@ -1,19 +1,16 @@ #include "memory.h" -#include -#include #include const char* ffDetectMemory(FFMemoryResult* ram) { - SYSTEM_INFO sysInfo; - GetNativeSystemInfo(&sysInfo); - - SYSTEM_PERFORMANCE_INFORMATION info; - if (!NT_SUCCESS(NtQuerySystemInformation(SystemPerformanceInformation, &info, sizeof(info), NULL))) - return "NtQuerySystemInformation(SystemPerformanceInformation) failed"; - ram->bytesUsed = (uint64_t)(info.TotalCommitLimit - info.AvailablePages) * sysInfo.dwPageSize; - ram->bytesTotal = (uint64_t)info.TotalCommitLimit * sysInfo.dwPageSize; + MEMORYSTATUSEX statex = { + .dwLength = sizeof(statex), + }; + if (!GlobalMemoryStatusEx(&statex)) + return "GlobalMemoryStatusEx() failed"; + ram->bytesTotal = statex.ullTotalPhys; + ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys; return NULL; } diff --git a/src/detection/swap/swap_windows.c b/src/detection/swap/swap_windows.c index 0855f76e4..f541f1964 100644 --- a/src/detection/swap/swap_windows.c +++ b/src/detection/swap/swap_windows.c @@ -1,4 +1,5 @@ #include "swap.h" +#include "util/mallocHelper.h" #include #include @@ -9,11 +10,22 @@ const char* ffDetectSwap(FFSwapResult* swap) SYSTEM_INFO sysInfo; GetNativeSystemInfo(&sysInfo); - SYSTEM_PAGEFILE_INFORMATION info; - if (!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, &info, sizeof(info), NULL))) - return "NtQuerySystemInformation(SystemPagefileInformation) failed"; - swap->bytesUsed = (uint64_t)info.TotalUsed * sysInfo.dwPageSize; - swap->bytesTotal = (uint64_t)info.CurrentSize * sysInfo.dwPageSize; + ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION); + SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size); + while(true) + { + NTSTATUS status = NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size); + if(status == STATUS_INFO_LENGTH_MISMATCH) + { + if(!(pstart = (SYSTEM_PAGEFILE_INFORMATION*)realloc(pstart, size))) + return "realloc(pstart, size) failed"; + } + else if(!NT_SUCCESS(status)) + return "NtQuerySystemInformation(SystemPagefileInformation, size) failed"; + break; + } + swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize; + swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize; return NULL; } From 16aedae843e5c424ea033dd52dc45a325b4085a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 5 Aug 2023 20:32:54 +0800 Subject: [PATCH 426/493] TerminalFont: detect `.kitty-wrapped` as `kitty` Fixes #510 --- src/detection/terminalfont/terminalfont.c | 2 +- src/detection/terminalshell/terminalshell_linux.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 58320d223..ec7161d36 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -355,7 +355,7 @@ static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell, #ifndef _WIN32 else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/")) ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS"); - else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty")) + else if(ffStrbufIgnCaseEqualS(&terminalShell->shellPrettyName, "kitty")) detectKitty(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 497cbc88d..8684e0aca 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -369,6 +369,8 @@ const FFTerminalShellResult* ffDetectTerminalShell() ffStrbufInitStatic(&result.shellPrettyName, "nushell"); else if(ffStrbufIgnCaseEqualS(&result.shellProcessName, "python") && getenv("XONSH_VERSION")) ffStrbufInitStatic(&result.shellPrettyName, "xonsh"); + else if(ffStrbufEqualS(&result.shellProcessName, ".kitty-wrapped")) + ffStrbufInitStatic(&result.shellPrettyName, "kitty"); // #510 else { // https://github.com/fastfetch-cli/fastfetch/discussions/280#discussioncomment-3831734 From 97f3860d1eb563b377db5d7c514a85faaa5adf75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 5 Aug 2023 23:08:47 +0800 Subject: [PATCH 427/493] TerminalFont: Fix #510 2rd try --- src/detection/terminalshell/terminalshell_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 8684e0aca..fa8be7e72 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -369,8 +369,6 @@ const FFTerminalShellResult* ffDetectTerminalShell() ffStrbufInitStatic(&result.shellPrettyName, "nushell"); else if(ffStrbufIgnCaseEqualS(&result.shellProcessName, "python") && getenv("XONSH_VERSION")) ffStrbufInitStatic(&result.shellPrettyName, "xonsh"); - else if(ffStrbufEqualS(&result.shellProcessName, ".kitty-wrapped")) - ffStrbufInitStatic(&result.shellPrettyName, "kitty"); // #510 else { // https://github.com/fastfetch-cli/fastfetch/discussions/280#discussioncomment-3831734 @@ -380,6 +378,8 @@ const FFTerminalShellResult* ffDetectTerminalShell() if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) ffStrbufInitStatic(&result.terminalPrettyName, "WezTerm"); + else if(ffStrbufEqualS(&result.terminalProcessName, ".kitty-wrapped")) + ffStrbufInitStatic(&result.terminalPrettyName, "kitty"); // #510 #if defined(__linux__) || defined(__FreeBSD__) From eef8040ea9df8abf30cb63a32d2487037cf0c483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 6 Aug 2023 09:25:09 +0800 Subject: [PATCH 428/493] TerminalFont: Fix #510 3rd try --- src/detection/terminalfont/terminalfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index ec7161d36..515c25350 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -355,7 +355,7 @@ static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell, #ifndef _WIN32 else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/")) ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS"); - else if(ffStrbufIgnCaseEqualS(&terminalShell->shellPrettyName, "kitty")) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalPrettyName, "kitty")) detectKitty(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); From f1d4611a7d78a66e667e6888b58c535eafe1d98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 09:03:22 +0800 Subject: [PATCH 429/493] Temps (macOS): adjust CPU and GPU sensors for m2 apple silicon Ref: https://github.com/exelban/stats/commit/14e29c4d60229c363cca9c9d25c30c87b7870830 --- src/detection/temps/temps_apple.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/detection/temps/temps_apple.c b/src/detection/temps/temps_apple.c index 02ed59d7e..0a612edb6 100644 --- a/src/detection/temps/temps_apple.c +++ b/src/detection/temps/temps_apple.c @@ -358,15 +358,14 @@ const char *ffDetectCoreTemps(enum FFTempType type, FFlist *result) break; case FF_TEMP_CPU_M2X: - detectTemp(conn, "Tp05", "CPU efficient core 1", result); - detectTemp(conn, "Tp0D", "CPU efficient core 2", result); - detectTemp(conn, "Tp0j", "CPU efficient core 3", result); - detectTemp(conn, "Tp0r", "CPU efficient core 4", result); - - detectTemp(conn, "Tp01", "CPU performance core 1", result); - detectTemp(conn, "Tp09", "CPU performance core 2", result); - detectTemp(conn, "Tp0f", "CPU performance core 3", result); - detectTemp(conn, "Tp0n", "CPU performance core 4", result); + detectTemp(conn, "Tp0A", "CPU core 1", result); + detectTemp(conn, "Tp0D", "CPU core 2", result); + detectTemp(conn, "Tp0E", "CPU core 3", result); + detectTemp(conn, "Tp01", "CPU core 4", result); + detectTemp(conn, "Tp02", "CPU core 5", result); + detectTemp(conn, "Tp05", "CPU core 6", result); + detectTemp(conn, "Tp06", "CPU core 7", result); + detectTemp(conn, "Tp09", "CPU core 8", result); break; case FF_TEMP_GPU_INTEL: @@ -392,7 +391,7 @@ const char *ffDetectCoreTemps(enum FFTempType type, FFlist *result) case FF_TEMP_GPU_M2X: detectTemp(conn, "Tg0f", "GPU 1", result); - detectTemp(conn, "Tg0n", "GPU 2", result); + detectTemp(conn, "Tg0j", "GPU 2", result); break; case FF_TEMP_BATTERY: From 74233ac0cbf3d1e32d5c613fcdcf67172ac96a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 10:15:08 +0800 Subject: [PATCH 430/493] Temps (macOS): code refactors --- CHANGELOG.md | 3 +- src/detection/battery/battery_apple.c | 21 +-- src/detection/cpu/cpu_apple.c | 28 ++-- src/detection/gpu/gpu_apple.c | 30 ++--- src/detection/temps/temps_apple.c | 180 +++++++++++--------------- src/detection/temps/temps_apple.h | 2 +- 6 files changed, 100 insertions(+), 164 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 403c33fef..3d627cd44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ Changes: * Remove the special handling of Command module (it can be set once in the triditional `config.conf`). Use JSON config with Command module instead * Change `--wm-theme-*` to `--wmtheme-*`. Affect `key` and `format` (WMTheme) * Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` (TerminalFont) -* Module `Command` uses `/bin/sh` as the default shell on systems other than Windows (Command) +* Module `Command` uses `/bin/sh` as the default shell on systems other than Windows (Command) +* Fix M2 CPU temperature detection (CPU, macOS) Features: * FreeBSD support is improved greatly, and actually tested in a phycial machine diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index 82b020179..dc1281dda 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -7,23 +7,11 @@ static double detectBatteryTemp(void) { - FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); + double result = 0; - ffDetectCoreTemps(FF_TEMP_BATTERY, &temps); - - if(temps.length == 0) + if(ffDetectCoreTemps(FF_TEMP_BATTERY, &result)) return FF_BATTERY_TEMP_UNSET; - double result = 0; - for(uint32_t i = 0; i < temps.length; ++i) - { - FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i); - result += tempValue->value; - //TODO: do we really need this? - ffStrbufDestroy(&tempValue->name); - ffStrbufDestroy(&tempValue->deviceClass); - } - result /= temps.length; return result; } @@ -90,10 +78,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) else ffStrbufAppendS(&battery->status, ""); - if(options->temp) - battery->temperature = detectBatteryTemp(); - else - battery->temperature = FF_BATTERY_TEMP_UNSET; + battery->temperature = options->temp ? detectBatteryTemp() : FF_BATTERY_TEMP_UNSET; CFRelease(properties); IOObjectRelease(registryEntry); diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index 6de492132..9dcb07edd 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -15,28 +15,19 @@ static double getFrequency(const char* propName) static double detectCpuTemp(const FFstrbuf* cpuName) { - FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); + double result = 0; + const char* error = NULL; if(ffStrbufStartsWithS(cpuName, "Apple M1")) - ffDetectCoreTemps(FF_TEMP_CPU_M1X, &temps); + error = ffDetectCoreTemps(FF_TEMP_CPU_M1X, &result); else if(ffStrbufStartsWithS(cpuName, "Apple M2")) - ffDetectCoreTemps(FF_TEMP_CPU_M2X, &temps); - else //TODO: PPC? - ffDetectCoreTemps(FF_TEMP_CPU_X64, &temps); + error = ffDetectCoreTemps(FF_TEMP_CPU_M2X, &result); + else // PPC? + error = ffDetectCoreTemps(FF_TEMP_CPU_X64, &result); - if(temps.length == 0) + if(error) return FF_CPU_TEMP_UNSET; - double result = 0; - for(uint32_t i = 0; i < temps.length; ++i) - { - FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i); - result += tempValue->value; - //TODO: do we really need this? - ffStrbufDestroy(&tempValue->name); - ffStrbufDestroy(&tempValue->deviceClass); - } - result /= temps.length; return result; } @@ -63,10 +54,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) if(cpu->frequencyMax == 0.0) cpu->frequencyMax = getFrequency("hw.cpufrequency"); - if (options->temp) - cpu->temperature = detectCpuTemp(&cpu->name); - else - cpu->temperature = FF_CPU_TEMP_UNSET; + cpu->temperature = options->temp ? detectCpuTemp(&cpu->name) : FF_CPU_TEMP_UNSET; return NULL; } diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 21c2a0a27..6cb786d6a 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -8,32 +8,23 @@ static double detectGpuTemp(const FFstrbuf* gpuName) { - FF_LIST_AUTO_DESTROY temps = ffListCreate(sizeof(FFTempValue)); + double result = 0; + const char* error; if(ffStrbufStartsWithS(gpuName, "Apple M1")) - ffDetectCoreTemps(FF_TEMP_GPU_M1X, &temps); + error = ffDetectCoreTemps(FF_TEMP_GPU_M1X, &result); else if(ffStrbufStartsWithS(gpuName, "Apple M2")) - ffDetectCoreTemps(FF_TEMP_GPU_M2X, &temps); + error = ffDetectCoreTemps(FF_TEMP_GPU_M2X, &result); else if(ffStrbufStartsWithS(gpuName, "Intel")) - ffDetectCoreTemps(FF_TEMP_GPU_INTEL, &temps); + error = ffDetectCoreTemps(FF_TEMP_GPU_INTEL, &result); else if(ffStrbufStartsWithS(gpuName, "Radeon") || ffStrbufStartsWithS(gpuName, "AMD")) - ffDetectCoreTemps(FF_TEMP_GPU_AMD, &temps); + error = ffDetectCoreTemps(FF_TEMP_GPU_AMD, &result); else - ffDetectCoreTemps(FF_TEMP_GPU_UNKNOWN, &temps); + error = ffDetectCoreTemps(FF_TEMP_GPU_UNKNOWN, &result); - if(temps.length == 0) + if(error) return FF_GPU_TEMP_UNSET; - double result = 0; - for(uint32_t i = 0; i < temps.length; ++i) - { - FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i); - result += tempValue->value; - //TODO: do we really need this? - ffStrbufDestroy(&tempValue->name); - ffStrbufDestroy(&tempValue->deviceClass); - } - result /= temps.length; return result; } @@ -99,10 +90,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) gpu->type = FF_GPU_TYPE_DISCRETE; } - if(options->temp) - gpu->temperature = detectGpuTemp(&gpu->name); - else - gpu->temperature = FF_GPU_TEMP_UNSET; + gpu->temperature = options->temp ? detectGpuTemp(&gpu->name) : FF_GPU_TEMP_UNSET; CFRelease(properties); IOObjectRelease(registryEntry); diff --git a/src/detection/temps/temps_apple.c b/src/detection/temps/temps_apple.c index 0a612edb6..7af1e12fe 100644 --- a/src/detection/temps/temps_apple.c +++ b/src/detection/temps/temps_apple.c @@ -6,35 +6,6 @@ #include #include -static const char kDataTypeFlt[] = "flt "; -static const char kDataTypeFp1f[] = "fp1f"; -static const char kDataTypeFp4c[] = "fp4c"; -static const char kDataTypeFp5b[] = "fp5b"; -static const char kDataTypeFp6a[] = "fp6a"; -static const char kDataTypeFp79[] = "fp79"; -static const char kDataTypeFp88[] = "fp88"; -static const char kDataTypeFpa6[] = "fpa6"; -static const char kDataTypeFpc4[] = "fpc4"; -static const char kDataTypeFpe2[] = "fpe2"; -static const char kDataTypeSp1e[] = "sp1e"; -static const char kDataTypeSp3c[] = "sp3c"; -static const char kDataTypeSp4b[] = "sp4b"; -static const char kDataTypeSp5a[] = "sp5a"; -static const char kDataTypeSp69[] = "sp69"; -static const char kDataTypeSp78[] = "sp78"; -static const char kDataTypeSp87[] = "sp87"; -static const char kDataTypeSp96[] = "sp96"; -static const char kDataTypeSpb4[] = "spb4"; -static const char kDataTypeSpf0[] = "spf0"; -static const char kDataTypeUi8[] = "ui8 "; -static const char kDataTypeUi16[] = "ui16"; -static const char kDataTypeUi32[] = "ui32"; -static const char kDataTypeUi64[] = "ui64"; -static const char kDataTypeSi8[] = "si8 "; -static const char kDataTypeSi16[] = "si16"; -static const char kDataTypePwm[] = "{pwm"; - -static const char *kIOAppleSmcHiddenClassName = "AppleSMC"; static const char kSmcCmdReadBytes = 5; static const char kSmcCmdReadKeyInfo = 9; static const uint32_t kKernelIndexSmc = 2; @@ -169,7 +140,7 @@ static const char *smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcV static const char *smcOpen(io_connect_t *conn) { - CFMutableDictionaryRef matchDict = IOServiceMatching(kIOAppleSmcHiddenClassName); + CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSMC"); if (matchDict == NULL) return "IOServiceMatching(\"AppleSmartBattery\") failed"; @@ -199,108 +170,108 @@ static const char *smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl if (val.dataSize == 0) return "Empty SMC result"; - if (ffStrEquals(val.dataType, kDataTypeUi8) || - ffStrEquals(val.dataType, kDataTypeUi16) || - ffStrEquals(val.dataType, kDataTypeUi32) || - ffStrEquals(val.dataType, kDataTypeUi64)) + if (ffStrEquals(val.dataType, "ui8 ") || + ffStrEquals(val.dataType, "ui16") || + ffStrEquals(val.dataType, "ui32") || + ffStrEquals(val.dataType, "ui64")) { uint64_t tmp = 0; for (uint32_t i = 0; i < val.dataSize; i++) tmp += (uint64_t)((uint8_t)(val.bytes[i]) * pow(256, val.dataSize - 1 - i)); *value = (double)tmp; } - else if (ffStrEquals(val.dataType, kDataTypeFlt)) + else if (ffStrEquals(val.dataType, "flt ")) { *value = *(float *)(val.bytes); } - else if (ffStrEquals(val.dataType, kDataTypeFp1f) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp1f") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 32768.0; } - else if (ffStrEquals(val.dataType, kDataTypeFp4c) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp4c") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4096.0; } - else if (ffStrEquals(val.dataType, kDataTypeFp5b) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp5b") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 2048.0; } - else if (ffStrEquals(val.dataType, kDataTypeFp6a) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp6a") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1024.0; } - else if (ffStrEquals(val.dataType, kDataTypeFp79) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp79") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 512.0; } - else if (ffStrEquals(val.dataType, kDataTypeFp88) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fp88") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 256.0; } - else if (ffStrEquals(val.dataType, kDataTypeFpa6) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fpa6") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 64.0; } - else if (ffStrEquals(val.dataType, kDataTypeFpc4) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fpc4") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16.0; } - else if (ffStrEquals(val.dataType, kDataTypeFpe2) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "fpe2") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp1e) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp1e") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16384.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp3c) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp3c") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 4096.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp4b) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp4b") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 2048.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp5a) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp5a") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1024.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp69) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp69") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 512.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp78) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp78") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 256.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp87) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp87") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 128.0; } - else if (ffStrEquals(val.dataType, kDataTypeSp96) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "sp96") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 64.0; } - else if (ffStrEquals(val.dataType, kDataTypeSpb4) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "spb4") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 16.0; } - else if (ffStrEquals(val.dataType, kDataTypeSpf0) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "spf0") && val.dataSize == 2) { *value = ntohs(*(uint16_t *)(val.bytes)) / 1.0; } - else if (ffStrEquals(val.dataType, kDataTypeSi8) && val.dataSize == 1) + else if (ffStrEquals(val.dataType, "si8 ") && val.dataSize == 1) { signed char *bytes = (signed char *)val.bytes; int16_t temp = 0; temp += (int8_t)(bytes[0]); *value = temp; } - else if (ffStrEquals(val.dataType, kDataTypeSi16) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "si16") && val.dataSize == 2) { *value = ntohs(*(int16_t *)(val.bytes)); } - else if (ffStrEquals(val.dataType, kDataTypePwm) && val.dataSize == 2) + else if (ffStrEquals(val.dataType, "{pwm") && val.dataSize == 2) { *value = (double)ntohs(*(uint16_t *)(val.bytes)) * 100 / 65536.0; } @@ -309,23 +280,18 @@ static const char *smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl return NULL; } -static void detectTemp(io_connect_t conn, const char *sensor, const char *name, FFlist *list) +static bool detectTemp(io_connect_t conn, const char *sensor, double* sum) { double temp = 0; const char* error = smcReadValue(conn, sensor, &temp); - if (error) - return; - - FFTempValue* tempValue= (FFTempValue*)ffListAdd(list); - tempValue->value = temp; - - assert(strlen(sensor) == 4); - ffStrbufInitNS(&tempValue->deviceClass, 4, sensor); - - ffStrbufInitS(&tempValue->name, name); + if (error) return false; + // https://github.com/exelban/stats/blob/14e29c4d60229c363cca9c9d25c30c87b7870830/Modules/Sensors/readers.swift#L124 + if (temp < 10 || temp > 120) return false; + *sum += temp; + return true; } -const char *ffDetectCoreTemps(enum FFTempType type, FFlist *result) +const char *ffDetectCoreTemps(enum FFTempType type, double *result) { static io_connect_t conn; static dispatch_once_t once_control; @@ -333,75 +299,83 @@ const char *ffDetectCoreTemps(enum FFTempType type, FFlist *result) if(!conn) return "smcOpen() failed"; + uint32_t count = 0; + *result = 0; + // https://github.com/exelban/stats/blob/master/Modules/Sensors/values.swift switch (type) { case FF_TEMP_CPU_X64: - detectTemp(conn, "TC0D", "CPU diode", result); - detectTemp(conn, "TC0E", "CPU diode virtual", result); - detectTemp(conn, "TC0F", "CPU diode filtered", result); - detectTemp(conn, "TC0P", "CPU proximity", result); + count += detectTemp(conn, "TC0D", result); // CPU diode + count += detectTemp(conn, "TC0E", result); // CPU diode virtual + count += detectTemp(conn, "TC0F", result); // CPU diode filtered + count += detectTemp(conn, "TC0P", result); // CPU proximity break; case FF_TEMP_CPU_M1X: - detectTemp(conn, "Tp09", "CPU efficient core 1", result); - detectTemp(conn, "Tp0T", "CPU efficient core 2", result); + count += detectTemp(conn, "Tp09", result); // CPU efficient core 1 + count += detectTemp(conn, "Tp0T", result); // CPU efficient core 2 - detectTemp(conn, "Tp01", "CPU performance core 1", result); - detectTemp(conn, "Tp05", "CPU performance core 2", result); - detectTemp(conn, "Tp0D", "CPU performance core 3", result); - detectTemp(conn, "Tp0H", "CPU performance core 4", result); - detectTemp(conn, "Tp0L", "CPU performance core 5", result); - detectTemp(conn, "Tp0P", "CPU performance core 6", result); - detectTemp(conn, "Tp0X", "CPU performance core 7", result); - detectTemp(conn, "Tp0b", "CPU performance core 8", result); + count += detectTemp(conn, "Tp01", result); // CPU performance core 1 + count += detectTemp(conn, "Tp05", result); // CPU performance core 2 + count += detectTemp(conn, "Tp0D", result); // CPU performance core 3 + count += detectTemp(conn, "Tp0H", result); // CPU performance core 4 + count += detectTemp(conn, "Tp0L", result); // CPU performance core 5 + count += detectTemp(conn, "Tp0P", result); // CPU performance core 6 + count += detectTemp(conn, "Tp0X", result); // CPU performance core 7 + count += detectTemp(conn, "Tp0b", result); // CPU performance core 8 break; case FF_TEMP_CPU_M2X: - detectTemp(conn, "Tp0A", "CPU core 1", result); - detectTemp(conn, "Tp0D", "CPU core 2", result); - detectTemp(conn, "Tp0E", "CPU core 3", result); - detectTemp(conn, "Tp01", "CPU core 4", result); - detectTemp(conn, "Tp02", "CPU core 5", result); - detectTemp(conn, "Tp05", "CPU core 6", result); - detectTemp(conn, "Tp06", "CPU core 7", result); - detectTemp(conn, "Tp09", "CPU core 8", result); + count += detectTemp(conn, "Tp0A", result); // CPU core 1 + count += detectTemp(conn, "Tp0D", result); // CPU core 2 + count += detectTemp(conn, "Tp0E", result); // CPU core 3 + count += detectTemp(conn, "Tp01", result); // CPU core 4 + count += detectTemp(conn, "Tp02", result); // CPU core 5 + count += detectTemp(conn, "Tp05", result); // CPU core 6 + count += detectTemp(conn, "Tp06", result); // CPU core 7 + count += detectTemp(conn, "Tp09", result); // CPU core 8 break; case FF_TEMP_GPU_INTEL: - detectTemp(conn, "TCGC", "GPU Intel Graphics", result); + count += detectTemp(conn, "TCGC", result); // GPU Intel Graphics goto gpu_unknown; case FF_TEMP_GPU_AMD: - detectTemp(conn, "TGDD", "GPU AMD Radeon", result); + count += detectTemp(conn, "TGDD", result); // GPU AMD Radeon goto gpu_unknown; case FF_TEMP_GPU_UNKNOWN: // Nvidia? gpu_unknown: - detectTemp(conn, "TG0D", "GPU diode", result); - detectTemp(conn, "TG0P", "GPU proximity", result); + count += detectTemp(conn, "TG0D", result); // GPU diode + count += detectTemp(conn, "TG0P", result); // GPU proximity break; case FF_TEMP_GPU_M1X: - detectTemp(conn, "Tg05", "GPU 1", result); - detectTemp(conn, "Tg0D", "GPU 2", result); - detectTemp(conn, "Tg0L", "GPU 3", result); - detectTemp(conn, "Tg0T", "GPU 4", result); + count += detectTemp(conn, "Tg05", result); // GPU 1 + count += detectTemp(conn, "Tg0D", result); // GPU 2 + count += detectTemp(conn, "Tg0L", result); // GPU 3 + count += detectTemp(conn, "Tg0T", result); // GPU 4 break; case FF_TEMP_GPU_M2X: - detectTemp(conn, "Tg0f", "GPU 1", result); - detectTemp(conn, "Tg0j", "GPU 2", result); + count += detectTemp(conn, "Tg0f", result); // GPU 1 + count += detectTemp(conn, "Tg0j", result); // GPU 2 break; case FF_TEMP_BATTERY: - detectTemp(conn, "TB1T", "Battery", result); + count += detectTemp(conn, "TB1T", result); // Battery break; case FF_TEMP_MEMORY: - detectTemp(conn, "Tm02", "Memory", result); + count += detectTemp(conn, "Tm02", result); // Memory break; } + if (count == 0) + return "No temperatures detected"; + + *result /= count; + return NULL; } diff --git a/src/detection/temps/temps_apple.h b/src/detection/temps/temps_apple.h index 147c32d07..0fe4b0174 100644 --- a/src/detection/temps/temps_apple.h +++ b/src/detection/temps/temps_apple.h @@ -30,6 +30,6 @@ enum FFTempType FF_TEMP_MEMORY, }; -const char *ffDetectCoreTemps(enum FFTempType type, FFlist *result); +const char *ffDetectCoreTemps(enum FFTempType type, double* result); #endif From 2c71568448c9c064663be715875a32e2c0d4610d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 10:32:16 +0800 Subject: [PATCH 431/493] Weather: document `--weather-location` --- src/data/config_user.txt | 2 +- src/data/help.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 594b3e99d..de8973418 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -222,7 +222,7 @@ #--publicip-timeout 0 # Weather location option: -# Sets location to be used. It must be URI encoded. +# Sets the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`). # Default is empty (guessing by public IP) #--weather-location "Location" diff --git a/src/data/help.txt b/src/data/help.txt index f56ea5d5c..2d6ef4dd4 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -141,6 +141,7 @@ Module specific options: --localip-compact : Show all IPs in one line. Default is false --publicip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0) --publicip-url: The URL of public IP detection server to be used. + --weather-location: Set the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`). --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use From cc1a35e3797639a19f1e30833e6aaf139773e84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 13:30:14 +0800 Subject: [PATCH 432/493] Logo: more --- README.md | 2 +- src/logo/ascii/arch.txt | 4 ++-- src/logo/ascii/arch2.txt | 19 +++++++++++++++++++ src/logo/ascii/evolutionos.txt | 18 ++++++++++++++++++ src/logo/builtin.c | 20 ++++++++++++++++++++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 src/logo/ascii/arch2.txt create mode 100644 src/logo/ascii/evolutionos.txt diff --git a/README.md b/README.md index aa4cf591e..b2152044f 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin +Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, Arch2, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin ``` Run `fastfetch --print-logos` to print them diff --git a/src/logo/ascii/arch.txt b/src/logo/ascii/arch.txt index 933c7a200..b3d234755 100644 --- a/src/logo/ascii/arch.txt +++ b/src/logo/ascii/arch.txt @@ -1,4 +1,4 @@ -$1 -` + -` .o+` `ooo/ `+oooo: @@ -16,4 +16,4 @@ $2 .oossssso-````/ossssss+` `/ossssso+/:- -:/+osssso+- `+sso+:-` `.-/+oso: `++:. `-/+/ -.` `/ \ No newline at end of file +.` `/ diff --git a/src/logo/ascii/arch2.txt b/src/logo/ascii/arch2.txt new file mode 100644 index 000000000..5da1b5540 --- /dev/null +++ b/src/logo/ascii/arch2.txt @@ -0,0 +1,19 @@ + ▄ + ▟█▙ + ▟███▙ + ▟█████▙ + ▟███████▙ + ▂▔▀▜██████▙ + ▟██▅▂▝▜█████▙ + ▟█████████████▙ + ▟███████████████▙ + ▟█████████████████▙ + ▟███████████████████▙ +$2 ▟█████████▛▀▀▜████████▙ + ▟████████▛ ▜███████▙ + ▟█████████ ████████▙ + ▟██████████ █████▆▅▄▃▂ + ▟██████████▛ ▜█████████▙ + ▟██████▀▀▀ ▀▀██████▙ + ▟███▀▘ ▝▀███▙ +▟▛▀ ▀▜▙ diff --git a/src/logo/ascii/evolutionos.txt b/src/logo/ascii/evolutionos.txt new file mode 100644 index 000000000..7a6622d4a --- /dev/null +++ b/src/logo/ascii/evolutionos.txt @@ -0,0 +1,18 @@ + dddddddddddddddddddddddd +.dddd''''''''''''''''''''''dddd. +dd: dddddddddddddddddddd; dd: +dd: ldl:'''''''''''''''' dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: ddddddd; ddddd; dd: +dd: ldl: ''''''' ''''' dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: dd: +dd: ldl: ddddddddddddddd; dd: +dddd:.''' ''''''''''''''' dddd: + dddddddddddddddddddddddddd;;' + ''''''''''''''''''''''''' diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 5b097f3c6..f71a801dd 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -252,6 +252,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_CYAN, }, + // Arch2 + { + .names = {"arch2", "archlinux2", "arch-linux2"}, + .lines = FASTFETCH_DATATEXT_LOGO_ARCH2, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_CYAN, + }, // ArchSmall { .names = {"arch_small", "archlinux_small", "arch-linux-small"}, @@ -1174,6 +1185,15 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // EvolutionOS + { + .names = {"EvolutionOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_EVOLUTIONOS, + .colors = { + FF_COLOR_FG_LIGHT_BLUE, + FF_COLOR_FG_WHITE, + }, + }, // Exherbo { .names = {"exherbo", "exherbo-linux"}, From 6071c1b09da7b76c7c059320763f7de22f94d224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 14:15:11 +0800 Subject: [PATCH 433/493] JsonConfig: support generate default config file with `--gen-config` --- CMakeLists.txt | 1 + README.md | 6 +++++- src/data/config_user.jsonc | 43 +++++++++++++++++++++++++++++++++++++ src/data/help.txt | 30 +++++++++++++------------- src/fastfetch.c | 25 ++++++++++++++++----- src/fastfetch_datatext.h.in | 1 + 6 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 src/data/config_user.jsonc diff --git a/CMakeLists.txt b/CMakeLists.txt index bc31ea211..882997f14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,7 @@ endfunction(fastfetch_load_text) fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE) fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM) fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER) +fastfetch_load_text(src/data/config_user.jsonc DATATEXT_CONFIG_USER_JSONC) fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES) fastfetch_load_text(src/data/help.txt DATATEXT_HELP) fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR) diff --git a/README.md b/README.md index b2152044f..1c3dff53b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/ With customization and speed being two competing goals, this project actually builds two executables: -* The main one is `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent by modifying `$XDG_CONFIG_HOME/fastfetch/config.conf`. To view the available options, run `fastfetch --help`. +* The main one is `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent by modifying `$XDG_CONFIG_HOME/fastfetch/config.conf`. Use `fastfetch --gen-config conf` to generate one. To view the available options, run `fastfetch --help`. * The second executable is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). Currently, the performance difference is measurable, but too small to be recognizable by humans. But with more options planned, the leap will get bigger over time and on slow machines this might actually make a difference. @@ -27,6 +27,10 @@ There are some premade config files in [`presets`](presets), including the ones Logos can be heavily customized too; see the [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for more information. +### Customization with new JSONC format + +A new, structure based, and user-friendly config file format was introduced in v2.0.0. This format is based on [JSONC](https://jsonc.org/). [See more details in Wiki](https://github.com/fastfetch-cli/fastfetch/wiki/Configuration) + ## Dependencies Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most Linux distributions. diff --git a/src/data/config_user.jsonc b/src/data/config_user.jsonc new file mode 100644 index 000000000..2e3bbb36f --- /dev/null +++ b/src/data/config_user.jsonc @@ -0,0 +1,43 @@ +// ~/.config/fastfetch/config.jsonc +// See https://github.com/fastfetch-cli/fastfetch/wiki/Configuration for more details +// See *.jsonc in https://github.com/fastfetch-cli/fastfetch/tree/dev/presets/examples for more examples +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "padding": { + "top": 2 + } + }, + "display": { + "percentType": 9 // colored percent number + }, + "modules": [ + "title", + "separator", + "os", + "host", + "kernel", + "uptime", + "packages", + "shell", + "display", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "terminal", + "terminalfont", + "cpu", + "gpu", + "memory", + "disk", + "battery", + "poweradapter", + "locale", + "break", + "colors" + ] +} diff --git a/src/data/help.txt b/src/data/help.txt index 2d6ef4dd4..95a74429c 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -1,21 +1,21 @@ Usage: fastfetch Informative options: - -h,--help: Show this message - -h,--help : Show help for a specific command - -v,--version: Show the version of fastfetch - --list-config-paths: List search paths of config files - --list-data-paths: List search paths of presets and logos - --list-logos: List available logos - --list-modules: List available modules - --list-presets: List presets fastfetch knows about; they can be loaded with --load-config (+) - --list-features: List the supported features fastfetch was compiled with (mainly for development) - --print-logos: Print available logos - --print-config-system: Print the default system config - --print-config-user: Print the default user config - --print-structure: Print the default structure - --gen-config: Generate a sample config file in the default path - --gen-config-force: Generate a sample config file in the default path. Overwrite the existing one + -h,--help: Show this message + -h,--help : Show help for a specific command + -v,--version: Show the version of fastfetch + --list-config-paths: List search paths of config files + --list-data-paths: List search paths of presets and logos + --list-logos: List available logos + --list-modules: List available modules + --list-presets: List presets fastfetch knows about; they can be loaded with --load-config (+) + --list-features: List the supported features fastfetch was compiled with (mainly for development) + --print-logos: Print available logos + --print-config-system: Print the default system config + --print-config-user: Print the default user config + --print-structure: Print the default structure + --gen-config : Generate a sample config file in the default path. Param `type` can be `jsonc` or `conf` + --gen-config-force : Generate a sample config file in the default path. Overwrite the existing one General options: --load-config : Load a config file or preset (+) diff --git a/src/fastfetch.c b/src/fastfetch.c index f12ffe0ca..2e7faf24b 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -619,11 +619,23 @@ static bool parseConfigFile(FFdata* data, const char* path) return true; } -static void generateConfigFile(bool force) +static void generateConfigFile(bool force, const char* type) { FFstrbuf* filename = (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0); // Paths generated in `init.c/initConfigDirs` end with `/` - ffStrbufAppendS(filename, "fastfetch/config.conf"); + bool isJsonc = false; + if (type) + { + if (ffStrEqualsIgnCase(type, "jsonc")) + isJsonc = true; + else if (!ffStrEqualsIgnCase(type, "conf")) + { + fputs("config type can only be `jsonc` or `conf`\n", stderr); + exit(1); + } + } + + ffStrbufAppendS(filename, isJsonc ? "fastfetch/config.jsonc" : "fastfetch/config.conf"); if (!force && ffPathExists(filename->chars, FF_PATHTYPE_FILE)) { @@ -632,7 +644,10 @@ static void generateConfigFile(bool force) } else { - ffWriteFileData(filename->chars, sizeof(FASTFETCH_DATATEXT_CONFIG_USER), FASTFETCH_DATATEXT_CONFIG_USER); + ffWriteFileData( + filename->chars, + isJsonc ? strlen(FASTFETCH_DATATEXT_CONFIG_USER_JSONC) : strlen(FASTFETCH_DATATEXT_CONFIG_USER), + isJsonc ? FASTFETCH_DATATEXT_CONFIG_USER_JSONC : FASTFETCH_DATATEXT_CONFIG_USER); printf("A sample config file has been written in `%s`\n", filename->chars); exit(0); } @@ -843,9 +858,9 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffStrEqualsIgnCase(key, "--load-config")) optionParseConfigFile(data, key, value); else if(ffStrEqualsIgnCase(key, "--gen-config")) - generateConfigFile(false); + generateConfigFile(false, value); else if(ffStrEqualsIgnCase(key, "--gen-config-force")) - generateConfigFile(true); + generateConfigFile(true, value); else if(ffStrEqualsIgnCase(key, "--thread") || ffStrEqualsIgnCase(key, "--multithreading")) instance.config.multithreading = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--stat")) diff --git a/src/fastfetch_datatext.h.in b/src/fastfetch_datatext.h.in index dd5418f3a..f8a699427 100644 --- a/src/fastfetch_datatext.h.in +++ b/src/fastfetch_datatext.h.in @@ -6,6 +6,7 @@ #define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@" #define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" #define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set +#define FASTFETCH_DATATEXT_CONFIG_USER_JSONC "@DATATEXT_CONFIG_USER_JSONC@" #define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@" #define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@" #define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@" From cebc5cd77a76e7b1afb263c368ba5fb57932de30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 7 Aug 2023 08:40:51 +0000 Subject: [PATCH 434/493] Wifi (Linux): support signal quality detection with ioctl Also don't show 802.11 as protocol --- src/detection/wifi/wifi_linux.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index f15d0932f..9a75d587e 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -249,7 +249,7 @@ static const char* detectWifiWithIoctls(FFlist* result) if(!ffAppendFileBuffer(path.chars, &item->inf.status) || !ffStrbufEqualS(&item->inf.status, "up")) continue; - int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + FF_AUTO_CLOSE_FD int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if(sock < 0) continue; @@ -262,7 +262,7 @@ static const char* detectWifiWithIoctls(FFlist* result) if(ioctl(sock, SIOCGIWESSID, &iwr) >= 0) ffStrbufRecalculateLength(&item->conn.ssid); - if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0) + if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0 && !ffStrEqualsIgnCase(iwr.u.name, "IEEE 802.11")) { if(ffStrStartsWithIgnCase(iwr.u.name, "IEEE ")) ffStrbufSetS(&item->conn.protocol, iwr.u.name + strlen("IEEE ")); @@ -277,9 +277,16 @@ static const char* detectWifiWithIoctls(FFlist* result) ffStrbufTrimRight(&item->conn.macAddress, '-'); } - //FIXME: doesn't work - if(ioctl(sock, SIOCGIWSPY, &iwr) >= 0) - item->conn.signalQuality = iwr.u.qual.level; + struct iw_statistics stats; + iwr.u.data.pointer = &stats; + iwr.u.data.length = sizeof(stats); + iwr.u.data.flags = 0; + + if(ioctl(sock, SIOCGIWSTATS, &iwr) >= 0) + { + int8_t level = (int8_t) stats.qual.level; // https://stackoverflow.com/questions/18079771/wireless-h-how-do-i-print-out-the-signal-level + item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2; + } //FIXME: doesn't work struct iw_encode_ext iwe; @@ -311,8 +318,6 @@ static const char* detectWifiWithIoctls(FFlist* result) break; } } - - close(sock); } if_freenameindex(infs); From e7f05258fbcdfa18e727fa51303d53f119574be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 08:58:13 +0800 Subject: [PATCH 435/493] Logo: add Ubuntu Unity --- README.md | 2 +- src/logo/ascii/ubuntu_unity.txt | 25 +++++++++++++++++++++++++ src/logo/builtin.c | 9 +++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/logo/ascii/ubuntu_unity.txt diff --git a/README.md b/README.md index 1c3dff53b..4e9dce9d5 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, Arch2, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin +Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, Arch2, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin ``` Run `fastfetch --print-logos` to print them diff --git a/src/logo/ascii/ubuntu_unity.txt b/src/logo/ascii/ubuntu_unity.txt new file mode 100644 index 000000000..2de1ead72 --- /dev/null +++ b/src/logo/ascii/ubuntu_unity.txt @@ -0,0 +1,25 @@ + .-/+ooosssssssooo+\-. + ,:+sssssssssssssssssssss+:. + -+ssssssssssssssssssss${c2}.....${c1}ssss+- + .ssssss${c2},${c1}ss${c2}:cloooooo:${c1}ss${c2}.:loooo.${c1}ssssss. + .ssssssss${c2}loo${c1}ss${c2}oooooooc${c1}ss${c2}.ooooooooo${c1}ssssss. + .ssssss${c2}.;looooool:,''.${c1}ss${c2}:ooooooooooc${c1}ssssss. + +ssssss${c2};loooool;.${c1}ssssssssss${c2}ooooooooo${c1}ssssssss+ + /ssssss${c2};clool'${c1}sssssssssssssss${c2}ooooooc${c1}ssss${c2},,${c1}sssss. +.sssssssssssssssssssssssssssssssssssss${c2}.:oo,${c1}sssss. +.sssss${c2}.;clol:,.${c1}ssssssssssssssssssssss${c2}.loooo'${c1}ssss. ++ssss${c2}:ooooooooo,${c1}ssssssssssssssssssssss${c2}'ooool${c1}ssss+ +osss${c2}'ooooooooooo.${c1}ssssssssssssssssssssss${c2}loooo.${c1}ssso +osss${c2}'ooooooooool${c1}sssssssssssssssssssssss${c2}co${c1}ssssssso +ossss${c2},looooooc.${c1}sssssssssssssssssssssss${c2}.loooo.${c1}ssso ++ssssss${c2}.,;;;'.${c1}ssssssssssssssssssssssss${c2};ooooc${c1}ssss+ +.ssssssssssssssssssssssssssssssssssss${c2},ooool.${c1}ssss. +.sssssss${c2}.cooooc.${c1}sssssssssssss${c2}.,,,,.${c1}ss${c2}.cooo.${c1}sssss. + `sssssss${c2}ooooo:.${c1}ssssssssssss${c2}oooooooc.${c1}ss${c2}:l.${c1}sssss' + +ssssss${c2}.coooooc,..${c1}sssssss${c2}cooooooooo.${c1}ssssssss+ + `sssssss${c2}.:oo${c1}s${c2}ooooolc:.${c1}s${c2}.ooooooooooo'${c1}ssssss' + .sssssss${c2}.o${c1}ss${c2}`:loooo;${c1}sss${c2},ooooooooc${c1}sssssss. + `sssssssss${c2};oooo';:c'${c1}ssss${c2}`:ooo:'${c1}sssssss' + -+sssssssssssssssssssssssssssssss+- + `:+sssssssssssssssssssssss+:' + `-\+ooosssssssooo+/-' diff --git a/src/logo/builtin.c b/src/logo/builtin.c index f71a801dd..bf10b8a6b 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -3578,6 +3578,15 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // UbuntuUnity + { + .names = {"ubuntu unity", "ubuntu-unity"}, + .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_UNITY, + .colors = { + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_WHITE, + }, + }, // Ubuntu2Small { .names = {"ubuntu2_small", "ubuntu2-small"}, From 4bef1274c857c74fca1cbb1dd9a3022c3ce4ef3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 15:37:14 +0800 Subject: [PATCH 436/493] Logo: add Panwah --- src/logo/ascii/panwah.txt | 21 +++++++++++++++++++++ src/logo/builtin.c | 10 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/logo/ascii/panwah.txt diff --git a/src/logo/ascii/panwah.txt b/src/logo/ascii/panwah.txt new file mode 100644 index 000000000..dc33feae7 --- /dev/null +++ b/src/logo/ascii/panwah.txt @@ -0,0 +1,21 @@ + HHH + HAAAH HHH + HAAAAH HAAAH + HAAAAAAH HAAAAH + HAAAAAAH HAAAAAH + HAAAAAAAAH${c2}WWWWWWWWWWWWWWWW ${c1}HAAAAAH + HAAAAAAAAH${c2}WWWWWWWWWWWWWWWWWWWW${c1} HAAAAAH + HAA${c2}WWWWWWWWWWWWWWWWWWWWWWWWWWWWW${c1}AAAAAH${c2} + WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW${c1}WAH${c2} + WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW + WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW + WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW +WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW +WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW +WWWWWWW${c1}AAA${c2}WWWW WWWWWWWWWWWWWWWWWWWWWWWWWWW + WWWW${c1}AAA${c2}WWWWW WWWWWWW WWWWWWWWWWWWWWW + WW${c1}AAA${c2}WWWWWWWWWWWWWWWWW WWWWW${c1}AAA${c2}WWWWWWWW + ${c1}AAA${c2}WWWWW${c1}OOOOOOOOOOO${c2}WWWWWWWWWWW${c1}AAA${c2}WWWWWW + ${c1}OOOO${c3}GGGGGGG${c1}OOOO${c2}WWWWWWWWWW${c1}AAA${c2}WWWW + ${c1}OOO${c3}GGGGGGG${c1}OOO${c2}WWWWWWWWWWWW${c1}AAA${c2}W + ${c1}OOOOOOOOO diff --git a/src/logo/builtin.c b/src/logo/builtin.c index bf10b8a6b..70f63db5c 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2660,6 +2660,16 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // Panwah + { + .names = {"Panwah"}, + .lines = FASTFETCH_DATATEXT_LOGO_PANWAH, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLACK, + }, + }, // Parabola { .names = {"parabola", "parabola-gnulinux"}, From 38044acf753352947fa668fd41d4d27d5c2162fa Mon Sep 17 00:00:00 2001 From: shivanandvp Date: Tue, 8 Aug 2023 05:02:35 -0500 Subject: [PATCH 437/493] Logo(Builtin): Fix `RebornOS` --- src/logo/ascii/reborn.txt | 40 ++++++++++++++++----------------- src/logo/ascii/reborn_small.txt | 18 ++++++--------- src/logo/builtin.c | 1 + 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/logo/ascii/reborn.txt b/src/logo/ascii/reborn.txt index 8aaaf0de2..255deba84 100644 --- a/src/logo/ascii/reborn.txt +++ b/src/logo/ascii/reborn.txt @@ -1,20 +1,20 @@ - ::::::::::::::::::::::: - .:^!!!!!!!!!^.^!!!!!!!!!^:. - .:~!!!!!!!!!!^.^!!!!!!!!!!~:. - .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:. - .^!!!!!~::$2=====:.:=====$1::~!!!!!^. - .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::. - .:~~^:::^.$2^77777!!^.^7!77777^$1.^:::^~~:. - .:~!!!!~::::$2^~!!::^^^^^::!!~^$1::::~!!!!~:. - .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^. -.:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:. -.:^!!!!!~:$2^77777~.~JJJJJJJJJ~.~77777^$1:~!!!!!^:. - .^!!!!!~::$2!7!~^:.^?JJJJJ?^.:^~!7!$1::~!!!!!^. - .:~!!!!~::$2::^~!!::^^^^^::!!~^::$1::~!!!!~:. - .:~~^:::^.$2^77777!!^.^7!77777^.$1^:::^~~:. - .::^~~!!~:$2^77777?~.~?77777^$1:~!!~~^::. - .^!!!!!~::$2=====:.:=====$1::~!!!!!^. - .:~!!!!!~~~~~~^.^~~~~~~!!!!!~:. - .:~!!!!!!!!!!^.^!!!!!!!!!!~:. - .:^!!!!!!!!!^.^!!!!!!!!!^:. - ::::::::::::::::::::::: + $1.======================. + $1.#$2#*********$1%%$2*********#$1%: + $1:%$2#**********$1%%$2**********#$1%- + $1-%$2************$1%%$2************$1%= + $1+%$2******$1%%#####$1%%#####%%$2******$1%+ + $1*%%#$2****$1%#$3+=====$1%%$3=====+$1#%$2****$1#%%* + $1*%$2*#$1#%%#%#$3====+++$1%%$3+++====$1#%#%%#$2#*$1##. + $1.##$2*****$1#%%%#$3*++$1%######%$3*+*$1#%%%#$2*****$1#%. + $1:%#$2*****$1#%$3*=+*$1#%%$3*++++++*$1%%#$3*+=*$1%#$2*****$1#%: +$1-%#$2*****$1#%$3+====*$1%$3*++++++++*$1%#$3====+$1%#$2******$1%- +$1-%#$2*****$1#%$3+====*$1%$3*++++++++*$1%#$3====+$1%#$2******$1%= + $1:%#$2*****$1#%$3*=+*$1#%%$3*++++++*$1%%#$3*+=*$1%#$2*****$1#%- + $1.##$2*****$1#%%%#$3*+*$1%######%$3*+*$1#%%%#$2*****$1#%: + $1.##$2**$1#%%#%#$3====+++$1%%$3+++====$1#%#%%#$2#*$1##. + $1*%%#$2****$1%#$3+=====$1%%$3=====+$1#%$2****$1#%%* + $1+%$2******$1%%#####%%#####%%$2******$1%* + $1-%$2************$1%%$2************$1%= + $1:%$2#**********$1%%$2**********#$1%- + $1:%$2#*********$1%%$2*********#$1%: + $1.======================. \ No newline at end of file diff --git a/src/logo/ascii/reborn_small.txt b/src/logo/ascii/reborn_small.txt index a5f6980bc..dbb028872 100644 --- a/src/logo/ascii/reborn_small.txt +++ b/src/logo/ascii/reborn_small.txt @@ -1,11 +1,7 @@ - _______________ - / \ / \ - / \_______/ \ - / / \ / \ \ - / / \___/ \ \ -/____/____/ \____\____\ -\ \ \___/ / / - \ \ / \ / / - \ \/_______\/ / - \ / \ / - \_/___________\_/ + _______ + /\_____/\ + / /\___/\ \ +/_/_/ \_\_\ +\ \ \___/ / / + \ \/___\/ / + \/_____\/ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 70f63db5c..84a2d5934 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2985,6 +2985,7 @@ const FFlogo ffLogoBuiltins[] = { .names = {"Reborn", "Reborn OS", "reborn-os", "rebornos", "rebornos-linux", "reborn-os-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_REBORN, .colors = { + FF_COLOR_FG_BLACK, FF_COLOR_FG_BLUE, FF_COLOR_FG_CYAN, }, From a58db92ab874f210484e5455b158ef9324e9a223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 19:39:05 +0800 Subject: [PATCH 438/493] NativeResolution: init code --- CMakeLists.txt | 6 + src/common/jsonconfig.c | 6 + .../nativeresolution/nativeresolution.h | 10 ++ .../nativeresolution_nosupport.c | 6 + src/fastfetch.c | 3 + src/fastfetch.h | 1 + src/modules/modules.h | 1 + .../nativeresolution/nativeresolution.c | 106 ++++++++++++++++++ .../nativeresolution/nativeresolution.h | 11 ++ src/modules/nativeresolution/option.h | 11 ++ src/modules/options.h | 1 + 11 files changed, 162 insertions(+) create mode 100644 src/detection/nativeresolution/nativeresolution.h create mode 100644 src/detection/nativeresolution/nativeresolution_nosupport.c create mode 100644 src/modules/nativeresolution/nativeresolution.c create mode 100644 src/modules/nativeresolution/nativeresolution.h create mode 100644 src/modules/nativeresolution/option.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 882997f14..1792122dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,6 +328,7 @@ set(LIBFASTFETCH_SRC src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c + src/modules/nativeresolution/nativeresolution.c src/modules/opencl/opencl.c src/modules/opengl/opengl.c src/modules/os/os.c @@ -393,6 +394,7 @@ if(LINUX) src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c src/detection/memory/memory_linux.c + src/detection/nativeresolution/nativeresolution_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -438,6 +440,7 @@ elseif(ANDROID) src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_nosupport.c src/detection/memory/memory_linux.c + src/detection/nativeresolution/nativeresolution_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_android.c src/detection/packages/packages_linux.c @@ -489,6 +492,7 @@ elseif(BSD) src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c src/detection/memory/memory_bsd.c + src/detection/nativeresolution/nativeresolution_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -536,6 +540,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c + src/detection/nativeresolution/nativeresolution_nosupport.c src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c @@ -582,6 +587,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c + src/detection/nativeresolution/nativeresolution_nosupport.c src/detection/opengl/opengl_windows.c src/detection/os/os_windows.cpp src/detection/packages/packages_windows.c diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 9e7f1e481..55ba7d6e0 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -157,6 +157,12 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) false; } + case 'N': { + return + tryModule(type, module, FF_NATIVERESOLUTION_MODULE_NAME, ffParseNativeResolutionJsonObject) || + false; + } + case 'O': { return tryModule(type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) || diff --git a/src/detection/nativeresolution/nativeresolution.h b/src/detection/nativeresolution/nativeresolution.h new file mode 100644 index 000000000..aa07971c1 --- /dev/null +++ b/src/detection/nativeresolution/nativeresolution.h @@ -0,0 +1,10 @@ +#include "fastfetch.h" + +typedef struct FFNativeResolutionResult +{ + FFstrbuf name; + uint32_t width; + uint32_t height; +} FFNativeResolutionResult; + +const char* ffDetectNativeResolution(FFlist* results); diff --git a/src/detection/nativeresolution/nativeresolution_nosupport.c b/src/detection/nativeresolution/nativeresolution_nosupport.c new file mode 100644 index 000000000..6731a0dde --- /dev/null +++ b/src/detection/nativeresolution/nativeresolution_nosupport.c @@ -0,0 +1,6 @@ +#include "nativeresolution.h" + +const char* ffDetectNativeResolution(FF_MAYBE_UNUSED FFlist* results) +{ + return "Not supported on this platform"; +} diff --git a/src/fastfetch.c b/src/fastfetch.c index 2e7faf24b..6f451ab84 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1018,6 +1018,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {} else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {} + else if(ffParseNativeResolutionCommandOptions(&instance.config.nativeResolution, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {} @@ -1251,6 +1252,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues) ffPrintPlayer(&instance.config.player); else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) ffPrintMedia(&instance.config.media); + else if(ffStrEqualsIgnCase(line, FF_NATIVERESOLUTION_MODULE_NAME)) + ffPrintNativeResolution(&instance.config.nativeResolution); else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) ffPrintDateTime(&instance.config.dateTime); else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index b261654ee..09501bd5f 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -110,6 +110,7 @@ typedef struct FFconfig FFWeatherOptions weather; FFPlayerOptions player; FFMediaOptions media; + FFNativeResolutionOptions nativeResolution; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; FFOpenGLOptions openGL; diff --git a/src/modules/modules.h b/src/modules/modules.h index f2a6f6799..70521efd0 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -30,6 +30,7 @@ #include "modules/localip/localip.h" #include "modules/media/media.h" #include "modules/memory/memory.h" +#include "modules/nativeresolution/nativeresolution.h" #include "modules/opengl/opengl.h" #include "modules/opencl/opencl.h" #include "modules/os/os.h" diff --git a/src/modules/nativeresolution/nativeresolution.c b/src/modules/nativeresolution/nativeresolution.c new file mode 100644 index 000000000..bbdc25ab7 --- /dev/null +++ b/src/modules/nativeresolution/nativeresolution.c @@ -0,0 +1,106 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/nativeresolution/nativeresolution.h" +#include "modules/nativeresolution/nativeresolution.h" +#include "util/stringUtils.h" + +#define FF_NATIVERESOLUTION_DISPLAY_NAME "Native Resolution" +#define FF_NATIVERESOLUTION_NUM_FORMAT_ARGS 3 + +void ffPrintNativeResolution(FFNativeResolutionOptions* options) +{ + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFNativeResolutionResult)); + + const char* error = ffDetectNativeResolution(&result); + + if(error) + { + ffPrintError(FF_NATIVERESOLUTION_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(!result.length) + { + ffPrintError(FF_NATIVERESOLUTION_DISPLAY_NAME, 0, &options->moduleArgs, "No devices detected"); + return; + } + + uint8_t index = 0; + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + FF_LIST_FOR_EACH(FFNativeResolutionResult, display, result) + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_NATIVERESOLUTION_DISPLAY_NAME, display->name.chars); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + }); + } + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + + printf("%ux%u", display->width, display->height); + } + else + { + ffPrintFormat(FF_NATIVERESOLUTION_DISPLAY_NAME, index, &options->moduleArgs, FF_NATIVERESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + {FF_FORMAT_ARG_TYPE_UINT, &display->width}, + {FF_FORMAT_ARG_TYPE_UINT, &display->height}, + }); + } + + ffStrbufDestroy(&display->name); + } +} + +void ffInitNativeResolutionOptions(FFNativeResolutionOptions* options) +{ + options->moduleName = FF_NATIVERESOLUTION_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParseNativeResolutionCommandOptions(FFNativeResolutionOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_NATIVERESOLUTION_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyNativeResolutionOptions(FFNativeResolutionOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParseNativeResolutionJsonObject(yyjson_val* module) +{ + FFNativeResolutionOptions __attribute__((__cleanup__(ffDestroyNativeResolutionOptions))) options; + ffInitNativeResolutionOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(FF_NATIVERESOLUTION_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintNativeResolution(&options); +} diff --git a/src/modules/nativeresolution/nativeresolution.h b/src/modules/nativeresolution/nativeresolution.h new file mode 100644 index 000000000..e7d065394 --- /dev/null +++ b/src/modules/nativeresolution/nativeresolution.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_NATIVERESOLUTION_MODULE_NAME "NativeResolution" + +void ffPrintNativeResolution(FFNativeResolutionOptions* options); +void ffInitNativeResolutionOptions(FFNativeResolutionOptions* options); +bool ffParseNativeResolutionCommandOptions(FFNativeResolutionOptions* options, const char* key, const char* value); +void ffDestroyNativeResolutionOptions(FFNativeResolutionOptions* options); +void ffParseNativeResolutionJsonObject(yyjson_val* module); diff --git a/src/modules/nativeresolution/option.h b/src/modules/nativeresolution/option.h new file mode 100644 index 000000000..7c5f6fdd7 --- /dev/null +++ b/src/modules/nativeresolution/option.h @@ -0,0 +1,11 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" + +typedef struct FFNativeResolutionOptions +{ + const char* moduleName; + FFModuleArgs moduleArgs; +} FFNativeResolutionOptions; diff --git a/src/modules/options.h b/src/modules/options.h index 7d9c0668d..c93103387 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,6 +29,7 @@ #include "modules/localip/option.h" #include "modules/media/option.h" #include "modules/memory/option.h" +#include "modules/nativeresolution/option.h" #include "modules/opengl/option.h" #include "modules/opencl/option.h" #include "modules/os/option.h" From c28ced9dcb3b55cb8a4b8432752a52fe6398f135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 20:23:26 +0800 Subject: [PATCH 439/493] NativeResolution (Linux): add support --- CMakeLists.txt | 3 +- .../nativeresolution/nativeresolution_linux.c | 60 +++++++++++++++++++ src/util/edidHelper.c | 8 +++ src/util/edidHelper.h | 10 ++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/detection/nativeresolution/nativeresolution_linux.c create mode 100644 src/util/edidHelper.c create mode 100644 src/util/edidHelper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1792122dc..4dc60b91e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,6 +356,7 @@ set(LIBFASTFETCH_SRC src/modules/wifi/wifi.c src/modules/wm/wm.c src/modules/wmtheme/wmtheme.c + src/util/edidHelper.c src/util/FFlist.c src/util/FFstrbuf.c src/util/platform/FFPlatform.c @@ -394,7 +395,7 @@ if(LINUX) src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c src/detection/memory/memory_linux.c - src/detection/nativeresolution/nativeresolution_nosupport.c + src/detection/nativeresolution/nativeresolution_linux.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c diff --git a/src/detection/nativeresolution/nativeresolution_linux.c b/src/detection/nativeresolution/nativeresolution_linux.c new file mode 100644 index 000000000..bb7e5a5e1 --- /dev/null +++ b/src/detection/nativeresolution/nativeresolution_linux.c @@ -0,0 +1,60 @@ +#include "nativeresolution.h" + +#include "common/io/io.h" +#include "util/edidHelper.h" +#include "util/stringUtils.h" + +#include + +const char* ffDetectNativeResolution(FFlist* results) +{ + const char* drmDirPath = "/sys/class/drm/"; + + DIR* dirp = opendir(drmDirPath); + if(dirp == NULL) + return "opendir(drmDirPath) == NULL"; + + FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64); + ffStrbufAppendS(&drmDir, drmDirPath); + + uint32_t drmDirLength = drmDir.length; + + struct dirent* entry; + while((entry = readdir(dirp)) != NULL) + { + if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) + continue; + + ffStrbufAppendS(&drmDir, entry->d_name); + ffStrbufAppendS(&drmDir, "/edid"); + + uint8_t edidData[128]; + if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData)) + { + ffStrbufSubstrBefore(&drmDir, drmDirLength); + continue; + } + + uint32_t width, height; + ffEdidGetNativeResolution(edidData, &width, &height); + if (width != 0 && height != 0) + { + const char* plainName = entry->d_name; + if (ffStrStartsWith(plainName, "card")) + { + const char* tmp = strchr(plainName + strlen("card"), '-'); + if (tmp) plainName = tmp + 1; + } + + FFNativeResolutionResult* display = (FFNativeResolutionResult*) ffListAdd(results); + display->width = width; + display->height = height; + ffStrbufInitS(&display->name, plainName); + } + + ffStrbufSubstrBefore(&drmDir, drmDirLength); + } + + closedir(dirp); + return NULL; +} diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c new file mode 100644 index 000000000..fa765d55f --- /dev/null +++ b/src/util/edidHelper.c @@ -0,0 +1,8 @@ +#include "edidHelper.h" + +void ffEdidGetNativeResolution(uint8_t edid[128], uint32_t* width, uint32_t* height) +{ + const int dtd = 54; + *width = ((edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; + *height = ((edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; +} diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h new file mode 100644 index 000000000..8a9540860 --- /dev/null +++ b/src/util/edidHelper.h @@ -0,0 +1,10 @@ +#pragma once + +#ifndef FF_INCLUDED_EDID_HELPER_H +#define FF_INCLUDED_EDID_HELPER_H + +#include + +void ffEdidGetNativeResolution(uint8_t edid[128], uint32_t* width, uint32_t* height); + +#endif From 5c603145ab664b2a0766b89ab19fdef9fdd6c710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 23:18:41 +0800 Subject: [PATCH 440/493] Battery (Windows): tidy --- src/detection/battery/battery_windows.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index 3afbb996e..66df36cf3 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -36,16 +36,13 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = - SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); + SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if(hdev == INVALID_HANDLE_VALUE) - return "SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY) failed"; + return "SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY) failed"; - for(DWORD idev = 0;; idev++) + SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) }; + for(DWORD idev = 0; SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did); idev++) { - SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) }; - if(!SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did)) - break; - DWORD cbRequired = 0; SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired); From 7598e5770466a75972e3160e8f0413a3cfff70ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 8 Aug 2023 23:19:22 +0800 Subject: [PATCH 441/493] NativeResolution (Windows): add support --- CMakeLists.txt | 2 +- .../nativeresolution_windows.c | 48 +++++++++++++++++++ src/util/edidHelper.c | 4 +- src/util/windows/registry.c | 18 +++++++ src/util/windows/registry.h | 1 + 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 src/detection/nativeresolution/nativeresolution_windows.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dc60b91e..ad8904a8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -588,7 +588,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c - src/detection/nativeresolution/nativeresolution_nosupport.c + src/detection/nativeresolution/nativeresolution_windows.c src/detection/opengl/opengl_windows.c src/detection/os/os_windows.cpp src/detection/packages/packages_windows.c diff --git a/src/detection/nativeresolution/nativeresolution_windows.c b/src/detection/nativeresolution/nativeresolution_windows.c new file mode 100644 index 000000000..e5b9a5d16 --- /dev/null +++ b/src/detection/nativeresolution/nativeresolution_windows.c @@ -0,0 +1,48 @@ +#include "nativeresolution.h" + +#include "common/io/io.h" +#include "util/edidHelper.h" +#include "util/stringUtils.h" +#include "util/windows/registry.h" +#include "util/windows/unicode.h" + +#include +#include +#include + +static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) +{ + if(*hdev) + SetupDiDestroyDeviceInfoList(*hdev); +} + +const char* ffDetectNativeResolution(FFlist* results) +{ + //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices + HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = + SetupDiGetClassDevsW(&GUID_DEVCLASS_MONITOR, 0, 0, DIGCF_PRESENT); + if(hdev == INVALID_HANDLE_VALUE) + return "SetupDiGetClassDevsW(&GUID_DEVCLASS_MONITOR) failed"; + + SP_DEVINFO_DATA did = { .cbSize = sizeof(did) }; + for (DWORD idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); ++idev) + { + FF_HKEY_AUTO_DESTROY hKey = SetupDiOpenDevRegKey(hdev, &did, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE); + if (!hKey) continue; + + uint8_t edidData[256] = {}; + if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue; + uint32_t width, height; + ffEdidGetNativeResolution(edidData, &width, &height); + if (width == 0 || height == 0) continue; + + wchar_t wName[MAX_PATH] = {}; // MONITOR\BOE09F9 + if (!SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_HARDWAREID, NULL, (BYTE*) wName, sizeof(wName), NULL)) continue; + + FFNativeResolutionResult* display = (FFNativeResolutionResult*) ffListAdd(results); + display->width = width; + display->height = height; + ffStrbufInitWS(&display->name, wcschr(wName, L'\\') + 1); + } + return NULL; +} diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index fa765d55f..bbd87cc17 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -3,6 +3,6 @@ void ffEdidGetNativeResolution(uint8_t edid[128], uint32_t* width, uint32_t* height) { const int dtd = 54; - *width = ((edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; - *height = ((edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; + *width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; + *height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; } diff --git a/src/util/windows/registry.c b/src/util/windows/registry.c index d4dbffa93..f56d59c50 100644 --- a/src/util/windows/registry.c +++ b/src/util/windows/registry.c @@ -64,6 +64,24 @@ bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFs return true; } +bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t* result, uint32_t bufSize, FFstrbuf* error) +{ + static_assert(sizeof(DWORD) == sizeof(uint32_t), ""); + LONG err = RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_BINARY, NULL, result, (DWORD*) &bufSize); + if(err != ERROR_SUCCESS) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_SZ) failed", valueNameA.chars); + } + return false; + } + return true; +} + bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error) { DWORD bufSize = sizeof(*result); diff --git a/src/util/windows/registry.h b/src/util/windows/registry.h index 222b468a7..8e582ac54 100644 --- a/src/util/windows/registry.h +++ b/src/util/windows/registry.h @@ -17,6 +17,7 @@ static inline void wrapRegCloseKey(HKEY* phKey) bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrbuf* error); bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error); +bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t* result, uint32_t bufSize, FFstrbuf* error); bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error); bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error); bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error); From 3acbe845705119e73e75c3004015d01ce820702b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 09:00:29 +0800 Subject: [PATCH 442/493] Brightness (macOS): code refactor --- src/detection/brightness/brightness_apple.c | 23 ++------------------- src/util/edidHelper.c | 22 +++++++++++++++++++- src/util/edidHelper.h | 4 +++- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index c584fc4a4..21b89d419 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -1,6 +1,7 @@ #include "brightness.h" #include "detection/displayserver/displayserver.h" #include "util/apple/cf_helpers.h" +#include "util/edidHelper.h" #include @@ -34,26 +35,6 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa return NULL; } -static void getNameFromEdid(uint8_t edid[128], FFstrbuf* name) -{ - // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c - for (uint32_t i = 0x36; i < 0x7E; i += 0x12) - { // read through descriptor blocks... - if (edid[i] == 0x00) - { // not a timing descriptor - if (edid[i+3] == 0xfc) - { // Model Name tag - for (uint32_t j = 0; j < 13; j++) - { - if (edid[i + 5 + j] == 0x0a) - return; - ffStrbufAppendC(name, (char) edid[i + 5 + j]); - } - } - } - } -} - // https://github.com/waydabber/m1ddc // Works for Apple Silicon and USB-C adapter connection ( but not HTMI ) static const char* detectWithDdcci(FFlist* result) @@ -120,7 +101,7 @@ static const char* detectWithDdcci(FFlist* result) uint8_t edid[128] = {}; if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, sizeof(edid)) == KERN_SUCCESS) - getNameFromEdid(edid, &brightness->name); + ffEdidGetName(edid, &brightness->name); } } diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index bbd87cc17..b89dfbf66 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -1,8 +1,28 @@ #include "edidHelper.h" -void ffEdidGetNativeResolution(uint8_t edid[128], uint32_t* width, uint32_t* height) +void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height) { const int dtd = 54; *width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; *height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; } + +void ffEdidGetName(uint8_t edid[128], FFstrbuf* name) +{ + // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c + for (uint32_t i = 0x36; i < 0x7E; i += 0x12) + { // read through descriptor blocks... + if (edid[i] == 0x00) + { // not a timing descriptor + if (edid[i+3] == 0xfc) + { // Model Name tag + for (uint32_t j = 0; j < 13; j++) + { + if (edid[i + 5 + j] == 0x0a) + return; + ffStrbufAppendC(name, (char) edid[i + 5 + j]); + } + } + } + } +} diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 8a9540860..3c81ffd28 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -4,7 +4,9 @@ #define FF_INCLUDED_EDID_HELPER_H #include +#include "util/FFstrbuf.h" -void ffEdidGetNativeResolution(uint8_t edid[128], uint32_t* width, uint32_t* height); +void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height); +void ffEdidGetName(uint8_t edid[128], FFstrbuf* name); #endif From bb0279bae116bcc163c96e9398aeaf14432412bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 09:03:32 +0800 Subject: [PATCH 443/493] NativeResolution: rename module to PhycialDisplay --- CMakeLists.txt | 12 +- src/common/jsonconfig.c | 2 +- .../nativeresolution/nativeresolution.h | 10 -- .../nativeresolution_nosupport.c | 6 - src/detection/phycialdisplay/phycialdisplay.h | 10 ++ .../phycialdisplay_linux.c} | 8 +- .../phycialdisplay/phycialdisplay_nosupport.c | 6 + .../phycialdisplay_windows.c} | 8 +- src/fastfetch.c | 6 +- src/fastfetch.h | 2 +- src/modules/modules.h | 2 +- .../nativeresolution/nativeresolution.c | 106 ------------------ .../nativeresolution/nativeresolution.h | 11 -- src/modules/options.h | 2 +- .../option.h | 4 +- src/modules/phycialdisplay/phycialdisplay.c | 106 ++++++++++++++++++ src/modules/phycialdisplay/phycialdisplay.h | 11 ++ 17 files changed, 156 insertions(+), 156 deletions(-) delete mode 100644 src/detection/nativeresolution/nativeresolution.h delete mode 100644 src/detection/nativeresolution/nativeresolution_nosupport.c create mode 100644 src/detection/phycialdisplay/phycialdisplay.h rename src/detection/{nativeresolution/nativeresolution_linux.c => phycialdisplay/phycialdisplay_linux.c} (85%) create mode 100644 src/detection/phycialdisplay/phycialdisplay_nosupport.c rename src/detection/{nativeresolution/nativeresolution_windows.c => phycialdisplay/phycialdisplay_windows.c} (86%) delete mode 100644 src/modules/nativeresolution/nativeresolution.c delete mode 100644 src/modules/nativeresolution/nativeresolution.h rename src/modules/{nativeresolution => phycialdisplay}/option.h (72%) create mode 100644 src/modules/phycialdisplay/phycialdisplay.c create mode 100644 src/modules/phycialdisplay/phycialdisplay.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ad8904a8a..4de34905b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,7 +328,7 @@ set(LIBFASTFETCH_SRC src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c - src/modules/nativeresolution/nativeresolution.c + src/modules/phycialdisplay/phycialdisplay.c src/modules/opencl/opencl.c src/modules/opengl/opengl.c src/modules/os/os.c @@ -395,7 +395,7 @@ if(LINUX) src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c src/detection/memory/memory_linux.c - src/detection/nativeresolution/nativeresolution_linux.c + src/detection/phycialdisplay/phycialdisplay_linux.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -441,7 +441,7 @@ elseif(ANDROID) src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_nosupport.c src/detection/memory/memory_linux.c - src/detection/nativeresolution/nativeresolution_nosupport.c + src/detection/phycialdisplay/phycialdisplay_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_android.c src/detection/packages/packages_linux.c @@ -493,7 +493,7 @@ elseif(BSD) src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c src/detection/memory/memory_bsd.c - src/detection/nativeresolution/nativeresolution_nosupport.c + src/detection/phycialdisplay/phycialdisplay_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -541,7 +541,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c - src/detection/nativeresolution/nativeresolution_nosupport.c + src/detection/phycialdisplay/phycialdisplay_nosupport.c src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c @@ -588,7 +588,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c - src/detection/nativeresolution/nativeresolution_windows.c + src/detection/phycialdisplay/phycialdisplay_windows.c src/detection/opengl/opengl_windows.c src/detection/os/os_windows.cpp src/detection/packages/packages_windows.c diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 55ba7d6e0..5494b81b3 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -159,7 +159,7 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) case 'N': { return - tryModule(type, module, FF_NATIVERESOLUTION_MODULE_NAME, ffParseNativeResolutionJsonObject) || + tryModule(type, module, FF_PHYCIALDISPLAY_MODULE_NAME, ffParsePhycialDisplayJsonObject) || false; } diff --git a/src/detection/nativeresolution/nativeresolution.h b/src/detection/nativeresolution/nativeresolution.h deleted file mode 100644 index aa07971c1..000000000 --- a/src/detection/nativeresolution/nativeresolution.h +++ /dev/null @@ -1,10 +0,0 @@ -#include "fastfetch.h" - -typedef struct FFNativeResolutionResult -{ - FFstrbuf name; - uint32_t width; - uint32_t height; -} FFNativeResolutionResult; - -const char* ffDetectNativeResolution(FFlist* results); diff --git a/src/detection/nativeresolution/nativeresolution_nosupport.c b/src/detection/nativeresolution/nativeresolution_nosupport.c deleted file mode 100644 index 6731a0dde..000000000 --- a/src/detection/nativeresolution/nativeresolution_nosupport.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "nativeresolution.h" - -const char* ffDetectNativeResolution(FF_MAYBE_UNUSED FFlist* results) -{ - return "Not supported on this platform"; -} diff --git a/src/detection/phycialdisplay/phycialdisplay.h b/src/detection/phycialdisplay/phycialdisplay.h new file mode 100644 index 000000000..faa7a7172 --- /dev/null +++ b/src/detection/phycialdisplay/phycialdisplay.h @@ -0,0 +1,10 @@ +#include "fastfetch.h" + +typedef struct FFPhycialDisplayResult +{ + FFstrbuf name; + uint32_t width; + uint32_t height; +} FFPhycialDisplayResult; + +const char* ffDetectPhycialDisplay(FFlist* results); diff --git a/src/detection/nativeresolution/nativeresolution_linux.c b/src/detection/phycialdisplay/phycialdisplay_linux.c similarity index 85% rename from src/detection/nativeresolution/nativeresolution_linux.c rename to src/detection/phycialdisplay/phycialdisplay_linux.c index bb7e5a5e1..245f9e685 100644 --- a/src/detection/nativeresolution/nativeresolution_linux.c +++ b/src/detection/phycialdisplay/phycialdisplay_linux.c @@ -1,4 +1,4 @@ -#include "nativeresolution.h" +#include "phycialdisplay.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -6,7 +6,7 @@ #include -const char* ffDetectNativeResolution(FFlist* results) +const char* ffDetectPhycialDisplay(FFlist* results) { const char* drmDirPath = "/sys/class/drm/"; @@ -36,7 +36,7 @@ const char* ffDetectNativeResolution(FFlist* results) } uint32_t width, height; - ffEdidGetNativeResolution(edidData, &width, &height); + ffEdidGetPhycialDisplay(edidData, &width, &height); if (width != 0 && height != 0) { const char* plainName = entry->d_name; @@ -46,7 +46,7 @@ const char* ffDetectNativeResolution(FFlist* results) if (tmp) plainName = tmp + 1; } - FFNativeResolutionResult* display = (FFNativeResolutionResult*) ffListAdd(results); + FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInitS(&display->name, plainName); diff --git a/src/detection/phycialdisplay/phycialdisplay_nosupport.c b/src/detection/phycialdisplay/phycialdisplay_nosupport.c new file mode 100644 index 000000000..5254f52c6 --- /dev/null +++ b/src/detection/phycialdisplay/phycialdisplay_nosupport.c @@ -0,0 +1,6 @@ +#include "phycialdisplay.h" + +const char* ffDetectPhycialDisplay(FF_MAYBE_UNUSED FFlist* results) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/nativeresolution/nativeresolution_windows.c b/src/detection/phycialdisplay/phycialdisplay_windows.c similarity index 86% rename from src/detection/nativeresolution/nativeresolution_windows.c rename to src/detection/phycialdisplay/phycialdisplay_windows.c index e5b9a5d16..ad8161ce3 100644 --- a/src/detection/nativeresolution/nativeresolution_windows.c +++ b/src/detection/phycialdisplay/phycialdisplay_windows.c @@ -1,4 +1,4 @@ -#include "nativeresolution.h" +#include "phycialdisplay.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -16,7 +16,7 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) SetupDiDestroyDeviceInfoList(*hdev); } -const char* ffDetectNativeResolution(FFlist* results) +const char* ffDetectPhycialDisplay(FFlist* results) { //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = @@ -33,13 +33,13 @@ const char* ffDetectNativeResolution(FFlist* results) uint8_t edidData[256] = {}; if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue; uint32_t width, height; - ffEdidGetNativeResolution(edidData, &width, &height); + ffEdidGetPhycialDisplay(edidData, &width, &height); if (width == 0 || height == 0) continue; wchar_t wName[MAX_PATH] = {}; // MONITOR\BOE09F9 if (!SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_HARDWAREID, NULL, (BYTE*) wName, sizeof(wName), NULL)) continue; - FFNativeResolutionResult* display = (FFNativeResolutionResult*) ffListAdd(results); + FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInitWS(&display->name, wcschr(wName, L'\\') + 1); diff --git a/src/fastfetch.c b/src/fastfetch.c index 6f451ab84..b1de0d875 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1018,7 +1018,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {} else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {} - else if(ffParseNativeResolutionCommandOptions(&instance.config.nativeResolution, key, value)) {} + else if(ffParsePhycialDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {} @@ -1252,8 +1252,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues) ffPrintPlayer(&instance.config.player); else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) ffPrintMedia(&instance.config.media); - else if(ffStrEqualsIgnCase(line, FF_NATIVERESOLUTION_MODULE_NAME)) - ffPrintNativeResolution(&instance.config.nativeResolution); + else if(ffStrEqualsIgnCase(line, FF_PHYCIALDISPLAY_MODULE_NAME)) + ffPrintPhycialDisplay(&instance.config.nativeResolution); else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) ffPrintDateTime(&instance.config.dateTime); else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index 09501bd5f..a4ffb6ff8 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -110,7 +110,7 @@ typedef struct FFconfig FFWeatherOptions weather; FFPlayerOptions player; FFMediaOptions media; - FFNativeResolutionOptions nativeResolution; + FFPhycialDisplayOptions nativeResolution; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; FFOpenGLOptions openGL; diff --git a/src/modules/modules.h b/src/modules/modules.h index 70521efd0..532679faa 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -30,7 +30,7 @@ #include "modules/localip/localip.h" #include "modules/media/media.h" #include "modules/memory/memory.h" -#include "modules/nativeresolution/nativeresolution.h" +#include "modules/phycialdisplay/phycialdisplay.h" #include "modules/opengl/opengl.h" #include "modules/opencl/opencl.h" #include "modules/os/os.h" diff --git a/src/modules/nativeresolution/nativeresolution.c b/src/modules/nativeresolution/nativeresolution.c deleted file mode 100644 index bbdc25ab7..000000000 --- a/src/modules/nativeresolution/nativeresolution.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "common/printing.h" -#include "common/jsonconfig.h" -#include "detection/nativeresolution/nativeresolution.h" -#include "modules/nativeresolution/nativeresolution.h" -#include "util/stringUtils.h" - -#define FF_NATIVERESOLUTION_DISPLAY_NAME "Native Resolution" -#define FF_NATIVERESOLUTION_NUM_FORMAT_ARGS 3 - -void ffPrintNativeResolution(FFNativeResolutionOptions* options) -{ - FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFNativeResolutionResult)); - - const char* error = ffDetectNativeResolution(&result); - - if(error) - { - ffPrintError(FF_NATIVERESOLUTION_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); - return; - } - - if(!result.length) - { - ffPrintError(FF_NATIVERESOLUTION_DISPLAY_NAME, 0, &options->moduleArgs, "No devices detected"); - return; - } - - uint8_t index = 0; - FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFNativeResolutionResult, display, result) - { - if(options->moduleArgs.outputFormat.length == 0) - { - ffStrbufClear(&key); - if(options->moduleArgs.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_NATIVERESOLUTION_DISPLAY_NAME, display->name.chars); - } - else - { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, - }); - } - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - - printf("%ux%u", display->width, display->height); - } - else - { - ffPrintFormat(FF_NATIVERESOLUTION_DISPLAY_NAME, index, &options->moduleArgs, FF_NATIVERESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, - {FF_FORMAT_ARG_TYPE_UINT, &display->width}, - {FF_FORMAT_ARG_TYPE_UINT, &display->height}, - }); - } - - ffStrbufDestroy(&display->name); - } -} - -void ffInitNativeResolutionOptions(FFNativeResolutionOptions* options) -{ - options->moduleName = FF_NATIVERESOLUTION_MODULE_NAME; - ffOptionInitModuleArg(&options->moduleArgs); -} - -bool ffParseNativeResolutionCommandOptions(FFNativeResolutionOptions* options, const char* key, const char* value) -{ - const char* subKey = ffOptionTestPrefix(key, FF_NATIVERESOLUTION_MODULE_NAME); - if (!subKey) return false; - if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) - return true; - - return false; -} - -void ffDestroyNativeResolutionOptions(FFNativeResolutionOptions* options) -{ - ffOptionDestroyModuleArg(&options->moduleArgs); -} - -void ffParseNativeResolutionJsonObject(yyjson_val* module) -{ - FFNativeResolutionOptions __attribute__((__cleanup__(ffDestroyNativeResolutionOptions))) options; - ffInitNativeResolutionOptions(&options); - - if (module) - { - yyjson_val *key_, *val; - size_t idx, max; - yyjson_obj_foreach(module, idx, max, key_, val) - { - const char* key = yyjson_get_str(key_); - if(ffStrEqualsIgnCase(key, "type")) - continue; - - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) - continue; - - ffPrintError(FF_NATIVERESOLUTION_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } - } - - ffPrintNativeResolution(&options); -} diff --git a/src/modules/nativeresolution/nativeresolution.h b/src/modules/nativeresolution/nativeresolution.h deleted file mode 100644 index e7d065394..000000000 --- a/src/modules/nativeresolution/nativeresolution.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "fastfetch.h" - -#define FF_NATIVERESOLUTION_MODULE_NAME "NativeResolution" - -void ffPrintNativeResolution(FFNativeResolutionOptions* options); -void ffInitNativeResolutionOptions(FFNativeResolutionOptions* options); -bool ffParseNativeResolutionCommandOptions(FFNativeResolutionOptions* options, const char* key, const char* value); -void ffDestroyNativeResolutionOptions(FFNativeResolutionOptions* options); -void ffParseNativeResolutionJsonObject(yyjson_val* module); diff --git a/src/modules/options.h b/src/modules/options.h index c93103387..6f33a048a 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,7 +29,7 @@ #include "modules/localip/option.h" #include "modules/media/option.h" #include "modules/memory/option.h" -#include "modules/nativeresolution/option.h" +#include "modules/phycialdisplay/option.h" #include "modules/opengl/option.h" #include "modules/opencl/option.h" #include "modules/os/option.h" diff --git a/src/modules/nativeresolution/option.h b/src/modules/phycialdisplay/option.h similarity index 72% rename from src/modules/nativeresolution/option.h rename to src/modules/phycialdisplay/option.h index 7c5f6fdd7..2f16f55a7 100644 --- a/src/modules/nativeresolution/option.h +++ b/src/modules/phycialdisplay/option.h @@ -4,8 +4,8 @@ #include "common/option.h" -typedef struct FFNativeResolutionOptions +typedef struct FFPhycialDisplayOptions { const char* moduleName; FFModuleArgs moduleArgs; -} FFNativeResolutionOptions; +} FFPhycialDisplayOptions; diff --git a/src/modules/phycialdisplay/phycialdisplay.c b/src/modules/phycialdisplay/phycialdisplay.c new file mode 100644 index 000000000..9a14c8a44 --- /dev/null +++ b/src/modules/phycialdisplay/phycialdisplay.c @@ -0,0 +1,106 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/phycialdisplay/phycialdisplay.h" +#include "modules/phycialdisplay/phycialdisplay.h" +#include "util/stringUtils.h" + +#define FF_PHYCIALDISPLAY_DISPLAY_NAME "Phycial Display" +#define FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS 3 + +void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) +{ + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhycialDisplayResult)); + + const char* error = ffDetectPhycialDisplay(&result); + + if(error) + { + ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(!result.length) + { + ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No phycial display detected"); + return; + } + + uint8_t index = 0; + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + FF_LIST_FOR_EACH(FFPhycialDisplayResult, display, result) + { + if(options->moduleArgs.outputFormat.length == 0) + { + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_PHYCIALDISPLAY_DISPLAY_NAME, display->name.chars); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + }); + } + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + + printf("%ux%u\n", display->width, display->height); + } + else + { + ffPrintFormat(FF_PHYCIALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + {FF_FORMAT_ARG_TYPE_UINT, &display->width}, + {FF_FORMAT_ARG_TYPE_UINT, &display->height}, + }); + } + + ffStrbufDestroy(&display->name); + } +} + +void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options) +{ + options->moduleName = FF_PHYCIALDISPLAY_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PHYCIALDISPLAY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParsePhycialDisplayJsonObject(yyjson_val* module) +{ + FFPhycialDisplayOptions __attribute__((__cleanup__(ffDestroyPhycialDisplayOptions))) options; + ffInitPhycialDisplayOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(FF_PHYCIALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPhycialDisplay(&options); +} diff --git a/src/modules/phycialdisplay/phycialdisplay.h b/src/modules/phycialdisplay/phycialdisplay.h new file mode 100644 index 000000000..d65876643 --- /dev/null +++ b/src/modules/phycialdisplay/phycialdisplay.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_PHYCIALDISPLAY_MODULE_NAME "PhycialDisplay" + +void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options); +void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options); +bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value); +void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options); +void ffParsePhycialDisplayJsonObject(yyjson_val* module); From 1d1ce83567c18578c8d5ce6a9f7936e68c820077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 10:11:24 +0800 Subject: [PATCH 444/493] PhycialDisplay (macOS): add support --- CMakeLists.txt | 2 +- src/detection/brightness/brightness_apple.c | 37 ++---- .../phycialdisplay/phycialdisplay_apple.c | 107 ++++++++++++++++++ src/util/apple/ddcci.h | 15 +++ src/util/edidHelper.c | 4 +- src/util/edidHelper.h | 4 +- 6 files changed, 137 insertions(+), 32 deletions(-) create mode 100644 src/detection/phycialdisplay/phycialdisplay_apple.c create mode 100644 src/util/apple/ddcci.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de34905b..496ab8572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -541,7 +541,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c - src/detection/phycialdisplay/phycialdisplay_nosupport.c + src/detection/phycialdisplay/phycialdisplay_apple.c src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 21b89d419..eaa21cdf0 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -1,20 +1,11 @@ #include "brightness.h" #include "detection/displayserver/displayserver.h" #include "util/apple/cf_helpers.h" +#include "util/apple/ddcci.h" #include "util/edidHelper.h" -#include - extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float *brightness) __attribute__((weak_import)); -// DDC/CI -typedef CFTypeRef IOAVServiceRef; -extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import)); -extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import)); -extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import)); -extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import)); -extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import)); - // Works for internal display static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) { @@ -23,12 +14,15 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) { - float value; - if(DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) + if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) { - FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); - brightness->value = value * 100; - ffStrbufInitCopy(&brightness->name, &display->name); + float value; + if(DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) + { + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + brightness->value = value * 100; + ffStrbufInitCopy(&brightness->name, &display->name); + } } } @@ -108,22 +102,11 @@ static const char* detectWithDdcci(FFlist* result) return NULL; } -static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) -{ - FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) - { - if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) - return true; - } - return false; -} - const char* ffDetectBrightness(FFlist* result) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); - if (hasBuiltinDisplay(displayServer)) - detectWithDisplayServices(displayServer, result); + detectWithDisplayServices(displayServer, result); if (instance.config.allowSlowOperations && displayServer->displays.length > result->length) detectWithDdcci(result); diff --git a/src/detection/phycialdisplay/phycialdisplay_apple.c b/src/detection/phycialdisplay/phycialdisplay_apple.c new file mode 100644 index 000000000..e611a28b6 --- /dev/null +++ b/src/detection/phycialdisplay/phycialdisplay_apple.c @@ -0,0 +1,107 @@ +#include "phycialdisplay.h" +#include "detection/displayserver/displayserver.h" +#include "util/apple/cf_helpers.h" +#include "util/apple/ddcci.h" +#include "util/edidHelper.h" + +extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); + +static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* results) +{ + if(!CoreDisplay_DisplayCreateInfoDictionary) return "CoreDisplay_DisplayCreateInfoDictionary is not available"; + + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) + { + if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) + { + CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary((CGDirectDisplayID) display->id); + if(displayInfo) + { + int width, height; + if (ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelWidth"), &width) || + ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelHeight"), &height) || + width <= 0 || height <= 0) + continue; + + FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); + display->width = (uint32_t) width; + display->height = (uint32_t) height; + ffStrbufInit(&display->name); + + CFDictionaryRef productNames; + if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) + ffCfDictGetString(productNames, CFSTR("en_US"), &display->name); + } + } + } + return NULL; +} + +static const char* detectWithDdcci(FFlist* results) +{ + if (!IOAVServiceCreate || !IOAVServiceReadI2C) + return "IOAVService is not available"; + + CFMutableDictionaryRef matchDict = IOServiceMatching("DCPAVServiceProxy"); + if (matchDict == NULL) + return "IOServiceMatching(\"DCPAVServiceProxy\") failed"; + + io_iterator_t iterator; + if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess) + return "IOServiceGetMatchingServices() failed"; + + FF_STRBUF_AUTO_DESTROY location = ffStrbufCreate(); + + io_registry_entry_t registryEntry; + while((registryEntry = IOIteratorNext(iterator)) != 0) + { + CFMutableDictionaryRef properties; + if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) + { + IOObjectRelease(registryEntry); + continue; + } + + ffStrbufClear(&location); + if(ffCfDictGetString(properties, CFSTR("Location"), &location) || ffStrbufEqualS(&location, "Embedded")) + { + // Builtin display should be handled by DisplayServices + IOObjectRelease(registryEntry); + continue; + } + + FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreateWithService(kCFAllocatorDefault, (io_service_t) registryEntry); + IOObjectRelease(registryEntry); + + if (!service) continue; + + FF_CFTYPE_AUTO_RELEASE CFDataRef edid = NULL; + if (IOAVServiceCopyEDID(service, &edid) != KERN_SUCCESS ) + continue; + + if (CFDataGetLength(edid) < 128) + continue; + + uint32_t width, height; + ffEdidGetPhycialDisplay(CFDataGetBytePtr(edid), &width, &height); + if (width == 0 || height == 0) continue; + + FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); + display->width = width; + display->height = height; + ffStrbufInit(&display->name); + ffEdidGetName(CFDataGetBytePtr(edid), &display->name); + } + return NULL; +} + +const char* ffDetectPhycialDisplay(FFlist* results) +{ + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + + detectWithDisplayServices(displayServer, results); + + if (displayServer->displays.length > results->length) + detectWithDdcci(results); + return NULL; +} diff --git a/src/util/apple/ddcci.h b/src/util/apple/ddcci.h new file mode 100644 index 000000000..a0de17482 --- /dev/null +++ b/src/util/apple/ddcci.h @@ -0,0 +1,15 @@ +#pragma once + +#ifndef FASTFETCH_INCLUDED_util_apple_ddcci_h + +#include + +// DDC/CI +typedef CFTypeRef IOAVServiceRef; +extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import)); +extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import)); +extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import)); +extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import)); +extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import)); + +#endif diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index b89dfbf66..4e6f31a64 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -1,13 +1,13 @@ #include "edidHelper.h" -void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height) +void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height) { const int dtd = 54; *width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; *height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; } -void ffEdidGetName(uint8_t edid[128], FFstrbuf* name) +void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) { // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c for (uint32_t i = 0x36; i < 0x7E; i += 0x12) diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 3c81ffd28..bef07c6c6 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -6,7 +6,7 @@ #include #include "util/FFstrbuf.h" -void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height); -void ffEdidGetName(uint8_t edid[128], FFstrbuf* name); +void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height); +void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); #endif From abae204ab8a35a2a1c5634df541e7a53c0d9770e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 10:32:35 +0800 Subject: [PATCH 445/493] PhycialDisplay: tidy --- src/detection/phycialdisplay/phycialdisplay.h | 4 ++-- src/detection/phycialdisplay/phycialdisplay_apple.c | 12 ++++++------ src/detection/phycialdisplay/phycialdisplay_linux.c | 2 +- .../phycialdisplay/phycialdisplay_windows.c | 2 +- src/util/edidHelper.c | 2 +- src/util/edidHelper.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/detection/phycialdisplay/phycialdisplay.h b/src/detection/phycialdisplay/phycialdisplay.h index faa7a7172..81731e875 100644 --- a/src/detection/phycialdisplay/phycialdisplay.h +++ b/src/detection/phycialdisplay/phycialdisplay.h @@ -3,8 +3,8 @@ typedef struct FFPhycialDisplayResult { FFstrbuf name; - uint32_t width; - uint32_t height; + uint32_t width; // native / maximum resolution, in pixels + uint32_t height; // native / maximum resolution, in pixels } FFPhycialDisplayResult; const char* ffDetectPhycialDisplay(FFlist* results); diff --git a/src/detection/phycialdisplay/phycialdisplay_apple.c b/src/detection/phycialdisplay/phycialdisplay_apple.c index e611a28b6..824028951 100644 --- a/src/detection/phycialdisplay/phycialdisplay_apple.c +++ b/src/detection/phycialdisplay/phycialdisplay_apple.c @@ -23,14 +23,14 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa width <= 0 || height <= 0) continue; - FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); - display->width = (uint32_t) width; - display->height = (uint32_t) height; - ffStrbufInit(&display->name); + FFPhycialDisplayResult* phycialDisplay = (FFPhycialDisplayResult*) ffListAdd(results); + phycialDisplay->width = (uint32_t) width; + phycialDisplay->height = (uint32_t) height; + ffStrbufInit(&phycialDisplay->name); CFDictionaryRef productNames; if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &display->name); + ffCfDictGetString(productNames, CFSTR("en_US"), &phycialDisplay->name); } } } @@ -83,7 +83,7 @@ static const char* detectWithDdcci(FFlist* results) continue; uint32_t width, height; - ffEdidGetPhycialDisplay(CFDataGetBytePtr(edid), &width, &height); + ffEdidGetPhycialResolution(CFDataGetBytePtr(edid), &width, &height); if (width == 0 || height == 0) continue; FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); diff --git a/src/detection/phycialdisplay/phycialdisplay_linux.c b/src/detection/phycialdisplay/phycialdisplay_linux.c index 245f9e685..681eb33db 100644 --- a/src/detection/phycialdisplay/phycialdisplay_linux.c +++ b/src/detection/phycialdisplay/phycialdisplay_linux.c @@ -36,7 +36,7 @@ const char* ffDetectPhycialDisplay(FFlist* results) } uint32_t width, height; - ffEdidGetPhycialDisplay(edidData, &width, &height); + ffEdidGetPhycialResolution(edidData, &width, &height); if (width != 0 && height != 0) { const char* plainName = entry->d_name; diff --git a/src/detection/phycialdisplay/phycialdisplay_windows.c b/src/detection/phycialdisplay/phycialdisplay_windows.c index ad8161ce3..999fcf3e7 100644 --- a/src/detection/phycialdisplay/phycialdisplay_windows.c +++ b/src/detection/phycialdisplay/phycialdisplay_windows.c @@ -33,7 +33,7 @@ const char* ffDetectPhycialDisplay(FFlist* results) uint8_t edidData[256] = {}; if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue; uint32_t width, height; - ffEdidGetPhycialDisplay(edidData, &width, &height); + ffEdidGetPhycialResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; wchar_t wName[MAX_PATH] = {}; // MONITOR\BOE09F9 diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 4e6f31a64..646630a1f 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -1,6 +1,6 @@ #include "edidHelper.h" -void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height) +void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height) { const int dtd = 54; *width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index bef07c6c6..921f7d767 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -6,7 +6,7 @@ #include #include "util/FFstrbuf.h" -void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height); void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); +void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); #endif From 008c9a597eee3a151bb531617a5444cc9dbe3335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 10:52:12 +0800 Subject: [PATCH 446/493] PhycialDisplay: detect phycial size --- src/detection/phycialdisplay/phycialdisplay.h | 2 ++ src/detection/phycialdisplay/phycialdisplay_apple.c | 10 ++++++++-- src/detection/phycialdisplay/phycialdisplay_linux.c | 1 + src/detection/phycialdisplay/phycialdisplay_windows.c | 7 +++---- src/modules/phycialdisplay/phycialdisplay.c | 9 ++++++++- src/util/edidHelper.c | 6 ++++++ src/util/edidHelper.h | 1 + 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/detection/phycialdisplay/phycialdisplay.h b/src/detection/phycialdisplay/phycialdisplay.h index 81731e875..99e449686 100644 --- a/src/detection/phycialdisplay/phycialdisplay.h +++ b/src/detection/phycialdisplay/phycialdisplay.h @@ -5,6 +5,8 @@ typedef struct FFPhycialDisplayResult FFstrbuf name; uint32_t width; // native / maximum resolution, in pixels uint32_t height; // native / maximum resolution, in pixels + uint32_t phycialWidth; // in mm + uint32_t phycialHeight; // in mm } FFPhycialDisplayResult; const char* ffDetectPhycialDisplay(FFlist* results); diff --git a/src/detection/phycialdisplay/phycialdisplay_apple.c b/src/detection/phycialdisplay/phycialdisplay_apple.c index 824028951..80ed3b973 100644 --- a/src/detection/phycialdisplay/phycialdisplay_apple.c +++ b/src/detection/phycialdisplay/phycialdisplay_apple.c @@ -31,6 +31,10 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa CFDictionaryRef productNames; if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) ffCfDictGetString(productNames, CFSTR("en_US"), &phycialDisplay->name); + + CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id); + phycialDisplay->phycialWidth = (uint32_t) (size.width + 0.5); + phycialDisplay->phycialHeight = (uint32_t) (size.height + 0.5); } } } @@ -83,14 +87,16 @@ static const char* detectWithDdcci(FFlist* results) continue; uint32_t width, height; - ffEdidGetPhycialResolution(CFDataGetBytePtr(edid), &width, &height); + const uint8_t* edidData = CFDataGetBytePtr(edid); + ffEdidGetPhycialResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInit(&display->name); - ffEdidGetName(CFDataGetBytePtr(edid), &display->name); + ffEdidGetName(edidData, &display->name); + ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); } return NULL; } diff --git a/src/detection/phycialdisplay/phycialdisplay_linux.c b/src/detection/phycialdisplay/phycialdisplay_linux.c index 681eb33db..3063b512c 100644 --- a/src/detection/phycialdisplay/phycialdisplay_linux.c +++ b/src/detection/phycialdisplay/phycialdisplay_linux.c @@ -50,6 +50,7 @@ const char* ffDetectPhycialDisplay(FFlist* results) display->width = width; display->height = height; ffStrbufInitS(&display->name, plainName); + ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); } ffStrbufSubstrBefore(&drmDir, drmDirLength); diff --git a/src/detection/phycialdisplay/phycialdisplay_windows.c b/src/detection/phycialdisplay/phycialdisplay_windows.c index 999fcf3e7..3f02df66c 100644 --- a/src/detection/phycialdisplay/phycialdisplay_windows.c +++ b/src/detection/phycialdisplay/phycialdisplay_windows.c @@ -36,13 +36,12 @@ const char* ffDetectPhycialDisplay(FFlist* results) ffEdidGetPhycialResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; - wchar_t wName[MAX_PATH] = {}; // MONITOR\BOE09F9 - if (!SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_HARDWAREID, NULL, (BYTE*) wName, sizeof(wName), NULL)) continue; - FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); display->width = width; display->height = height; - ffStrbufInitWS(&display->name, wcschr(wName, L'\\') + 1); + ffStrbufInit(&display->name); + ffEdidGetName(edidData, &display->name); + ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); } return NULL; } diff --git a/src/modules/phycialdisplay/phycialdisplay.c b/src/modules/phycialdisplay/phycialdisplay.c index 9a14c8a44..b2df93b77 100644 --- a/src/modules/phycialdisplay/phycialdisplay.c +++ b/src/modules/phycialdisplay/phycialdisplay.c @@ -4,6 +4,8 @@ #include "modules/phycialdisplay/phycialdisplay.h" #include "util/stringUtils.h" +#include + #define FF_PHYCIALDISPLAY_DISPLAY_NAME "Phycial Display" #define FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS 3 @@ -29,6 +31,8 @@ void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); FF_LIST_FOR_EACH(FFPhycialDisplayResult, display, result) { + double inch = sqrt(display->phycialWidth * display->phycialWidth + display->phycialHeight * display->phycialHeight) / 25.4; + if(options->moduleArgs.outputFormat.length == 0) { ffStrbufClear(&key); @@ -44,7 +48,7 @@ void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) } ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - printf("%ux%u\n", display->width, display->height); + printf("%upx x %upx - %umm x %umm (%.2f inches)\n", display->width, display->height, display->phycialWidth, display->phycialHeight, inch); } else { @@ -52,6 +56,9 @@ void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, {FF_FORMAT_ARG_TYPE_UINT, &display->width}, {FF_FORMAT_ARG_TYPE_UINT, &display->height}, + {FF_FORMAT_ARG_TYPE_UINT, &display->phycialWidth}, + {FF_FORMAT_ARG_TYPE_UINT, &display->phycialHeight}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &inch}, }); } diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 646630a1f..b8acc7dbc 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -26,3 +26,9 @@ void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) } } } + +void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) +{ + *width = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66]; + *height = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67]; +} diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 921f7d767..b5e3fa8c1 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -8,5 +8,6 @@ void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); +void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm #endif From 44d02b3bfc34072f6e5be397fbdf3662bf0dac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 11:00:53 +0800 Subject: [PATCH 447/493] PhycialDisplay: only print physical sizes if detected successfully --- src/modules/phycialdisplay/phycialdisplay.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/phycialdisplay/phycialdisplay.c b/src/modules/phycialdisplay/phycialdisplay.c index b2df93b77..fa660034c 100644 --- a/src/modules/phycialdisplay/phycialdisplay.c +++ b/src/modules/phycialdisplay/phycialdisplay.c @@ -48,7 +48,11 @@ void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) } ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - printf("%upx x %upx - %umm x %umm (%.2f inches)\n", display->width, display->height, display->phycialWidth, display->phycialHeight, inch); + printf("%upx x %upx", display->width, display->height); + if (inch > 0) + printf(" - %umm x %umm (%.2f inches)\n", display->phycialWidth, display->phycialHeight, inch); + else + putchar('\n'); } else { From 921f3e3c3428871a63de1a90504bcf7ec7ac08ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 13:25:22 +0800 Subject: [PATCH 448/493] PhysicalDisplay: fix typo --- CHANGELOG.md | 2 +- CMakeLists.txt | 12 +- README.md | 2 +- doc/json_schema.json | 2 + src/common/jsonconfig.c | 2 +- src/data/config_user.txt | 3 + src/detection/phycialdisplay/phycialdisplay.h | 12 -- .../phycialdisplay/phycialdisplay_nosupport.c | 6 - .../physicaldisplay/physicaldisplay.h | 12 ++ .../physicaldisplay_apple.c} | 24 ++-- .../physicaldisplay_linux.c} | 10 +- .../physicaldisplay_nosupport.c | 6 + .../physicaldisplay_windows.c} | 10 +- src/fastfetch.c | 17 ++- src/fastfetch.h | 2 +- src/modules/modules.h | 2 +- src/modules/options.h | 2 +- src/modules/phycialdisplay/phycialdisplay.c | 117 ------------------ src/modules/phycialdisplay/phycialdisplay.h | 11 -- .../option.h | 4 +- src/modules/physicaldisplay/physicaldisplay.c | 117 ++++++++++++++++++ src/modules/physicaldisplay/physicaldisplay.h | 11 ++ src/util/edidHelper.c | 4 +- src/util/edidHelper.h | 4 +- 24 files changed, 205 insertions(+), 189 deletions(-) delete mode 100644 src/detection/phycialdisplay/phycialdisplay.h delete mode 100644 src/detection/phycialdisplay/phycialdisplay_nosupport.c create mode 100644 src/detection/physicaldisplay/physicaldisplay.h rename src/detection/{phycialdisplay/phycialdisplay_apple.c => physicaldisplay/physicaldisplay_apple.c} (82%) rename src/detection/{phycialdisplay/phycialdisplay_linux.c => physicaldisplay/physicaldisplay_linux.c} (81%) create mode 100644 src/detection/physicaldisplay/physicaldisplay_nosupport.c rename src/detection/{phycialdisplay/phycialdisplay_windows.c => physicaldisplay/physicaldisplay_windows.c} (80%) delete mode 100644 src/modules/phycialdisplay/phycialdisplay.c delete mode 100644 src/modules/phycialdisplay/phycialdisplay.h rename src/modules/{phycialdisplay => physicaldisplay}/option.h (73%) create mode 100644 src/modules/physicaldisplay/physicaldisplay.c create mode 100644 src/modules/physicaldisplay/physicaldisplay.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d627cd44..2483713c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Changes: * Fix M2 CPU temperature detection (CPU, macOS) Features: -* FreeBSD support is improved greatly, and actually tested in a phycial machine +* FreeBSD support is improved greatly, and actually tested in a physical machine * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module * Support `--colors-symbol` and `--colors-padding-left` (Colors) diff --git a/CMakeLists.txt b/CMakeLists.txt index 496ab8572..d3b60aca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,7 +328,7 @@ set(LIBFASTFETCH_SRC src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c - src/modules/phycialdisplay/phycialdisplay.c + src/modules/physicaldisplay/physicaldisplay.c src/modules/opencl/opencl.c src/modules/opengl/opengl.c src/modules/os/os.c @@ -395,7 +395,7 @@ if(LINUX) src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c src/detection/memory/memory_linux.c - src/detection/phycialdisplay/phycialdisplay_linux.c + src/detection/physicaldisplay/physicaldisplay_linux.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -441,7 +441,7 @@ elseif(ANDROID) src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_nosupport.c src/detection/memory/memory_linux.c - src/detection/phycialdisplay/phycialdisplay_nosupport.c + src/detection/physicaldisplay/physicaldisplay_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_android.c src/detection/packages/packages_linux.c @@ -493,7 +493,7 @@ elseif(BSD) src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c src/detection/memory/memory_bsd.c - src/detection/phycialdisplay/phycialdisplay_nosupport.c + src/detection/physicaldisplay/physicaldisplay_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -541,7 +541,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c - src/detection/phycialdisplay/phycialdisplay_apple.c + src/detection/physicaldisplay/physicaldisplay_apple.c src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c @@ -588,7 +588,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c - src/detection/phycialdisplay/phycialdisplay_windows.c + src/detection/physicaldisplay/physicaldisplay_windows.c src/detection/opengl/opengl_windows.c src/detection/os/os_windows.cpp src/detection/packages/packages_windows.c diff --git a/README.md b/README.md index 4e9dce9d5..8e601d73a 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ All categories not listed here should work without needing a specific implementa ##### Available Modules ``` -Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme +Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Physical Display, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme ``` ##### Builtin logos diff --git a/doc/json_schema.json b/doc/json_schema.json index 92f2779ee..50773239f 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -493,6 +493,7 @@ "opengl", "os", "packages", + "physicaldisplay", "player", "poweradapter", "processes", @@ -564,6 +565,7 @@ "opencl", "os", "packages", + "physicaldisplay", "player", "poweradapter", "processes", diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 5494b81b3..14610c45d 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -159,7 +159,7 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) case 'N': { return - tryModule(type, module, FF_PHYCIALDISPLAY_MODULE_NAME, ffParsePhycialDisplayJsonObject) || + tryModule(type, module, FF_PHYSICALDISPLAY_MODULE_NAME, ffParsePhysicalDisplayJsonObject) || false; } diff --git a/src/data/config_user.txt b/src/data/config_user.txt index de8973418..049399208 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -372,6 +372,7 @@ #--publicip-key Public IP #--wifi-key Wifi #--weather-key Weather +#--physicaldisplay-key Physical Display #--player-key Media Player #--media-key Media #--datetime-key Date Time @@ -421,6 +422,7 @@ #--localip-format #--publicip-format #--weather-format +#--physicaldisplay-format #--player-format #--media-format #--datetime-format @@ -467,6 +469,7 @@ #--localip-key-color #--publicip-key-color #--weather-key-color +#--physicaldisplay-key-color #--player-key-color #--media-key-color #--datetime-key-color diff --git a/src/detection/phycialdisplay/phycialdisplay.h b/src/detection/phycialdisplay/phycialdisplay.h deleted file mode 100644 index 99e449686..000000000 --- a/src/detection/phycialdisplay/phycialdisplay.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "fastfetch.h" - -typedef struct FFPhycialDisplayResult -{ - FFstrbuf name; - uint32_t width; // native / maximum resolution, in pixels - uint32_t height; // native / maximum resolution, in pixels - uint32_t phycialWidth; // in mm - uint32_t phycialHeight; // in mm -} FFPhycialDisplayResult; - -const char* ffDetectPhycialDisplay(FFlist* results); diff --git a/src/detection/phycialdisplay/phycialdisplay_nosupport.c b/src/detection/phycialdisplay/phycialdisplay_nosupport.c deleted file mode 100644 index 5254f52c6..000000000 --- a/src/detection/phycialdisplay/phycialdisplay_nosupport.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "phycialdisplay.h" - -const char* ffDetectPhycialDisplay(FF_MAYBE_UNUSED FFlist* results) -{ - return "Not supported on this platform"; -} diff --git a/src/detection/physicaldisplay/physicaldisplay.h b/src/detection/physicaldisplay/physicaldisplay.h new file mode 100644 index 000000000..dd29cdd26 --- /dev/null +++ b/src/detection/physicaldisplay/physicaldisplay.h @@ -0,0 +1,12 @@ +#include "fastfetch.h" + +typedef struct FFPhysicalDisplayResult +{ + FFstrbuf name; + uint32_t width; // native / maximum resolution, in pixels + uint32_t height; // native / maximum resolution, in pixels + uint32_t physicalWidth; // in mm + uint32_t physicalHeight; // in mm +} FFPhysicalDisplayResult; + +const char* ffDetectPhysicalDisplay(FFlist* results); diff --git a/src/detection/phycialdisplay/phycialdisplay_apple.c b/src/detection/physicaldisplay/physicaldisplay_apple.c similarity index 82% rename from src/detection/phycialdisplay/phycialdisplay_apple.c rename to src/detection/physicaldisplay/physicaldisplay_apple.c index 80ed3b973..304f3dbda 100644 --- a/src/detection/phycialdisplay/phycialdisplay_apple.c +++ b/src/detection/physicaldisplay/physicaldisplay_apple.c @@ -1,4 +1,4 @@ -#include "phycialdisplay.h" +#include "physicaldisplay.h" #include "detection/displayserver/displayserver.h" #include "util/apple/cf_helpers.h" #include "util/apple/ddcci.h" @@ -23,18 +23,18 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa width <= 0 || height <= 0) continue; - FFPhycialDisplayResult* phycialDisplay = (FFPhycialDisplayResult*) ffListAdd(results); - phycialDisplay->width = (uint32_t) width; - phycialDisplay->height = (uint32_t) height; - ffStrbufInit(&phycialDisplay->name); + FFPhysicalDisplayResult* physicalDisplay = (FFPhysicalDisplayResult*) ffListAdd(results); + physicalDisplay->width = (uint32_t) width; + physicalDisplay->height = (uint32_t) height; + ffStrbufInit(&physicalDisplay->name); CFDictionaryRef productNames; if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &phycialDisplay->name); + ffCfDictGetString(productNames, CFSTR("en_US"), &physicalDisplay->name); CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id); - phycialDisplay->phycialWidth = (uint32_t) (size.width + 0.5); - phycialDisplay->phycialHeight = (uint32_t) (size.height + 0.5); + physicalDisplay->physicalWidth = (uint32_t) (size.width + 0.5); + physicalDisplay->physicalHeight = (uint32_t) (size.height + 0.5); } } } @@ -88,20 +88,20 @@ static const char* detectWithDdcci(FFlist* results) uint32_t width, height; const uint8_t* edidData = CFDataGetBytePtr(edid); - ffEdidGetPhycialResolution(edidData, &width, &height); + ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; - FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); + FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); - ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); + ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); } return NULL; } -const char* ffDetectPhycialDisplay(FFlist* results) +const char* ffDetectPhysicalDisplay(FFlist* results) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); diff --git a/src/detection/phycialdisplay/phycialdisplay_linux.c b/src/detection/physicaldisplay/physicaldisplay_linux.c similarity index 81% rename from src/detection/phycialdisplay/phycialdisplay_linux.c rename to src/detection/physicaldisplay/physicaldisplay_linux.c index 3063b512c..08d94225b 100644 --- a/src/detection/phycialdisplay/phycialdisplay_linux.c +++ b/src/detection/physicaldisplay/physicaldisplay_linux.c @@ -1,4 +1,4 @@ -#include "phycialdisplay.h" +#include "physicaldisplay.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -6,7 +6,7 @@ #include -const char* ffDetectPhycialDisplay(FFlist* results) +const char* ffDetectPhysicalDisplay(FFlist* results) { const char* drmDirPath = "/sys/class/drm/"; @@ -36,7 +36,7 @@ const char* ffDetectPhycialDisplay(FFlist* results) } uint32_t width, height; - ffEdidGetPhycialResolution(edidData, &width, &height); + ffEdidGetPhysicalResolution(edidData, &width, &height); if (width != 0 && height != 0) { const char* plainName = entry->d_name; @@ -46,11 +46,11 @@ const char* ffDetectPhycialDisplay(FFlist* results) if (tmp) plainName = tmp + 1; } - FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); + FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInitS(&display->name, plainName); - ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); + ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); } ffStrbufSubstrBefore(&drmDir, drmDirLength); diff --git a/src/detection/physicaldisplay/physicaldisplay_nosupport.c b/src/detection/physicaldisplay/physicaldisplay_nosupport.c new file mode 100644 index 000000000..07282b1bf --- /dev/null +++ b/src/detection/physicaldisplay/physicaldisplay_nosupport.c @@ -0,0 +1,6 @@ +#include "physicaldisplay.h" + +const char* ffDetectPhysicalDisplay(FF_MAYBE_UNUSED FFlist* results) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/phycialdisplay/phycialdisplay_windows.c b/src/detection/physicaldisplay/physicaldisplay_windows.c similarity index 80% rename from src/detection/phycialdisplay/phycialdisplay_windows.c rename to src/detection/physicaldisplay/physicaldisplay_windows.c index 3f02df66c..cf6de8168 100644 --- a/src/detection/phycialdisplay/phycialdisplay_windows.c +++ b/src/detection/physicaldisplay/physicaldisplay_windows.c @@ -1,4 +1,4 @@ -#include "phycialdisplay.h" +#include "physicaldisplay.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -16,7 +16,7 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) SetupDiDestroyDeviceInfoList(*hdev); } -const char* ffDetectPhycialDisplay(FFlist* results) +const char* ffDetectPhysicalDisplay(FFlist* results) { //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = @@ -33,15 +33,15 @@ const char* ffDetectPhycialDisplay(FFlist* results) uint8_t edidData[256] = {}; if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue; uint32_t width, height; - ffEdidGetPhycialResolution(edidData, &width, &height); + ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; - FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results); + FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); - ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight); + ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); } return NULL; } diff --git a/src/fastfetch.c b/src/fastfetch.c index b1de0d875..414647902 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -393,6 +393,17 @@ static inline void printCommandHelp(const char* command) "Connection Security algorithm" ); } + else if(ffStrEqualsIgnCase(command, "physicaldisplay-format")) + { + constructAndPrintCommandHelpFormat("physicaldisplay", "{}", 6, + "Display name", + "Display native resolution width in pixels", + "Display native resolution height in pixels", + "Display physical width in millimeters", + "Display physical height in millimeters", + "Display physical length in inches" + ); + } else if(ffStrEqualsIgnCase(command, "player-format")) { constructAndPrintCommandHelpFormat("player", "{}", 4, @@ -1018,7 +1029,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {} else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {} - else if(ffParsePhycialDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {} + else if(ffParsePhysicalDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {} @@ -1252,8 +1263,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues) ffPrintPlayer(&instance.config.player); else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) ffPrintMedia(&instance.config.media); - else if(ffStrEqualsIgnCase(line, FF_PHYCIALDISPLAY_MODULE_NAME)) - ffPrintPhycialDisplay(&instance.config.nativeResolution); + else if(ffStrEqualsIgnCase(line, FF_PHYSICALDISPLAY_MODULE_NAME)) + ffPrintPhysicalDisplay(&instance.config.nativeResolution); else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) ffPrintDateTime(&instance.config.dateTime); else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index a4ffb6ff8..94438178d 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -110,7 +110,7 @@ typedef struct FFconfig FFWeatherOptions weather; FFPlayerOptions player; FFMediaOptions media; - FFPhycialDisplayOptions nativeResolution; + FFPhysicalDisplayOptions nativeResolution; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; FFOpenGLOptions openGL; diff --git a/src/modules/modules.h b/src/modules/modules.h index 532679faa..3f0ee25ef 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -30,7 +30,7 @@ #include "modules/localip/localip.h" #include "modules/media/media.h" #include "modules/memory/memory.h" -#include "modules/phycialdisplay/phycialdisplay.h" +#include "modules/physicaldisplay/physicaldisplay.h" #include "modules/opengl/opengl.h" #include "modules/opencl/opencl.h" #include "modules/os/os.h" diff --git a/src/modules/options.h b/src/modules/options.h index 6f33a048a..14e665539 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,7 +29,7 @@ #include "modules/localip/option.h" #include "modules/media/option.h" #include "modules/memory/option.h" -#include "modules/phycialdisplay/option.h" +#include "modules/physicaldisplay/option.h" #include "modules/opengl/option.h" #include "modules/opencl/option.h" #include "modules/os/option.h" diff --git a/src/modules/phycialdisplay/phycialdisplay.c b/src/modules/phycialdisplay/phycialdisplay.c deleted file mode 100644 index fa660034c..000000000 --- a/src/modules/phycialdisplay/phycialdisplay.c +++ /dev/null @@ -1,117 +0,0 @@ -#include "common/printing.h" -#include "common/jsonconfig.h" -#include "detection/phycialdisplay/phycialdisplay.h" -#include "modules/phycialdisplay/phycialdisplay.h" -#include "util/stringUtils.h" - -#include - -#define FF_PHYCIALDISPLAY_DISPLAY_NAME "Phycial Display" -#define FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS 3 - -void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options) -{ - FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhycialDisplayResult)); - - const char* error = ffDetectPhycialDisplay(&result); - - if(error) - { - ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); - return; - } - - if(!result.length) - { - ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No phycial display detected"); - return; - } - - uint8_t index = 0; - FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFPhycialDisplayResult, display, result) - { - double inch = sqrt(display->phycialWidth * display->phycialWidth + display->phycialHeight * display->phycialHeight) / 25.4; - - if(options->moduleArgs.outputFormat.length == 0) - { - ffStrbufClear(&key); - if(options->moduleArgs.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_PHYCIALDISPLAY_DISPLAY_NAME, display->name.chars); - } - else - { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, - }); - } - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - - printf("%upx x %upx", display->width, display->height); - if (inch > 0) - printf(" - %umm x %umm (%.2f inches)\n", display->phycialWidth, display->phycialHeight, inch); - else - putchar('\n'); - } - else - { - ffPrintFormat(FF_PHYCIALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, - {FF_FORMAT_ARG_TYPE_UINT, &display->width}, - {FF_FORMAT_ARG_TYPE_UINT, &display->height}, - {FF_FORMAT_ARG_TYPE_UINT, &display->phycialWidth}, - {FF_FORMAT_ARG_TYPE_UINT, &display->phycialHeight}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &inch}, - }); - } - - ffStrbufDestroy(&display->name); - } -} - -void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options) -{ - options->moduleName = FF_PHYCIALDISPLAY_MODULE_NAME; - ffOptionInitModuleArg(&options->moduleArgs); -} - -bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value) -{ - const char* subKey = ffOptionTestPrefix(key, FF_PHYCIALDISPLAY_MODULE_NAME); - if (!subKey) return false; - if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) - return true; - - return false; -} - -void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options) -{ - ffOptionDestroyModuleArg(&options->moduleArgs); -} - -void ffParsePhycialDisplayJsonObject(yyjson_val* module) -{ - FFPhycialDisplayOptions __attribute__((__cleanup__(ffDestroyPhycialDisplayOptions))) options; - ffInitPhycialDisplayOptions(&options); - - if (module) - { - yyjson_val *key_, *val; - size_t idx, max; - yyjson_obj_foreach(module, idx, max, key_, val) - { - const char* key = yyjson_get_str(key_); - if(ffStrEqualsIgnCase(key, "type")) - continue; - - if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) - continue; - - ffPrintError(FF_PHYCIALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); - } - } - - ffPrintPhycialDisplay(&options); -} diff --git a/src/modules/phycialdisplay/phycialdisplay.h b/src/modules/phycialdisplay/phycialdisplay.h deleted file mode 100644 index d65876643..000000000 --- a/src/modules/phycialdisplay/phycialdisplay.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "fastfetch.h" - -#define FF_PHYCIALDISPLAY_MODULE_NAME "PhycialDisplay" - -void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options); -void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options); -bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value); -void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options); -void ffParsePhycialDisplayJsonObject(yyjson_val* module); diff --git a/src/modules/phycialdisplay/option.h b/src/modules/physicaldisplay/option.h similarity index 73% rename from src/modules/phycialdisplay/option.h rename to src/modules/physicaldisplay/option.h index 2f16f55a7..3930a6253 100644 --- a/src/modules/phycialdisplay/option.h +++ b/src/modules/physicaldisplay/option.h @@ -4,8 +4,8 @@ #include "common/option.h" -typedef struct FFPhycialDisplayOptions +typedef struct FFPhysicalDisplayOptions { const char* moduleName; FFModuleArgs moduleArgs; -} FFPhycialDisplayOptions; +} FFPhysicalDisplayOptions; diff --git a/src/modules/physicaldisplay/physicaldisplay.c b/src/modules/physicaldisplay/physicaldisplay.c new file mode 100644 index 000000000..5895a1ae0 --- /dev/null +++ b/src/modules/physicaldisplay/physicaldisplay.c @@ -0,0 +1,117 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "detection/physicaldisplay/physicaldisplay.h" +#include "modules/physicaldisplay/physicaldisplay.h" +#include "util/stringUtils.h" + +#include + +#define FF_PHYSICALDISPLAY_DISPLAY_NAME "Physical Display" +#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 6 + +void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) +{ + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalDisplayResult)); + + const char* error = ffDetectPhysicalDisplay(&result); + + if(error) + { + ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + return; + } + + if(!result.length) + { + ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No physical display detected"); + return; + } + + uint8_t index = 0; + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + FF_LIST_FOR_EACH(FFPhysicalDisplayResult, display, result) + { + double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4; + + if(options->moduleArgs.outputFormat.length == 0) + { + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_PHYSICALDISPLAY_DISPLAY_NAME, display->name.chars); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + }); + } + ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + + printf("%upx x %upx", display->width, display->height); + if (inch > 0) + printf(" - %umm x %umm (%.2f inches)\n", display->physicalWidth, display->physicalHeight, inch); + else + putchar('\n'); + } + else + { + ffPrintFormat(FF_PHYSICALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + {FF_FORMAT_ARG_TYPE_UINT, &display->width}, + {FF_FORMAT_ARG_TYPE_UINT, &display->height}, + {FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth}, + {FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &inch}, + }); + } + + ffStrbufDestroy(&display->name); + } +} + +void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options) +{ + options->moduleName = FF_PHYSICALDISPLAY_MODULE_NAME; + ffOptionInitModuleArg(&options->moduleArgs); +} + +bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PHYSICALDISPLAY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} + +void ffParsePhysicalDisplayJsonObject(yyjson_val* module) +{ + FFPhysicalDisplayOptions __attribute__((__cleanup__(ffDestroyPhysicalDisplayOptions))) options; + ffInitPhysicalDisplayOptions(&options); + + if (module) + { + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) + continue; + + ffPrintError(FF_PHYSICALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + } + } + + ffPrintPhysicalDisplay(&options); +} diff --git a/src/modules/physicaldisplay/physicaldisplay.h b/src/modules/physicaldisplay/physicaldisplay.h new file mode 100644 index 000000000..a63213d65 --- /dev/null +++ b/src/modules/physicaldisplay/physicaldisplay.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_PHYSICALDISPLAY_MODULE_NAME "PhysicalDisplay" + +void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options); +void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options); +bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value); +void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options); +void ffParsePhysicalDisplayJsonObject(yyjson_val* module); diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index b8acc7dbc..0537907ba 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -1,6 +1,6 @@ #include "edidHelper.h" -void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height) +void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height) { const int dtd = 54; *width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2]; @@ -27,7 +27,7 @@ void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) } } -void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) +void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) { *width = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66]; *height = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67]; diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index b5e3fa8c1..4081dceba 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -7,7 +7,7 @@ #include "util/FFstrbuf.h" void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); -void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); -void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm +void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); +void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm #endif From 6c156ebba4e157844d0f533376630f1af6b23b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 16:07:01 +0800 Subject: [PATCH 449/493] PhysicalDisplay (Linux): using sqrt requires linking with libm --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b60aca3..9b658f410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -787,7 +787,11 @@ if(ENABLE_PCI_MEMORY) target_compile_definitions(libfastfetch PRIVATE FF_USE_PCI_MEMORY) endif() -if(APPLE) +if(LINUX) + target_link_libraries(libfastfetch + PRIVATE "m" + ) +elseif(APPLE) target_link_libraries(libfastfetch PRIVATE "-framework Cocoa" PRIVATE "-framework CoreFoundation" From 4b57e4261eb4b880c866f5423d947204da33dd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 16:18:57 +0800 Subject: [PATCH 450/493] PhysicalDisplay: calculate ppi --- src/fastfetch.c | 3 ++- src/modules/physicaldisplay/physicaldisplay.c | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 414647902..84bd26689 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -401,7 +401,8 @@ static inline void printCommandHelp(const char* command) "Display native resolution height in pixels", "Display physical width in millimeters", "Display physical height in millimeters", - "Display physical length in inches" + "Display physical diagonal length in inches", + "Display physical pixels per inch (PPI)" ); } else if(ffStrEqualsIgnCase(command, "player-format")) diff --git a/src/modules/physicaldisplay/physicaldisplay.c b/src/modules/physicaldisplay/physicaldisplay.c index 5895a1ae0..a8e9b51ad 100644 --- a/src/modules/physicaldisplay/physicaldisplay.c +++ b/src/modules/physicaldisplay/physicaldisplay.c @@ -7,7 +7,7 @@ #include #define FF_PHYSICALDISPLAY_DISPLAY_NAME "Physical Display" -#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 6 +#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 7 void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) { @@ -32,6 +32,7 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) FF_LIST_FOR_EACH(FFPhysicalDisplayResult, display, result) { double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4; + double ppi = sqrt(display->width * display->width + display->height * display->height) / inch; if(options->moduleArgs.outputFormat.length == 0) { @@ -48,9 +49,9 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) } ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); - printf("%upx x %upx", display->width, display->height); + printf("%ux%u px", display->width, display->height); if (inch > 0) - printf(" - %umm x %umm (%.2f inches)\n", display->physicalWidth, display->physicalHeight, inch); + printf(" - %ux%u mm (%.2f inches, %.2f ppi)\n", display->physicalWidth, display->physicalHeight, inch, ppi); else putchar('\n'); } @@ -63,6 +64,7 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) {FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth}, {FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight}, {FF_FORMAT_ARG_TYPE_DOUBLE, &inch}, + {FF_FORMAT_ARG_TYPE_DOUBLE, &ppi}, }); } From d8e221517b1dcdc783006ef7f378006aad499633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 16:29:04 +0800 Subject: [PATCH 451/493] Brightness: fix `--brightness-format` --- CHANGELOG.md | 1 + src/fastfetch.c | 7 +++++++ src/modules/brightness/brightness.c | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2483713c9..83308f87c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Bugfixes: * Fix compatibility with Fig (Terminal, macOS) * Fix option `--title-fqdn` doesn't work (Title) * Fix used spaces calculation (Disk, Linux / BSD / macOS, #508) +* Fix `--brightness-format` (Brightness) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: diff --git a/src/fastfetch.c b/src/fastfetch.c index 84bd26689..23ae425ae 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -193,6 +193,13 @@ static inline void printCommandHelp(const char* command) "Screen rotation" ); } + else if(ffStrEqualsIgnCase(command, "brightness-format")) + { + constructAndPrintCommandHelpFormat("brightness", "{}", 2, + "Screen brightness", + "Screen name" + ); + } else if(ffStrEqualsIgnCase(command, "de-format")) { constructAndPrintCommandHelpFormat("de", "{2} {3}", 3, diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 5798b6719..3e5ea3663 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -64,8 +64,8 @@ void ffPrintBrightness(FFBrightnessOptions* options) else { ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &item->value}, - {FF_FORMAT_ARG_TYPE_FLOAT, &item->name} + {FF_FORMAT_ARG_TYPE_FLOAT, &item->value}, + {FF_FORMAT_ARG_TYPE_STRBUF, &item->name}, }); } From 79651073479bc944f2f38cde5d172fbbb5965b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 16:31:24 +0800 Subject: [PATCH 452/493] PhysicalDisplay: rename module to Monitor --- CMakeLists.txt | 12 +++--- README.md | 2 +- doc/json_schema.json | 4 +- src/common/jsonconfig.c | 7 +-- src/data/config_user.txt | 6 +-- .../physicaldisplay.h => monitor/monitor.h} | 6 +-- .../monitor_apple.c} | 20 ++++----- .../monitor_linux.c} | 6 +-- src/detection/monitor/monitor_nosupport.c | 6 +++ .../monitor_windows.c} | 6 +-- .../physicaldisplay_nosupport.c | 6 --- src/fastfetch.c | 30 ++++++------- src/fastfetch.h | 2 +- src/modules/modules.h | 2 +- .../physicaldisplay.c => monitor/monitor.c} | 43 +++++++++---------- src/modules/monitor/monitor.h | 11 +++++ .../{physicaldisplay => monitor}/option.h | 4 +- src/modules/options.h | 2 +- src/modules/physicaldisplay/physicaldisplay.h | 11 ----- 19 files changed, 90 insertions(+), 96 deletions(-) rename src/detection/{physicaldisplay/physicaldisplay.h => monitor/monitor.h} (67%) rename src/detection/{physicaldisplay/physicaldisplay_apple.c => monitor/monitor_apple.c} (85%) rename src/detection/{physicaldisplay/physicaldisplay_linux.c => monitor/monitor_linux.c} (90%) create mode 100644 src/detection/monitor/monitor_nosupport.c rename src/detection/{physicaldisplay/physicaldisplay_windows.c => monitor/monitor_windows.c} (89%) delete mode 100644 src/detection/physicaldisplay/physicaldisplay_nosupport.c rename src/modules/{physicaldisplay/physicaldisplay.c => monitor/monitor.c} (59%) create mode 100644 src/modules/monitor/monitor.h rename src/modules/{physicaldisplay => monitor}/option.h (73%) delete mode 100644 src/modules/physicaldisplay/physicaldisplay.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b658f410..423f1df40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,7 +328,7 @@ set(LIBFASTFETCH_SRC src/modules/locale/locale.c src/modules/localip/localip.c src/modules/memory/memory.c - src/modules/physicaldisplay/physicaldisplay.c + src/modules/monitor/monitor.c src/modules/opencl/opencl.c src/modules/opengl/opengl.c src/modules/os/os.c @@ -395,7 +395,7 @@ if(LINUX) src/detection/gamepad/gamepad_linux.c src/detection/media/media_linux.c src/detection/memory/memory_linux.c - src/detection/physicaldisplay/physicaldisplay_linux.c + src/detection/monitor/monitor_linux.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -441,7 +441,7 @@ elseif(ANDROID) src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_nosupport.c src/detection/memory/memory_linux.c - src/detection/physicaldisplay/physicaldisplay_nosupport.c + src/detection/monitor/monitor_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_android.c src/detection/packages/packages_linux.c @@ -493,7 +493,7 @@ elseif(BSD) src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c src/detection/memory/memory_bsd.c - src/detection/physicaldisplay/physicaldisplay_nosupport.c + src/detection/monitor/monitor_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c @@ -541,7 +541,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c - src/detection/physicaldisplay/physicaldisplay_apple.c + src/detection/monitor/monitor_apple.c src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c @@ -588,7 +588,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c - src/detection/physicaldisplay/physicaldisplay_windows.c + src/detection/monitor/monitor_windows.c src/detection/opengl/opengl_windows.c src/detection/os/os_windows.cpp src/detection/packages/packages_windows.c diff --git a/README.md b/README.md index 8e601d73a..c84ccf393 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ All categories not listed here should work without needing a specific implementa ##### Available Modules ``` -Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Physical Display, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme +Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme ``` ##### Builtin logos diff --git a/doc/json_schema.json b/doc/json_schema.json index 50773239f..279aac96c 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -489,11 +489,11 @@ "localip", "media", "memory", + "monitor", "opencl", "opengl", "os", "packages", - "physicaldisplay", "player", "poweradapter", "processes", @@ -562,10 +562,10 @@ "locale", "media", "memory", + "monitor", "opencl", "os", "packages", - "physicaldisplay", "player", "poweradapter", "processes", diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 14610c45d..4ac9ddc2d 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -154,12 +154,7 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) return tryModule(type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) || tryModule(type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) || - false; - } - - case 'N': { - return - tryModule(type, module, FF_PHYSICALDISPLAY_MODULE_NAME, ffParsePhysicalDisplayJsonObject) || + tryModule(type, module, FF_MONITOR_MODULE_NAME, ffParseMonitorJsonObject) || false; } diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 049399208..619bdfdc3 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -349,6 +349,7 @@ #--shell-key Shell #--display-key Display {1} #--brightness-key Brightness ({1}) +#--monitor-key Monitor #--de-key DE #--wm-key WM #--wmtheme-key WM Theme @@ -372,7 +373,6 @@ #--publicip-key Public IP #--wifi-key Wifi #--weather-key Weather -#--physicaldisplay-key Physical Display #--player-key Media Player #--media-key Media #--datetime-key Date Time @@ -422,7 +422,7 @@ #--localip-format #--publicip-format #--weather-format -#--physicaldisplay-format +#--monitor-format #--player-format #--media-format #--datetime-format @@ -469,7 +469,7 @@ #--localip-key-color #--publicip-key-color #--weather-key-color -#--physicaldisplay-key-color +#--monitor-key-color #--player-key-color #--media-key-color #--datetime-key-color diff --git a/src/detection/physicaldisplay/physicaldisplay.h b/src/detection/monitor/monitor.h similarity index 67% rename from src/detection/physicaldisplay/physicaldisplay.h rename to src/detection/monitor/monitor.h index dd29cdd26..1fc514d90 100644 --- a/src/detection/physicaldisplay/physicaldisplay.h +++ b/src/detection/monitor/monitor.h @@ -1,12 +1,12 @@ #include "fastfetch.h" -typedef struct FFPhysicalDisplayResult +typedef struct FFMonitorResult { FFstrbuf name; uint32_t width; // native / maximum resolution, in pixels uint32_t height; // native / maximum resolution, in pixels uint32_t physicalWidth; // in mm uint32_t physicalHeight; // in mm -} FFPhysicalDisplayResult; +} FFMonitorResult; -const char* ffDetectPhysicalDisplay(FFlist* results); +const char* ffDetectMonitor(FFlist* results); diff --git a/src/detection/physicaldisplay/physicaldisplay_apple.c b/src/detection/monitor/monitor_apple.c similarity index 85% rename from src/detection/physicaldisplay/physicaldisplay_apple.c rename to src/detection/monitor/monitor_apple.c index 304f3dbda..bd4a43354 100644 --- a/src/detection/physicaldisplay/physicaldisplay_apple.c +++ b/src/detection/monitor/monitor_apple.c @@ -1,4 +1,4 @@ -#include "physicaldisplay.h" +#include "monitor.h" #include "detection/displayserver/displayserver.h" #include "util/apple/cf_helpers.h" #include "util/apple/ddcci.h" @@ -23,18 +23,18 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa width <= 0 || height <= 0) continue; - FFPhysicalDisplayResult* physicalDisplay = (FFPhysicalDisplayResult*) ffListAdd(results); - physicalDisplay->width = (uint32_t) width; - physicalDisplay->height = (uint32_t) height; - ffStrbufInit(&physicalDisplay->name); + FFMonitorResult* monitor = (FFMonitorResult*) ffListAdd(results); + monitor->width = (uint32_t) width; + monitor->height = (uint32_t) height; + ffStrbufInit(&monitor->name); CFDictionaryRef productNames; if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &physicalDisplay->name); + ffCfDictGetString(productNames, CFSTR("en_US"), &monitor->name); CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id); - physicalDisplay->physicalWidth = (uint32_t) (size.width + 0.5); - physicalDisplay->physicalHeight = (uint32_t) (size.height + 0.5); + monitor->physicalWidth = (uint32_t) (size.width + 0.5); + monitor->physicalHeight = (uint32_t) (size.height + 0.5); } } } @@ -91,7 +91,7 @@ static const char* detectWithDdcci(FFlist* results) ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; - FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); + FFMonitorResult* display = (FFMonitorResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInit(&display->name); @@ -101,7 +101,7 @@ static const char* detectWithDdcci(FFlist* results) return NULL; } -const char* ffDetectPhysicalDisplay(FFlist* results) +const char* ffDetectMonitor(FFlist* results) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); diff --git a/src/detection/physicaldisplay/physicaldisplay_linux.c b/src/detection/monitor/monitor_linux.c similarity index 90% rename from src/detection/physicaldisplay/physicaldisplay_linux.c rename to src/detection/monitor/monitor_linux.c index 08d94225b..9bbc7f6b7 100644 --- a/src/detection/physicaldisplay/physicaldisplay_linux.c +++ b/src/detection/monitor/monitor_linux.c @@ -1,4 +1,4 @@ -#include "physicaldisplay.h" +#include "monitor.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -6,7 +6,7 @@ #include -const char* ffDetectPhysicalDisplay(FFlist* results) +const char* ffDetectMonitor(FFlist* results) { const char* drmDirPath = "/sys/class/drm/"; @@ -46,7 +46,7 @@ const char* ffDetectPhysicalDisplay(FFlist* results) if (tmp) plainName = tmp + 1; } - FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); + FFMonitorResult* display = (FFMonitorResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInitS(&display->name, plainName); diff --git a/src/detection/monitor/monitor_nosupport.c b/src/detection/monitor/monitor_nosupport.c new file mode 100644 index 000000000..c5bd0547a --- /dev/null +++ b/src/detection/monitor/monitor_nosupport.c @@ -0,0 +1,6 @@ +#include "monitor.h" + +const char* ffDetectMonitor(FF_MAYBE_UNUSED FFlist* results) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/physicaldisplay/physicaldisplay_windows.c b/src/detection/monitor/monitor_windows.c similarity index 89% rename from src/detection/physicaldisplay/physicaldisplay_windows.c rename to src/detection/monitor/monitor_windows.c index cf6de8168..5bd57dc64 100644 --- a/src/detection/physicaldisplay/physicaldisplay_windows.c +++ b/src/detection/monitor/monitor_windows.c @@ -1,4 +1,4 @@ -#include "physicaldisplay.h" +#include "monitor.h" #include "common/io/io.h" #include "util/edidHelper.h" @@ -16,7 +16,7 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev) SetupDiDestroyDeviceInfoList(*hdev); } -const char* ffDetectPhysicalDisplay(FFlist* results) +const char* ffDetectMonitor(FFlist* results) { //https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) = @@ -36,7 +36,7 @@ const char* ffDetectPhysicalDisplay(FFlist* results) ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; - FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results); + FFMonitorResult* display = (FFMonitorResult*) ffListAdd(results); display->width = width; display->height = height; ffStrbufInit(&display->name); diff --git a/src/detection/physicaldisplay/physicaldisplay_nosupport.c b/src/detection/physicaldisplay/physicaldisplay_nosupport.c deleted file mode 100644 index 07282b1bf..000000000 --- a/src/detection/physicaldisplay/physicaldisplay_nosupport.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "physicaldisplay.h" - -const char* ffDetectPhysicalDisplay(FF_MAYBE_UNUSED FFlist* results) -{ - return "Not supported on this platform"; -} diff --git a/src/fastfetch.c b/src/fastfetch.c index 23ae425ae..40b87db6a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -200,6 +200,18 @@ static inline void printCommandHelp(const char* command) "Screen name" ); } + else if(ffStrEqualsIgnCase(command, "monitor-format")) + { + constructAndPrintCommandHelpFormat("monitor", "{}", 6, + "Display name", + "Display native resolution width in pixels", + "Display native resolution height in pixels", + "Display physical width in millimeters", + "Display physical height in millimeters", + "Display physical diagonal length in inches", + "Display physical pixels per inch (PPI)" + ); + } else if(ffStrEqualsIgnCase(command, "de-format")) { constructAndPrintCommandHelpFormat("de", "{2} {3}", 3, @@ -400,18 +412,6 @@ static inline void printCommandHelp(const char* command) "Connection Security algorithm" ); } - else if(ffStrEqualsIgnCase(command, "physicaldisplay-format")) - { - constructAndPrintCommandHelpFormat("physicaldisplay", "{}", 6, - "Display name", - "Display native resolution width in pixels", - "Display native resolution height in pixels", - "Display physical width in millimeters", - "Display physical height in millimeters", - "Display physical diagonal length in inches", - "Display physical pixels per inch (PPI)" - ); - } else if(ffStrEqualsIgnCase(command, "player-format")) { constructAndPrintCommandHelpFormat("player", "{}", 4, @@ -1010,6 +1010,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseShellCommandOptions(&instance.config.shell, key, value)) {} else if(ffParseDisplayCommandOptions(&instance.config.display, key, value)) {} else if(ffParseBrightnessCommandOptions(&instance.config.brightness, key, value)) {} + else if(ffParseMonitorCommandOptions(&instance.config.nativeResolution, key, value)) {} else if(ffParseDECommandOptions(&instance.config.de, key, value)) {} else if(ffParseWifiCommandOptions(&instance.config.wifi, key, value)) {} else if(ffParseWMCommandOptions(&instance.config.wm, key, value)) {} @@ -1037,7 +1038,6 @@ static void parseOption(FFdata* data, const char* key, const char* value) else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {} else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {} else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {} - else if(ffParsePhysicalDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {} else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {} else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {} else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {} @@ -1271,8 +1271,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues) ffPrintPlayer(&instance.config.player); else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) ffPrintMedia(&instance.config.media); - else if(ffStrEqualsIgnCase(line, FF_PHYSICALDISPLAY_MODULE_NAME)) - ffPrintPhysicalDisplay(&instance.config.nativeResolution); + else if(ffStrEqualsIgnCase(line, FF_MONITOR_MODULE_NAME)) + ffPrintMonitor(&instance.config.nativeResolution); else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) ffPrintDateTime(&instance.config.dateTime); else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) diff --git a/src/fastfetch.h b/src/fastfetch.h index 94438178d..3e77c204b 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -110,7 +110,7 @@ typedef struct FFconfig FFWeatherOptions weather; FFPlayerOptions player; FFMediaOptions media; - FFPhysicalDisplayOptions nativeResolution; + FFMonitorOptions nativeResolution; FFDateTimeOptions dateTime; FFVulkanOptions vulkan; FFOpenGLOptions openGL; diff --git a/src/modules/modules.h b/src/modules/modules.h index 3f0ee25ef..c5e75e525 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -30,7 +30,7 @@ #include "modules/localip/localip.h" #include "modules/media/media.h" #include "modules/memory/memory.h" -#include "modules/physicaldisplay/physicaldisplay.h" +#include "modules/monitor/monitor.h" #include "modules/opengl/opengl.h" #include "modules/opencl/opencl.h" #include "modules/os/os.h" diff --git a/src/modules/physicaldisplay/physicaldisplay.c b/src/modules/monitor/monitor.c similarity index 59% rename from src/modules/physicaldisplay/physicaldisplay.c rename to src/modules/monitor/monitor.c index a8e9b51ad..980223481 100644 --- a/src/modules/physicaldisplay/physicaldisplay.c +++ b/src/modules/monitor/monitor.c @@ -1,35 +1,34 @@ #include "common/printing.h" #include "common/jsonconfig.h" -#include "detection/physicaldisplay/physicaldisplay.h" -#include "modules/physicaldisplay/physicaldisplay.h" +#include "detection/monitor/monitor.h" +#include "modules/monitor/monitor.h" #include "util/stringUtils.h" #include -#define FF_PHYSICALDISPLAY_DISPLAY_NAME "Physical Display" -#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 7 +#define FF_MONITOR_NUM_FORMAT_ARGS 7 -void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) +void ffPrintMonitor(FFMonitorOptions* options) { - FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalDisplayResult)); + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMonitorResult)); - const char* error = ffDetectPhysicalDisplay(&result); + const char* error = ffDetectMonitor(&result); if(error) { - ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); + ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, "%s", error); return; } if(!result.length) { - ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No physical display detected"); + ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, "No physical display detected"); return; } uint8_t index = 0; FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); - FF_LIST_FOR_EACH(FFPhysicalDisplayResult, display, result) + FF_LIST_FOR_EACH(FFMonitorResult, display, result) { double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4; double ppi = sqrt(display->width * display->width + display->height * display->height) / inch; @@ -39,7 +38,7 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) ffStrbufClear(&key); if(options->moduleArgs.key.length == 0) { - ffStrbufAppendF(&key, "%s (%s)", FF_PHYSICALDISPLAY_DISPLAY_NAME, display->name.chars); + ffStrbufAppendF(&key, "%s (%s)", FF_MONITOR_MODULE_NAME, display->name.chars); } else { @@ -57,7 +56,7 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) } else { - ffPrintFormat(FF_PHYSICALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormat(FF_MONITOR_MODULE_NAME, index, &options->moduleArgs, FF_MONITOR_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, {FF_FORMAT_ARG_TYPE_UINT, &display->width}, {FF_FORMAT_ARG_TYPE_UINT, &display->height}, @@ -72,15 +71,15 @@ void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options) } } -void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options) +void ffInitMonitorOptions(FFMonitorOptions* options) { - options->moduleName = FF_PHYSICALDISPLAY_MODULE_NAME; + options->moduleName = FF_MONITOR_MODULE_NAME; ffOptionInitModuleArg(&options->moduleArgs); } -bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value) +bool ffParseMonitorCommandOptions(FFMonitorOptions* options, const char* key, const char* value) { - const char* subKey = ffOptionTestPrefix(key, FF_PHYSICALDISPLAY_MODULE_NAME); + const char* subKey = ffOptionTestPrefix(key, FF_MONITOR_MODULE_NAME); if (!subKey) return false; if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; @@ -88,15 +87,15 @@ bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, con return false; } -void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options) +void ffDestroyMonitorOptions(FFMonitorOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); } -void ffParsePhysicalDisplayJsonObject(yyjson_val* module) +void ffParseMonitorJsonObject(yyjson_val* module) { - FFPhysicalDisplayOptions __attribute__((__cleanup__(ffDestroyPhysicalDisplayOptions))) options; - ffInitPhysicalDisplayOptions(&options); + FFMonitorOptions __attribute__((__cleanup__(ffDestroyMonitorOptions))) options; + ffInitMonitorOptions(&options); if (module) { @@ -111,9 +110,9 @@ void ffParsePhysicalDisplayJsonObject(yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs)) continue; - ffPrintError(FF_PHYSICALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); + ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key); } } - ffPrintPhysicalDisplay(&options); + ffPrintMonitor(&options); } diff --git a/src/modules/monitor/monitor.h b/src/modules/monitor/monitor.h new file mode 100644 index 000000000..a95a3fa74 --- /dev/null +++ b/src/modules/monitor/monitor.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_MONITOR_MODULE_NAME "Monitor" + +void ffPrintMonitor(FFMonitorOptions* options); +void ffInitMonitorOptions(FFMonitorOptions* options); +bool ffParseMonitorCommandOptions(FFMonitorOptions* options, const char* key, const char* value); +void ffDestroyMonitorOptions(FFMonitorOptions* options); +void ffParseMonitorJsonObject(yyjson_val* module); diff --git a/src/modules/physicaldisplay/option.h b/src/modules/monitor/option.h similarity index 73% rename from src/modules/physicaldisplay/option.h rename to src/modules/monitor/option.h index 3930a6253..ee2efc964 100644 --- a/src/modules/physicaldisplay/option.h +++ b/src/modules/monitor/option.h @@ -4,8 +4,8 @@ #include "common/option.h" -typedef struct FFPhysicalDisplayOptions +typedef struct FFMonitorOptions { const char* moduleName; FFModuleArgs moduleArgs; -} FFPhysicalDisplayOptions; +} FFMonitorOptions; diff --git a/src/modules/options.h b/src/modules/options.h index 14e665539..fbd845d3a 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -29,7 +29,7 @@ #include "modules/localip/option.h" #include "modules/media/option.h" #include "modules/memory/option.h" -#include "modules/physicaldisplay/option.h" +#include "modules/monitor/option.h" #include "modules/opengl/option.h" #include "modules/opencl/option.h" #include "modules/os/option.h" diff --git a/src/modules/physicaldisplay/physicaldisplay.h b/src/modules/physicaldisplay/physicaldisplay.h deleted file mode 100644 index a63213d65..000000000 --- a/src/modules/physicaldisplay/physicaldisplay.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "fastfetch.h" - -#define FF_PHYSICALDISPLAY_MODULE_NAME "PhysicalDisplay" - -void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options); -void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options); -bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value); -void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options); -void ffParsePhysicalDisplayJsonObject(yyjson_val* module); From e7487e24ae48deb37f9e2425b02c928fb922cf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 20:05:39 +0800 Subject: [PATCH 453/493] DisplayServer (Linux): better rotation detection for X11 --- src/detection/displayserver/linux/xcb.c | 24 +++++++++++++++++++--- src/detection/displayserver/linux/xlib.c | 26 ++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index e27e5a174..7851afd05 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -184,6 +184,7 @@ typedef struct XcbRandrData //init per screen uint32_t defaultRefreshRate; + uint32_t defaultRotation; xcb_randr_get_screen_resources_reply_t* screenResources; } XcbRandrData; @@ -316,7 +317,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* data->defaultRefreshRate, (uint32_t) monitor->width, (uint32_t) monitor->height, - 0, + data->defaultRotation, &name, FF_DISPLAY_TYPE_UNKNOWN, !!monitor->primary, @@ -356,11 +357,28 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) if(screenInfoReply != NULL) { data->defaultRefreshRate = screenInfoReply->rate; + switch (screenInfoReply->rotation) + { + case XCB_RANDR_ROTATION_ROTATE_90: + data->defaultRotation = 90; + break; + case XCB_RANDR_ROTATION_ROTATE_180: + data->defaultRotation = 180; + break; + case XCB_RANDR_ROTATION_ROTATE_270: + data->defaultRotation = 270; + break; + default: + data->defaultRotation = 0; + break; + } free(screenInfoReply); } else + { data->defaultRefreshRate = 0; - + data->defaultRotation = 0; + } //Init screen resources. They are used to iterate over all modes. xcbRandrHandleMode checks for " == NULL", to fail as late as possible. xcb_randr_get_screen_resources_cookie_t screenResourcesCookie = data->ffxcb_randr_get_screen_resources(data->connection, screen->root); data->screenResources = data->ffxcb_randr_get_screen_resources_reply(data->connection, screenResourcesCookie, NULL); @@ -381,7 +399,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) data->defaultRefreshRate, (uint32_t) screen->width_in_pixels, (uint32_t) screen->height_in_pixels, - 0, + data->defaultRotation, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 7bccf5faa..3a1ab03ca 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -132,6 +132,7 @@ typedef struct XrandrData //Init per screen uint32_t defaultRefreshRate; + uint32_t defaultRotation; XRRScreenResources* screenResources; } XrandrData; @@ -223,7 +224,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) data->defaultRefreshRate, (uint32_t) monitorInfo->width, (uint32_t) monitorInfo->height, - 0, + data->defaultRotation, NULL, FF_DISPLAY_TYPE_UNKNOWN, !!monitorInfo->primary, @@ -259,10 +260,30 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) if(screenConfiguration != NULL) { data->defaultRefreshRate = (uint32_t) data->ffXRRConfigCurrentRate(screenConfiguration); + Rotation rotation = 0; + data->ffXRRConfigCurrentConfiguration(screenConfiguration, &rotation); + switch (rotation) + { + case RR_Rotate_90: + data->defaultRotation = 90; + break; + case RR_Rotate_180: + data->defaultRotation = 180; + break; + case RR_Rotate_270: + data->defaultRotation = 270; + break; + default: + data->defaultRotation = 0; + break; + } data->ffXRRFreeScreenConfigInfo(screenConfiguration); } else + { data->defaultRefreshRate = 0; + data->defaultRotation = 0; + } //Init screen resources data->screenResources = data->ffXRRGetScreenResources(data->display, RootWindowOfScreen(screen)); @@ -282,7 +303,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) data->defaultRefreshRate, (uint32_t) WidthOfScreen(screen), (uint32_t) HeightOfScreen(screen), - 0, + data->defaultRotation, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, @@ -301,6 +322,7 @@ void ffdsConnectXrandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenInfo,) FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentRate,); + FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentConfiguration,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetMonitors,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenResources,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputInfo,); From fada8113c1481aee969ac615156d075be38da181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 21:56:40 +0800 Subject: [PATCH 454/493] DisplayServer (Linux): get EDID (WIP) --- src/detection/displayserver/linux/xcb.c | 32 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 7851afd05..b8fd28ddc 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -154,6 +154,7 @@ void ffdsConnectXcb(FFDisplayServerResult* result) #endif #ifdef FF_HAVE_XCB_RANDR +#include "util/edidHelper.h" #include typedef struct XcbRandrData @@ -175,7 +176,12 @@ typedef struct XcbRandrData FF_LIBRARY_SYMBOL(xcb_randr_get_output_info_reply) FF_LIBRARY_SYMBOL(xcb_randr_get_crtc_info) FF_LIBRARY_SYMBOL(xcb_randr_get_crtc_info_reply) - FF_LIBRARY_SYMBOL(xcb_get_atom_name) + FF_LIBRARY_SYMBOL(xcb_randr_get_output_property) + FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_reply) + FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_data) + FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_data_length) + FF_LIBRARY_SYMBOL(xcb_intern_atom) + FF_LIBRARY_SYMBOL(xcb_intern_atom_reply) //init once xcb_connection_t* connection; @@ -271,13 +277,25 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary) { xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME); - xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL); + FF_AUTO_FREE xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL); if(outputInfoReply == NULL) return false; - bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary); + xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen("EDID"), "EDID"); + FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL); - free(outputInfoReply); + xcb_randr_get_output_property_cookie_t outputPropertyCookie = data->ffxcb_randr_get_output_property(data->connection, output, requestAtomReply->atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 100, false, false); + FF_AUTO_FREE xcb_randr_get_output_property_reply_t* outputPropertyReply = data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL); + if(outputPropertyReply) + { + if(data->ffxcb_randr_get_output_property_data_length(outputPropertyReply) >= 128) + { + ffStrbufClear(name); + ffEdidGetName(data->ffxcb_randr_get_output_property_data(outputPropertyReply), name); + } + } + + bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary); return res; } @@ -418,6 +436,8 @@ void ffdsConnectXcbRandr(FFDisplayServerResult* result) XcbRandrData data; + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom,) + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom_reply,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_reply,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_modes_iterator,) @@ -433,6 +453,10 @@ void ffdsConnectXcbRandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_output_next,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info_reply,) + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property,) + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_reply,) + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data,) + FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data_length,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info,) FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info_reply,) From 3bab3eddfc4b4bdcf1a33b1b43706ffbd8f6a7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 9 Aug 2023 22:59:23 +0800 Subject: [PATCH 455/493] EdidHelper: use vendor / model id if model name is not set in EDID --- src/util/edidHelper.c | 25 +++++++++++++++++++++---- src/util/edidHelper.h | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 0537907ba..3b44f3556 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -7,24 +7,41 @@ void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint3 *height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; } -void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) +void ffEdidGetVendorAndModel(const uint8_t edid[128], FFstrbuf* result) +{ + // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c + ffStrbufAppendF(result, "%c%c%c%04X", + (char) (((uint32_t)edid[8] >> 2 & 0x1f) + 'A' - 1), + (char) (((((uint32_t)edid[8] & 0x3) << 3) | (((uint32_t)edid[9] & 0xe0) >> 5)) + 'A' - 1), + (char) (((uint32_t)edid[9] & 0x1f) + 'A' - 1), + (uint32_t) (edid[10] + (uint32_t) (edid[11] << 8)) + ); +} + +bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) { // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c for (uint32_t i = 0x36; i < 0x7E; i += 0x12) { // read through descriptor blocks... if (edid[i] == 0x00) { // not a timing descriptor - if (edid[i+3] == 0xfc) + if (edid[i + 3] == 0xfc) { // Model Name tag for (uint32_t j = 0; j < 13; j++) { if (edid[i + 5 + j] == 0x0a) - return; - ffStrbufAppendC(name, (char) edid[i + 5 + j]); + { + ffStrbufAppendNS(name, j, (const char*) &edid[i + 5]); + return true; + } } } } } + + // use manufacturer + model number as monitor name + ffEdidGetVendorAndModel(edid, name); + return false; } void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 4081dceba..1c424e1f4 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -6,7 +6,8 @@ #include #include "util/FFstrbuf.h" -void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); +void ffEdidGetVendorAndModel(const uint8_t edid[128], FFstrbuf* result); +bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm From 33dc097c3f4c4ed5de8930df2a241faa29ac75f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 09:35:00 +0800 Subject: [PATCH 456/493] DisplayServer (Linux): get EDID --- src/detection/displayserver/linux/xcb.c | 16 ++++++----- src/detection/displayserver/linux/xlib.c | 34 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index b8fd28ddc..d968bfbad 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -283,15 +283,17 @@ static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen("EDID"), "EDID"); FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL); - - xcb_randr_get_output_property_cookie_t outputPropertyCookie = data->ffxcb_randr_get_output_property(data->connection, output, requestAtomReply->atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 100, false, false); - FF_AUTO_FREE xcb_randr_get_output_property_reply_t* outputPropertyReply = data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL); - if(outputPropertyReply) + if(requestAtomReply) { - if(data->ffxcb_randr_get_output_property_data_length(outputPropertyReply) >= 128) + xcb_randr_get_output_property_cookie_t outputPropertyCookie = data->ffxcb_randr_get_output_property(data->connection, output, requestAtomReply->atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 100, false, false); + FF_AUTO_FREE xcb_randr_get_output_property_reply_t* outputPropertyReply = data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL); + if(outputPropertyReply) { - ffStrbufClear(name); - ffEdidGetName(data->ffxcb_randr_get_output_property_data(outputPropertyReply), name); + if(data->ffxcb_randr_get_output_property_data_length(outputPropertyReply) >= 128) + { + ffStrbufClear(name); + ffEdidGetName(data->ffxcb_randr_get_output_property_data(outputPropertyReply), name); + } } } diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 3a1ab03ca..19b6fee37 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -109,16 +109,20 @@ void ffdsConnectXlib(FFDisplayServerResult* result) #endif //FF_HAVE_X11 #ifdef FF_HAVE_XRANDR +#include "util/edidHelper.h" #include typedef struct XrandrData { + FF_LIBRARY_SYMBOL(XInternAtom) + FF_LIBRARY_SYMBOL(XGetAtomName); FF_LIBRARY_SYMBOL(XRRGetScreenInfo) FF_LIBRARY_SYMBOL(XRRConfigCurrentConfiguration) FF_LIBRARY_SYMBOL(XRRConfigCurrentRate) FF_LIBRARY_SYMBOL(XRRGetMonitors) FF_LIBRARY_SYMBOL(XRRGetScreenResources) FF_LIBRARY_SYMBOL(XRRGetOutputInfo) + FF_LIBRARY_SYMBOL(XRRGetOutputProperty) FF_LIBRARY_SYMBOL(XRRGetCrtcInfo) FF_LIBRARY_SYMBOL(XRRFreeCrtcInfo) FF_LIBRARY_SYMBOL(XRRFreeOutputInfo) @@ -149,7 +153,7 @@ static double xrandrHandleMode(XrandrData* data, RRMode mode) return data->defaultRefreshRate; } -static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary) +static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, FFstrbuf* name, bool primary) { //We do the check here, because we want the best fallback display if this call failed if(data->screenResources == NULL) @@ -184,7 +188,7 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary) (uint32_t) crtcInfo->width, (uint32_t) crtcInfo->height, rotation, - NULL, + name, FF_DISPLAY_TYPE_UNKNOWN, primary, 0 @@ -194,13 +198,27 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary) return res; } -static bool xrandrHandleOutput(XrandrData* data, RROutput output, bool primary) +static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name, bool primary) { XRROutputInfo* outputInfo = data->ffXRRGetOutputInfo(data->display, data->screenResources, output); if(outputInfo == NULL) return false; - bool res = xrandrHandleCrtc(data, outputInfo->crtc, primary); + Atom atomEdid = data->ffXInternAtom(data->display, "EDID", true); + if (atomEdid != None) + { + unsigned long nitems = 0; + uint8_t* edidData = NULL; + if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, 0, 0, AnyPropertyType, NULL, NULL, &nitems, NULL, &edidData) == Success) + { + if (nitems >= 128) + { + ffStrbufClear(name); + ffEdidGetName(edidData, name); + } + } + } + bool res = xrandrHandleCrtc(data, outputInfo->crtc, name, primary); data->ffXRRFreeOutputInfo(outputInfo); @@ -211,9 +229,10 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) { bool foundOutput = false; + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(data->ffXGetAtomName(data->display, monitorInfo->name)); for(int i = 0; i < monitorInfo->noutput; i++) { - if(xrandrHandleOutput(data, monitorInfo->outputs[i], monitorInfo->primary)) + if(xrandrHandleOutput(data, monitorInfo->outputs[i], &name, monitorInfo->primary)) foundOutput = true; } @@ -225,7 +244,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) (uint32_t) monitorInfo->width, (uint32_t) monitorInfo->height, data->defaultRotation, - NULL, + &name, FF_DISPLAY_TYPE_UNKNOWN, !!monitorInfo->primary, 0 @@ -320,12 +339,15 @@ void ffdsConnectXrandr(FFDisplayServerResult* result) XrandrData data; + FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XInternAtom,); + FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XGetAtomName,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenInfo,) FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentRate,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentConfiguration,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetMonitors,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenResources,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputInfo,); + FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputProperty,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetCrtcInfo,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeCrtcInfo,); FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeOutputInfo,); From 2f2856eacb177d2cc794429a9599b9773cbebff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 09:58:31 +0800 Subject: [PATCH 457/493] Display (Linux): detect monitor name for wayland --- src/detection/displayserver/linux/wayland.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 814129e8a..9f259a104 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -32,6 +32,8 @@ typedef struct WaylandDisplay enum wl_output_transform transform; FFDisplayType type; FFstrbuf name; + FFstrbuf description; + FFstrbuf vendorAndModelId; } WaylandDisplay; #ifndef __FreeBSD__ @@ -90,6 +92,8 @@ static void waylandOutputGeometryListener(void *data, { WaylandDisplay* display = data; display->transform = (enum wl_output_transform) transform; + ffStrbufAppendS(&display->vendorAndModelId, make); + ffStrbufAppendS(&display->vendorAndModelId, model); } static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name) @@ -102,6 +106,13 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp ffStrbufAppendS(&display->name, name); } +static void waylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED struct wl_output* wl_output, const char* description) +{ + WaylandDisplay* display = data; + while (*description == ' ') ++description; + ffStrbufAppendS(&display->description, description); +} + static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) { struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL); @@ -117,6 +128,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist .type = FF_DISPLAY_TYPE_UNKNOWN, }; ffStrbufInit(&display.name); + ffStrbufInit(&display.description); + ffStrbufInit(&display.vendorAndModelId); // Dirty hack for #477 // The order of these callbacks MUST follow `struct wl_output_listener` @@ -126,7 +139,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist stubListener, // done waylandOutputScaleListener, // scale waylandOutputNameListener, // name - stubListener, // description + waylandOutputDescriptionListener, // description }; static_assert( sizeof(outputListener) >= sizeof(struct wl_output_listener), @@ -185,7 +198,10 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist (uint32_t) (display.width / display.scale), (uint32_t) (display.height / display.scale), rotation, - &display.name, + display.description.length + ? &display.description + : display.vendorAndModelId.length + ? &display.vendorAndModelId : &display.name, display.type, false, 0 From 3bd4694a521de0158364b09bffb1ee50e93b90c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 10:12:25 +0800 Subject: [PATCH 458/493] Display (Linux): detect monitor name when using DRM --- .../displayserver/linux/displayserver_linux.c | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 13ffcf5e6..3c93d29c0 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -1,4 +1,6 @@ #include "displayserver_linux.h" +#include "common/io/io.h" +#include "util/edidHelper.h" #include "util/stringUtils.h" #include @@ -37,14 +39,25 @@ static void parseDRM(FFDisplayServerResult* result) int scanned = fscanf(modeFile, "%ux%u", &width, &height); if(scanned == 2 && width > 0 && height > 0) { - const char* plainName = entry->d_name; - if (ffStrStartsWith(plainName, "card")) + ffStrbufSubstrBefore(&drmDir, drmDirLength); + ffStrbufAppendS(&drmDir, entry->d_name); + ffStrbufAppendS(&drmDir, "/edid"); + + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); + uint8_t edidData[128]; + if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) == sizeof(edidData)) + ffEdidGetName(edidData, &name); + else { - const char* tmp = strchr(plainName + strlen("card"), '-'); - if (tmp) plainName = tmp + 1; + const char* plainName = entry->d_name; + if (ffStrStartsWith(plainName, "card")) + { + const char* tmp = strchr(plainName + strlen("card"), '-'); + if (tmp) plainName = tmp + 1; + } + ffStrbufAppendS(&name, plainName); } - FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(plainName); ffdsAppendDisplay( result, width, height, From b4ad245212208cca8808c0976d07595c9df71750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 10:15:02 +0800 Subject: [PATCH 459/493] Monitor (Linux): detect monitor name --- src/detection/monitor/monitor_linux.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/detection/monitor/monitor_linux.c b/src/detection/monitor/monitor_linux.c index 9bbc7f6b7..cca0c7de3 100644 --- a/src/detection/monitor/monitor_linux.c +++ b/src/detection/monitor/monitor_linux.c @@ -39,17 +39,11 @@ const char* ffDetectMonitor(FFlist* results) ffEdidGetPhysicalResolution(edidData, &width, &height); if (width != 0 && height != 0) { - const char* plainName = entry->d_name; - if (ffStrStartsWith(plainName, "card")) - { - const char* tmp = strchr(plainName + strlen("card"), '-'); - if (tmp) plainName = tmp + 1; - } - FFMonitorResult* display = (FFMonitorResult*) ffListAdd(results); display->width = width; display->height = height; - ffStrbufInitS(&display->name, plainName); + ffStrbufInit(&display->name); + ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); } From e0c59b939506da5ea521a0608901ed7ef903a552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 10:39:48 +0800 Subject: [PATCH 460/493] Brightness (Linux): try detect monitor name --- src/detection/brightness/brightness_linux.c | 76 +++++++-------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 8f3e0f4c9..5168dd0d6 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -1,5 +1,6 @@ #include "brightness.h" #include "common/io/io.h" +#include "util/edidHelper.h" #include "util/stringUtils.h" #include @@ -45,9 +46,29 @@ static const char* detectWithBacklight(FFlist* result) if(realpath(backlightDir.chars, brightness->name.chars)) { ffStrbufRecalculateLength(&brightness->name); - ffStrbufSubstrAfterLastC(&brightness->name, '/'); - if(ffStrbufStartsWithS(&brightness->name, "card") && isdigit(brightness->name.chars[4])) - ffStrbufSubstrAfterFirstC(&brightness->name, '-'); + // if we managed to get edid, use it + ffStrbufAppendS(&brightness->name, "/edid"); + uint8_t edidData[128]; + if(ffReadFileData(brightness->name.chars, sizeof(edidData), edidData) == sizeof(edidData)) + { + ffStrbufClear(&brightness->name); + ffEdidGetName(edidData, &brightness->name); + } + else + { + ffStrbufSubstrBeforeLastC(&brightness->name, '/'); // remove "/edid" + ffStrbufSubstrAfterLastC(&brightness->name, '/'); // try getting DRM connector name + if(ffStrbufStartsWithS(&brightness->name, "0000:")) + { + // PCI address, give up + ffStrbufSetS(&brightness->name, entry->d_name); + } + else + { + if(ffStrbufStartsWithS(&brightness->name, "card") && isdigit(brightness->name.chars[4])) + ffStrbufSubstrAfterFirstC(&brightness->name, '-'); + } + } } else ffStrbufInitS(&brightness->name, entry->d_name); @@ -70,44 +91,6 @@ static const char* detectWithBacklight(FFlist* result) #include -static bool findDrmByEdid(const uint8_t srcEdidData[128], FFstrbuf* result) -{ - const char* drmDirPath = "/sys/class/drm/"; - - DIR* dirp = opendir(drmDirPath); - if(dirp == NULL) - return false; - - FF_STRBUF_AUTO_DESTROY drmDir = ffStrbufCreateA(64); - ffStrbufAppendS(&drmDir, drmDirPath); - - uint32_t drmDirLength = drmDir.length; - - struct dirent* entry; - while((entry = readdir(dirp)) != NULL) - { - if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, "..")) - continue; - - ffStrbufAppendS(&drmDir, entry->d_name); - ffStrbufAppendS(&drmDir, "/edid"); - - uint8_t edidData[128]; - if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData)) - { - ffStrbufSubstrBefore(&drmDir, drmDirLength); - continue; - } - if (memcmp(srcEdidData, edidData, sizeof(edidData)) == 0) - { - ffStrbufAppendS(result, entry->d_name); - closedir(dirp); - return true; - } - } - return false; -} - static const char* detectWithDdcci(FFlist* result) { FF_LIBRARY_LOAD(libddcutil, &instance.config.libDdcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 4); @@ -141,16 +124,7 @@ static const char* detectWithDdcci(FFlist* result) FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); brightness->value = (float) current * 100.f / (float) max; - ffStrbufInit(&brightness->name); - if (findDrmByEdid(display->edid_bytes, &brightness->name)) - { - if (ffStrbufStartsWithS(&brightness->name, "card")) - ffStrbufSubstrAfterFirstC(&brightness->name, '-'); - } - else - { - ffStrbufAppendS(&brightness->name, display->model_name); - } + ffStrbufInitS(&brightness->name, display->model_name); } ffddca_close_display(handle); } From 77f79dc5d7db71c871426d30ccb44e490e78b294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 10:51:25 +0800 Subject: [PATCH 461/493] Doc: update changelog, metion `libm` usage --- CHANGELOG.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83308f87c..b2ca60035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Changes: * Change `--terminal-font-*` to `--terminalfont-*`. Affect `key` and `format` (TerminalFont) * Module `Command` uses `/bin/sh` as the default shell on systems other than Windows (Command) * Fix M2 CPU temperature detection (CPU, macOS) +* Detect monitor name when available, instead of using DRM connector name (Display / Brightness, Linux) Features: * FreeBSD support is improved greatly, and actually tested in a physical machine diff --git a/README.md b/README.md index c84ccf393..f2076ae90 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ A new, structure based, and user-friendly config file format was introduced in v ## Dependencies -Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most Linux distributions. +Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl`, `libm` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most Linux distributions. The following libraries are used if present at runtime: From f478b5bfb36f124190d435a8fe874aed07cee5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 11:11:44 +0800 Subject: [PATCH 462/493] Monitor: add to `presets/all` --- presets/all | 2 +- presets/all.jsonc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/presets/all b/presets/all index 506ee7a65..48d24b4a7 100644 --- a/presets/all +++ b/presets/all @@ -1 +1 @@ ---structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors +--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:Monitor:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors diff --git a/presets/all.jsonc b/presets/all.jsonc index 3659006d0..a1e722fae 100644 --- a/presets/all.jsonc +++ b/presets/all.jsonc @@ -15,6 +15,7 @@ "shell", "display", "brightness", + "monitor", "lm", "de", "wm", From 8151848a5adaa1f0e8971c00fa16fbc4c6adeb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 13:49:05 +0800 Subject: [PATCH 463/493] Logo (Builtin): more --- src/logo/ascii/salix.txt | 18 +++++ src/logo/builtin.c | 139 +++++++++++++++++++++------------------ 2 files changed, 92 insertions(+), 65 deletions(-) create mode 100644 src/logo/ascii/salix.txt diff --git a/src/logo/ascii/salix.txt b/src/logo/ascii/salix.txt new file mode 100644 index 000000000..828e4783d --- /dev/null +++ b/src/logo/ascii/salix.txt @@ -0,0 +1,18 @@ + __s_aaaaaaaaauuoXSSSSSSSS: + ._xSSSSSSSSSSSSSSSSSSSSSSSSSS: + _aSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: + _xSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: + + nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS} + nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS}` + XSSSSSSSSSSSSSSSSSSSSSSSSSSSS"` + SSSSSSSSSSSSSSSSSSSSSSSSS!"` +-""""""""""""""""""""""` diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 84a2d5934..15257b4e9 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2239,71 +2239,6 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, - // Windows11 - { - .names = {"Windows 11", "Windows Server 2022"}, - .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11, - .colors = { - FF_COLOR_FG_BLUE, - FF_COLOR_FG_BLUE, - FF_COLOR_FG_BLUE, - FF_COLOR_FG_BLUE, - }, - .colorKeys = FF_COLOR_FG_YELLOW, - .colorTitle = FF_COLOR_FG_CYAN, - }, - // Windows11Small - { - .names = {"Windows 11_small", "Windows 11-small"}, - .small = true, - .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL, - .colors = { - FF_COLOR_FG_BLUE, - }, - .colorKeys = FF_COLOR_FG_YELLOW, - .colorTitle = FF_COLOR_FG_CYAN, - }, - // Windows8 - { - .names = {"Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019"}, - .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_8, - .colors = { - FF_COLOR_FG_CYAN, - FF_COLOR_FG_CYAN, - FF_COLOR_FG_CYAN, - FF_COLOR_FG_CYAN, - }, - .colorKeys = FF_COLOR_FG_YELLOW, - .colorTitle = FF_COLOR_FG_WHITE, - }, - // Windows - { - .names = {"Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2"}, - .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS, - .colors = { - FF_COLOR_FG_RED, - FF_COLOR_FG_GREEN, - FF_COLOR_FG_BLUE, - FF_COLOR_FG_YELLOW, - }, - .colorKeys = FF_COLOR_FG_BLUE, - .colorTitle = FF_COLOR_FG_GREEN, - }, - // Windows95 - { - .names = {"Windows 95", "Windows 9x"}, - .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_95, - .colors = { - FF_COLOR_FG_CYAN, - FF_COLOR_FG_BLUE, - FF_COLOR_FG_YELLOW, - FF_COLOR_FG_GREEN, - FF_COLOR_FG_RED, - FF_COLOR_FG_BLACK, - }, - .colorKeys = FF_COLOR_FG_CYAN, - .colorTitle = FF_COLOR_FG_BLUE, - }, // NixOS { .names = {"NixOS", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"}, @@ -3172,6 +3107,15 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // Salix + { + .names = {"Salix"}, + .lines = FASTFETCH_DATATEXT_LOGO_SALIX, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_GREEN, + }, + }, // SambaBOX { .names = {"SambaBOX", "Profelis SambaBOX"}, @@ -3750,6 +3694,71 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // Windows11 + { + .names = {"Windows 11", "Windows Server 2022"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // Windows11Small + { + .names = {"Windows 11_small", "Windows 11-small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // Windows8 + { + .names = {"Windows 8", "Windows 8.1", "Windows 10", "Windows Server 2012", "Windows Server 2012 R2", "Windows Server 2016", "Windows Server 2019"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_8, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_WHITE, + }, + // Windows + { + .names = {"Windows", "Windows 7", "Windows Server 2008", "Windows Server 2008 R2"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // Windows95 + { + .names = {"Windows 95", "Windows 9x"}, + .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_95, + .colors = { + FF_COLOR_FG_CYAN, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_GREEN, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLACK, + }, + .colorKeys = FF_COLOR_FG_CYAN, + .colorTitle = FF_COLOR_FG_BLUE, + }, // Xferience { .names = {"Xferience"}, From 0f8d757950d48f3a7dea216081a7da62dbe408d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 15:47:19 +0800 Subject: [PATCH 464/493] Logo (Builtin): improve searching performance --- src/logo/ascii/suse.txt | 11 + src/logo/builtin.c | 468 +++++++++++++++++++++++++++++++--------- src/logo/logo.c | 58 ++--- src/logo/logo.h | 4 +- 4 files changed, 417 insertions(+), 124 deletions(-) create mode 100644 src/logo/ascii/suse.txt diff --git a/src/logo/ascii/suse.txt b/src/logo/ascii/suse.txt new file mode 100644 index 000000000..fc2128f65 --- /dev/null +++ b/src/logo/ascii/suse.txt @@ -0,0 +1,11 @@ + kKKKKKd' Okxol:;,. +kKKKKKKK0kOKKKKKKKKKKOxo:, +KKKKKKKKKKKKKKKKKKK0P^,,,^dx: +KKKKKKKKKKKKKKKKKKk'.oOPPb.'0k. +KKKKKKKKKKKKKKKKKK: kKx..dd lKd +KKKKKKKKKKKKOx0KKKd ^0KKKO' kKKc +KKKKKKKKKKKKK;.;oOKx,..^..;kKKK0. +KKKKKKKKKKKKK0o;...^cdxxOK0O/^^' +KKKKKKKKKKKKKKKKK0x;,,......,;od +kKKKKKKKKKKKKKKKKKKKKKKK00KKOo^ + kKKKKKOxddxkOO00000Okxoc;'' diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 15257b4e9..b88f8bb1f 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2,17 +2,17 @@ #include "logo_builtin.h" #include "common/color.h" -const FFlogo ffLogoBuiltins[] = { - // Unknown - { - .names = {"unknown", "question mark", "?"}, - .lines = FASTFETCH_DATATEXT_LOGO_UNKNOWN, - .colors = { - FF_COLOR_FG_WHITE, - }, - .colorKeys = "", - .colorTitle = "", +const FFlogo ffLogoUnknown = { + .names = {"unknown"}, + .lines = FASTFETCH_DATATEXT_LOGO_UNKNOWN, + .colors = { + FF_COLOR_FG_WHITE, }, + .colorKeys = "", + .colorTitle = "", +}; + +static const FFlogo A[] = { // AIX { .names = {"aix"}, @@ -201,6 +201,35 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_WHITE, }, + // Apple + { + .names = {"Apple"}, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // AppleSmall + { + .names = {"Apple_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, + }, // Apricity { .names = {"Apricity"}, @@ -433,6 +462,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_WHITE, }, + // Ataraxia + { + .names = {"Ataraxia Linux", "Ataraxia"}, + .lines = FASTFETCH_DATATEXT_LOGO_JANUSLINUX, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_MAGENTA, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_MAGENTA, + }, // Athena { .names = {"Athena"}, @@ -444,6 +484,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo B[] = { // Bedrock { .names = {"bedrock", "bedrocklinux", "bedrock-linux"}, @@ -547,7 +592,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Bonsai { - .names = {"bonsai"}, + .names = {"Bonsai"}, .lines = FASTFETCH_DATATEXT_LOGO_BONSAI, .colors = { FF_COLOR_FG_CYAN, @@ -559,7 +604,7 @@ const FFlogo ffLogoBuiltins[] = { }, // BSD { - .names = {"bsd"}, + .names = {"BSD"}, .lines = FASTFETCH_DATATEXT_LOGO_BSD, .colors = { FF_COLOR_FG_RED, @@ -581,9 +626,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo C[] = { // CachyOS { - .names = {"cachy", "cachyos", "cachy-linux", "cachyos-linux"}, + .names = {"Cachy", "cachyos", "cachy-linux", "cachyos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS, .colors = { FF_COLOR_FG_CYAN, @@ -595,7 +645,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CachyOSSmall { - .names = {"cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small"}, + .names = {"Cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL, .colors = { @@ -617,7 +667,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CalinixOS { - .names = {"calinix", "calinixos"}, + .names = {"Calinix", "calinixos"}, .lines = FASTFETCH_DATATEXT_LOGO_CALINIXOS, .colors = { FF_COLOR_FG_MAGENTA, @@ -627,7 +677,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CalinixOSSmall { - .names = {"calinix_small", "calinixos_small"}, + .names = {"Calinix_small", "calinixos_small"}, .lines = FASTFETCH_DATATEXT_LOGO_CALINIXOS_SMALL, .colors = { FF_COLOR_FG_MAGENTA, @@ -657,7 +707,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CelOS { - .names = {"cel", "celos", "cel-linux", "celos-linux"}, + .names = {"Cel", "celos", "cel-linux", "celos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CELOS, .colors = { FF_COLOR_FG_MAGENTA, @@ -678,7 +728,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CentOS { - .names = {"cent", "centos", "cent-linux", "centos-linux"}, + .names = {"Cent", "centos", "cent-linux", "centos-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CENTOS, .colors = { FF_COLOR_FG_YELLOW, @@ -692,7 +742,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CentOSSmall { - .names = {"cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small"}, + .names = {"Cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL, .colors = { @@ -772,7 +822,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CleanjaroSmall { - .names = {"cleanjaro_small"}, + .names = {"Cleanjaro_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_CLEANJARO_SMALL, .colors = { @@ -841,7 +891,7 @@ const FFlogo ffLogoBuiltins[] = { }, // ContainerLinux { - .names = {"Container Linux by CoreOS", "ContainerLinux", "Container Linux"}, + .names = {"ContainerLinux", "Container Linux", "Container Linux by CoreOS"}, .lines = FASTFETCH_DATATEXT_LOGO_CONTAINER_LINUX, .colors = { FF_COLOR_FG_BLUE, @@ -878,7 +928,7 @@ const FFlogo ffLogoBuiltins[] = { }, // CrystalLinux { - .names = {"crystal", "Crystal", "crystal-linux", "Crystal-Linux"}, + .names = {"Crystal", "Crystal", "crystal-linux", "Crystal-Linux"}, .lines = FASTFETCH_DATATEXT_LOGO_CRYSTAL, .colors = { FF_COLOR_FG_MAGENTA, @@ -931,6 +981,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_CYAN, }, + // LAST + {}, +}; + +static const FFlogo D[] = { // dahlia { .names = {"dahlia"}, @@ -957,7 +1012,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Debian { - .names = {"debian", "debian-linux"}, + .names = {"Debian", "debian-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN, .colors = { FF_COLOR_FG_RED, @@ -968,7 +1023,7 @@ const FFlogo ffLogoBuiltins[] = { }, // DebianSmall { - .names = {"debian_small", "debian-linux-small"}, + .names = {"Debian_small", "debian-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL, .colors = { @@ -1000,7 +1055,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Devuan { - .names = {"devuan", "devuan-linux"}, + .names = {"Devuan", "devuan-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN, .colors = { FF_COLOR_FG_MAGENTA, @@ -1010,7 +1065,7 @@ const FFlogo ffLogoBuiltins[] = { }, // DevuanSmall { - .names = {"devuan_small", "devuan-linux-small"}, + .names = {"Devuan_small", "devuan-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL, .colors = { @@ -1098,9 +1153,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_LIGHT_GREEN, }, + // LAST + {}, +}; + +static const FFlogo E[] = { // Elementary { - .names = {"elementary"}, + .names = {"Elementary"}, .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY, .colors = { FF_COLOR_FG_WHITE, @@ -1110,7 +1170,7 @@ const FFlogo ffLogoBuiltins[] = { }, // ElementarySmall { - .names = {"elementary_small", "elementary-small"}, + .names = {"Elementary_small", "elementary-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL, .colors = { @@ -1143,7 +1203,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Endeavour { - .names = {"endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, + .names = {"Endeavour", "endeavour-linux", "endeavouros", "endeavouros-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_ENDEAVOUR, .colors = { FF_COLOR_FG_MAGENTA, @@ -1166,7 +1226,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Enso { - .names = {"enso", "uqc"}, + .names = {"Enso"}, .lines = FASTFETCH_DATATEXT_LOGO_ENSO, .colors = { FF_COLOR_FG_WHITE, @@ -1196,7 +1256,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Exherbo { - .names = {"exherbo", "exherbo-linux"}, + .names = {"Exherbo", "exherbo-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_EXHERBO, .colors = { FF_COLOR_FG_BLUE, @@ -1216,9 +1276,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // LAST + {}, +}; + +static const FFlogo F[] = { // Fedora { - .names = {"fedora", "fedora-linux"}, + .names = {"Fedora", "fedora-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA, .colors = { FF_COLOR_FG_BLUE, @@ -1229,7 +1294,7 @@ const FFlogo ffLogoBuiltins[] = { }, // FedoraSmall { - .names = {"fedora_small", "fedora-linux-small"}, + .names = {"Fedora_small", "fedora-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL, .colors = { @@ -1240,7 +1305,7 @@ const FFlogo ffLogoBuiltins[] = { }, // FedoraOld { - .names = {"fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old"}, + .names = {"Fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old"}, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_OLD, .colors = { FF_COLOR_FG_BLUE, @@ -1292,7 +1357,7 @@ const FFlogo ffLogoBuiltins[] = { }, // FreeBSD { - .names = {"freebsd", "HardenedBSD"}, + .names = {"Freebsd"}, .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD, .colors = { FF_COLOR_FG_WHITE, @@ -1344,6 +1409,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo G[] = { // GalliumOS { .names = {"GalliumOS"}, @@ -1357,7 +1427,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Garuda { - .names = {"garuda", "garuda-linux"}, + .names = {"Garuda", "garuda-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA, .colors = { FF_COLOR_FG_RED, @@ -1367,7 +1437,7 @@ const FFlogo ffLogoBuiltins[] = { }, // GarudaDragon { - .names = {"garudadragon", "garuda-dragon", "garuda-linux-dragon"}, + .names = {"GarudaDragon", "garuda-dragon", "garuda-linux-dragon"}, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_DRAGON, .colors = { FF_COLOR_FG_RED, @@ -1377,7 +1447,7 @@ const FFlogo ffLogoBuiltins[] = { }, // GarudaSmall { - .names = {"garuda_small", "garudalinux_small", "garuda-linux-small"}, + .names = {"Garuda_small", "garudalinux_small", "garuda-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL, .colors = { @@ -1388,7 +1458,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Gentoo { - .names = {"gentoo", "gentoo-linux"}, + .names = {"Gentoo", "gentoo-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_GENTOO, .colors = { FF_COLOR_FG_MAGENTA, @@ -1399,7 +1469,7 @@ const FFlogo ffLogoBuiltins[] = { }, // GentooSmall { - .names = {"gentoo_small", "gentoo-linux-small"}, + .names = {"Gentoo_small", "gentoo-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL, .colors = { @@ -1411,7 +1481,7 @@ const FFlogo ffLogoBuiltins[] = { }, // GhostBSD { - .names = {"ghostbsd"}, + .names = {"GhostBSD"}, .lines = FASTFETCH_DATATEXT_LOGO_GHOSTBSD, .colors = { FF_COLOR_FG_BLUE, @@ -1511,6 +1581,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo H[] = { // Haiku { .names = {"Haiku"}, @@ -1559,15 +1634,25 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // HardenedBSD + { + .names = {"HardenedBSD"}, + .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_RED, + }, // Hash { .names = {"Hash"}, .lines = FASTFETCH_DATATEXT_LOGO_HASH, .colors = { FF_COLOR_FG_256 "123", + FF_COLOR_FG_256 "123", }, - .colorKeys = FF_COLOR_FG_256 "123", - .colorTitle = FF_COLOR_FG_256 "123", }, // Huayra { @@ -1621,6 +1706,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_LIGHT_BLACK, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo I[] = { // Iglunix { .names = {"Iglunix", "Iglu"}, @@ -1662,9 +1752,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_RED, }, + // LAST + {}, +}; + +static const FFlogo J[] = { // januslinux { - .names = {"januslinux", "janus", "Ataraxia Linux", "Ataraxia"}, + .names = {"januslinux", "janus"}, .lines = FASTFETCH_DATATEXT_LOGO_JANUSLINUX, .colors = { FF_COLOR_FG_BLUE, @@ -1673,6 +1768,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_MAGENTA, }, + // LAST + {}, +}; + +static const FFlogo K[] = { // Kaisen { .names = {"Kaisen"}, @@ -1686,7 +1786,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Kali { - .names = {"Kali", "Kalilinux", "Kali-linux"}, + .names = {"Kali", "Kalilinux"}, .lines = FASTFETCH_DATATEXT_LOGO_KALI, .colors = { FF_COLOR_FG_BLUE, @@ -1720,7 +1820,7 @@ const FFlogo ffLogoBuiltins[] = { }, // KDENeon { - .names = {"kde", "kde-neon", "neon"}, + .names = {"KDE", "kde-neon"}, .lines = FASTFETCH_DATATEXT_LOGO_KDE, .colors = { FF_COLOR_FG_GREEN, @@ -1742,7 +1842,7 @@ const FFlogo ffLogoBuiltins[] = { }, // KISSLinux { - .names = {"kiss", "kiss-linux", "kisslinux"}, + .names = {"KISS", "kiss-linux", "kisslinux"}, .lines = FASTFETCH_DATATEXT_LOGO_KISS, .colors = { FF_COLOR_FG_MAGENTA, @@ -1798,7 +1898,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Kubuntu { - .names = {"kubuntu", "kubuntu-linux", "kde-ubuntu", "ubuntu-kde", "ubuntu-plasma"}, + .names = {"Kubuntu", "kubuntu-linux", "kde-ubuntu"}, .lines = FASTFETCH_DATATEXT_LOGO_KUBUNTU, .colors = { FF_COLOR_FG_BLUE, @@ -1807,6 +1907,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // LAST + {}, +}; + +static const FFlogo L[] = { // LangitKetujuh { .names = {"langitketujuh", "l7"}, @@ -1856,7 +1961,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Linspire { - .names = {"Linspire", "Freespire", "Lindows"}, + .names = {"Linspire", "Lindows"}, .lines = FASTFETCH_DATATEXT_LOGO_LINSPIRE, .colors = { FF_COLOR_FG_BLUE, @@ -1867,7 +1972,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Linux { - .names = {"linux", "linux-generic"}, + .names = {"Linux", "linux-generic"}, .lines = FASTFETCH_DATATEXT_LOGO_LINUX, .colors = { FF_COLOR_FG_WHITE, @@ -1879,7 +1984,7 @@ const FFlogo ffLogoBuiltins[] = { }, // LinuxSmall { - .names = {"linux_small", "linux-generic_small"}, + .names = {"Linux_small", "linux-generic_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_LINUX_SMALL, .colors = { @@ -1913,6 +2018,40 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_WHITE, }, + // LinuxMint + { + .names = {"linuxmint", "linux-mint"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINT, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // LinuxMintSmall + { + .names = {"linuxmint_small", "linux-mint_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // LinuxMintOld + { + .names = {"linux-mint_old", "linux-mint-old"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // Live_Raizo { .names = {"Live Raizo", "Live_Raizo"}, @@ -1946,9 +2085,14 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // LAST + {}, +}; + +static const FFlogo M[] = { // MacOS { - .names = {"macos", "mac", "apple", "darwin", "osx"}, + .names = {"macos", "mac"}, .lines = FASTFETCH_DATATEXT_LOGO_MACOS, .colors = { FF_COLOR_FG_GREEN, @@ -1962,7 +2106,7 @@ const FFlogo ffLogoBuiltins[] = { }, // MacOSSmall { - .names = {"macos_small", "mac_small", "apple_small", "darwin_small", "osx_small"}, + .names = {"macos_small", "mac_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, .colors = { @@ -1977,7 +2121,7 @@ const FFlogo ffLogoBuiltins[] = { }, // MacOS2 { - .names = {"macos2", "mac2", "apple2", "darwin2", "osx2"}, + .names = {"macos2", "mac2"}, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2, .colors = { FF_COLOR_FG_GREEN, @@ -1991,7 +2135,7 @@ const FFlogo ffLogoBuiltins[] = { }, // MacOS2Small { - .names = {"macos2_small", "mac2_small", "apple2_small", "darwin2_small", "osx2_small"}, + .names = {"macos2_small", "mac2_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL, .colors = { @@ -2071,21 +2215,9 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, - // Minix - { - .names = {"minix"}, - .lines = FASTFETCH_DATATEXT_LOGO_MINIX, - .colors = { - FF_COLOR_FG_RED, - FF_COLOR_FG_WHITE, - FF_COLOR_FG_YELLOW, - }, - .colorKeys = FF_COLOR_FG_RED, - .colorTitle = FF_COLOR_FG_YELLOW, - }, // MassOS { - .names = {"massos", "mass"}, + .names = {"MassOS", "mass"}, .lines = FASTFETCH_DATATEXT_LOGO_MASSOS, .colors = { FF_COLOR_FG_WHITE, @@ -2139,7 +2271,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Mint { - .names = {"mint", "linuxmint", "mint-linux", "linux-mint"}, + .names = {"mint", "mint-linux"}, .lines = FASTFETCH_DATATEXT_LOGO_MINT, .colors = { FF_COLOR_FG_GREEN, @@ -2150,7 +2282,7 @@ const FFlogo ffLogoBuiltins[] = { }, // MintSmall { - .names = {"mint_small", "linuxmint_small", "mint-linux-small"}, + .names = {"mint_small", "mint-linux-small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, .colors = { @@ -2162,7 +2294,7 @@ const FFlogo ffLogoBuiltins[] = { }, // MintOld { - .names = {"mint_old", "mint-old", "mint-linux_old", "mint-linux-old", "linux-mint_old", "linux-mint-old"}, + .names = {"mint_old", "mint-old", "mint-linux_old", "mint-linux-old"}, .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, .colors = { FF_COLOR_FG_GREEN, @@ -2171,6 +2303,18 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // Minix + { + .names = {"Minix"}, + .lines = FASTFETCH_DATATEXT_LOGO_MINIX, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + FF_COLOR_FG_YELLOW, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, + }, // MiracleLinux { .names = {"MIRACLE LINUX", "miracle_linux"}, @@ -2183,7 +2327,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Msys2 { - .names = {"msys2"}, + .names = {"Msys2"}, .lines = FASTFETCH_DATATEXT_LOGO_MSYS2, .colors = { FF_COLOR_FG_MAGENTA, @@ -2193,6 +2337,31 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_RED, }, + // MX + { + .names = {"MX"}, + .lines = FASTFETCH_DATATEXT_LOGO_MX, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // MXSmall + { + .names = {"MX_small", "mx-small"}, + .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, + // LAST + {}, +}; + +static const FFlogo N[] = { // Namib { .names = {"Namib"}, @@ -2283,26 +2452,6 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, - // MX - { - .names = {"mx"}, - .lines = FASTFETCH_DATATEXT_LOGO_MX, - .colors = { - FF_COLOR_FG_WHITE, - }, - .colorKeys = FF_COLOR_FG_BLUE, - .colorTitle = FF_COLOR_FG_CYAN, - }, - // MXSmall - { - .names = {"mx_small", "mx-small"}, - .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, - .colors = { - FF_COLOR_FG_WHITE, - }, - .colorKeys = FF_COLOR_FG_BLUE, - .colorTitle = FF_COLOR_FG_CYAN, - }, // NetBSD { .names = {"netbsd"}, @@ -2352,6 +2501,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_RED, }, }, + // LAST + {}, +}; + +static const FFlogo O[] = { // Obarun { .names = {"Obarun"}, @@ -2454,7 +2608,7 @@ const FFlogo ffLogoBuiltins[] = { }, // OpenSuse { - .names = {"suse", "opensuse", "open_suse", "open-suse", "suse-linux"}, + .names = {"opensuse", "open_suse", "open-suse"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE, .colors = { FF_COLOR_FG_GREEN, @@ -2465,7 +2619,7 @@ const FFlogo ffLogoBuiltins[] = { }, // OpenSuseSmall { - .names = {"suse_small", "opensuse_small", "open_suse_small", "open-suse_small"}, + .names = {"opensuse_small", "open_suse_small", "open-suse_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, .colors = { @@ -2586,6 +2740,40 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // OSX + { + .names = {"OSX"}, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // OSXSmall + { + .names = {"OSX_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_YELLOW, + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_YELLOW, + .colorTitle = FF_COLOR_FG_GREEN, + }, + // LAST + {}, +}; + +static const FFlogo P[] = { // PacBSD { .names = {"PacBSD"}, @@ -2837,6 +3025,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // LAST + {}, +}; + +static const FFlogo Q[] = { // Q4OS { .names = {"Q4OS"}, @@ -2874,6 +3067,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // LAST + {}, +}; + +static const FFlogo R[] = { // Radix { .names = {"Radix"}, @@ -2885,7 +3083,7 @@ const FFlogo ffLogoBuiltins[] = { }, // Raspbian { - .names = {"raspbian", "raspi", "raspberrypi", "raspberrypios", "pios"}, + .names = {"raspbian", "raspi", "raspberrypi", "raspberrypios"}, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN, .colors = { FF_COLOR_FG_RED, @@ -2896,7 +3094,7 @@ const FFlogo ffLogoBuiltins[] = { }, // RaspbianSmall { - .names = {"raspbian_small", "raspi_small", "raspberrypi_small" "raspberrypios_small" "pios_small"}, + .names = {"raspbian_small", "raspi_small", "raspberrypi_small", "raspberrypios_small"}, .small = true, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL, .colors = { @@ -3059,6 +3257,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_256 "202", }, + // LAST + {}, +}; + +static const FFlogo S[] = { // Sabayon { .names = {"Sabayon"}, @@ -3348,6 +3551,25 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // Suse + { + .names = {"suse", "suse-linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_SUSE, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_GREEN, + }, + }, + // SuseSmall + { + .names = {"suse_small", "suse-linux_small"}, + .small = true, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_GREEN, + }, + }, // Swagarch { .names = {"Swagarch"}, @@ -3357,6 +3579,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // LAST + {}, +}; + +static const FFlogo T[] = { // T2 { .names = {"T2"}, @@ -3416,6 +3643,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_WHITE, }, }, + // LAST + {}, +}; + +static const FFlogo U[] = { // Ubuntu { .names = {"ubuntu", "ubuntu-linux"}, @@ -3429,7 +3661,7 @@ const FFlogo ffLogoBuiltins[] = { }, // UbuntuBudgie { - .names = {"ubuntu-budgie"}, + .names = {"ubuntu budgie", "ubuntu-budgie"}, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_BUDGIE, .colors = { FF_COLOR_FG_BLUE, @@ -3495,6 +3727,17 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_RED, }, + // UbuntuKde + { + .names = {"ubuntu kde", "ubuntu-kde", "ubuntu-plasma"}, + .lines = FASTFETCH_DATATEXT_LOGO_KUBUNTU, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_BLUE, + }, // UbuntuSmall { .names = {"ubuntu_small", "ubuntu-linux-small"}, @@ -3622,6 +3865,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_256 "52", }, }, + // LAST + {}, +}; + +static const FFlogo V[] = { // Vanilla { .names = {"vanilla", "vanilla-os", "vanilla-linux"}, @@ -3685,6 +3933,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_WHITE, .colorTitle = FF_COLOR_FG_GREEN, }, + // LAST + {}, +}; + +static const FFlogo W[] = { // WiiLinuxNgx { .names = {"WiiLinuxNgx"}, @@ -3759,6 +4012,11 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_BLUE, }, + // LAST + {}, +}; + +static const FFlogo X[] = { // Xferience { .names = {"Xferience"}, @@ -3768,6 +4026,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_CYAN, }, }, + // LAST + {}, +}; + +static const FFlogo Y[] = { // YiffOS { .names = {"YiffOS"}, @@ -3777,6 +4040,11 @@ const FFlogo ffLogoBuiltins[] = { FF_COLOR_FG_256 "92", }, }, + // LAST + {}, +}; + +static const FFlogo Z[] = { // Zorin { .names = {"zorin", "zorin-linux", "zorinos", "zorinos-linux"}, @@ -3787,6 +4055,10 @@ const FFlogo ffLogoBuiltins[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, + // LAST + {}, }; -const uint32_t ffLogoBuiltinLength = sizeof(ffLogoBuiltins) / sizeof(ffLogoBuiltins[0]); +const FFlogo* ffLogoBuiltins[] = { + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, +}; diff --git a/src/logo/logo.c b/src/logo/logo.c index 343eba264..c4da5f3d5 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -214,7 +214,7 @@ static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) if (name->length == 0) return NULL; - for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) + for(const FFlogo* logo = ffLogoBuiltins[toupper(name->chars[0]) - 'A']; *logo->names; ++logo) { switch (size) { @@ -259,7 +259,7 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) if(logo != NULL) return logo; - return &ffLogoBuiltins[0]; // Unknown + return &ffLogoUnknown; } static inline void logoApplyColorsDetected(void) @@ -507,42 +507,52 @@ void ffLogoBuiltinPrint(void) { FFLogoOptions* options = &instance.config.logo; - for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) + for(uint8_t ch = 0; ch < 26; ++ch) { - printf("\033[%sm%s:\033[0m\n", logo->colors[0], logo->names[0]); - logoPrintStruct(logo); - ffLogoPrintRemaining(); + for(const FFlogo* logo = ffLogoBuiltins[ch]; *logo->names; ++logo) + { + printf("\033[%sm%s:\033[0m\n", logo->colors[0], logo->names[0]); + logoPrintStruct(logo); + ffLogoPrintRemaining(); - //reset everything - instance.state.logoHeight = 0; - instance.state.keysHeight = 0; - for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) - ffStrbufClear(&options->colors[i]); + //reset everything + instance.state.logoHeight = 0; + instance.state.keysHeight = 0; + for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++) + ffStrbufClear(&options->colors[i]); - putchar('\n'); + putchar('\n'); + } } } void ffLogoBuiltinList(void) { - for(uint32_t counter = 0; counter < ffLogoBuiltinLength; ++counter) + uint32_t counter = 0; + for(uint8_t ch = 0; ch < 26; ++ch) { - const FFlogo* logo = &ffLogoBuiltins[counter]; - printf("%u)%s ", counter, counter < 10 ? " " : ""); + for(const FFlogo* logo = ffLogoBuiltins[ch]; *logo->names; ++logo) + { + ++counter; + printf("%u)%s ", counter, counter < 10 ? " " : ""); - for( - const char* const* names = logo->names; - *names != NULL && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; - ++names - ) - printf("\"%s\" ", *names); + for( + const char* const* names = logo->names; + *names != NULL && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES]; + ++names + ) + printf("\"%s\" ", *names); - putchar('\n'); + putchar('\n'); + } } } void ffLogoBuiltinListAutocompletion(void) { - for(const FFlogo* logo = ffLogoBuiltins; logo < ffLogoBuiltins + ffLogoBuiltinLength; ++logo) - printf("%s\n", logo->names[0]); + for(uint8_t ch = 0; ch < 26; ++ch) + { + for(const FFlogo* logo = ffLogoBuiltins[ch]; *logo->names; ++logo) + printf("%s\n", logo->names[0]); + } } diff --git a/src/logo/logo.h b/src/logo/logo.h index f80c6e79c..8b9a5d4ed 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -19,8 +19,8 @@ typedef struct FFlogo void ffLogoPrintChars(const char* data, bool doColorReplacement); //builtin.c -extern const FFlogo ffLogoBuiltins[]; -extern const uint32_t ffLogoBuiltinLength; +extern const FFlogo* ffLogoBuiltins[]; +extern const FFlogo ffLogoUnknown; //image/image.c bool ffLogoPrintImageIfExists(FFLogoType type, bool printError); From 75ba1161466b2a1c269a3565cf815bffab9de432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 16:19:03 +0800 Subject: [PATCH 465/493] Logo (Builtin): don't match alternate logos --- src/logo/builtin.c | 108 +++++++++++++++++++++++++-------------------- src/logo/logo.c | 5 ++- src/logo/logo.h | 9 +++- 3 files changed, 71 insertions(+), 51 deletions(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index b88f8bb1f..690146b97 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -51,7 +51,7 @@ static const FFlogo A[] = { // AlpineSmall { .names = {"alpine_small", "alpine-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ALPINE_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -63,7 +63,7 @@ static const FFlogo A[] = { // Alpine2Small { .names = {"alpine2_small", "alpine-linux2-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT | FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ALPINE2_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -129,7 +129,7 @@ static const FFlogo A[] = { // AndroidSmall { .names = {"android-small", "android_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ANDROID_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -218,7 +218,7 @@ static const FFlogo A[] = { // AppleSmall { .names = {"Apple_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -263,6 +263,7 @@ static const FFlogo A[] = { // Archcraft2 { .names = {"Archcraft2"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARCHCRAFT2, .colors = { FF_COLOR_FG_CYAN, @@ -284,6 +285,7 @@ static const FFlogo A[] = { // Arch2 { .names = {"arch2", "archlinux2", "arch-linux2"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARCH2, .colors = { FF_COLOR_FG_CYAN, @@ -295,7 +297,7 @@ static const FFlogo A[] = { // ArchSmall { .names = {"arch_small", "archlinux_small", "arch-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARCH_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -338,7 +340,7 @@ static const FFlogo A[] = { // ArtixSmall { .names = {"artix_small", "artixlinux_small", "artix-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARTIX_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -349,7 +351,7 @@ static const FFlogo A[] = { // Artix2Small { .names = {"artix2_small", "artixlinux2_small", "artix-linux2-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT | FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARTIX2_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -371,7 +373,7 @@ static const FFlogo A[] = { // ArcoLinuxSmall { .names = {"arco_small", "arcolinux_small", "arco-linux_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ARCO_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -646,7 +648,7 @@ static const FFlogo C[] = { // CachyOSSmall { .names = {"Cachy_small", "cachyos_small", "cachy-linux-small", "cachyos-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_CACHYOS_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -743,7 +745,7 @@ static const FFlogo C[] = { // CentOSSmall { .names = {"Cent_small", "centos_small", "cent-linux_small", "cent-linux-small", "centos-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_CENTOS_SMALL, .colors = { FF_COLOR_FG_YELLOW, @@ -823,7 +825,7 @@ static const FFlogo C[] = { // CleanjaroSmall { .names = {"Cleanjaro_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_CLEANJARO_SMALL, .colors = { FF_COLOR_FG_WHITE, @@ -916,7 +918,7 @@ static const FFlogo C[] = { // CRUXSmall { .names = {"CRUX_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_CRUX_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -1024,7 +1026,7 @@ static const FFlogo D[] = { // DebianSmall { .names = {"Debian_small", "debian-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_DEBIAN_SMALL, .colors = { FF_COLOR_FG_RED, @@ -1066,7 +1068,7 @@ static const FFlogo D[] = { // DevuanSmall { .names = {"Devuan_small", "devuan-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_DEVUAN_SMALL, .colors = { FF_COLOR_FG_MAGENTA, @@ -1110,7 +1112,7 @@ static const FFlogo D[] = { // DragonFlySmall { .names = {"DragonFly_small", "DragonFly-BSD_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_DRAGONFLY_SMALL, .colors = { FF_COLOR_FG_RED, @@ -1122,6 +1124,7 @@ static const FFlogo D[] = { // DragonFlyOld { .names = {"DragonFly_old", "DragonFly-BSD_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_DRAGONFLY_OLD, .colors = { FF_COLOR_FG_RED, @@ -1171,7 +1174,7 @@ static const FFlogo E[] = { // ElementarySmall { .names = {"Elementary_small", "elementary-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ELEMENTARY_SMALL, .colors = { FF_COLOR_FG_WHITE, @@ -1295,7 +1298,7 @@ static const FFlogo F[] = { // FedoraSmall { .names = {"Fedora_small", "fedora-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -1306,6 +1309,7 @@ static const FFlogo F[] = { // FedoraOld { .names = {"Fedora_old", "fedora-old", "fedora-linux-old", "fedora-linux_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_FEDORA_OLD, .colors = { FF_COLOR_FG_BLUE, @@ -1369,7 +1373,7 @@ static const FFlogo F[] = { // FreeBSDSmall { .names = {"freebsd_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_FREEBSD_SMALL, .colors = { FF_COLOR_FG_RED, @@ -1448,7 +1452,7 @@ static const FFlogo G[] = { // GarudaSmall { .names = {"Garuda_small", "garudalinux_small", "garuda-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_GARUDA_SMALL, .colors = { FF_COLOR_FG_RED, @@ -1470,7 +1474,7 @@ static const FFlogo G[] = { // GentooSmall { .names = {"Gentoo_small", "gentoo-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_GENTOO_SMALL, .colors = { FF_COLOR_FG_MAGENTA, @@ -1602,7 +1606,7 @@ static const FFlogo H[] = { // HaikuSmall { .names = {"Haiku-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_HAIKU_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -1698,7 +1702,7 @@ static const FFlogo H[] = { // HyperbolaSmall { .names = {"Hyperbola_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_HYPERBOLA_SMALL, .colors = { FF_COLOR_FG_LIGHT_BLACK, @@ -1798,7 +1802,7 @@ static const FFlogo K[] = { // KaliSmall { .names = {"Kali_small", "Kalilinux_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_KALI_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -1985,7 +1989,7 @@ static const FFlogo L[] = { // LinuxSmall { .names = {"Linux_small", "linux-generic_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_LINUX_SMALL, .colors = { FF_COLOR_FG_BLACK, @@ -2009,7 +2013,7 @@ static const FFlogo L[] = { // LinuxLightSmall { .names = {"LinuxLite_small", "Linux Lite_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_LINUXLITE_SMALL, .colors = { FF_COLOR_FG_YELLOW, @@ -2032,7 +2036,7 @@ static const FFlogo L[] = { // LinuxMintSmall { .names = {"linuxmint_small", "linux-mint_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2044,6 +2048,7 @@ static const FFlogo L[] = { // LinuxMintOld { .names = {"linux-mint_old", "linux-mint-old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, .colors = { FF_COLOR_FG_GREEN, @@ -2107,7 +2112,7 @@ static const FFlogo M[] = { // MacOSSmall { .names = {"macos_small", "mac_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2122,6 +2127,7 @@ static const FFlogo M[] = { // MacOS2 { .names = {"macos2", "mac2"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2, .colors = { FF_COLOR_FG_GREEN, @@ -2136,7 +2142,7 @@ static const FFlogo M[] = { // MacOS2Small { .names = {"macos2_small", "mac2_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT | FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MACOS2_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2207,7 +2213,7 @@ static const FFlogo M[] = { // ManjaroSmall { .names = {"manjaro_small", "manjaro-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MANJARO_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2283,7 +2289,7 @@ static const FFlogo M[] = { // MintSmall { .names = {"mint_small", "mint-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MINT_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2295,6 +2301,7 @@ static const FFlogo M[] = { // MintOld { .names = {"mint_old", "mint-old", "mint-linux_old", "mint-linux-old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MINT_OLD, .colors = { FF_COLOR_FG_GREEN, @@ -2433,6 +2440,7 @@ static const FFlogo N[] = { // NixOsOld { .names = {"nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_OLD, .colors = { FF_COLOR_FG_BLUE, @@ -2444,7 +2452,7 @@ static const FFlogo N[] = { // NixOsSmall { .names = {"nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -2561,7 +2569,7 @@ static const FFlogo O[] = { // OpenBSDSmall { .names = {"openbsd_small", "openbsd-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_OPENBSD_SMALL, .colors = { FF_COLOR_FG_YELLOW, @@ -2620,7 +2628,7 @@ static const FFlogo O[] = { // OpenSuseSmall { .names = {"opensuse_small", "open_suse_small", "open-suse_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2651,6 +2659,7 @@ static const FFlogo O[] = { // OpenSuseTumbleweed2 { .names = {"opensuse_tumbleweed2"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2, .colors = { FF_COLOR_FG_WHITE, @@ -2712,7 +2721,7 @@ static const FFlogo O[] = { // OrchidSmall { .names = {"orchid_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ORCHID_SMALL, .colors = { FF_COLOR_FG_WHITE, @@ -2757,7 +2766,7 @@ static const FFlogo O[] = { // OSXSmall { .names = {"OSX_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MACOS_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -2806,7 +2815,7 @@ static const FFlogo P[] = { // ParabolaSmall { .names = {"parabola_small", "parabola-gnulinux_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_PARABOLA_SMALL, .colors = { FF_COLOR_FG_MAGENTA, @@ -2930,7 +2939,7 @@ static const FFlogo P[] = { }, // PNMLinux { - .names = {"PNM Linux", "WHPNM Linux"}, + .names = {"PNM Linux"}, .lines = FASTFETCH_DATATEXT_LOGO_PNM_LINUX, .colors = { FF_COLOR_FG_BLUE, @@ -2953,7 +2962,7 @@ static const FFlogo P[] = { // PopSmall { .names = {"pop_small", "popos_small", "pop_os_small", "pop-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_POP_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -3018,7 +3027,7 @@ static const FFlogo P[] = { // PureOSSmall { .names = {"PureOS_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_PUREOS_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -3095,7 +3104,7 @@ static const FFlogo R[] = { // RaspbianSmall { .names = {"raspbian_small", "raspi_small", "raspberrypi_small", "raspberrypios_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_RASPBIAN_SMALL, .colors = { FF_COLOR_FG_RED, @@ -3128,7 +3137,7 @@ static const FFlogo R[] = { // RebornSmall { .names = {"Reborn_small", "Reborn OS_small", "reborn-os-small", "rebornos_small", "rebornos-linux-small", "reborn-os-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_REBORN_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -3158,6 +3167,7 @@ static const FFlogo R[] = { // RedHatEnterpriseLinux_old { .names = {"rhel_old", "redhat_old", "redhat-linux_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_RHEL_OLD, .colors = { FF_COLOR_FG_RED, @@ -3435,7 +3445,7 @@ static const FFlogo S[] = { // SlackwareSmall { .names = {"slackware-small", "slackware-linux-small", "slackware_small", "slackwarelinux_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_SLACKWARE_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -3485,7 +3495,7 @@ static const FFlogo S[] = { // SolarisSmall { .names = {"solaris-small", "solaris_small", "sunos-small", "sunos_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_SOLARIS_SMALL, .colors = { FF_COLOR_FG_YELLOW, @@ -3563,7 +3573,7 @@ static const FFlogo S[] = { // SuseSmall { .names = {"suse_small", "suse-linux_small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -3719,6 +3729,7 @@ static const FFlogo U[] = { // UbuntuOld { .names = {"ubuntu_old", "ubuntu-linux_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_OLD, .colors = { FF_COLOR_FG_RED, @@ -3741,7 +3752,7 @@ static const FFlogo U[] = { // UbuntuSmall { .names = {"ubuntu_small", "ubuntu-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_SMALL, .colors = { FF_COLOR_FG_RED, @@ -3788,7 +3799,7 @@ static const FFlogo U[] = { // Ubuntu2Small { .names = {"ubuntu2_small", "ubuntu2-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT | FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU2_SMALL, .colors = { FF_COLOR_FG_RED, @@ -3799,6 +3810,7 @@ static const FFlogo U[] = { // Ubuntu2Old { .names = {"ubuntu2_old"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .lines = FASTFETCH_DATATEXT_LOGO_UBUNTU2_OLD, .colors = { FF_COLOR_FG_RED, @@ -3925,7 +3937,7 @@ static const FFlogo V[] = { // VoidSmall { .names = {"void_small", "void-linux-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_VOID_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -3963,7 +3975,7 @@ static const FFlogo W[] = { // Windows11Small { .names = {"Windows 11_small", "Windows 11-small"}, - .small = true, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_WINDOWS_11_SMALL, .colors = { FF_COLOR_FG_BLUE, diff --git a/src/logo/logo.c b/src/logo/logo.c index c4da5f3d5..78a430bf9 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -218,11 +218,12 @@ static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) { switch (size) { + // Never use alternate logos case FF_LOGO_SIZE_NORMAL: - if(logo->small) continue; + if(logo->type != FF_LOGO_LINE_TYPE_NORMAL) continue; break; case FF_LOGO_SIZE_SMALL: - if(!logo->small) continue; + if(logo->type != FF_LOGO_LINE_TYPE_SMALL_BIT) continue; break; default: break; diff --git a/src/logo/logo.h b/src/logo/logo.h index 8b9a5d4ed..62e884143 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -5,6 +5,13 @@ #include "fastfetch.h" +typedef enum FFLogoLineType +{ + FF_LOGO_LINE_TYPE_NORMAL = 0, + FF_LOGO_LINE_TYPE_SMALL_BIT = 1 << 0, // The names of small logo must end with `_small` or `-small` + FF_LOGO_LINE_TYPE_ALTER_BIT = 1 << 1, +} FFLogoLineType; + typedef struct FFlogo { const char* lines; @@ -12,7 +19,7 @@ typedef struct FFlogo const char* colors[FASTFETCH_LOGO_MAX_COLORS]; const char* colorKeys; const char* colorTitle; - bool small; // The names of small logo must end with `_small` or `-small` + FFLogoLineType type; } FFlogo; //logo.c From add33186a82d6ca647642f698dc654478d1b33b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 16:55:49 +0800 Subject: [PATCH 466/493] Fastfetch: improve performance of `--structure` parsing --- src/common/jsonconfig.c | 6 +- src/fastfetch.c | 239 ++++++++++++++++++++++------------------ 2 files changed, 132 insertions(+), 113 deletions(-) diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 4ac9ddc2d..7b623d7c5 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -93,10 +93,10 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) case 'C': { return tryModule(type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) || - tryModule(type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || - tryModule(type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || tryModule(type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) || tryModule(type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) || + tryModule(type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) || + tryModule(type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) || tryModule(type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) || tryModule(type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) || false; @@ -105,9 +105,9 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module) case 'D': { return tryModule(type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) || + tryModule(type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || tryModule(type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) || tryModule(type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) || - tryModule(type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) || false; } diff --git a/src/fastfetch.c b/src/fastfetch.c index 40b87db6a..71a0de160 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1185,116 +1185,135 @@ static void parseStructureCommand(const char* line, FFlist* customValues) } } - if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME)) - ffPrintBreak(); - else if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME)) - ffPrintTitle(&instance.config.title); - else if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME)) - ffPrintSeparator(&instance.config.separator); - else if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME)) - ffPrintOS(&instance.config.os); - else if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME)) - ffPrintHost(&instance.config.host); - else if(ffStrEqualsIgnCase(line, FF_BIOS_MODULE_NAME)) - ffPrintBios(&instance.config.bios); - else if(ffStrEqualsIgnCase(line, FF_BOARD_MODULE_NAME)) - ffPrintBoard(&instance.config.board); - else if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME)) - ffPrintBrightness(&instance.config.brightness); - else if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME)) - ffPrintChassis(&instance.config.chassis); - else if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME)) - ffPrintKernel(&instance.config.kernel); - else if(ffStrEqualsIgnCase(line, FF_PROCESSES_MODULE_NAME)) - ffPrintProcesses(&instance.config.processes); - else if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME)) - ffPrintUptime(&instance.config.uptime); - else if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME)) - ffPrintPackages(&instance.config.packages); - else if(ffStrEqualsIgnCase(line, FF_SHELL_MODULE_NAME)) - ffPrintShell(&instance.config.shell); - else if(ffStrEqualsIgnCase(line, FF_DISPLAY_MODULE_NAME)) - ffPrintDisplay(&instance.config.display); - else if(ffStrEqualsIgnCase(line, FF_DE_MODULE_NAME)) - ffPrintDE(&instance.config.de); - else if(ffStrEqualsIgnCase(line, FF_WM_MODULE_NAME)) - ffPrintWM(&instance.config.wm); - else if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME)) - ffPrintTheme(&instance.config.theme); - else if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME)) - ffPrintWMTheme(&instance.config.wmTheme); - else if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME)) - ffPrintIcons(&instance.config.icons); - else if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME)) - ffPrintWallpaper(&instance.config.wallpaper); - else if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME)) - ffPrintFont(&instance.config.font); - else if(ffStrEqualsIgnCase(line, FF_CURSOR_MODULE_NAME)) - ffPrintCursor(&instance.config.cursor); - else if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME)) - ffPrintTerminal(&instance.config.terminal); - else if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME)) - ffPrintTerminalFont(&instance.config.terminalFont); - else if(ffStrEqualsIgnCase(line, FF_TERMINALSIZE_MODULE_NAME)) - ffPrintTerminalSize(&instance.config.terminalSize); - else if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME)) - ffPrintCPU(&instance.config.cpu); - else if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME)) - ffPrintCPUUsage(&instance.config.cpuUsage); - else if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME)) - ffPrintCustom(&instance.config.custom); - else if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME)) - ffPrintGPU(&instance.config.gpu); - else if(ffStrEqualsIgnCase(line, FF_MEMORY_MODULE_NAME)) - ffPrintMemory(&instance.config.memory); - else if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME)) - ffPrintSwap(&instance.config.swap); - else if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME)) - ffPrintDisk(&instance.config.disk); - else if(ffStrEqualsIgnCase(line, FF_BATTERY_MODULE_NAME)) - ffPrintBattery(&instance.config.battery); - else if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME)) - ffPrintPowerAdapter(&instance.config.powerAdapter); - else if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME)) - ffPrintLM(&instance.config.lm); - else if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME)) - ffPrintLocale(&instance.config.locale); - else if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) - ffPrintLocalIp(&instance.config.localIP); - else if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME)) - ffPrintPublicIp(&instance.config.publicIP); - else if(ffStrEqualsIgnCase(line, FF_WIFI_MODULE_NAME)) - ffPrintWifi(&instance.config.wifi); - else if(ffStrEqualsIgnCase(line, FF_WEATHER_MODULE_NAME)) - ffPrintWeather(&instance.config.weather); - else if(ffStrEqualsIgnCase(line, FF_PLAYER_MODULE_NAME)) - ffPrintPlayer(&instance.config.player); - else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) - ffPrintMedia(&instance.config.media); - else if(ffStrEqualsIgnCase(line, FF_MONITOR_MODULE_NAME)) - ffPrintMonitor(&instance.config.nativeResolution); - else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) - ffPrintDateTime(&instance.config.dateTime); - else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) - ffPrintColors(&instance.config.colors); - else if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME)) - ffPrintVulkan(&instance.config.vulkan); - else if(ffStrEqualsIgnCase(line, FF_OPENGL_MODULE_NAME)) - ffPrintOpenGL(&instance.config.openGL); - else if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME)) - ffPrintOpenCL(&instance.config.openCL); - else if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME)) - ffPrintUsers(&instance.config.users); - else if(ffStrEqualsIgnCase(line, FF_COMMAND_MODULE_NAME)) - ffPrintCommand(&instance.config.command); - else if(ffStrEqualsIgnCase(line, FF_BLUETOOTH_MODULE_NAME)) - ffPrintBluetooth(&instance.config.bluetooth); - else if(ffStrEqualsIgnCase(line, FF_SOUND_MODULE_NAME)) - ffPrintSound(&instance.config.sound); - else if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME)) - ffPrintGamepad(&instance.config.gamepad); - else - ffPrintErrorString(line, 0, NULL, NULL, ""); + switch (toupper(line[0])) + { + case 'B': + if(ffStrEqualsIgnCase(line, FF_BATTERY_MODULE_NAME)) + return ffPrintBattery(&instance.config.battery); + if(ffStrEqualsIgnCase(line, FF_BIOS_MODULE_NAME)) + return ffPrintBios(&instance.config.bios); + if(ffStrEqualsIgnCase(line, FF_BLUETOOTH_MODULE_NAME)) + return ffPrintBluetooth(&instance.config.bluetooth); + if(ffStrEqualsIgnCase(line, FF_BOARD_MODULE_NAME)) + return ffPrintBoard(&instance.config.board); + if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME)) + return ffPrintBreak(); + if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME)) + return ffPrintBrightness(&instance.config.brightness); + case 'C': + if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME)) + return ffPrintChassis(&instance.config.chassis); + if(ffStrEqualsIgnCase(line, FF_COMMAND_MODULE_NAME)) + return ffPrintCommand(&instance.config.command); + if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME)) + return ffPrintCPU(&instance.config.cpu); + if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME)) + return ffPrintCPUUsage(&instance.config.cpuUsage); + if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME)) + return ffPrintColors(&instance.config.colors); + if(ffStrEqualsIgnCase(line, FF_CURSOR_MODULE_NAME)) + return ffPrintCursor(&instance.config.cursor); + if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME)) + return ffPrintCustom(&instance.config.custom); + case 'D': + if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) + return ffPrintDateTime(&instance.config.dateTime); + if(ffStrEqualsIgnCase(line, FF_DE_MODULE_NAME)) + return ffPrintDE(&instance.config.de); + if(ffStrEqualsIgnCase(line, FF_DISPLAY_MODULE_NAME)) + return ffPrintDisplay(&instance.config.display); + if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME)) + return ffPrintDisk(&instance.config.disk); + case 'F': + if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME)) + return ffPrintFont(&instance.config.font); + case 'G': + if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME)) + return ffPrintGamepad(&instance.config.gamepad); + if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME)) + return ffPrintGPU(&instance.config.gpu); + case 'H': + if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME)) + return ffPrintHost(&instance.config.host); + case 'I': + if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME)) + return ffPrintIcons(&instance.config.icons); + case 'K': + if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME)) + return ffPrintKernel(&instance.config.kernel); + case 'L': + if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME)) + return ffPrintLM(&instance.config.lm); + if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME)) + return ffPrintLocale(&instance.config.locale); + if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) + return ffPrintLocalIp(&instance.config.localIP); + case 'M': + if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) + return ffPrintMedia(&instance.config.media); + if(ffStrEqualsIgnCase(line, FF_MEMORY_MODULE_NAME)) + return ffPrintMemory(&instance.config.memory); + if(ffStrEqualsIgnCase(line, FF_MONITOR_MODULE_NAME)) + return ffPrintMonitor(&instance.config.nativeResolution); + case 'O': + if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME)) + return ffPrintOpenCL(&instance.config.openCL); + if(ffStrEqualsIgnCase(line, FF_OPENGL_MODULE_NAME)) + return ffPrintOpenGL(&instance.config.openGL); + if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME)) + return ffPrintOS(&instance.config.os); + case 'P': + if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME)) + return ffPrintPackages(&instance.config.packages); + if(ffStrEqualsIgnCase(line, FF_PLAYER_MODULE_NAME)) + return ffPrintPlayer(&instance.config.player); + if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME)) + return ffPrintPowerAdapter(&instance.config.powerAdapter); + if(ffStrEqualsIgnCase(line, FF_PROCESSES_MODULE_NAME)) + return ffPrintProcesses(&instance.config.processes); + if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME)) + return ffPrintPublicIp(&instance.config.publicIP); + case 'S': + if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME)) + return ffPrintSeparator(&instance.config.separator); + if(ffStrEqualsIgnCase(line, FF_SHELL_MODULE_NAME)) + return ffPrintShell(&instance.config.shell); + if(ffStrEqualsIgnCase(line, FF_SOUND_MODULE_NAME)) + return ffPrintSound(&instance.config.sound); + if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME)) + return ffPrintSwap(&instance.config.swap); + case 'T': + if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME)) + return ffPrintTerminal(&instance.config.terminal); + if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME)) + return ffPrintTerminalFont(&instance.config.terminalFont); + if(ffStrEqualsIgnCase(line, FF_TERMINALSIZE_MODULE_NAME)) + return ffPrintTerminalSize(&instance.config.terminalSize); + if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME)) + return ffPrintTitle(&instance.config.title); + if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME)) + return ffPrintTheme(&instance.config.theme); + case 'U': + if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME)) + return ffPrintUptime(&instance.config.uptime); + if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME)) + return ffPrintUsers(&instance.config.users); + case 'V': + if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME)) + return ffPrintVulkan(&instance.config.vulkan); + case 'W': + if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME)) + return ffPrintWallpaper(&instance.config.wallpaper); + if(ffStrEqualsIgnCase(line, FF_WEATHER_MODULE_NAME)) + return ffPrintWeather(&instance.config.weather); + if(ffStrEqualsIgnCase(line, FF_WIFI_MODULE_NAME)) + return ffPrintWifi(&instance.config.wifi); + if(ffStrEqualsIgnCase(line, FF_WM_MODULE_NAME)) + return ffPrintWM(&instance.config.wm); + if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME)) + return ffPrintWMTheme(&instance.config.wmTheme); + } + ffPrintErrorString(line, 0, NULL, NULL, ""); } int main(int argc, const char** argv) From 3c817ecf6d5d73198ed8b1ae826eb1bcb8840c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 19:03:49 +0800 Subject: [PATCH 467/493] Fastfetch: silence compiler warnings --- src/fastfetch.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/fastfetch.c b/src/fastfetch.c index 71a0de160..874a799f0 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1200,6 +1200,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintBreak(); if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME)) return ffPrintBrightness(&instance.config.brightness); + break; case 'C': if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME)) return ffPrintChassis(&instance.config.chassis); @@ -1215,6 +1216,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintCursor(&instance.config.cursor); if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME)) return ffPrintCustom(&instance.config.custom); + break; case 'D': if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME)) return ffPrintDateTime(&instance.config.dateTime); @@ -1224,23 +1226,29 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintDisplay(&instance.config.display); if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME)) return ffPrintDisk(&instance.config.disk); + break; case 'F': if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME)) return ffPrintFont(&instance.config.font); + break; case 'G': if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME)) return ffPrintGamepad(&instance.config.gamepad); if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME)) return ffPrintGPU(&instance.config.gpu); + break; case 'H': if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME)) return ffPrintHost(&instance.config.host); + break; case 'I': if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME)) return ffPrintIcons(&instance.config.icons); + break; case 'K': if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME)) return ffPrintKernel(&instance.config.kernel); + break; case 'L': if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME)) return ffPrintLM(&instance.config.lm); @@ -1248,6 +1256,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintLocale(&instance.config.locale); if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME)) return ffPrintLocalIp(&instance.config.localIP); + break; case 'M': if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME)) return ffPrintMedia(&instance.config.media); @@ -1255,6 +1264,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintMemory(&instance.config.memory); if(ffStrEqualsIgnCase(line, FF_MONITOR_MODULE_NAME)) return ffPrintMonitor(&instance.config.nativeResolution); + break; case 'O': if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME)) return ffPrintOpenCL(&instance.config.openCL); @@ -1262,6 +1272,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintOpenGL(&instance.config.openGL); if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME)) return ffPrintOS(&instance.config.os); + break; case 'P': if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME)) return ffPrintPackages(&instance.config.packages); @@ -1273,6 +1284,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintProcesses(&instance.config.processes); if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME)) return ffPrintPublicIp(&instance.config.publicIP); + break; case 'S': if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME)) return ffPrintSeparator(&instance.config.separator); @@ -1282,6 +1294,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintSound(&instance.config.sound); if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME)) return ffPrintSwap(&instance.config.swap); + break; case 'T': if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME)) return ffPrintTerminal(&instance.config.terminal); @@ -1293,14 +1306,17 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintTitle(&instance.config.title); if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME)) return ffPrintTheme(&instance.config.theme); + break; case 'U': if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME)) return ffPrintUptime(&instance.config.uptime); if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME)) return ffPrintUsers(&instance.config.users); + break; case 'V': if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME)) return ffPrintVulkan(&instance.config.vulkan); + break; case 'W': if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME)) return ffPrintWallpaper(&instance.config.wallpaper); @@ -1312,6 +1328,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintWM(&instance.config.wm); if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME)) return ffPrintWMTheme(&instance.config.wmTheme); + break; } ffPrintErrorString(line, 0, NULL, NULL, ""); } From 978e578e7a41e2dbec99c6e48371a26a664da5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 19:04:09 +0800 Subject: [PATCH 468/493] Display (Linux): fix memleaks --- src/detection/displayserver/linux/wayland.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 9f259a104..e0a4cd2de 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -207,6 +207,10 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist 0 ); + ffStrbufDestroy(&display.description); + ffStrbufDestroy(&display.vendorAndModelId); + ffStrbufDestroy(&display.name); + ffThreadMutexUnlock(&mutex); } From 8d7318c0246ffcb789b650ad593794965328346e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 20:58:52 +0800 Subject: [PATCH 469/493] Display (Linux): don't assume `DP-*` are external monitors --- src/detection/displayserver/linux/wayland.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index e0a4cd2de..cae30b86f 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -86,8 +86,8 @@ static void waylandOutputGeometryListener(void *data, FF_MAYBE_UNUSED int32_t physical_width, FF_MAYBE_UNUSED int32_t physical_height, FF_MAYBE_UNUSED int32_t subpixel, - FF_MAYBE_UNUSED const char *make, - FF_MAYBE_UNUSED const char *model, + const char *make, + const char *model, int32_t transform) { WaylandDisplay* display = data; @@ -101,7 +101,7 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp WaylandDisplay* display = data; if(ffStrStartsWith(name, "eDP-")) display->type = FF_DISPLAY_TYPE_BUILTIN; - else if(ffStrStartsWith(name, "HDMI-") || ffStrStartsWith(name, "DP-")) + else if(ffStrStartsWith(name, "HDMI-")) display->type = FF_DISPLAY_TYPE_EXTERNAL; ffStrbufAppendS(&display->name, name); } From d1a92f8cf953ac0fde010a5802790eef118ef554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 10 Aug 2023 20:59:54 +0800 Subject: [PATCH 470/493] Display (Linux): retreive EDID monitor name --- src/detection/displayserver/linux/wayland.c | 56 +++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index cae30b86f..14292b641 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -8,9 +8,11 @@ #include "common/library.h" #include "common/io/io.h" #include "common/thread.h" +#include "util/edidHelper.h" #include #include #include +#include typedef struct WaylandData { @@ -34,6 +36,7 @@ typedef struct WaylandDisplay FFstrbuf name; FFstrbuf description; FFstrbuf vendorAndModelId; + FFstrbuf edidName; } WaylandDisplay; #ifndef __FreeBSD__ @@ -96,6 +99,46 @@ static void waylandOutputGeometryListener(void *data, ffStrbufAppendS(&display->vendorAndModelId, model); } +static bool matchDrmConnector(const char* wlName, FFstrbuf* edidName) +{ + // https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name + // The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc." + // However I can't find a better method to get the edid data + const char* drmDirPath = "/sys/class/drm/"; + + DIR* dirp = opendir(drmDirPath); + if(dirp == NULL) + return false; + + struct dirent* entry; + while((entry = readdir(dirp)) != NULL) + { + const char* plainName = entry->d_name; + if (ffStrStartsWith(plainName, "card")) + { + const char* tmp = strchr(plainName + strlen("card"), '-'); + if (tmp) plainName = tmp + 1; + } + if (ffStrEquals(plainName, wlName)) + { + ffStrbufAppendF(edidName, "%s%s/edid", drmDirPath, entry->d_name); + + uint8_t edidData[128]; + if(ffReadFileData(edidName->chars, sizeof(edidData), edidData) == sizeof(edidData)) + { + ffStrbufClear(edidName); + ffEdidGetName(edidData, edidName); + closedir(dirp); + return true; + } + break; + } + } + ffStrbufClear(edidName); + closedir(dirp); + return false; +} + static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name) { WaylandDisplay* display = data; @@ -103,6 +146,7 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp display->type = FF_DISPLAY_TYPE_BUILTIN; else if(ffStrStartsWith(name, "HDMI-")) display->type = FF_DISPLAY_TYPE_EXTERNAL; + matchDrmConnector(name, &display->edidName); ffStrbufAppendS(&display->name, name); } @@ -130,6 +174,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist ffStrbufInit(&display.name); ffStrbufInit(&display.description); ffStrbufInit(&display.vendorAndModelId); + ffStrbufInit(&display.edidName); // Dirty hack for #477 // The order of these callbacks MUST follow `struct wl_output_listener` @@ -198,10 +243,12 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist (uint32_t) (display.width / display.scale), (uint32_t) (display.height / display.scale), rotation, - display.description.length - ? &display.description - : display.vendorAndModelId.length - ? &display.vendorAndModelId : &display.name, + display.edidName.length + ? &display.edidName + : display.description.length + ? &display.description + : display.vendorAndModelId.length + ? &display.vendorAndModelId : &display.name, display.type, false, 0 @@ -210,6 +257,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist ffStrbufDestroy(&display.description); ffStrbufDestroy(&display.vendorAndModelId); ffStrbufDestroy(&display.name); + ffStrbufDestroy(&display.edidName); ffThreadMutexUnlock(&mutex); } From d84bf00ca02eaec08f3c401bd31aba9ae4982ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 09:12:59 +0800 Subject: [PATCH 471/493] Logo (Builtin) remove OpenSuseTumbleweed2 --- src/logo/ascii/opensuse_tumbleweed.txt | 22 +++++++++++----------- src/logo/ascii/opensuse_tumbleweed2.txt | 13 ------------- src/logo/builtin.c | 11 ----------- 3 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 src/logo/ascii/opensuse_tumbleweed2.txt diff --git a/src/logo/ascii/opensuse_tumbleweed.txt b/src/logo/ascii/opensuse_tumbleweed.txt index 519e0258a..fefdeee4a 100644 --- a/src/logo/ascii/opensuse_tumbleweed.txt +++ b/src/logo/ascii/opensuse_tumbleweed.txt @@ -1,13 +1,13 @@ - ...... + ...... .,cdxxxoc,. .:kKMMMNWMMMNk:. - cKMMN0OOOKWMMXo. ; ;0MWk:. .:OMMk. - ;WMK;. .lKMMNM, :NMK, .OMW; - cMW; 'WMMMN ,XMK, oMM' -.MMc ..;l. xMN: KM0 -'MM. 'NMO oMM + cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. + ;WMK;' 'lKMMNM, :NMK' 'OMW; + cMW; WMMMN ,XMK' oMM. +.MMc ''^*~l. xMN: KM0 +'MM. .NMO oMM .MM, .kMMl xMN - KM0 .kMM0. .dl:,.. .WMd - .XM0. ,OMMK, OMMMK. .XMK - oWMO:. .;xNMMk, NNNMKl. .xWMx - :ONMMNXMMMKx; . ,xNMWKkxllox0NMWk, - ..... .:dOOXXKOxl, \ No newline at end of file + KM0 .kMM0' .dl>~,. .WMd + 'XM0. ,OMMK' OMMM7' .XMK + *WMO:. .;xNMMk' NNNMKl. .xWMx + ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' + ''''' ':dOOXXKOxl' \ No newline at end of file diff --git a/src/logo/ascii/opensuse_tumbleweed2.txt b/src/logo/ascii/opensuse_tumbleweed2.txt deleted file mode 100644 index fefdeee4a..000000000 --- a/src/logo/ascii/opensuse_tumbleweed2.txt +++ /dev/null @@ -1,13 +0,0 @@ - ...... - .,cdxxxoc,. .:kKMMMNWMMMNk:. - cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. - ;WMK;' 'lKMMNM, :NMK' 'OMW; - cMW; WMMMN ,XMK' oMM. -.MMc ''^*~l. xMN: KM0 -'MM. .NMO oMM -.MM, .kMMl xMN - KM0 .kMM0' .dl>~,. .WMd - 'XM0. ,OMMK' OMMM7' .XMK - *WMO:. .;xNMMk' NNNMKl. .xWMx - ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' - ''''' ':dOOXXKOxl' \ No newline at end of file diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 690146b97..7d20c5659 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2656,17 +2656,6 @@ static const FFlogo O[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, - // OpenSuseTumbleweed2 - { - .names = {"opensuse_tumbleweed2"}, - .type = FF_LOGO_LINE_TYPE_ALTER_BIT, - .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED2, - .colors = { - FF_COLOR_FG_WHITE, - }, - .colorKeys = FF_COLOR_FG_GREEN, - .colorTitle = FF_COLOR_FG_GREEN, - }, // OpenMandriva { .names = {"openmandriva", "open-mandriva", "open_mandriva"}, From 9177bc2b9b7799be1e296d560851db47bcf84396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 10:58:54 +0800 Subject: [PATCH 472/493] Display (Linux): don't use `unknown` as the display name --- src/detection/displayserver/linux/wayland.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 14292b641..06d7c7f75 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -95,8 +95,11 @@ static void waylandOutputGeometryListener(void *data, { WaylandDisplay* display = data; display->transform = (enum wl_output_transform) transform; - ffStrbufAppendS(&display->vendorAndModelId, make); - ffStrbufAppendS(&display->vendorAndModelId, model); + if (make && !ffStrEqualsIgnCase(make, "unknown") && model && !ffStrEqualsIgnCase(model, "unknown")) + { + ffStrbufAppendS(&display->vendorAndModelId, make); + ffStrbufAppendS(&display->vendorAndModelId, model); + } } static bool matchDrmConnector(const char* wlName, FFstrbuf* edidName) @@ -154,7 +157,8 @@ static void waylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED struct { WaylandDisplay* display = data; while (*description == ' ') ++description; - ffStrbufAppendS(&display->description, description); + if (!ffStrEquals(description, "Unknown Display")) + ffStrbufAppendS(&display->description, description); } static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version) From 8493c99146ccf7b9c5f815941b925934c831878f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 11:01:07 +0800 Subject: [PATCH 473/493] README: update builtin logo list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2076ae90..5176edee9 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos ``` -Unknown, AIX, AlmaLinux, Alpine, AlpineSmall, Alpine2Small, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOsRetro, AoscOsRetro_small, AoscOS, Aperture, Apricity, ArchBox, Archcraft, Archcraft2, Arch, Arch2, ArchSmall, Archlabs, ArchStrike, Artix, ArtixSmall, Artix2Small, ArcoLinux, ArcoLinuxSmall, ArseLinux, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlySmall, DragonFlyOld, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraSmall, FedoraOld, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxSmall, LinuxLight, LinuxLightSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOSSmall, MacOS2, MacOS2Small, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, Minix, MassOS, MatuusOS, MaUI, Meowix, Mer, Mint, MintSmall, MintOld, MiracleLinux, Msys2, Namib, Nekos, Neptune, NetRunner, Nitrux, Windows11, Windows11Small, Windows8, Windows, Windows95, NixOS, NixOS_small, NixOsOld, NixOsSmall, MX, MXSmall, NetBSD, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenKylin, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenMamba, OpenStage, OpenSuse, OpenSuseSmall, OpenSuseLeap, OpenSuseTumbleweed, OpenSuseTumbleweed2, OpenMandriva, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, PacBSD, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Proxmox, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slitaz, Slackware, SlackwareSmall, SmartOS, Soda, SourceMage, Solaris, SolarisSmall, Solus, Sparky, Star, StockLinux, SteamOS, Sulin, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ubuntu2Small, Ubuntu2Old, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Vzlinux, Void, VoidSmall, WiiLinuxNgx, Xferience, YiffOS, Zorin +AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin ``` Run `fastfetch --print-logos` to print them From ff685a52b48a3e785b8d7a12aea9a4ed59d966a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 14:29:24 +0800 Subject: [PATCH 474/493] Monitor (macOS): tidy --- src/detection/monitor/monitor_apple.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/detection/monitor/monitor_apple.c b/src/detection/monitor/monitor_apple.c index bd4a43354..d022d825b 100644 --- a/src/detection/monitor/monitor_apple.c +++ b/src/detection/monitor/monitor_apple.c @@ -12,13 +12,13 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) { - if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) + if (display->type == FF_DISPLAY_TYPE_BUILTIN) { CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary((CGDirectDisplayID) display->id); if(displayInfo) { int width, height; - if (ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelWidth"), &width) || + if (ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelWidth"), &width) || // Default resolution (limited by connectors, GPUs, etc.) ffCfDictGetInt(displayInfo, CFSTR("kCGDisplayPixelHeight"), &height) || width <= 0 || height <= 0) continue; @@ -26,11 +26,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa FFMonitorResult* monitor = (FFMonitorResult*) ffListAdd(results); monitor->width = (uint32_t) width; monitor->height = (uint32_t) height; - ffStrbufInit(&monitor->name); - - CFDictionaryRef productNames; - if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &monitor->name); + ffStrbufInitCopy(&monitor->name, &display->name); CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id); monitor->physicalWidth = (uint32_t) (size.width + 0.5); @@ -80,7 +76,7 @@ static const char* detectWithDdcci(FFlist* results) if (!service) continue; FF_CFTYPE_AUTO_RELEASE CFDataRef edid = NULL; - if (IOAVServiceCopyEDID(service, &edid) != KERN_SUCCESS ) + if (IOAVServiceCopyEDID(service, &edid) != KERN_SUCCESS) continue; if (CFDataGetLength(edid) < 128) From 126034f33eac80c755d005b5d7b7affe073a90be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 14:56:17 +0800 Subject: [PATCH 475/493] WM (macOS): detect if WindowServer is running --- .../displayserver/displayserver_apple.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 60feb6efe..84f3c48fe 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -19,8 +19,6 @@ static void detectDisplays(FFDisplayServerResult* ds) if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess) return; - CGDirectDisplayID primary = CGMainDisplayID(); - for(uint32_t i = 0; i < screenCount; i++) { CGDirectDisplayID screen = screens[i]; @@ -63,7 +61,7 @@ static void detectDisplays(FFDisplayServerResult* ds) (uint32_t)CGDisplayRotation(screen), &name, CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL, - screen == primary, + CGDisplayIsMain(screen), (uint64_t)screen ); CGDisplayModeRelease(mode); @@ -103,9 +101,20 @@ static void detectWMPlugin(FFstrbuf* name) void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { - ffStrbufInitStatic(&ds->wmProcessName, "WindowServer"); - ffStrbufInitStatic(&ds->wmPrettyName, "Quartz Compositor"); - ffStrbufInit(&ds->wmProtocolName); + { + FF_CFTYPE_AUTO_RELEASE CFMachPortRef port = CGWindowServerCreateServerPort(); + if (port) + { + ffStrbufInitStatic(&ds->wmProcessName, "WindowServer"); + ffStrbufInitStatic(&ds->wmPrettyName, "Quartz Compositor"); + } + else + { + ffStrbufInit(&ds->wmProcessName); + ffStrbufInit(&ds->wmPrettyName); + } + } + ffStrbufInitStatic(&ds->wmProtocolName, "Core Graphics"); if(instance.config.allowSlowOperations) { From b847fcac8bf24344582b12edca90adaaa65e6de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 15:43:45 +0800 Subject: [PATCH 476/493] Doc: document the incompatibility between `fastfetch` and `p10k-instant-prompt` --- .github/ISSUE_TEMPLATE/bug_report.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8a64fb180..87dc8be10 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -72,3 +72,10 @@ If you cannot do the instructions above, please upload the core dump file: * The terminal you used: * Upload the image file here, or paste the image URL: * Does it work with `--logo-width {WIDTH} --logo-height {HEIGHT}`? + +## If fastfetch behaves incorrectly on shell starting + + + +* The bug is reproduceable with fresh / clean shell configuration (i.e. `fastfetch` is the single line of `.zshrc` or `~/.config/fish/config.fish`): +* Does `sleep 1` before running `fastfetch` work? From 5a4de8b428d6cf9501075a80b78517e44f8f9b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 15:46:34 +0800 Subject: [PATCH 477/493] Doc: fix typo --- .github/ISSUE_TEMPLATE/bug_report.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 87dc8be10..f70839bb6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -75,7 +75,10 @@ If you cannot do the instructions above, please upload the core dump file: ## If fastfetch behaves incorrectly on shell starting - + * The bug is reproduceable with fresh / clean shell configuration (i.e. `fastfetch` is the single line of `.zshrc` or `~/.config/fish/config.fish`): * Does `sleep 1` before running `fastfetch` work? From 28d95c9f45ef9b66de9083cb4b2460f25fe91de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 15:56:02 +0800 Subject: [PATCH 478/493] WM (macOS): don't print `Core Graphics` --- src/detection/displayserver/displayserver_apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 84f3c48fe..dfd2fe77f 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -114,7 +114,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->wmPrettyName); } } - ffStrbufInitStatic(&ds->wmProtocolName, "Core Graphics"); + ffStrbufInit(&ds->wmProtocolName); if(instance.config.allowSlowOperations) { From d05cbc0af02bca3be8dd2f95a6a7bbd0edd7a3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 16:45:16 +0800 Subject: [PATCH 479/493] Monitor (macOS): detect HDR support --- CMakeLists.txt | 2 +- src/detection/monitor/monitor.h | 1 + .../{monitor_apple.c => monitor_apple.m} | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) rename src/detection/monitor/{monitor_apple.c => monitor_apple.m} (76%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 423f1df40..0326edecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -541,7 +541,7 @@ elseif(APPLE) src/detection/gamepad/gamepad_apple.c src/detection/media/media_apple.m src/detection/memory/memory_apple.c - src/detection/monitor/monitor_apple.c + src/detection/monitor/monitor_apple.m src/detection/opengl/opengl_apple.c src/detection/os/os_apple.m src/detection/packages/packages_apple.c diff --git a/src/detection/monitor/monitor.h b/src/detection/monitor/monitor.h index 1fc514d90..8314c4cf4 100644 --- a/src/detection/monitor/monitor.h +++ b/src/detection/monitor/monitor.h @@ -7,6 +7,7 @@ typedef struct FFMonitorResult uint32_t height; // native / maximum resolution, in pixels uint32_t physicalWidth; // in mm uint32_t physicalHeight; // in mm + bool hdrCompatible; } FFMonitorResult; const char* ffDetectMonitor(FFlist* results); diff --git a/src/detection/monitor/monitor_apple.c b/src/detection/monitor/monitor_apple.m similarity index 76% rename from src/detection/monitor/monitor_apple.c rename to src/detection/monitor/monitor_apple.m index d022d825b..41e88ae58 100644 --- a/src/detection/monitor/monitor_apple.c +++ b/src/detection/monitor/monitor_apple.m @@ -4,6 +4,9 @@ #include "util/apple/ddcci.h" #include "util/edidHelper.h" +#import +#import + extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* results) @@ -31,6 +34,30 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id); monitor->physicalWidth = (uint32_t) (size.width + 0.5); monitor->physicalHeight = (uint32_t) (size.height + 0.5); + monitor->hdrCompatible = false; + + if (CFDictionaryContainsKey(displayInfo, CFSTR("ReferencePeakHDRLuminance"))) + monitor->hdrCompatible = true; + else + { + NSScreen* mainScreen = NSScreen.mainScreen; + if (display->primary) + monitor->hdrCompatible = mainScreen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1; + else + { + for (NSScreen* screen in NSScreen.screens) + { + if (screen == mainScreen) continue; + NSNumber* screenNumber = [screen.deviceDescription valueForKey:@"NSScreenNumber"]; + if (screenNumber && screenNumber.longValue == 1) + { + monitor->hdrCompatible = screen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1; + break; + } + } + continue; + } + } } } } @@ -93,6 +120,7 @@ static const char* detectWithDdcci(FFlist* results) ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); + monitor->hdrCompatible = false; } return NULL; } From 045d7052d182d5a062f16fb02b829f0164fcbc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 19:37:23 +0800 Subject: [PATCH 480/493] Monitor (macOS): fix building --- src/detection/monitor/monitor_apple.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/monitor/monitor_apple.m b/src/detection/monitor/monitor_apple.m index 41e88ae58..35a8d413c 100644 --- a/src/detection/monitor/monitor_apple.m +++ b/src/detection/monitor/monitor_apple.m @@ -49,7 +49,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa { if (screen == mainScreen) continue; NSNumber* screenNumber = [screen.deviceDescription valueForKey:@"NSScreenNumber"]; - if (screenNumber && screenNumber.longValue == 1) + if (screenNumber && screenNumber.longValue == (long) display->id) { monitor->hdrCompatible = screen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1; break; @@ -120,7 +120,7 @@ static const char* detectWithDdcci(FFlist* results) ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); - monitor->hdrCompatible = false; + display->hdrCompatible = false; } return NULL; } From 519f3bfd50257cdc3fd391b528ae02fe03bbf29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 11 Aug 2023 22:04:26 +0800 Subject: [PATCH 481/493] Monitor (macOS): test HDR support for external monitors --- src/detection/monitor/monitor_apple.m | 6 ++++-- src/util/edidHelper.c | 29 +++++++++++++++++++++++++++ src/util/edidHelper.h | 1 + 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/detection/monitor/monitor_apple.m b/src/detection/monitor/monitor_apple.m index 35a8d413c..8f931a98d 100644 --- a/src/detection/monitor/monitor_apple.m +++ b/src/detection/monitor/monitor_apple.m @@ -106,11 +106,13 @@ static const char* detectWithDdcci(FFlist* results) if (IOAVServiceCopyEDID(service, &edid) != KERN_SUCCESS) continue; - if (CFDataGetLength(edid) < 128) + uint32_t edidLength = (uint32_t) CFDataGetLength(edid); + if (edidLength == 0 || edidLength % 128 != 0) continue; uint32_t width, height; const uint8_t* edidData = CFDataGetBytePtr(edid); + ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; @@ -120,7 +122,7 @@ static const char* detectWithDdcci(FFlist* results) ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); - display->hdrCompatible = false; + display->hdrCompatible = ffEdidGetHdrCompatible(edidData, edidLength); } return NULL; } diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 3b44f3556..456d8c58b 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -49,3 +49,32 @@ void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* h *width = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66]; *height = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67]; } + +bool ffEdidGetHdrCompatible(const uint8_t* edid, uint32_t length) +{ + if (length <= 128) return false; + for (const uint8_t* cta = &edid[128]; cta < &edid[length]; cta += 128) + { + // https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#CTA_EDID_Timing_Extension_Block + if (cta[0] != 0x02 /* CTA EDID */) continue; + if (cta[1] < 0x03 /* Version 3 */) continue; + const uint8_t offset = cta[2]; + if (offset <= 4) continue; + for (uint8_t i = 4; i < offset;) + { + uint8_t blkLen = cta[i] & 0x1f; + if (blkLen > 0) + { + uint8_t blkTag = (cta[i] & 0xe0) >> 5; + if (blkTag == 0x07 /* Extended Block Type Tag */) + { + uint8_t extendedTag = cta[i + 1]; + if (extendedTag == 6 /* HDR SMDB */ || extendedTag == 7 /* HDR DMDB */) + return true; + } + } + i += blkLen + 1; + } + } + return false; +} diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 1c424e1f4..200926376 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -10,5 +10,6 @@ void ffEdidGetVendorAndModel(const uint8_t edid[128], FFstrbuf* result); bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm +bool ffEdidGetHdrCompatible(const uint8_t edid[128], uint32_t length); #endif From 46b0c6e76b56f7a69f2e5b1be91e5caf20fdd8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 12 Aug 2023 00:07:24 +0800 Subject: [PATCH 482/493] Monitor (Windows): code refactor --- src/detection/monitor/monitor_windows.c | 10 ++++++++-- src/util/windows/registry.c | 26 +++++++++++++++++++++---- src/util/windows/registry.h | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/detection/monitor/monitor_windows.c b/src/detection/monitor/monitor_windows.c index 5bd57dc64..f56c5a188 100644 --- a/src/detection/monitor/monitor_windows.c +++ b/src/detection/monitor/monitor_windows.c @@ -2,6 +2,7 @@ #include "common/io/io.h" #include "util/edidHelper.h" +#include "util/mallocHelper.h" #include "util/stringUtils.h" #include "util/windows/registry.h" #include "util/windows/unicode.h" @@ -30,8 +31,12 @@ const char* ffDetectMonitor(FFlist* results) FF_HKEY_AUTO_DESTROY hKey = SetupDiOpenDevRegKey(hdev, &did, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE); if (!hKey) continue; - uint8_t edidData[256] = {}; - if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue; + FF_AUTO_FREE uint8_t* edidData = NULL; + uint32_t edidLength = 0; + if (!ffRegReadData(hKey, L"EDID", &edidData, &edidLength, NULL)) continue; + if (edidLength == 0 || edidLength % 128 != 0) + continue; + uint32_t width, height; ffEdidGetPhysicalResolution(edidData, &width, &height); if (width == 0 || height == 0) continue; @@ -39,6 +44,7 @@ const char* ffDetectMonitor(FFlist* results) FFMonitorResult* display = (FFMonitorResult*) ffListAdd(results); display->width = width; display->height = height; + display->hdrCompatible = ffEdidGetHdrCompatible(edidData, edidLength); // Doesn't work. edidLength is always 128 ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); diff --git a/src/util/windows/registry.c b/src/util/windows/registry.c index f56d59c50..998bfaf3c 100644 --- a/src/util/windows/registry.c +++ b/src/util/windows/registry.c @@ -64,10 +64,25 @@ bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFs return true; } -bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t* result, uint32_t bufSize, FFstrbuf* error) +bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t** result, uint32_t* length, FFstrbuf* error) { - static_assert(sizeof(DWORD) == sizeof(uint32_t), ""); - LONG err = RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_BINARY, NULL, result, (DWORD*) &bufSize); + assert(result && length); + DWORD bufSize = 0; + LONG err = RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_BINARY, NULL, NULL, &bufSize); + if(err != ERROR_SUCCESS || bufSize == 0) + { + if(error) + { + if(!valueNameW) + valueNameW = L"(default)"; + FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); + ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_BINARY, NULL, NULL, &bufSize) failed", valueNameA.chars); + } + return false; + } + + uint8_t* buf = (uint8_t*) malloc(bufSize); + err = RegGetValueW(hKey, NULL, valueNameW, RRF_RT_REG_BINARY, NULL, buf, &bufSize); if(err != ERROR_SUCCESS) { if(error) @@ -75,10 +90,13 @@ bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t* result, uint32 if(!valueNameW) valueNameW = L"(default)"; FF_STRBUF_AUTO_DESTROY valueNameA = ffStrbufCreateWS(valueNameW); - ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_SZ) failed", valueNameA.chars); + ffStrbufAppendF(error, "RegGetValueW(%s, NULL, RRF_RT_REG_BINARY, NULL, length) failed", valueNameA.chars); } + free(buf); return false; } + *result = buf; + *length = bufSize; return true; } diff --git a/src/util/windows/registry.h b/src/util/windows/registry.h index 8e582ac54..42dd08aaf 100644 --- a/src/util/windows/registry.h +++ b/src/util/windows/registry.h @@ -17,7 +17,7 @@ static inline void wrapRegCloseKey(HKEY* phKey) bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrbuf* error); bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error); -bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t* result, uint32_t bufSize, FFstrbuf* error); +bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t** result, uint32_t* length, FFstrbuf* error); bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error); bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error); bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error); From 97b779aefbc042dec09c1b7ec5fd9beecc252612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 12 Aug 2023 00:27:05 +0800 Subject: [PATCH 483/493] Monitor (Linux): try detecting HDR support --- src/detection/monitor/monitor_linux.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/detection/monitor/monitor_linux.c b/src/detection/monitor/monitor_linux.c index cca0c7de3..a04276412 100644 --- a/src/detection/monitor/monitor_linux.c +++ b/src/detection/monitor/monitor_linux.c @@ -3,8 +3,10 @@ #include "common/io/io.h" #include "util/edidHelper.h" #include "util/stringUtils.h" +#include "util/mallocHelper.h" #include +#include const char* ffDetectMonitor(FFlist* results) { @@ -28,7 +30,14 @@ const char* ffDetectMonitor(FFlist* results) ffStrbufAppendS(&drmDir, entry->d_name); ffStrbufAppendS(&drmDir, "/edid"); - uint8_t edidData[128]; + struct stat fileStat; + if (stat(drmDir.chars, &fileStat) < 0 || fileStat.st_size == 0 || fileStat.st_size % 128 != 0) + { + ffStrbufSubstrBefore(&drmDir, drmDirLength); + continue; + } + + FF_AUTO_FREE uint8_t* edidData = malloc((size_t) fileStat.st_size); if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData)) { ffStrbufSubstrBefore(&drmDir, drmDirLength); @@ -45,6 +54,7 @@ const char* ffDetectMonitor(FFlist* results) ffStrbufInit(&display->name); ffEdidGetName(edidData, &display->name); ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight); + display->hdrCompatible = ffEdidGetHdrCompatible(edidData, (uint32_t) fileStat.st_size); } ffStrbufSubstrBefore(&drmDir, drmDirLength); From a87a0470cae661cafd20960cf32c54989d4dbbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 12 Aug 2023 09:40:37 +0800 Subject: [PATCH 484/493] Fastfetch: fix #517 1. Fix specifying `--set-keyless` with the same key second time won't override the value set before 2. Fix specifying `--color` second time won't clear the value set before --- CHANGELOG.md | 2 ++ src/common/option.c | 1 + src/fastfetch.c | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2ca60035..be004f40b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ Bugfixes: * Fix option `--title-fqdn` doesn't work (Title) * Fix used spaces calculation (Disk, Linux / BSD / macOS, #508) * Fix `--brightness-format` (Brightness) +* Fix specifying `--set-keyless` with the same key second time won't override the value set before (#517) +* Fix specifying `--color` second time won't clear the value set before (#517) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: diff --git a/src/common/option.c b/src/common/option.c index faae31619..dc4be709d 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -132,6 +132,7 @@ bool ffOptionParseBoolean(const char* str) void ffOptionParseColor(const char* value, FFstrbuf* buffer) { + ffStrbufClear(buffer); ffStrbufEnsureFree(buffer, 63); while(*value != '\0') diff --git a/src/fastfetch.c b/src/fastfetch.c index 874a799f0..8156b7244 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -861,10 +861,24 @@ static void parseOption(FFdata* data, const char* key, const char* value) fprintf(stderr, "Error: usage: %s =\n", key); exit(477); } - FFCustomValue* customValue = (FFCustomValue*) ffListAdd(&data->customValues); - ffStrbufInitS(&customValue->value, &customValueStr.chars[index + 1]); - ffStrbufSubstrBefore(&customValueStr, index); - ffStrbufInitMove(&customValue->key, &customValueStr); + + FF_STRBUF_AUTO_DESTROY customKey = ffStrbufCreateNS(index, customValueStr.chars); + + FFCustomValue* customValue = NULL; + FF_LIST_FOR_EACH(FFCustomValue, x, data->customValues) + { + if(ffStrbufEqual(&x->key, &customKey)) + { + ffStrbufDestroy(&x->key); + ffStrbufDestroy(&x->value); + customValue = x; + break; + } + } + if(!customValue) customValue = (FFCustomValue*) ffListAdd(&data->customValues); + ffStrbufInitMove(&customValue->key, &customKey); + ffStrbufSubstrAfter(&customValueStr, index); + ffStrbufInitMove(&customValue->value, &customValueStr); customValue->printKey = *subkey == '\0'; } From 1f265c5d5c0803ac35eb6bb600f702521fa5ce25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 12 Aug 2023 10:09:36 +0800 Subject: [PATCH 485/493] Doc: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be004f40b..be70da113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Features: * Better CPU and Host detection for Android (Android) * Support yakuake terminal version & font detection (Terminal, Linux) * Add new option `--bright-color` which can be used to disable the default bright color of keys, title and ASCII logo. +* Add module `Monitor` which prints physical parameters (native resolutions and demensions) of connected monitors Bugfixes: * Fix possible hanging (TerminalFont, #493) From 082038f5fa050e78641b71c4c758d32dc60e8da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Aug 2023 09:22:04 +0800 Subject: [PATCH 486/493] Windows: silence compiler warnings --- src/util/wcwidth.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/wcwidth.c b/src/util/wcwidth.c index 3b799da66..7abd26f98 100644 --- a/src/util/wcwidth.c +++ b/src/util/wcwidth.c @@ -199,8 +199,13 @@ int mk_wcwidth(wchar_t ucs) (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */ (ucs >= 0xffe0 && ucs <= 0xffe6) || + +#ifndef _WIN32 // sizeof(wchar_t) == 2 (ucs >= 0x20000 && ucs <= 0x2fffd) || - (ucs >= 0x30000 && ucs <= 0x3fffd))); + (ucs >= 0x30000 && ucs <= 0x3fffd) || +#endif + 0 + )); } From 0b5631471a9931a956bd8328d16de8353776941f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Aug 2023 09:23:17 +0800 Subject: [PATCH 487/493] Logo: don't segfault if `--logo-source` starts with non-alpha charactors Ref: #518 --- src/logo/logo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logo/logo.c b/src/logo/logo.c index 78a430bf9..6cb49d1e9 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -211,7 +211,7 @@ static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) { - if (name->length == 0) + if (name->length == 0 || !isalpha(name->chars[0])) return NULL; for(const FFlogo* logo = ffLogoBuiltins[toupper(name->chars[0]) - 'A']; *logo->names; ++logo) From a34980e339f34325bc18d8cdf79077c23e56866a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Aug 2023 09:58:00 +0800 Subject: [PATCH 488/493] util/mallocHelper: add missing #include guards --- src/util/mallocHelper.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/mallocHelper.h b/src/util/mallocHelper.h index f7d5456fd..3cf19fad2 100644 --- a/src/util/mallocHelper.h +++ b/src/util/mallocHelper.h @@ -1,3 +1,8 @@ +#pragma once + +#ifndef FASTFETCH_INCLUDED_UTIL_MALLOC_HELPER +#define FASTFETCH_INCLUDED_UTIL_MALLOC_HELPER + #include #include @@ -9,3 +14,5 @@ static inline void ffWrapFree(void* pPtr) } #define FF_AUTO_FREE __attribute__((__cleanup__(ffWrapFree))) + +#endif From 290e721ee1943086c99d21121ec514f76d946b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Aug 2023 10:18:16 +0800 Subject: [PATCH 489/493] `--logo-source` / `--load-config`: support path with env variables (Windows) --- src/common/io/io.h | 1 + src/common/io/io_unix.c | 5 +++++ src/common/io/io_windows.c | 12 ++++++++++++ src/fastfetch.c | 11 +++++++++-- src/logo/logo.c | 5 +++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/common/io/io.h b/src/common/io/io.h index cfe730550..8cca6e147 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -82,6 +82,7 @@ typedef enum FFPathType #define FF_PATHTYPE_ANY (FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY) bool ffPathExists(const char* path, FFPathType pathType); +bool ffPathExpandEnv(const char* in, FFstrbuf* out); FF_C_SCANF(2, 3) const char* ffGetTerminalResponse(const char* request, const char* format, ...); diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 7680cab81..f0a69c537 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -107,6 +107,11 @@ bool ffPathExists(const char* path, FFPathType type) return false; } +bool ffPathExpandEnv(const char* in, FFstrbuf* out) +{ + return false; +} + const char* ffGetTerminalResponse(const char* request, const char* format, ...) { struct termios oldTerm, newTerm; diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index bf19540a2..2cd916bd8 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -98,6 +98,18 @@ bool ffPathExists(const char* path, FFPathType type) return false; } +bool ffPathExpandEnv(const char* in, FFstrbuf* out) +{ + DWORD length = ExpandEnvironmentStringsA(in, NULL, 0); + if (length <= 1) return false; + + ffStrbufClear(out); + ffStrbufEnsureFree(out, (uint32_t)length); + ExpandEnvironmentStringsA(in, out->chars, length); + out->length = (uint32_t)length - 1; + return true; +} + bool ffSuppressIO(bool suppress) { (void) suppress; //Not implemented. diff --git a/src/fastfetch.c b/src/fastfetch.c index 8156b7244..e0e32f9d7 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -693,9 +693,16 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val if(isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, value)) return; - //Try to load as a relative path - FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); + if (ffPathExpandEnv(value, &absolutePath)) + { + bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars); + + if(success) + return; + } + + //Try to load as a relative path FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { diff --git a/src/logo/logo.c b/src/logo/logo.c index 6cb49d1e9..f74818569 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -332,6 +332,11 @@ static void updateLogoPath(void) return; FF_STRBUF_AUTO_DESTROY fullPath = ffStrbufCreate(); + if (ffPathExpandEnv(options->source.chars, &fullPath) && ffPathExists(fullPath.chars, FF_PATHTYPE_FILE)) + { + ffStrbufSet(&options->source, &fullPath); + return; + } FF_LIST_FOR_EACH(FFstrbuf, dataDir, instance.state.platform.dataDirs) { From 658598f43a19598915191e32071d1d72f1def6d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Aug 2023 10:59:50 +0800 Subject: [PATCH 490/493] `--logo-source` / `--load-config`: support path with env variables (*nix) --- CHANGELOG.md | 1 + src/common/io/io_unix.c | 16 +++++++++++++++- src/logo/logo.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be70da113..858bb5c56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Features: * Support yakuake terminal version & font detection (Terminal, Linux) * Add new option `--bright-color` which can be used to disable the default bright color of keys, title and ASCII logo. * Add module `Monitor` which prints physical parameters (native resolutions and demensions) of connected monitors +* Support path with environment variables for `--logo-source` and `--load-config`. Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index f0a69c537..d1e635e11 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -6,6 +6,7 @@ #include #include #include +#include static void createSubfolders(const char* fileName) { @@ -109,7 +110,20 @@ bool ffPathExists(const char* path, FFPathType type) bool ffPathExpandEnv(const char* in, FFstrbuf* out) { - return false; + bool result = false; + wordexp_t exp; + if(wordexp(in, &exp, WRDE_NOCMD) != 0) + return false; + + if (exp.we_wordc == 1) + { + result = true; + ffStrbufSetS(out, exp.we_wordv[0]); + } + + wordfree(&exp); + + return result; } const char* ffGetTerminalResponse(const char* request, const char* format, ...) diff --git a/src/logo/logo.c b/src/logo/logo.c index f74818569..fa074e7d6 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -361,7 +361,7 @@ static bool logoPrintFileIfExists(bool doColorReplacement, bool raw) if(!ffAppendFileBuffer(options->source.chars, &content)) { - fputs("Logo: Failed to load file content from logo source\n", stderr); + fprintf(stderr, "Logo: Failed to load file content from logo source: %s \n", options->source.chars); return false; } From 9bc1ec9f363ec3a1c24c9b4fab638c2ecc51cf74 Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Sun, 13 Aug 2023 23:34:50 +0300 Subject: [PATCH 491/493] Add Slackel logo --- src/logo/ascii/slackel.txt | 22 ++++++++++++++++++++++ src/logo/builtin.c | 9 +++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/logo/ascii/slackel.txt diff --git a/src/logo/ascii/slackel.txt b/src/logo/ascii/slackel.txt new file mode 100644 index 000000000..d650f26f1 --- /dev/null +++ b/src/logo/ascii/slackel.txt @@ -0,0 +1,22 @@ + _aawmmmmmwwaaaaas,,,_. + .ammmmm###mmmmmmm###BQmm##mws + .am###mmBmBmBmBmBmBmmmmm#mmmm#2 + Date: Mon, 14 Aug 2023 09:19:33 +0800 Subject: [PATCH 492/493] Doc: update builtin logo list --- README.md | 3 ++- src/logo/builtin.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5176edee9..71d29bfaf 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,9 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos + ``` -AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, gNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin +AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin ``` Run `fastfetch --print-logos` to print them diff --git a/src/logo/builtin.c b/src/logo/builtin.c index a2e23461f..8e1438d5b 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -988,7 +988,7 @@ static const FFlogo C[] = { }; static const FFlogo D[] = { - // dahlia + // Dahlia { .names = {"dahlia"}, .lines = FASTFETCH_DATATEXT_LOGO_DAHLIA, @@ -1503,7 +1503,7 @@ static const FFlogo G[] = { .colorKeys = FF_COLOR_FG_MAGENTA, .colorTitle = FF_COLOR_FG_MAGENTA, }, - // gNewSense + // GNewSense { .names = {"gNewSense"}, .lines = FASTFETCH_DATATEXT_LOGO_GNEWSENSE, @@ -1761,7 +1761,7 @@ static const FFlogo I[] = { }; static const FFlogo J[] = { - // januslinux + // Januslinux { .names = {"januslinux", "janus"}, .lines = FASTFETCH_DATATEXT_LOGO_JANUSLINUX, From 550011c5f1a97d56cb2553c11f5f8966aa56c1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 14 Aug 2023 09:24:33 +0800 Subject: [PATCH 493/493] Release: v2.0.0 --- CHANGELOG.md | 4 ++-- CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 858bb5c56..89cfb0b40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ -# 2.0.0 +# 2.0.0 (beta) -This release introduces a new configuration file format: JSON config. Please refer to +Fastfetch v2 introduces a new configuration file format: JSON config. Please refer to for details. Changes: * Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0326edecb..d461a209e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url & FetchContent project(fastfetch - VERSION 1.12.2 + VERSION 2.0.0 LANGUAGES C DESCRIPTION "Fast system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"