WM (Linux): correctly fall back to calling wm --version if ffBinaryExtractStrings fails

Fix #1657
This commit is contained in:
李通洲
2025-04-02 10:14:53 +08:00
parent 760e82913a
commit d650f67ece
2 changed files with 9 additions and 9 deletions
+1
View File
@@ -31,6 +31,7 @@ Bugfixes:
* Fix multiple paging file support (Swap, Windows)
* Fix memleaks, code smells in multiple modules
* Fix boot time calculation on NetBSD (Uptime, NetBSD)
* Temporarily fix Hyprland version detection (WM, Linux, #1657)
Logo:
* Fix opensuse-tumbleweed_small (#1636)
+8 -9
View File
@@ -18,7 +18,7 @@ static bool extractHyprlandVersion(const char* line, FF_MAYBE_UNUSED uint32_t le
sscanf(line, " version: bump to v%*d.%*d.%*d%n", &count);
if (count == 0) return true;
// SUPER hacky
// SUPER hacky and doesn't work for development versions
uint32_t prefixLen = (uint32_t) strlen(" version: bump to v"); // version bump commit message
ffStrbufSetNS((FFstrbuf*) userdata, len - prefixLen, line + prefixLen);
return false;
@@ -30,8 +30,8 @@ static const char* getHyprland(FFstrbuf* result)
const char* error = ffFindExecutableInPath("Hyprland", &path);
if (error) return "Failed to find Hyprland executable path";
if (ffBinaryExtractStrings(path.chars, extractHyprlandVersion, result, (uint32_t) strlen(" version: bump to v0.0.0")) == NULL)
return NULL;
ffBinaryExtractStrings(path.chars, extractHyprlandVersion, result, (uint32_t) strlen(" version: bump to v0.0.0"));
if (result->length > 0) return NULL;
if (ffProcessAppendStdOut(result, (char* const[]){
path.chars,
@@ -51,7 +51,9 @@ static bool extractSwayVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, v
{
if (!ffStrStartsWith(line, "sway version ")) return true;
ffStrbufSetNS((FFstrbuf*) userdata, len - (uint32_t) strlen("sway version "), line + strlen("sway version "));
FFstrbuf* result = (FFstrbuf*) userdata;
ffStrbufSetNS(result, len - (uint32_t) strlen("sway version "), line + strlen("sway version "));
ffStrbufTrimRightSpace(result);
return false;
}
@@ -61,11 +63,8 @@ static const char* getSway(FFstrbuf* result)
const char* error = ffFindExecutableInPath("sway", &path);
if (error) return "Failed to find sway executable path";
if (ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0")) == NULL)
{
ffStrbufTrimRightSpace(result);
return NULL;
}
ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0"));
if (result->length > 0) return NULL;
if (ffProcessAppendStdOut(result, (char* const[]){
path.chars,