Skip to content

Commit d650f67

Browse files
committed
WM (Linux): correctly fall back to calling wm --version if ffBinaryExtractStrings fails
Fix #1657
1 parent 760e829 commit d650f67

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Bugfixes:
3131
* Fix multiple paging file support (Swap, Windows)
3232
* Fix memleaks, code smells in multiple modules
3333
* Fix boot time calculation on NetBSD (Uptime, NetBSD)
34+
* Temporarily fix Hyprland version detection (WM, Linux, #1657)
3435

3536
Logo:
3637
* Fix opensuse-tumbleweed_small (#1636)

src/detection/wm/wm_linux.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static bool extractHyprlandVersion(const char* line, FF_MAYBE_UNUSED uint32_t le
1818
sscanf(line, " version: bump to v%*d.%*d.%*d%n", &count);
1919
if (count == 0) return true;
2020

21-
// SUPER hacky
21+
// SUPER hacky and doesn't work for development versions
2222
uint32_t prefixLen = (uint32_t) strlen(" version: bump to v"); // version bump commit message
2323
ffStrbufSetNS((FFstrbuf*) userdata, len - prefixLen, line + prefixLen);
2424
return false;
@@ -30,8 +30,8 @@ static const char* getHyprland(FFstrbuf* result)
3030
const char* error = ffFindExecutableInPath("Hyprland", &path);
3131
if (error) return "Failed to find Hyprland executable path";
3232

33-
if (ffBinaryExtractStrings(path.chars, extractHyprlandVersion, result, (uint32_t) strlen(" version: bump to v0.0.0")) == NULL)
34-
return NULL;
33+
ffBinaryExtractStrings(path.chars, extractHyprlandVersion, result, (uint32_t) strlen(" version: bump to v0.0.0"));
34+
if (result->length > 0) return NULL;
3535

3636
if (ffProcessAppendStdOut(result, (char* const[]){
3737
path.chars,
@@ -51,7 +51,9 @@ static bool extractSwayVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, v
5151
{
5252
if (!ffStrStartsWith(line, "sway version ")) return true;
5353

54-
ffStrbufSetNS((FFstrbuf*) userdata, len - (uint32_t) strlen("sway version "), line + strlen("sway version "));
54+
FFstrbuf* result = (FFstrbuf*) userdata;
55+
ffStrbufSetNS(result, len - (uint32_t) strlen("sway version "), line + strlen("sway version "));
56+
ffStrbufTrimRightSpace(result);
5557
return false;
5658
}
5759

@@ -61,11 +63,8 @@ static const char* getSway(FFstrbuf* result)
6163
const char* error = ffFindExecutableInPath("sway", &path);
6264
if (error) return "Failed to find sway executable path";
6365

64-
if (ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0")) == NULL)
65-
{
66-
ffStrbufTrimRightSpace(result);
67-
return NULL;
68-
}
66+
ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0"));
67+
if (result->length > 0) return NULL;
6968

7069
if (ffProcessAppendStdOut(result, (char* const[]){
7170
path.chars,

0 commit comments

Comments
 (0)