mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
WM: honors general.detectVersion
This commit is contained in:
+23
-20
@@ -36,32 +36,35 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
|
||||
!ffStrEqualsIgnCase(comm, "rectangle")
|
||||
) continue;
|
||||
|
||||
char buf[PROC_PIDPATHINFO_MAXSIZE];
|
||||
int length = proc_pidpath(proc->kp_proc.p_pid, buf, ARRAY_SIZE(buf));
|
||||
if (length > 0)
|
||||
if (instance.config.general.detectVersion)
|
||||
{
|
||||
char* lastSlash = strrchr(buf, '/');
|
||||
if (lastSlash)
|
||||
char buf[PROC_PIDPATHINFO_MAXSIZE];
|
||||
int length = proc_pidpath(proc->kp_proc.p_pid, buf, ARRAY_SIZE(buf));
|
||||
if (length > 0)
|
||||
{
|
||||
*lastSlash = '\0';
|
||||
if (ffStrEndsWith(buf, ".app/Contents/MacOS"))
|
||||
char* lastSlash = strrchr(buf, '/');
|
||||
if (lastSlash)
|
||||
{
|
||||
lastSlash -= strlen("MacOS");
|
||||
strcpy(lastSlash, "Info.plist"); // X.app/Contents/Info.plist
|
||||
NSError* error;
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(buf)]
|
||||
error:&error];
|
||||
if (dict)
|
||||
*lastSlash = '\0';
|
||||
if (ffStrEndsWith(buf, ".app/Contents/MacOS"))
|
||||
{
|
||||
ffStrbufSetS(pluginName, [dict[@"CFBundleName"] UTF8String]);
|
||||
NSString* version = dict[@"CFBundleShortVersionString"];
|
||||
if (version)
|
||||
lastSlash -= strlen("MacOS");
|
||||
strcpy(lastSlash, "Info.plist"); // X.app/Contents/Info.plist
|
||||
NSError* error;
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(buf)]
|
||||
error:&error];
|
||||
if (dict)
|
||||
{
|
||||
ffStrbufAppendC(pluginName, ' ');
|
||||
ffStrbufAppendS(pluginName, version.UTF8String);
|
||||
}
|
||||
ffStrbufSetS(pluginName, [dict[@"CFBundleName"] UTF8String]);
|
||||
NSString* version = dict[@"CFBundleShortVersionString"];
|
||||
if (version)
|
||||
{
|
||||
ffStrbufAppendC(pluginName, ' ');
|
||||
ffStrbufAppendS(pluginName, version.UTF8String);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
|
||||
memcmp(ptr->ImageName.Buffer, L"FancyWM-GUI.exe", ptr->ImageName.Length) == 0 &&
|
||||
isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_WINDOWS_STORE | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer))
|
||||
) {
|
||||
if (ffGetFileVersion(filePath->Buffer, NULL, pluginName))
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName))
|
||||
ffStrbufPrependS(pluginName, "FancyWM ");
|
||||
else
|
||||
ffStrbufSetStatic(pluginName, "FancyWM");
|
||||
@@ -150,7 +150,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
|
||||
memcmp(ptr->ImageName.Buffer, L"glazewm-watcher.exe", ptr->ImageName.Length) == 0 &&
|
||||
isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_SIGNED | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer))
|
||||
) {
|
||||
if (ffGetFileVersion(filePath->Buffer, NULL, pluginName))
|
||||
if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName))
|
||||
ffStrbufPrependS(pluginName, "GlazeWM ");
|
||||
else
|
||||
ffStrbufSetStatic(pluginName, "GlazeWM");
|
||||
@@ -160,14 +160,17 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
|
||||
memcmp(ptr->ImageName.Buffer, L"komorebi.exe", ptr->ImageName.Length) == 0 &&
|
||||
isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_CUI, filePath, sizeof(buffer))
|
||||
) {
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateNWS(filePath->Length / sizeof(wchar_t), filePath->Buffer);
|
||||
if (ffProcessAppendStdOut(pluginName, (char *const[]) {
|
||||
path.chars,
|
||||
"--version",
|
||||
NULL,
|
||||
}) == NULL)
|
||||
ffStrbufSubstrBeforeFirstC(pluginName, '\n');
|
||||
else
|
||||
if (instance.config.general.detectVersion)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateNWS(filePath->Length / sizeof(wchar_t), filePath->Buffer);
|
||||
if (ffProcessAppendStdOut(pluginName, (char *const[]) {
|
||||
path.chars,
|
||||
"--version",
|
||||
NULL,
|
||||
}) == NULL)
|
||||
ffStrbufSubstrBeforeFirstC(pluginName, '\n');
|
||||
}
|
||||
if (pluginName->length == 0)
|
||||
ffStrbufSetStatic(pluginName, "Komorebi");
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user