Skip to content

Commit

Permalink
query: user: fix get_wm_name()
Browse files Browse the repository at this point in the history
I need to do a release right after this
  • Loading branch information
Toni500github committed Aug 26, 2024
1 parent 56ee3ba commit 43d8a0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/query/unix/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 2 additions & 13 deletions src/query/unix/utils/dewm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 43d8a0c

Please sign in to comment.