Skip to content

Commit 81738aa

Browse files
committed
WM (Linux): fixes compatibility with WSL 2.9.3+
1 parent 113f7d3 commit 81738aa

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/detection/wm/wm_linux.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,19 @@ static const char* getWslg(FFstrbuf* result) {
191191
return "Failed to read /mnt/wslg/versions.txt";
192192
}
193193

194-
if (!ffStrbufStartsWithS(result, "WSLg ")) {
195-
return "Failed to find WSLg version";
194+
if (ffStrbufStartsWithS(result, "WSLg: ")) { // WSL 2.9.3+
195+
ffStrbufSubstrBeforeFirstC(result, '\n');
196+
ffStrbufSubstrAfter(result, (uint32_t) (strlen("WSLg: ") - 1));
197+
} else if (ffStrbufStartsWithS(result, "WSLg ")) {
198+
ffStrbufSubstrBeforeFirstC(result, '\n');
199+
ffStrbufSubstrBeforeFirstC(result, '+');
200+
ffStrbufSubstrAfterFirstC(result, ':');
201+
ffStrbufTrimLeft(result, ' ');
202+
} else {
203+
ffStrbufClear(result);
204+
return "Failed to parse WSLg version from /mnt/wslg/versions.txt";
196205
}
197206

198-
ffStrbufSubstrBeforeFirstC(result, '\n');
199-
ffStrbufSubstrBeforeFirstC(result, '+');
200-
ffStrbufSubstrAfterFirstC(result, ':');
201-
ffStrbufTrimLeft(result, ' ');
202207
return NULL;
203208
}
204209
#endif

0 commit comments

Comments
 (0)