From dd2cc116bd8abf05349f407626fe5dc1fc162221 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 28 Mar 2024 14:10:44 +0800 Subject: [PATCH 1/7] TerminalFont (Linux): support weston-terminal --- src/detection/terminalfont/terminalfont_linux.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 3a6ac9086..247959fc3 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -325,6 +325,19 @@ static void detectWarp(FFTerminalFontResult* terminalFont) } } +static void detectWestonTerminal(FFTerminalFontResult* terminalFont) +{ + FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY size = ffStrbufCreate(); + ffParsePropFileConfigValues("weston.ini", 2, (FFpropquery[]) { + {"font=", &font}, + {"font-size=", &size}, + }); + if (!font.length) ffStrbufSetStatic(&font, "DejaVu Sans Mono"); + if (!size.length) ffStrbufSetStatic(&size, "14"); + ffFontInitValues(&terminalFont->font, font.chars, size.chars); +} + void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminal->processName, "konsole")) @@ -355,4 +368,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo detectSt(terminalFont, terminal->pid); else if(ffStrbufIgnCaseEqualS(&terminal->processName, "warp")) detectWarp(terminalFont); + else if(ffStrbufIgnCaseEqualS(&terminal->processName, "weston-terminal")) + detectWestonTerminal(terminalFont); } From 3d78666ed3a1c5365f28dc138496064b43456b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 6 Apr 2024 17:37:31 +0800 Subject: [PATCH 2/7] Doc: update changelog weston-terminal font detection was not pushed in v2.9.0 --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 584f7cc0a..d9f9800a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ +# 2.9.1 + +Features: +* Support weston-terminal (TerminalFont, Linux) + # 2.9.0 Features: * Support Lxterminal version detection (Terminal, Linux) -* Support weston-terminal version and font detection (TerminalFont, Linux) +* Support weston-terminal version detection (Terminal, Linux) * Support `am` package manager detection (#771, Packages, Linux) * Support network prefix length detection for IPv6 (LocalIP) * Display all IPs when multiple IPs are assigned to the same interface (LocalIP) From 12ac0ac7a90cd9ab301f2154e388922c27e95e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 7 Apr 2024 19:35:22 +0800 Subject: [PATCH 3/7] Cursor: tidy --- src/common/parsing.c | 10 +++++----- src/detection/cursor/cursor_linux.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/parsing.c b/src/common/parsing.c index b3f07a509..0d1aaba54 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -100,19 +100,19 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co { if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0) { - if((ffStrbufIgnCaseComp(gtk2, gtk3) == 0) && (ffStrbufIgnCaseComp(gtk2, gtk4) == 0)) + if((ffStrbufIgnCaseEqual(gtk2, gtk3)) && (ffStrbufIgnCaseEqual(gtk2, gtk4))) { ffStrbufAppend(buffer, gtk4); ffStrbufAppendS(buffer, " [GTK2/3/4]"); } - else if(ffStrbufIgnCaseComp(gtk2, gtk3) == 0) + else if(ffStrbufIgnCaseEqual(gtk2, gtk3)) { ffStrbufAppend(buffer, gtk3); ffStrbufAppendS(buffer, " [GTK2/3], "); ffStrbufAppend(buffer, gtk4); ffStrbufAppendS(buffer, " [GTK4]"); } - else if(ffStrbufIgnCaseComp(gtk3, gtk4) == 0) + else if(ffStrbufIgnCaseEqual(gtk3, gtk4)) { ffStrbufAppend(buffer, gtk2); ffStrbufAppendS(buffer, " [GTK2], "); @@ -131,7 +131,7 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co } else if(gtk2->length > 0 && gtk3->length > 0) { - if(ffStrbufIgnCaseComp(gtk2, gtk3) == 0) + if(ffStrbufIgnCaseEqual(gtk2, gtk3)) { ffStrbufAppend(buffer, gtk3); ffStrbufAppendS(buffer, " [GTK2/3]"); @@ -146,7 +146,7 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co } else if(gtk3->length > 0 && gtk4->length > 0) { - if(ffStrbufIgnCaseComp(gtk3, gtk4) == 0) + if(ffStrbufIgnCaseEqual(gtk3, gtk4)) { ffStrbufAppend(buffer, gtk4); ffStrbufAppendS(buffer, " [GTK3/4]"); diff --git a/src/detection/cursor/cursor_linux.c b/src/detection/cursor/cursor_linux.c index 17ff04765..406e95ef0 100644 --- a/src/detection/cursor/cursor_linux.c +++ b/src/detection/cursor/cursor_linux.c @@ -72,11 +72,11 @@ void ffDetectCursor(FFCursorResult* result) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(); - if(ffStrbufCompS(&wmde->wmPrettyName, FF_WM_PRETTY_WSLG) == 0) + if(ffStrbufEqualS(&wmde->wmPrettyName, FF_WM_PRETTY_WSLG)) ffStrbufAppendS(&result->error, "WSLg uses native windows cursor"); - else if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0) + else if(ffStrbufIgnCaseEqualS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY)) ffStrbufAppendS(&result->error, "Cursor isn't supported in TTY"); - else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA) == 0) + else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA)) detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) detectCursorFromConfigFile("lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); From 5374feb24bedaa89bd6b8a823a69724fc96c9166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 7 Apr 2024 20:08:41 +0800 Subject: [PATCH 4/7] Cursor (Linux): support hyprcursor detection Fix: #776 --- CHANGELOG.md | 1 + src/detection/cursor/cursor_linux.c | 15 +++++++++++++++ src/detection/displayserver/displayserver.h | 1 + src/detection/displayserver/linux/wmde.c | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f9800a0..01b49ee7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Features: * Support weston-terminal (TerminalFont, Linux) +* Support hyprcursor detection (Cursor, Linux) # 2.9.0 diff --git a/src/detection/cursor/cursor_linux.c b/src/detection/cursor/cursor_linux.c index 406e95ef0..ff2422249 100644 --- a/src/detection/cursor/cursor_linux.c +++ b/src/detection/cursor/cursor_linux.c @@ -68,6 +68,19 @@ static bool detectCursorFromEnv(FFCursorResult* result) return true; } +static bool detectCursorHyprcursor(FFCursorResult* result) +{ + const char* hyprcursor_theme = getenv("HYPRCURSOR_THEME"); + + if(!ffStrSet(hyprcursor_theme)) + return false; + + ffStrbufAppendS(&result->theme, hyprcursor_theme); + ffStrbufAppendS(&result->size, getenv("HYPRCURSOR_SIZE")); + + return true; +} + void ffDetectCursor(FFCursorResult* result) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(); @@ -80,6 +93,8 @@ void ffDetectCursor(FFCursorResult* result) detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) detectCursorFromConfigFile("lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); + else if(ffStrbufIgnCaseEqualS(&wmde->wmPrettyName, FF_WM_PRETTY_HYPRLAND) && detectCursorHyprcursor(result)) + return; else if( !detectCursorGTK(result) && !detectCursorFromEnv(result) && diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index b5655a84f..9c6c2d96e 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -21,6 +21,7 @@ #define FF_WM_PRETTY_XFWM4 "Xfwm4" #define FF_WM_PRETTY_OPENBOX "Openbox" #define FF_WM_PRETTY_I3 "i3" +#define FF_WM_PRETTY_HYPRLAND "Hyprland" #define FF_WM_PRETTY_WAYFIRE "Wayfire" #define FF_WM_PRETTY_SWAY "Sway" #define FF_WM_PRETTY_BSPWM "bspwm" diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 625f04e47..5d21f1d6c 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -52,6 +52,9 @@ static const char* parseEnv(void) if(getenv("TDE_FULL_SESSION") != NULL) return "Trinity"; + if(getenv("HYPRLAND_CMD") != NULL) + return "Hyprland"; + #ifdef __linux__ if( getenv("WAYLAND_DISPLAY") != NULL && @@ -116,6 +119,8 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_ICEWM); else if(ffStrEqualsIgnCase(name, "dtwm")) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_DTWM); + else if(ffStrEqualsIgnCase(name, "hyprland")) + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_HYPRLAND); } static void applyNameIfWM(FFDisplayServerResult* result, const char* processName) From aa45e70910b180235eb4cbdde5103a6459e22913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 7 Apr 2024 20:41:01 +0800 Subject: [PATCH 5/7] Revert "fastfetch: add the missing new-line in config files (#772)" Fix #778 This reverts commit 4430b7145ebca48a6607133ebf58f3d8a7285211. --- src/fastfetch.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 20f316d0e..0109c2717 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -821,7 +821,6 @@ static void run(FFdata* data) if (instance.state.resultDoc) { yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); - //TODO should use YYJSON_WRITE_NEWLINE_AT_END when it is available putchar('\n'); } else @@ -841,23 +840,24 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename) ffOptionsGenerateLibraryJsonConfig(&instance.config.library, doc); ffMigrateCommandOptionToJsonc(data, doc); - FILE *fp = stdout; - bool writeToStdout = ffStrbufEqualS(filename, "-"); - if (!writeToStdout) - fp = fopen(filename->chars, "w"); - - bool ok = yyjson_mut_write_fp(fp, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); - //TODO should use YYJSON_WRITE_NEWLINE_AT_END when it is available - fputc('\n', fp); - if (!ok) + if (ffStrbufEqualS(filename, "-")) + yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); + else { - fprintf(stderr, "Error: failed to generate config in `%s`\n", writeToStdout ? "stdout" : filename->chars); - exit(1); - } - if (ok && !writeToStdout) - { - fclose(fp); - printf("The generated config file has been written in `%s`\n", filename->chars); + size_t len; + FF_AUTO_FREE const char* str = yyjson_mut_write(doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, &len); + if (!str) + { + printf("Error: failed to generate config file\n"); + exit(1); + } + if (ffWriteFileData(filename->chars, len, str)) + printf("The generated config file has been written in `%s`\n", filename->chars); + else + { + printf("Error: failed to write file in `%s`\n", filename->chars); + exit(1); + } } yyjson_mut_doc_free(doc); From fd1a2072b3b2ef82b0b4b7391fc40c09dc76d90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 7 Apr 2024 20:44:17 +0800 Subject: [PATCH 6/7] Cursor: tidy --- src/detection/cursor/cursor_linux.c | 2 +- src/detection/gtk_qt/qt.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/cursor/cursor_linux.c b/src/detection/cursor/cursor_linux.c index ff2422249..bd8c9b1cd 100644 --- a/src/detection/cursor/cursor_linux.c +++ b/src/detection/cursor/cursor_linux.c @@ -91,7 +91,7 @@ void ffDetectCursor(FFCursorResult* result) ffStrbufAppendS(&result->error, "Cursor isn't supported in TTY"); else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA)) detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); - else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) + else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) detectCursorFromConfigFile("lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); else if(ffStrbufIgnCaseEqualS(&wmde->wmPrettyName, FF_WM_PRETTY_HYPRLAND) && detectCursorHyprcursor(result)) return; diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index a18a324b1..331de6609 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -151,9 +151,9 @@ const FFQtResult* ffDetectQt(void) const FFDisplayServerResult* wmde = ffConnectDisplayServer(); - if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA) == 0) + if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA)) detectPlasma(&result); - else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT) == 0) + else if(ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) detectLXQt(&result); return &result; From e16f8ef3498541d9f055cc1085d198c541fb568a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 7 Apr 2024 20:47:19 +0800 Subject: [PATCH 7/7] Release: v2.9.1 --- CHANGELOG.md | 7 +++++-- CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b49ee7d..753feb5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # 2.9.1 Features: -* Support weston-terminal (TerminalFont, Linux) -* Support hyprcursor detection (Cursor, Linux) +* Support weston-terminal (missed commit in v2.9.0) (TerminalFont, Linux) +* Support hyprcursor detection (#776, Cursor, Linux) + +Bugfixes: +* Fix `fastfetch --gen-config` raises SIGSEGV when `~/.config/fastfetch` doesn't exist. Regression of `2.9.0` (#778) # 2.9.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6470145a3..316048646 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 project(fastfetch - VERSION 2.9.0 + VERSION 2.9.1 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"