[FEAT]: ability to swap focused WS on one monitor with visible WS on other monitor #445

Closed
opened 2026-01-05 14:50:47 +01:00 by adam · 1 comment
Owner

Originally created by @edgimar on GitHub (Aug 14, 2024).

In issue #88, the question was brought up as to whether Komorebi is able to replicate xmonad-like behavior. The move-workspace-to-monitor command was introduced to address this, but it does not handle the use-case of wanting to swap focused workspaces. For example, let's assume we have the following:

Monitor 0:
  WS_A [focused]
  WS_B

Monitor 1:
  WS_C
  WS_D [visible]

The behavior I would like to see is a command that results in the following:

Monitor 0:
  WS_D [visible]
  WS_B

Monitor 1:
  WS_C
  WS_A [focused]

(or maybe an additional command parameter to affect which monitor is focused in the end)

Is this currently possible in any easy way? If not, would it be possible to add something like a swap-workspace-with-monitor command?

Originally created by @edgimar on GitHub (Aug 14, 2024). In issue #88, the question was brought up as to whether Komorebi is able to replicate xmonad-like behavior. The `move-workspace-to-monitor` command was introduced to address this, but it does not handle the use-case of wanting to swap focused workspaces. For example, let's assume we have the following: ``` Monitor 0: WS_A [focused] WS_B Monitor 1: WS_C WS_D [visible] ``` The behavior I would like to see is a command that results in the following: ``` Monitor 0: WS_D [visible] WS_B Monitor 1: WS_C WS_A [focused] ``` (or maybe an additional command parameter to affect which monitor is focused in the end) Is this currently possible in any easy way? If not, would it be possible to add something like a `swap-workspace-with-monitor` command?
adam added the enhancement label 2026-01-05 14:50:47 +01:00
adam closed this issue 2026-01-05 14:50:47 +01:00
Author
Owner

@LeoCalbi commented on GitHub (Oct 21, 2024):

Hi,
I managed to achieve something similar to what you're describing with this workaround:

alt + 1                 : $monitor_id=komorebic query focused-monitor-index; $workspace_id=komorebic query focused-workspace-index; komorebic focus-named-workspace I; $other_monitor_id=komorebic query focused-monitor-index; if ($monitor_id -ne $other_monitor_id){ komorebic move-workspace-to-monitor $monitor_id; komorebic focus-monitor-workspace $monitor_id $workspace_id; komorebic move-workspace-to-monitor $other_monitor_id; komorebic focus-named-workspace I; }
alt + 2                 : $monitor_id=komorebic query focused-monitor-index; $workspace_id=komorebic query focused-workspace-index; komorebic focus-named-workspace II; $other_monitor_id=komorebic query focused-monitor-index; if ($monitor_id -ne $other_monitor_id){ komorebic move-workspace-to-monitor $monitor_id; komorebic focus-monitor-workspace $monitor_id $workspace_id; komorebic move-workspace-to-monitor $other_monitor_id; komorebic focus-named-workspace II; }
... # For all the other alt +

This allows the swap only if necessary and focused the target workspace in the source monitor.
Hopefully it's somewhat useful, let me know if you manage to find a better way.

@LeoCalbi commented on GitHub (Oct 21, 2024): Hi, I managed to achieve something similar to what you're describing with this workaround: ``` alt + 1 : $monitor_id=komorebic query focused-monitor-index; $workspace_id=komorebic query focused-workspace-index; komorebic focus-named-workspace I; $other_monitor_id=komorebic query focused-monitor-index; if ($monitor_id -ne $other_monitor_id){ komorebic move-workspace-to-monitor $monitor_id; komorebic focus-monitor-workspace $monitor_id $workspace_id; komorebic move-workspace-to-monitor $other_monitor_id; komorebic focus-named-workspace I; } alt + 2 : $monitor_id=komorebic query focused-monitor-index; $workspace_id=komorebic query focused-workspace-index; komorebic focus-named-workspace II; $other_monitor_id=komorebic query focused-monitor-index; if ($monitor_id -ne $other_monitor_id){ komorebic move-workspace-to-monitor $monitor_id; komorebic focus-monitor-workspace $monitor_id $workspace_id; komorebic move-workspace-to-monitor $other_monitor_id; komorebic focus-named-workspace II; } ... # For all the other alt + ``` This allows the swap only if necessary and focused the target workspace in the source monitor. Hopefully it's somewhat useful, let me know if you manage to find a better way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#445