mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
WM is once again shown in a plasma session
This commit is contained in:
+7
-1
@@ -225,7 +225,7 @@ void ffPrintError(FFinstance* instance, const char* key, const char* message, ..
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
void ffGetFileContent(const char* fileName, FFstrbuf* buffer)
|
||||
void ffAppendFileContent(const char* fileName, FFstrbuf* buffer)
|
||||
{
|
||||
int fd = open(fileName, O_RDONLY);
|
||||
if(fd == -1)
|
||||
@@ -247,6 +247,12 @@ void ffGetFileContent(const char* fileName, FFstrbuf* buffer)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void ffGetFileContent(const char* fileName, FFstrbuf* buffer)
|
||||
{
|
||||
ffStrbufClear(buffer);
|
||||
ffAppendFileContent(fileName, buffer);
|
||||
}
|
||||
|
||||
static const FFstrbuf* getCacheDir(FFinstance* instance)
|
||||
{
|
||||
static FFstrbuf cacheDir;
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ static inline void printCommandHelp(const char* command)
|
||||
else if(strcasecmp(command, "de-format") == 0)
|
||||
constructAndPrintCommandHelpFormat("de", "{} {} ({})", 3, "DE name", "DE version", "Name of display server");
|
||||
else if(strcasecmp(command, "wm-format") == 0)
|
||||
constructAndPrintCommandHelpFormat("wm", "{}", 1, "WM name");
|
||||
constructAndPrintCommandHelpFormat("wm", "{2}", 2, "WM process name", "WM pretty name");
|
||||
else if(strcasecmp(command, "theme-format") == 0)
|
||||
constructAndPrintCommandHelpFormat("theme", "{} [Plasma], {5}", 5, "Plasma theme", "GTK2 theme", "GTK3 theme", "GTK4 theme", "Combined GTK themes");
|
||||
else if(strcasecmp(command, "icons-format") == 0)
|
||||
|
||||
@@ -119,6 +119,7 @@ void ffInitState(FFstate* state);
|
||||
void ffDefaultConfig(FFconfig* config);
|
||||
void ffPrintKey(FFconfig* config, const char* key);
|
||||
void ffPrintLogoAndKey(FFinstance* instance, const char* key);
|
||||
void ffAppendFileContent(const char* fileName, FFstrbuf* buffer);
|
||||
void ffGetFileContent(const char* fileName, FFstrbuf* buffer);
|
||||
void ffParsePropFile(const char* file, const char* regex, char* buffer);
|
||||
void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer);
|
||||
|
||||
+14
-20
@@ -2,16 +2,6 @@
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
static bool parseProcessName(FFstrbuf* name)
|
||||
{
|
||||
if(ffStrbufIgnCaseCompS(name, "kwin_wayland") == 0 || ffStrbufIgnCaseCompS(name, "kwin_x11") == 0)
|
||||
ffStrbufSetS(name, "KWin");
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffPrintWM(FFinstance* instance)
|
||||
{
|
||||
DIR* proc = opendir("/proc/");
|
||||
@@ -23,9 +13,8 @@ void ffPrintWM(FFinstance* instance)
|
||||
|
||||
struct dirent* dirent;
|
||||
|
||||
FF_STRBUF_CREATE(name);
|
||||
|
||||
bool found = false;
|
||||
FF_STRBUF_CREATE(processName);
|
||||
FF_STRBUF_CREATE(prettyName);
|
||||
|
||||
while((dirent = readdir(proc)) != NULL)
|
||||
{
|
||||
@@ -35,9 +24,12 @@ void ffPrintWM(FFinstance* instance)
|
||||
char path[20];
|
||||
sprintf(path, "/proc/%.8s/comm", dirent->d_name);
|
||||
|
||||
ffGetFileContent(path, &name);
|
||||
ffGetFileContent(path, &processName);
|
||||
|
||||
if((found = parseProcessName(&name)))
|
||||
if(ffStrbufIgnCaseCompS(&processName, "kwin_wayland") == 0 || ffStrbufIgnCaseCompS(&processName, "kwin_x11") == 0)
|
||||
ffStrbufSetS(&prettyName, "KWin");
|
||||
|
||||
if(prettyName.length > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -45,21 +37,23 @@ void ffPrintWM(FFinstance* instance)
|
||||
|
||||
if(instance->config.wmFormat.length == 0)
|
||||
{
|
||||
if(!found)
|
||||
if(prettyName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, "WM", "No process name matches the name of known display managers");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, "WM");
|
||||
ffStrbufPutTo(&name, stdout);
|
||||
ffStrbufPutTo(&prettyName, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, "WM", &instance->config.wmFormat, 1,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &name}
|
||||
ffPrintFormatString(instance, "WM", &instance->config.wmFormat, 2,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &processName},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &prettyName}
|
||||
);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&name);
|
||||
ffStrbufDestroy(&processName);
|
||||
ffStrbufDestroy(&prettyName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user