Repository navigation
Cycle Super + L on into a floating workspace - #8260
omarchybot wants to merge 3 commits into
Conversation
Lua 5.5's standalone interpreter exits 0 when the script that raised the error came in on stdin, and exits 1 for the same error in a script file. The block here was piped in through a heredoc, so every assertion in it reported as passing however wrong the value was: changing the expected layout to one the toggle never writes still left the file green.
Super + L cycled a workspace between dwindle and scrolling. It now carries on into floating, where every window on the workspace floats.
Floating cannot be a third `layout` on the workspace rule. Hyprland has no layout by that name and accepts one anyway: `hl.workspace_rule({ layout = "floating" })` returns ok and silently leaves the workspace on dwindle, exactly as a misspelt name does. So the mode floats the windows themselves, through the same `float` dispatcher SUPER + T uses.
Ending the mode has to tile the windows the mode floated and only those, so each one is tagged with `omarchy-mode-floated`. A window already floating when the mode reaches it -- an app with a float rule of its own, a dialog, one popped out with SUPER + T -- is left unclaimed and is still floating when the mode ends. The tag lives on the window rather than in a table here: it dies with the window, follows it between workspaces, and survives the config reload that plugging in a monitor performs, none of which a table on this side would do. A pinned window is left alone entirely, because tiling one unpins it as well.
Windows arrive on a workspace three ways and a window rule only covers one of them, so the mode watches events: window.open for what opens there, window.move_to_workspace for what is carried in, and the same event for what is carried back out, which gives up the floating the mode gave it rather than staying floating on a workspace that tiles. Every tiled window is claimed before any of them is floated, because floating one member of a group floats the rest, and claiming as it went would find those already floating and leave them stranded.
The mode is read back from the saved file rather than from the compositor. Hyprland reports a workspace's tiled layout and floating is not one, so a floating workspace still answers dwindle or scrolling; trusting that answer would skip a step of the cycle. A file saved before floating existed names a layout rather than a mode and falls through to what Hyprland reports, so the cycle keeps working and the next press rewrites it.
Two faults in the old script had to go first, because saving the mode makes both persistent. Named workspaces report a negative id, which passed the `^-?[0-9]+$` guard, and Hyprland reads a leading "-" as a selector relative to the current workspace: pressing Super + L on a named workspace reconfigured workspace 1 instead, and would now save a file that did it again at every login. And the saved state was written under $HOME/.local/state while the Hyprland side reads XDG_STATE_HOME, which also had to reach package.path: the loader lists that directory but loads the files by module name, so a state home anywhere else listed the saved layouts and then loaded same-named ones from the home directory.
Saving is checked too. The mode reaching the compositor and the mode reaching disk are separate things that can fail separately, and a save that failed silently would leave the next press reading a file that never got written, cycling between two modes and never reaching the third.
The guard against named workspaces stops new files being written, but an earlier version already wrote them, and they go on being loaded at every login. A migration removes the saved layouts named for a negative id.
The keyword fallback is gone. `hyprctl keyword` refuses a Lua configuration outright -- "keyword can't work with non-legacy parsers. Use eval." -- and exits 0 while doing so, so as a fallback it neither worked nor reported that it had not. A failed apply now says so and saves nothing, rather than announcing a layout the screen does not show and restoring it at the next login.
Co-Authored-By: Codex XHigh <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a persistent per-workspace floating mode to the existing layout cycle.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Changes:
- Cycles dwindle → scrolling → floating.
- Tracks mode-floated windows and handles window events.
- Adds migration, persistence fixes, tests, and documentation.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-hyprland-workspace-layout-toggle |
Applies and persists workspace modes. |
default/hypr/workspace-modes.lua |
Implements floating-mode ownership and events. |
default/hypr/workspace-layouts.lua |
Loads persisted modes from XDG state. |
default/hypr/bindings/tiling.lua |
Renames the binding description. |
migrations/1787679775.sh |
Removes invalid named-workspace state. |
manual/04-navigation.md |
Documents floating workspace behavior. |
manual/07-hotkeys.md |
Updates the shortcut reference. |
test/shell.d/hyprland-workspace-layout-test.sh |
Expands mode, migration, and persistence tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if window.floating then | ||
| return |
There was a problem hiding this comment.
Agreed, and it is the limitation an independent Codex review at xhigh raised too. It is written up in the pull request body under Consequences, for a decision rather than a fix rather than left for someone to discover.
Both directions are real, and for the reason you give: Hyprland floats and tiles a group as one target, so a window opened into a mode-floated group arrives already floating and is never claimed, while tiling a claimed member takes unclaimed ones with it.
What stops it being a small fix is that Hyprland 0.56 has no grouping event to hang ownership on. The window events its Lua API exposes are open, open_early, close, destroy, move_to_workspace, active, class, title, fullscreen, pin, urgent, kill and update_rules — nothing for a window joining or leaving a group. Ownership would have to be re-derived by polling group membership, which is more bookkeeping than the rest of this change put together. That is worth deciding on deliberately rather than slipping in beside the feature.
| for _, window in ipairs(claiming) do | ||
| set_floating(window, true) |
There was a problem hiding this comment.
This one is not introduced here. The branch does not touch bin/omarchy-hyprland-window-pop, and on quattro today that command already toggles floating on anything unpinned: pressing Super + O on any window that is already floating — org.omarchy.terminal, imv, mpv, a 1Password window, or one popped out earlier and unpinned since — tiles it instead of popping it. A floating workspace makes that easier to meet; it does not create it.
Teaching pop to preserve whether the window was already floating, on the way in and on the way back out, is a real fix and worth doing. It belongs in its own change against that command, where it can be tested against the app-floated cases that already hit it, rather than folded in here. It is noted in the pull request body for that reason.
|
| dofile(os.getenv("OMARCHY_PATH") .. "/default/hypr/bootstrap.lua") | ||
| require("default.hypr.helpers") | ||
| require("default.hypr.workspace-layouts") |
There was a problem hiding this comment.
The tests load workspace-layouts once, then call o.workspace_mode repeatedly. They never rebuild Lua state while the floated windows and their tags remain, so a change that strands windows after a reload could pass.
Add a reload case that preserves those windows and tags, reloads the saved mode, and checks that leaving floating tiles only the claimed windows.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| run_migration() { | ||
| env HOME="$migration_home" XDG_STATE_HOME="$migration_home/.local/state" \ | ||
| HYPRCTL_LOG="$tmpdir/migration-hyprctl.log" PATH="$stub_dir:$PATH" \ | ||
| bash -euo pipefail "$migration" >/dev/null |
There was a problem hiding this comment.
Custom state cleanup is untested
run_migration sets XDG_STATE_HOME to the same directory derived from HOME. The migration promises to clean both locations, but this test checks one directory twice. A change that stops cleaning a separate custom directory would still pass.
Add a distinct state directory with a negative-id file and a numbered file. Check that the migration removes only the negative-id files from both locations.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Superseded by #14482, which includes these commits and builds the full floating desktop (titlebars, edge snapping, and the window Shelf) on top of this Super + L cycle. |
Super + L toggled the active workspace between the dwindle and scrolling tiled layouts. It now cycles dwindle → scrolling → floating → dwindle, and on a floating workspace every window floats.
Floating cannot be a third layout
Hyprland has no tiled layout called
floating, and it does not complain when asked for one.hl.workspace_rule({ workspace = "1", layout = "floating" })returnsokand leaves the workspace on dwindle — the same silence a misspelt name gets. The one-word version of this change would have been a no-op that still announced "Workspace layout set to floating".hyprctl activeworkspacenames the fieldtiledLayoutfor the reason underneath that: floating is a property of a window, not an arrangement of them.So the mode floats the windows themselves, through the same
floatdispatcher Super + T uses.default/hypr/workspace-modes.luaholds it, andbin/reaches it throughhyprctl eval, which shares the config's Lua state.Giving back only what it took
Ending the mode has to tile the windows the mode floated and leave the rest alone, so each one it floats is tagged
omarchy-mode-floated. A window already floating when the mode reaches it — an app with a float rule of its own, a dialog, one popped out with Super + T — is never claimed, and is still floating when the mode ends. Without that, one trip through floating would tile every window that is meant to float always: everything taggedfloating-windowinapps/system.lua, andorg.omarchy.terminal,imv,mpv, 1Password among them.The tag lives on the window rather than in a table on the Lua side, because a table does not survive
hyprctl reload— whichomarchy-hyprland-monitor-watchperforms when a monitor is plugged in, andomarchy-hyprland-window-gaps-toggleon a keypress. A reload rebuilds the Lua state, and provenance kept there would be lost while the windows stayed floating, so leaving the mode afterwards would strand them. The tag also follows a window between workspaces and dies with it, so nothing has to be cleaned up when a window closes.A pinned window is left alone entirely: tiling one unpins it too, and it was put above everything on purpose.
Why events rather than a window rule
Windows arrive on a workspace three ways and a rule only covers one.
window.opencatches what opens there,window.move_to_workspacewhat is carried in, and the same event what is carried back out — which gives up the floating the mode gave it rather than leaving it floating on a workspace that tiles. A rule also cannot tell a window it floated from one that was floating already, which is the distinction the whole of the section above rests on.Every tiled window is claimed in one pass before any is floated in the next, because floating one member of a group floats the rest, and claiming as it went would find those already floating and leave them stranded.
What remembers the mode
The saved file, not the compositor. Hyprland reports a workspace's tiled layout and floating is not one, so a floating workspace still answers
dwindleorscrolling; a cycle that trusted that answer would skip a step. A file saved before floating existed names a layout rather than a mode, falls through to what Hyprland reports, and is rewritten by the next press, so nothing needs migrating.Two faults that had to go first
Saving the mode makes both of them persistent rather than momentary.
Named workspaces report a negative id, which passed the old
^-?[0-9]+$guard, and Hyprland reads a leading-as a selector relative to the current workspace. Pressing Super + L on a named workspace reconfigured workspace 1 instead —name:mailreports-1337, and targeting it moved workspace 1 to scrolling. It would now also save a file that did the same at every login. Such a workspace is left alone.A migration removes the ones an earlier version already wrote, because the guard only stops new ones and the files on disk go on being loaded at every login.
The saved state was written under
$HOME/.local/statewhile the Hyprland side readsXDG_STATE_HOME, and that had to reachpackage.pathas well: the loader lists the directory but loads the files by module name, so a state home anywhere else listed the saved layouts and then loaded same-named ones from the home directory.toggles.luaalready solves this the same way.Applying and saving fail separately
Reaching the compositor and reaching disk are different things that go wrong for different reasons, and the next press reads the mode back from the file. A save that failed quietly would leave the cycle running between two modes and never arriving at the third, so it is reported: a mode that applied but could not be saved says so rather than counting as set.
The keyword fallback is gone
The old script fell back to
hyprctl keyword workspace "<id>, layout:<layout>"when the Lua call failed.hyprctl keywordrefuses a Lua configuration outright — keyword can't work with non-legacy parsers. Use eval. — and exits 0 while doing so, so as a fallback it neither worked nor reported that it had not. A failed apply now says so and saves nothing, rather than announcing a layout the screen does not show and restoring it at the next login.Consequences, for a decision rather than a fix
Super + Omis-fires on a window that is floating, becauseomarchy-hyprland-window-popbegins by toggling float on anything unpinned. That is true today of any window with its own float rule; a floating workspace only makes it easier to meet. It belongs in its own change.The first commit is separate because it is a different bug: Lua 5.5 exits 0 when a failing script arrives on stdin, so the heredoc form this test used made every Lua assertion in it unfailable — pointing one at a layout the toggle never writes still left the file green. It runs as a script file now.
Checked by Codex at xhigh as an independent reviewer.