Skip to content

[Feature request] Add Niri window count module #3653

@itshog

Description

@itshog

The scrolling nature of Niri means that it's common and expected to have windows (even lots of them) on the current workspace but not visible, placed to the right and left of the currently visible ones. I think that in this case it would be useful to have a little indicator in the bar showing the total number of windows on the active workspace, so one could get the idea of how many windows there are to the right and left without needing to move around. Note that the same principle applies to classic tiling wms too when windows are stacked on top of each other (the "monocle" mode of many wms): for instance, the built-in bar of dwm does exactly this if I recall correctly, showing the number of windows in the tag when in monocle mode.

I implemented this in a dirty shell script to show what kind of output I'd like to have in this module, and also to understand which events needs to be considered when updating the module (well, window opening/closing and workspace switching are kind of obvious):

#!/bin/sh

idfocused="$(niri msg -j workspaces | jq ".[] | select(.is_focused == true ) | .id")"
num="$(niri msg -j windows | jq "[.[] | select(.workspace_id == $idfocused)] | length")"
printf "%d\n" "$num"

niri msg event-stream |\
    while read -r line; do
        case "$line" in
            "Window opened"*|"Window closed"*|"Workspace focused"*)
                idfocused="$(niri msg -j workspaces | jq ".[] | select(.is_focused == true ) | .id")"
                num="$(niri msg -j windows | jq "[.[] | select(.workspace_id == $idfocused)] | length")"
                printf "%d\n" "$num"
                ;;
        esac
    done

Also, maybe someone finds this useful in the absence of a native module (but I don't think performance is great...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions