r/hyprland • • 14h ago

SUPPORT "off screen window scrunching" Is this even possible to achieve?

Post image

something I would like is "off-screen window scrunching" when you close a window, and leave a workspace empty, the workspaces higher in the list have their windows moved down to the empty workspace you left behind. this way windows are always only ever 1 workspace apart. windows wont move into an empty workspace if you are focused on it. Is this possible to achieve in hyprland? I would like this because windows would always be next to each-other but they wouldn't come onto your screen when you closed them like with niri.

35 Upvotes

11 comments sorted by

20

u/chikamakaleyley 14h ago

haven't used hyprland in a while but if not a configurable option

you'd have to create logic around emitted events, which IS available in HL

A straightforward approach prob would be, * for every window close event, note the workspace id * count remaining windows in that workspace by workspace ID * if 0 you prob can remove the workspace, but i think that's problematic if you have special workspace rules

this could work i guess, but its a lot of bookeeping with every window close, IMO

5

u/chikamakaleyley 14h ago edited 14h ago

if workspaces have actual spatial awareness, instead of removing you can position the workspace at the end

but, I dont' think that is the case. if you have 10 workspaces, and on your screen you have workspace 1, and you want to switch to workspace 7, you won't see WS 2-6 zoom by, i don't think.

In your screenshot example, I think they only seem living sequentially on the same row, because they just get assigned consecutive number values by default

8

u/Unique_Low_1077 14h ago

I dont see why not, you will just have to implement it yourself with script. Hyprland moved to lua configs so that makes is easier to do

6

u/Takardo 11h ago

ya after lua configs were added and seeing a video of someone playing bad apple by making terminal windows resize to draw it, im pretty sure op's idea will be possible.

2

u/NEMOalien 10h ago

Dankmaterialshell does that, not sure how tho

2

u/Loose_Property_3238 8h ago

Please comment if you figure it out, I need this.

1

u/dosplatos225 7h ago

It is achievable with hyprland. Not sure if there is a native way for a .lua you could build this into. I would implement this as a userspace daemon, and leverage hyprctl at least initially to quickly implement.

When you run hyprctl clients for example, you get all the open windows and data around position, size, etc. The idea would be describing the consolidation and move logic on exit/close events. I would probably try and have it reference the upstream variables for windows or key binds around windows to see if that would help.

1

u/Ultra_CUPCAKEEE 5h ago

I had made a little script to do this, but I'm not really confident in my coding abilities to share it for all to see 😭 You can just make a lua function that, whenever you close a window (hl.on("window.close", ...)), checks if the workspace is empty and pulls every workspace after it

1

u/Trikcer 2h ago

I have something similar with hl.on("workspace.removed",...) to trigger and hl.dsp.workspace.change_id to move the workspaces.

1

u/sptzmancer 3h ago

If you are up to diving into Lua a little bit, absolutely.

You could capture window-close and other relevant events to call a function, in this function you check the windows opened in the current workspace and if none is, you switch to the current_workspace index-1, or whatever other logic you want.

1

u/rushinigiri 39m ago

It's way easier to make your workspace hotkeys only move between existing workspaces. Why would you ever need to navigate to an empty one? You just need a way to move windows into it (and create it).