Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.19k stars 684 forks source link

hyprland/workspaces window icons sometimes disappear #2802

Open flip-rossi opened 8 months ago

flip-rossi commented 8 months ago

When using the hyprland/workspaces modules in Waybar with Hyprland, sometimes the icon of a specific window will disappear for no apparent reason, and I can move the window around workspaces or monitors and it won't fix. However, if I open a new window with the same class and title, the icon will be there.

Example (there is a Firefox client in the "12" workspace but it's icon doesn't show up):
2024-01-04_10:48:42

One way I found to force this bug is to pin a floating window and then switch workspaces, but it also occurs seemly randomly in other situations I wasn't able to find patterns for.

I'm using FiraCode Nerd Font and Hyprland's split-monitor-workspaces plugin, if that makes any difference.

If I run hyprctl clients the window shows as normal:

Window 5583bc153850 -> Mozilla Firefox:
    mapped: 1
    hidden: 0
    at: 967,37
    size: 941,1031
    workspace: 12 (12)
    floating: 0
    monitor: 1
    class: firefox
    title: Mozilla Firefox
    initialClass: firefox
    initialTitle: Mozilla Firefox
    pid: 2607
    xwayland: 0
    pinned: 0
    fullscreen: 0
    fullscreenmode: 0
    fakefullscreen: 0
    grouped: 0
    swallowing: 0
    focusHistoryID: 2

My "hyprland/workspaces" field in config.jsonc:

    "hyprland/workspaces": {
         "all-outputs": false,
         "on-scroll-up": "hyprctl dispatch workspace e+1",
         "on-scroll-down": "hyprctl dispatch workspace e-1",

         "format": "[{name} {windows} ]",
         "format-window-separator": "  ",
         "window-rewrite-default": "",
         "window-rewrite": {
             // https://www.nerdfonts.com/cheat-sheet and https://fontawesome.com/icons
             "class<Alacritty>": "",
             "class<Pcmanfm>": "",
             "class<com.github.weclaw1.ImageRoll|nomacs>": "",
             "title<(.*[$%#] *)?nvim.*>": "",
             "title<(.*[$%#] *)?([hb]|nv)top.*>": "",
             "class<firefox>": "",
             "class<discord>": "",
             "title<Discord.*>": "",
             "title<.[0-9]+. Discord.*>": " °",
             "title<Signal>": "󰍡",
             "title<WhatsApp.*>": "",
             "title<.[0-9]+. WhatsApp.*>": "°",
             "title<(.* - )?(.[0-9]+. )?YouTube.*>": "",
             "title<.* - Gmail .*>": "󰊫",
             "class<obsidian>": "󱞁",
             "class<ONLYOFFICE Desktop Editors>": "󰈙",
             "class<calibre-.*>": "",
             "class<org.qbittorrent.qBittorrent>": "",
             "class<org.kde.kdeconnect.*>": "",
             "class<mpv>": "",
             "class<vlc>": "󰕼",
             "class<Gimp-.*>": "",
             "class<steam.*>": "󰓓", //  for FontAwesome
             "class<steam> title<Friends List>": "",
             "class<steam_app_[0-9]+>": "󰮂",
             "title<Winetricks.*>": "󰡶",
             "class<lutris>": "🦦",
             "class<Spotify>": "",
             "class<jetbrains-idea(-ce)?>": "",
             "class<Code>": "󰨞",
             "class<com.obsproject.Studio|zoom>": "",
             "class<io.github.whoozle.android-file-transfer>": "",
             "class<(Chromium)|(Chrome)>": "",
         },

Rules in style.css that affect the workspaces region (it's pretty much the default config):

* {
    font-family: FiraCode Nerd Font;
    font-size: 13px;
}

window#waybar {
    background-color: rgba(43, 48, 59, 0.5);
    border-bottom: 3px solid rgba(100, 114, 125, 0.5);
    color: #ffffff;
    transition-property: background-color;
    transition-duration: .5s;
}

window#waybar.hidden {
    opacity: 0.2;
}

