From 3f587a40f6dc7c162bd30e13d27b5ffe89bd73b9 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Thu, 13 Aug 2026 02:00:09 -0400 Subject: 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 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 --- CHANGELOG.md | 6 +++ config/hypr/lua/virtual_workspaces.lua | 72 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 config/hypr/lua/virtual_workspaces.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index bfec3498..51ecaffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## Added: +- `virtual_workspaces.lua` + - lua script to link monitors into one workspace(ish) + - It finds all the monitors, then when you move to a differnt workspace they move together + - I.e. `eDP-1` and `HDMI-A-1` would like Workspace 1 and 2. Moving to next Workspace would be 3 and 4 + | Note: Early stage development + - Selecting `zsh` now updates `.zprofile` ```sh 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) -- cgit v1.2.3