From 43d8a0c41a189b661dd1b00e0bc3055f171d114b Mon Sep 17 00:00:00 2001 From: Toni500git Date: Mon, 26 Aug 2024 14:51:31 +0200 Subject: [PATCH] query: user: fix get_wm_name() I need to do a release right after this --- src/query/unix/user.cpp | 6 +++--- src/query/unix/utils/dewm.cpp | 15 ++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/query/unix/user.cpp b/src/query/unix/user.cpp index c56385b..f3c980e 100644 --- a/src/query/unix/user.cpp +++ b/src/query/unix/user.cpp @@ -54,16 +54,16 @@ static std::string get_wm_name() path = dir_entry.path() / "cmdline"; std::ifstream f(path, std::ios::binary); std::getline(f, proc_name); - debug("proc_name = {}", proc_name); + debug("WM proc_name = {}", proc_name); size_t pos = 0; if ((pos = proc_name.find('\0')) != std::string::npos) proc_name.erase(pos); if ((pos = proc_name.rfind('/')) != std::string::npos) - proc_name.erase(pos); + proc_name.erase(0, pos + 1); - debug("proc_name after = {}", proc_name); + debug("WM proc_name after = {}", proc_name); if ((wm_name = prettify_wm_name(proc_name)) == MAGIC_LINE) continue; diff --git a/src/query/unix/utils/dewm.cpp b/src/query/unix/utils/dewm.cpp index 3d7e981..fbd35ac 100644 --- a/src/query/unix/utils/dewm.cpp +++ b/src/query/unix/utils/dewm.cpp @@ -57,19 +57,6 @@ std::string parse_de_env(void) noexcept std::string prettify_wm_name(const std::string_view name) noexcept { - if (name.find("kwin") != std::string::npos) - return "Kwin"; - - if (name.find("gnome-shell") != std::string::npos || name.find("Mutter") != std::string::npos || - name.find("gnome shell") != std::string::npos) - return "Mutter"; - - if (name.find("cinnamon") != std::string::npos || name.find("Muffin") != std::string::npos) - return "Muffin"; - - if (name.find("Marco") != std::string::npos) - return "Marco"; - // taken from this list // https://github.com/KittyKatt/screenFetch/blob/master/screenfetch-dev#L93 // added some missing. @@ -107,9 +94,11 @@ std::string prettify_wm_name(const std::string_view name) noexcept case "icewm"_fnv1a16: return "icewm"; case "kwin"_fnv1a16: return "Kwin"; case "kwin_wayland_wr"_fnv1a16: return "Kwin"; + case "marco"_fnv1a16: return "Marco"; case "metacity"_fnv1a16: return "Metacity"; case "monsterwm"_fnv1a16: return "monsterwm"; case "muffin"_fnv1a16: return "Muffin"; + case "mutter"_fnv1a16: return "Mutter"; case "musca"_fnv1a16: return "musca"; case "mwm"_fnv1a16: return "mwm"; case "notion"_fnv1a16: return "notion";