diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 2684d04f3..818e7d640 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -1,5 +1,7 @@ #include "fastfetch.h" +#include "common/io.h" #include "common/processing.h" +#include "common/properties.h" #ifdef _WIN32 @@ -186,6 +188,25 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v return getExeVersionGeneral(exe, version); } +#ifdef _WIN32 + +static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) +{ + FF_STRBUF_AUTO_DESTROY buildInfoPath; + ffStrbufInitNS(&buildInfoPath, ffStrbufLastIndexC(exe, '\\') + 1, exe->chars); + ffStrbufAppendS(&buildInfoPath, "BuildInfo.xml"); + + if(ffParsePropFile(buildInfoPath.chars, "StoreVersion=\"", version)) + { + ffStrbufTrimRight(version, '"'); + return true; + } + + return getFileVersion(exe->chars, version); +} + +#endif + bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ @@ -211,6 +232,13 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif + #ifdef _WIN32 + + if(ffStrbufIgnCaseEqualS(processName, "WindowsTerminal.exe")) + return getTerminalVersionWindowsTerminal(exe, version); + + #endif + #ifndef _WIN32 if(ffStrbufIgnCaseEqualS(processName, "kitty"))