Decide whether the other screens join in on workspaces
GNOME's Multitasking panel asked one workspace question worth reproducing, and it is not which workspace goes on which screen. It is whether the second screen participates at all: workspaces on the primary display only, or each screen with its own. Ten rows of per-workspace assignment would be more powerful and worse. Off is Hyprland's own behaviour and emits nothing. On pins workspaces 1 to 10 -- however many ALT+1..ALT+0 actually reach, read from keybinds.lua rather than written down twice -- to whichever output is recorded as primary. With no primary recorded, nothing is pinned: guessing one would move every workspace onto whichever output happened to sort first, and this machine is in exactly that state. Applying is a reload, which is the part that shaped the design. Hyprland reads workspace rules at config time and will not remove one afterwards -- a rule written with an empty monitor keeps its old binding, which was checked rather than assumed. Only a reload clears them, so the config is the only honest source and the page cannot pretend a change has landed before one happens. Hence a service that reads `hyprctl workspacerules` back rather than inferring success from having written the preference, and a Reload row that exists only while the two disagree. Verified end to end against the live compositor and put back: off emits nothing, on emits ten rules naming the primary, and turning it off clears them. The settings file came back byte-identical. Claude-Session: https://claude.ai/code/session_01Q84axqUE5inJhf5Jz9CFy1
This commit is contained in:
@@ -172,4 +172,40 @@ hl.monitor({
|
||||
scale = "auto",
|
||||
})
|
||||
|
||||
-- ── Workspaces on the primary display only ──────────────────────────────────
|
||||
--
|
||||
-- GNOME offered one workspace choice worth reproducing: whether the other
|
||||
-- screens join in. Off, every monitor has its own workspaces and switching
|
||||
-- affects whichever one has focus -- Hyprland's own behaviour, so it needs no
|
||||
-- rules at all. On, workspaces 1-10 are pinned to the primary display and a
|
||||
-- second screen keeps a workspace of its own that stays put.
|
||||
--
|
||||
-- Ten because that is how many the keybinds reach: ALT+1 through ALT+0 in
|
||||
-- keybinds.lua. Binding more would pin workspaces nothing can navigate to, and
|
||||
-- binding fewer would leave the last few behaving differently from the rest for
|
||||
-- no reason a person could see.
|
||||
--
|
||||
-- The rules are emitted here rather than written live because Hyprland reads
|
||||
-- them at config time and offers no way to remove one afterwards: writing an
|
||||
-- empty monitor leaves the previous binding in place. So the config is the only
|
||||
-- honest source, and applying a change is a reload.
|
||||
if prefs.get("workspacesOnPrimaryOnly", false) == true then
|
||||
local primary = nil
|
||||
for output, entry in pairs(displays) do
|
||||
if type(entry) == "table" and entry.primary == true
|
||||
and type(output) == "string" and output:match("^[%w_.-]+$") ~= nil then
|
||||
primary = output
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Without a primary there is nothing to pin to, and guessing one would move
|
||||
-- every workspace onto whichever screen happened to sort first.
|
||||
if primary ~= nil then
|
||||
for i = 1, 10 do
|
||||
hl.workspace_rule({ workspace = tostring(i), monitor = primary })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user