mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Deps: revert changes of JSON parse library
Let's not make the change before fastfetch 2.0
This commit is contained in:
@@ -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 libcjson-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 libcjson-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 mingw-w64-clang-x86_64-cjson
|
||||
|
||||
- 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/{libcjson,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 mingw-w64-clang-i686-cjson
|
||||
|
||||
- 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/{libcjson,OpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
@@ -15,9 +15,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)
|
||||
|
||||
|
||||
+4
-4
@@ -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_LIBCJSON "Enable libcjson" 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)
|
||||
cmake_dependent_option(USE_WIN_NTAPI "Allow using internal NTAPI" ON "WIN32" OFF)
|
||||
@@ -683,9 +683,9 @@ ff_lib_enable(PULSE
|
||||
"libpulse"
|
||||
"Pulse"
|
||||
)
|
||||
ff_lib_enable(JSONC
|
||||
"json-c"
|
||||
"json-c"
|
||||
ff_lib_enable(LIBCJSON
|
||||
"libcjson"
|
||||
"CJson"
|
||||
)
|
||||
|
||||
if(ENABLE_THREADS)
|
||||
|
||||
@@ -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.
|
||||
* [`json-c`](https://github.com/json-c/json-c): Needed for Windows Terminal font ( WSL ).
|
||||
* [`libcJSON`](https://github.com/DaveGamble/cJSON): 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.
|
||||
|
||||
@@ -70,7 +70,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.
|
||||
* [`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)
|
||||
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection. [`cjson`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-cjson)
|
||||
* [`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)
|
||||
|
||||
@@ -137,7 +137,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-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
```
|
||||
|
||||
Follow the building instructions of Linux next.
|
||||
|
||||
+4
-4
@@ -136,7 +136,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInitA(&instance->config.libGLX, 0);
|
||||
ffStrbufInitA(&instance->config.libOSMesa, 0);
|
||||
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
||||
ffStrbufInitA(&instance->config.libJSONC, 0);
|
||||
ffStrbufInitA(&instance->config.libcJSON, 0);
|
||||
ffStrbufInitA(&instance->config.libfreetype, 0);
|
||||
ffStrbufInit(&instance->config.libPulse);
|
||||
ffStrbufInit(&instance->config.libwlanapi);
|
||||
@@ -403,7 +403,7 @@ static void destroyConfig(FFinstance* instance)
|
||||
ffStrbufDestroy(&instance->config.libGLX);
|
||||
ffStrbufDestroy(&instance->config.libOSMesa);
|
||||
ffStrbufDestroy(&instance->config.libOpenCL);
|
||||
ffStrbufDestroy(&instance->config.libJSONC);
|
||||
ffStrbufDestroy(&instance->config.libcJSON);
|
||||
ffStrbufDestroy(&instance->config.libfreetype);
|
||||
ffStrbufDestroy(&instance->config.libPulse);
|
||||
ffStrbufDestroy(&instance->config.libwlanapi);
|
||||
@@ -508,8 +508,8 @@ void ffListFeatures()
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
"opencl\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_LIBJSONC
|
||||
"json-c\n"
|
||||
#ifdef FF_HAVE_LIBCJSON
|
||||
"libcjson\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
"freetype\n"
|
||||
|
||||
@@ -446,6 +446,6 @@
|
||||
#--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-cjson /usr/lib/libcjson.so
|
||||
#--lib-freetype /data/data/com.termux/files/usr/lib
|
||||
#--lib-pulse /usr/lib/libpulse.so
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ Library options: Set the path of a library to load
|
||||
--lib-glx <path>
|
||||
--lib-osmesa <path>
|
||||
--lib-opencl <path>
|
||||
--lib-jsonc <path>
|
||||
--lib-cjson <path>
|
||||
--lib-pulse <path>
|
||||
--lib-freetype <path>
|
||||
|
||||
|
||||
@@ -67,115 +67,110 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont)
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#ifdef FF_HAVE_LIBCJSON
|
||||
|
||||
#include "common/library.h"
|
||||
#include "common/processing.h"
|
||||
|
||||
#include <cjson/cJSON.h>
|
||||
#include <stdlib.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
typedef struct JSONCData
|
||||
typedef struct CJSONData
|
||||
{
|
||||
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)
|
||||
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)
|
||||
|
||||
json_object* root;
|
||||
} JSONCData;
|
||||
cJSON* root;
|
||||
} CJSONData;
|
||||
|
||||
static const char* detectWTProfile(JSONCData* data, json_object* profile, FFstrbuf* name, double* size)
|
||||
static const char* detectWTProfile(CJSONData* cjsonData, cJSON* profile, FFstrbuf* name, double* size)
|
||||
{
|
||||
json_object* font = data->ffjson_object_object_get(profile, "font");
|
||||
if (!font)
|
||||
return "json_object_object_get(profile, \"font\"); failed";
|
||||
if(!cjsonData->ffcJSON_IsObject(profile))
|
||||
return "cJSON_IsObject(profile) returns false";
|
||||
|
||||
if (!data->ffjson_object_is_type(font, json_type_object))
|
||||
return "json_object_is_type(font, json_type_object) returns false";
|
||||
cJSON* font = cjsonData->ffcJSON_GetObjectItemCaseSensitive(profile, "font");
|
||||
if(!cjsonData->ffcJSON_IsObject(font))
|
||||
return "cJSON_IsObject(font) returns false";
|
||||
|
||||
if (name->length == 0)
|
||||
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));
|
||||
cJSON* pface = cjsonData->ffcJSON_GetObjectItemCaseSensitive(font, "face");
|
||||
if(cjsonData->ffcJSON_IsString(pface))
|
||||
ffStrbufAppendS(name, cjsonData->ffcJSON_GetStringValue(pface));
|
||||
}
|
||||
|
||||
if (*size < 0)
|
||||
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);
|
||||
cJSON* psize = cjsonData->ffcJSON_GetObjectItemCaseSensitive(font, "size");
|
||||
if(cjsonData->ffcJSON_IsNumber(psize))
|
||||
*size = cjsonData->ffcJSON_GetNumberValue(psize);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void wrapJsoncFree(JSONCData* data)
|
||||
static inline void wrapCjsonFree(CJSONData* data)
|
||||
{
|
||||
assert(data);
|
||||
if (data->root)
|
||||
data->ffjson_object_put(data->root);
|
||||
data->ffcJSON_Delete(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)
|
||||
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)
|
||||
|
||||
data.root = data.ffjson_tokener_parse(content->chars);
|
||||
if (!data.root)
|
||||
return "Failed to parse WT JSON config file";
|
||||
cJSON* root = cjsonData.root = cjsonData.ffcJSON_Parse(content->chars);
|
||||
if(!cjsonData.ffcJSON_IsObject(root))
|
||||
return "cJSON_Parse() failed";
|
||||
|
||||
json_object* profiles = data.ffjson_object_object_get(data.root, "profiles");
|
||||
if (!profiles)
|
||||
return "json_object_object_get(root, \"profiles\") failed";
|
||||
cJSON* profiles = cjsonData.ffcJSON_GetObjectItemCaseSensitive(root, "profiles");
|
||||
if(!cjsonData.ffcJSON_IsObject(profiles))
|
||||
return "cJSON_GetObjectItemCaseSensitive(root, \"profiles\") failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY wtProfileId;
|
||||
ffStrbufInitS(&wtProfileId, getenv("WT_PROFILE_ID"));
|
||||
ffStrbufTrim(&wtProfileId, '\'');
|
||||
if (wtProfileId.length > 0)
|
||||
if(wtProfileId.length > 0)
|
||||
{
|
||||
array_list* list = data.ffjson_object_get_array(data.ffjson_object_object_get(profiles, "list"));
|
||||
if (list)
|
||||
cJSON* list = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profiles, "list");
|
||||
if(cjsonData.ffcJSON_IsArray(list))
|
||||
{
|
||||
for (size_t idx = 0; idx < list->length; ++idx)
|
||||
cJSON* profile;
|
||||
cJSON_ArrayForEach(profile, list)
|
||||
{
|
||||
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))
|
||||
if(!cjsonData.ffcJSON_IsObject(profile))
|
||||
continue;
|
||||
|
||||
if(ffStrbufEqualS(&wtProfileId, data.ffjson_object_get_string(guid)))
|
||||
cJSON* guid = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profile, "guid");
|
||||
if(!cjsonData.ffcJSON_IsString(guid))
|
||||
continue;
|
||||
if(ffStrbufCompS(&wtProfileId, cjsonData.ffcJSON_GetStringValue(guid)) == 0)
|
||||
{
|
||||
detectWTProfile(&data, profile, name, size);
|
||||
detectWTProfile(&cjsonData, profile, name, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json_object* defaults = data.ffjson_object_object_get(profiles, "defaults");
|
||||
if (defaults)
|
||||
detectWTProfile(&data, defaults, name, size);
|
||||
cJSON* defaults = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profiles, "defaults");
|
||||
if(defaults)
|
||||
detectWTProfile(&cjsonData, defaults, name, size);
|
||||
|
||||
if(name->length == 0)
|
||||
ffStrbufSetS(name, "Cascadia Mono");
|
||||
@@ -193,7 +188,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;
|
||||
FF_STRBUF_AUTO_DESTROY json;
|
||||
ffStrbufInit(&json);
|
||||
const char* error = NULL;
|
||||
|
||||
@@ -254,22 +249,19 @@ 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;
|
||||
FF_STRBUF_AUTO_DESTROY name;
|
||||
ffStrbufInit(&name);
|
||||
double size = -1;
|
||||
error = detectFromWTImpl(instance, &json, &name, &size);
|
||||
ffStrbufDestroy(&json);
|
||||
|
||||
if(error)
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
@@ -279,19 +271,17 @@ 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
|
||||
#else //FF_HAVE_CJSON
|
||||
|
||||
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");
|
||||
ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without libcJSON support");
|
||||
}
|
||||
|
||||
#endif //FF_HAVE_JSONC
|
||||
#endif //FF_HAVE_CJSON
|
||||
|
||||
#endif //defined(_WIN32) || defined(__linux__)
|
||||
|
||||
|
||||
+2
-2
@@ -1227,8 +1227,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, "-jsonc") == 0)
|
||||
optionParseString(key, value, &instance->config.libJSONC);
|
||||
else if(strcasecmp(subkey, "-cjson") == 0)
|
||||
optionParseString(key, value, &instance->config.libcJSON);
|
||||
else if(strcasecmp(subkey, "-wlanapi") == 0)
|
||||
optionParseString(key, value, &instance->config.libwlanapi);
|
||||
else if(strcasecmp(key, "-pulse") == 0)
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ typedef struct FFconfig
|
||||
FFstrbuf libGLX;
|
||||
FFstrbuf libOSMesa;
|
||||
FFstrbuf libOpenCL;
|
||||
FFstrbuf libJSONC;
|
||||
FFstrbuf libcJSON;
|
||||
FFstrbuf libfreetype;
|
||||
FFstrbuf libPulse;
|
||||
FFstrbuf libwlanapi;
|
||||
|
||||
Reference in New Issue
Block a user