diff options
| author | Don Williams <don.e.williams@gmail.com> | 2026-08-13 02:00:09 -0400 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-08-29 21:41:34 -0700 |
| commit | 3f587a40f6dc7c162bd30e13d27b5ffe89bd73b9 (patch) | |
| tree | 260633bcacac294f656a8b35e05b3b1aa97b2440 /config/hypr/lua/virtual_workspaces.lua | |
| parent | 3cbf1626b834eab6edf0e3f4003dba5f933b425d (diff) | |
Added virtual_workspaces.lua
Link workspaces in all monitors to move as one.
- I.e. two monitors WS1 and WS2 are linked, then moving to next WS would
be WS3, WS4
Signed-off-by: Don Williams <don.e.williams@gmail.com>
On branch development
Your branch is up to date with 'origin/development'.
Changes to be committed:
modified: CHANGELOG.md
new file: config/hypr/lua/virtual_workspaces.lua
Diffstat (limited to 'config/hypr/lua/virtual_workspaces.lua')
| -rw-r--r-- | config/hypr/lua/virtual_workspaces.lua | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/config/hypr/lua/virtual_workspaces.lua b/config/hypr/lua/virtual_workspaces.lua new file mode 100644 index 00000000..82d74c71 --- /dev/null +++ b/config/hypr/lua/virtual_workspaces.lua @@ -0,0 +1,72 @@ +-- ================================================== +-- KoolDots (2026) +-- Project URL: https://github.com/LinuxBeginnings +-- License: GNU GPLv3 +-- SPDX-License-Identifier: GPL-3.0-or-later +-- ======================================== + +local function sync_workspaces(delta, move_window) + local active_ws = hl.get_active_workspace() + if not active_ws then + return + end + + -- 1. Get all connected monitors and sort left-to-right by X position + local monitors = hl.get_monitors() + if #monitors == 0 then + return + end + table.sort(monitors, function(a, b) + return a.x < b.x + end) + + local num_monitors = #monitors + + -- 2. Determine current Virtual Desktop block (e.g. WS 1 or 2 with 2 monitors -> VD 1) + local current_vd = math.ceil(active_ws.id / num_monitors) + local target_vd = current_vd + delta + if target_vd < 1 then + target_vd = 1 + end + + local active_mon = hl.get_active_monitor() + + -- 3. If moving active window, send it to the target workspace on the current monitor + if move_window and active_mon then + for i, m in ipairs(monitors) do + if m.id == active_mon.id then + local target_ws = (target_vd - 1) * num_monitors + i + hl.dispatch(hl.dsp.window.move({ workspace = target_ws })) + break + end + end + end + + -- 4. Switch all monitors to their respective workspace in the target VD block + for i, m in ipairs(monitors) do + local target_ws = (target_vd - 1) * num_monitors + i + hl.dispatch(hl.dsp.focus({ monitor = m.name })) + hl.dispatch(hl.dsp.focus({ workspace = target_ws })) + end + + -- 5. Preserve focused monitor focus state + if active_mon then + hl.dispatch(hl.dsp.focus({ monitor = active_mon.name })) + end +end + +-- Keybindings +-- SUPER + Up / Down: Switch entire monitor pair up/down +-- SUPER + SHIFT + Up / Down: Move focused window along with the pair switch +hl.bind(mainMod .. " + up", function() + sync_workspaces(-1, false) +end) +hl.bind(mainMod .. " + down", function() + sync_workspaces(1, false) +end) +hl.bind(mainMod .. " + SHIFT + up", function() + sync_workspaces(-1, true) +end) +hl.bind(mainMod .. " + SHIFT + down", function() + sync_workspaces(1, true) +end) |
