From 7eaaed60245b8c08d0c5f826e7f618ccc7759fd4 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 31 Jul 2024 14:19:42 +0800 Subject: [PATCH] WM (Linux): don't use `wl-restart` as WM name Fix #1135 --- src/detection/displayserver/linux/wayland/wayland.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index 2b64bbce3..71671a74d 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -30,8 +30,19 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName)) return false; + // #1135: wl-restart is a special case + const char* filename = strrchr(result->wmProcessName.chars, '/'); + if (filename) + filename++; + else + filename = result->wmProcessName.chars; + + if (ffStrEquals(filename, "wl-restart")) + ffStrbufSubstrAfterFirstC(&result->wmProcessName, '\0'); + ffStrbufSubstrBeforeFirstC(&result->wmProcessName, '\0'); //Trim the arguments ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path + return true; } #else