Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

add Hyprland/windowcount module

Open nktnet1 opened this issue 1 year ago • 0 comments

Hyprland module to display the count of windows in the current workspace. E.g. if the current workspace (in this example, workspace 2) has 4 windows/clients opened:

image

This was requested in the following Reddit post, and also issue #672 (albeit for sway).

The windowcount module supports separate-outputs (i.e. "window count per monitor"), and was written based on the existing hyprland/window module. I'm not well-versed in c++ so there may be various rooms for improvements. Wiki documentation below.


Window Count

The windowcount module displays the number of windows in the current Hyprland workspace.

Configuration

Addressed by hyprland/windowcount.

option typeof default description
format string {} The format for how information should be displayed. On {}, the current workspace window count is displayed.
format-empty string Override the format when the workspace contains no windows.
format-windowed string Override the format when the workspace contains no fullscreen windows.
format-fullscreen string Override the format when the workspace contains a fullscreen window.
separate-outputs bool true Show the active workspace window count of the monitor the bar belongs to, instead of the focused workspace.

Example:

"hyprland/windowcount": {
    "format": "[{}]",
    "format-empty": "[X]",
    "format-windowed": "[T]",
    // "format-fullscreen": "[{}]",
    "separate-outputs": true
}

Style

  • #windowcount
  • window#waybar.empty #windowcount When no windows are in the workspace
  • window#waybar.fullscreen #windowcount When there is a fullscreen window in the workspace; useful with Hyprland's fullscreen, 1 mode

Example:

/* Adding margin and padding */
#windowcount {
    margin-left: 0px;
    padding: 0px 5px;
}

/* Different background when empty */
window#waybar.empty #windowcount {
    background: darkred;
}

/* Hide the windowcount module when not in windowed mode (i.e. not fullscreen) */
window#waybar:not(.fullscreen) #windowcount {
    opacity: 0;
}

nktnet1 avatar Aug 24 '24 05:08 nktnet1