Skip to content

Commit

Permalink
Merge pull request #779 from fastfetch-cli/dev
Browse files Browse the repository at this point in the history
Release v2.9.1
  • Loading branch information
CarterLi committed Apr 7, 2024
2 parents ba2636d + e16f8ef commit a1e79a9
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 30 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
@@ -1,8 +1,17 @@
# 2.9.1

Features:
* 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

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)
Expand Down
2 changes: 1 addition & 1 deletion 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"
Expand Down
10 changes: 5 additions & 5 deletions src/common/parsing.c
Expand Up @@ -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], ");
Expand All @@ -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]");
Expand All @@ -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]");
Expand Down
23 changes: 19 additions & 4 deletions src/detection/cursor/cursor_linux.c
Expand Up @@ -68,18 +68,33 @@ 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();

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))
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;
else if(
!detectCursorGTK(result) &&
!detectCursorFromEnv(result) &&
Expand Down
1 change: 1 addition & 0 deletions src/detection/displayserver/displayserver.h
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/detection/displayserver/linux/wmde.c
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/detection/gtk_qt/qt.c
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions src/detection/terminalfont/terminalfont_linux.c
Expand Up @@ -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"))
Expand Down Expand Up @@ -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);
}
34 changes: 17 additions & 17 deletions src/fastfetch.c
Expand Up @@ -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
Expand All @@ -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)
{
fprintf(stderr, "Error: failed to generate config in `%s`\n", writeToStdout ? "stdout" : filename->chars);
exit(1);
}
if (ok && !writeToStdout)
if (ffStrbufEqualS(filename, "-"))
yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL);
else
{
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);
Expand Down

0 comments on commit a1e79a9

Please sign in to comment.