window#waybar.termite {
    background-color: #3F3F3F;
}

window#waybar.chromium {
    background-color: #000000;
    border: none;
}

button {
    /* Use box-shadow instead of border so the text isn't offset */
    box-shadow: inset 0 -3px transparent;
    /* Avoid rounded borders under each button name */
    border: none;
    border-radius: 0;
}

/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
button:hover {
    background: inherit;
    box-shadow: inset 0 -3px #ffffff;
}

#workspaces button {
    padding: 0 5px;
    background-color: transparent;
    color: #ffffff;
}

#workspaces button:hover {
    background: rgba(0, 0, 0, 0.2);
}

#workspaces button.active {
    background-color: #64727D;
    box-shadow: inset 0 -3px #ffffff;
}

#workspaces button.urgent {
    background-color: #eb4d4b;
}

#window,
#workspaces {
    margin: 0 4px;
}

/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
    margin-left: 0;
}

/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
    margin-right: 0;
}
Syndelis commented 8 months ago

Hi there, @flip-rossi ! Could you please try building PR #2817 and see if that fixes the issue for you when moving windows accross monitors?

One way I found to force this bug is to pin a floating window and then switch workspaces

When I pin a floating window, it doesn't ever appear to change workspaces on the bar. It does make sense, however, as I can't see any mentions of movewindow on Hyprland's IPC when the pinned window follows me around. Can you check if it does for you? Simply run this command on a terminal:

socat - UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock

And see if it spits out any lines with movewindow when switching workspaces while a floating window is pinned.

flip-rossi commented 7 months ago

Hey, sorry for the delayed response

Could you please try building PR https://github.com/Alexays/Waybar/pull/2817 and see if that fixes the issue for you when moving windows accross monitors?

Yeah, it does! Nice

I can't see any mentions of movewindow on Hyprland's IPC when the pinned window follows me around. Can you check if it does for you?

Nope, no movewindow. But at least now the window icon doesn't seem to disappear, it just doesn't move, like your case. Not ideal but better than before.

Sorry to bother, I'll close this PR

flip-rossi commented 7 months ago

Nevermind, I rebooted and now the icons disappear again when changing workspaces with a pinned window 😓. (The issue when moving windows across monitors seems to have been fixed for good tho)

Running socat - UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock gives me:

activewindow>>firefox,Mozilla Firefox
activewindowv2>>5f67ea800020
openwindow>>5f67ea800020,2,firefox,Mozilla Firefox
changefloatingmode>>5f67ea800020,1
createworkspace>>3
activewindow>>firefox,Mozilla Firefox
activewindowv2>>5f67ea800020
workspace>>3
destroyworkspace>>2
changefloatingmode>>5f67ea800020,0
createworkspace>>4
movewindow>>5f67ea800020,4
activewindow>>,
activewindowv2>>,
activewindow>>firefox,Mozilla Firefox
workspace>>4
activewindowv2>>5f67ea800020
destroyworkspace>>3

Here I opened Firefox, made it floating, pinned it, changed to workspace 3, made Firefox not floating, moved it to workspace 4, and moved focus to workspace 4. The icon disappeared as soon as I changed to workspace 3 with Firefox pinned.

Syndelis commented 7 months ago

Here I opened Firefox, made it floating, pinned it, changed to workspace 3, made Firefox not floating, moved it to workspace 4, and moved focus to workspace 3. The icon disappeared as soon as I changed to workspace 3 with Firefox pinned.

That's a very good way to reproduce the problem. Seems to be related to workspaces being destroyed. I'll see what I can do, although I think I'll submit a PR to Hyprland itself since it's a problem of it not accusing the window of being moved and then actually notifying that the workspace has been destroyed; Waybar is behaving as expected in this case, it can't suppose that Hyprland didn't notify it