sway icon indicating copy to clipboard operation
sway copied to clipboard

Extend swap command to support workspaces

Open fabianscode opened this issue 1 year ago • 7 comments

This extends the swap command to also support workspace swapping. It solves an issue a friend and me had in sway, which is swapping the contents of two workspaces efficiently.

The syntax goes as follows: swap workspace with [number] <name>

It will swap the content of the specified workspace with the content of the currently focused workspace. The currently focused workspace stays focused. If the other workspace doesnt exist, it will be created, otherwise if the other workspace is empty afterwards, it will potentially be destroyed.

It was achieved by simpy swapping relevant fields of the workspaces and updating a few variables of the affected containers.

fabianscode avatar Jan 12 '24 15:01 fabianscode

Why add an entirely new command? The swap command already exists and intuitively it should work on the content of workspaces too.

To me it feels more like there is an oversight with swap, that needs to be fixed, as it is not working with workspaces.

bonsaiiV avatar Feb 05 '24 14:02 bonsaiiV

I have been looking for a nice way to swap all windows from one workspace (on monitor one), to a second workspace (on monitor two). The swayr project looks promising but I'd love to see more stuff like this in native sway.

https://sr.ht/~tsdh/swayr/#menu-switchers

At the moment I have been using (swaymsg -t get_outputs) the following...

bindsym $mod+m output "HDMI-A-1" toggle
bindsym $mod+Control+Shift+Right move workspace to output right
bindsym $mod+Control+Shift+Left move workspace to output left
bindsym $mod+Control+Shift+Down move workspace to output down
bindsym $mod+Control+Shift+Up move workspace to output up

simonfogliato avatar Feb 06 '24 18:02 simonfogliato

Why add an entirely new command? The swap command already exists and intuitively it should work on the content of workspaces too.

To me it feels more like there is an oversight with swap, that needs to be fixed, as it is not working with workspaces.

I guess that seems reasonable... any other opinions?

fabianscode avatar Feb 07 '24 12:02 fabianscode

I have a script on my Todo list as a workaround and think this is really a good feature, especially when working with more than one screen.

cartok avatar Feb 22 '24 07:02 cartok

Why add an entirely new command? The swap command already exists and intuitively it should work on the content of workspaces too.

To me it feels more like there is an oversight with swap, that needs to be fixed, as it is not working with workspaces.

the latest commit implements exactly that. Any thoughts?

fabianscode avatar Feb 26 '24 17:02 fabianscode

I just noticed i3/i3#3952. This is what i described in my review. Since the maintainers want sway to be compatible to i3, it might be necessary to implement the enhancement for i3 first ... .

bonsaiiV avatar Mar 09 '24 21:03 bonsaiiV

I just noticed i3/i3#3952. This is what i described in my review. Since the maintainers want sway to be compatible to i3, it might be necessary to implement the enhancement for i3 first ... .

the way I understood it, the intension is for sway to be a superset of i3, right?

fabianscode avatar Mar 12 '24 12:03 fabianscode