mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Terminal (Haiku): detect terminal version
This commit is contained in:
+2
-1
@@ -1148,7 +1148,7 @@ elseif(Haiku)
|
||||
src/detection/gtk_qt/gtk.c
|
||||
src/detection/host/host_windows.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/initsystem/initsystem_haiku.cpp
|
||||
src/detection/initsystem/initsystem_haiku.c
|
||||
src/detection/keyboard/keyboard_haiku.cpp
|
||||
src/detection/libc/libc_nosupport.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
@@ -1184,6 +1184,7 @@ elseif(Haiku)
|
||||
src/detection/zpool/zpool_nosupport.c
|
||||
src/util/platform/FFPlatform_unix.c
|
||||
src/util/binary_linux.c
|
||||
src/util/haiku/version.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -315,6 +315,25 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
{
|
||||
team_info info;
|
||||
if (get_team_info(pid, &info) == B_OK)
|
||||
{
|
||||
// This is tricky. info.args is not encoded, so that we don't know if
|
||||
// a whitespace in args is part of the file path or an argument separator
|
||||
if (info.argc == 1)
|
||||
ffStrbufSetS(exe, info.args);
|
||||
else
|
||||
{
|
||||
int argc = info.argc;
|
||||
for (const char* p = info.args; (p = strchr(p, ' ')); ++p)
|
||||
--argc;
|
||||
if (argc == 1)
|
||||
ffStrbufSetS(exe, info.args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exePath)
|
||||
{
|
||||
image_info info;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "initsystem.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/haiku/version.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <OS.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* ffDetectInitSystem(FFInitSystemResult* result)
|
||||
{
|
||||
// Since it runs first, registrar does not know about it,
|
||||
// so we can't query be_roster for it.
|
||||
const char* path = "/boot/system/servers/launch_daemon";
|
||||
if (!ffPathExists(path, FF_PATHTYPE_FILE))
|
||||
return "launch_daemon is not found";
|
||||
|
||||
ffStrbufSetStatic(&result->exe, path);
|
||||
ffStrbufSetStatic(&result->name, "launch_daemon");
|
||||
|
||||
team_info teamInfo;
|
||||
int32 cookie = 0;
|
||||
while (get_next_team_info(&cookie, &teamInfo) == B_OK)
|
||||
{
|
||||
if (ffStrEquals(teamInfo.args, path))
|
||||
{
|
||||
result->pid = (uint32_t) teamInfo.team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ffGetFileVersion(path, &result->version);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
extern "C" {
|
||||
#include "initsystem.h"
|
||||
#include "common/processing.h"
|
||||
#include "util/binary.h"
|
||||
#include "util/stringUtils.h"
|
||||
};
|
||||
|
||||
#include <AppFileInfo.h>
|
||||
#include <File.h>
|
||||
#include <libgen.h>
|
||||
#include <OS.h>
|
||||
#include <Path.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* ffDetectInitSystem(FFInitSystemResult* result)
|
||||
{
|
||||
team_info teamInfo;
|
||||
int32 cookie = 0;
|
||||
|
||||
// Since it runs first, registrar does not know about it,
|
||||
// so we can't query be_roster for it.
|
||||
BPath path("/boot/system/servers/launch_daemon");
|
||||
if (path.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
|
||||
ffStrbufSetS(&result->exe, path.Path());
|
||||
ffStrbufSetStatic(&result->name, "launch_daemon");
|
||||
|
||||
while (get_next_team_info(&cookie, &teamInfo) == B_OK)
|
||||
{
|
||||
if (strcmp(teamInfo.args, path.Path()) == 0)
|
||||
{
|
||||
result->pid = (int)teamInfo.team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BFile f(path.Path(), B_READ_ONLY);
|
||||
if (f.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
BAppFileInfo fileInfo(&f);
|
||||
if (f.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
|
||||
version_info version;
|
||||
if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK)
|
||||
return NULL;
|
||||
|
||||
ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -27,6 +27,8 @@ static bool getFileVersion(const FFstrbuf* exePath, FFstrbuf* version)
|
||||
if (len <= 0) return false;
|
||||
return ffGetFileVersion(exePathW, version);
|
||||
}
|
||||
#elif __HAIKU__
|
||||
#include "util/haiku/version.h"
|
||||
#endif
|
||||
|
||||
static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version)
|
||||
@@ -847,6 +849,11 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe
|
||||
if(ffStrbufStartsWithIgnCaseS(processName, "zed"))
|
||||
return getTerminalVersionZed(exe, version);
|
||||
|
||||
#if __HAIKU__
|
||||
if(ffStrbufEqualS(processName, "Terminal"))
|
||||
return ffGetFileVersion(exe->chars, version);
|
||||
#endif
|
||||
|
||||
const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION");
|
||||
if(termProgramVersion)
|
||||
{
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf)
|
||||
strbuf->chars = CHAR_NULL_PTR;
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate()
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate(void)
|
||||
{
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInit(&strbuf);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
extern "C" {
|
||||
#include "version.h"
|
||||
}
|
||||
|
||||
#include <File.h>
|
||||
#include <AppFileInfo.h>
|
||||
|
||||
bool ffGetFileVersion(const char* filePath, FFstrbuf* version)
|
||||
{
|
||||
BFile f(filePath, B_READ_ONLY);
|
||||
if (f.InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
BAppFileInfo fileInfo(&f);
|
||||
if (f.InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
version_info info;
|
||||
if (fileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) != B_OK)
|
||||
return false;
|
||||
|
||||
ffStrbufSetF(version, "%d.%d.%d", (int)info.major, (int)info.middle, (int)info.minor);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "util/FFstrbuf.h"
|
||||
|
||||
bool ffGetFileVersion(const char* filePath, FFstrbuf* version);
|
||||
Reference in New Issue
Block a user