1
0
mirror of https://github.com/dperelman/swap-workspaces.git synced 2026-05-10 02:12:02 -04:00
Swap/move the current workspace (and all its windows), with either the next, previous or a specified target workspace.
Go to file
2026-04-26 01:48:05 -07:00
delete-empty-workspace.sh Add helper scripts for inserting/deleting workspaces in the middle. 2026-04-26 01:38:10 -07:00
insert-workspace.sh Add helper scripts for inserting/deleting workspaces in the middle. 2026-04-26 01:38:10 -07:00
LICENSE Initial commit 2020-12-15 02:05:04 -08:00
move-to-workspace.sh Rework script to use rename-desktop to avoid Xfce dependency. 2026-04-26 01:37:19 -07:00
notes.adoc Add my notes that I used to figure this out. 2020-12-15 11:58:17 -08:00
README.adoc Update README. 2026-04-26 01:48:05 -07:00
swap-workspaces.sh Rework script to use rename-desktop to avoid Xfce dependency. 2026-04-26 01:37:19 -07:00

# swap-workspaces

Swap/move the current workspace, with either the next, previous or a specified target workspace.

This swaps over all the windows from the src and target workspaces, then swaps the workspace names.

Also includes helper scripts that use that `insert-workspace.sh` and
`delete-empty-workspace.sh` that will add/remove a workspace in the middle of
the list instead of the normal behavior of doing so at the end by swapping
workspaces before/after deleting/adding the workspace.

Also includes another script `move-to-workspace.sh` that allowing moving just
some windows to a different workspace to support splitting a workspace into
two or more workspaces. It uses `zenity` to allow selection of which desktop
to move windows to and then every window left-clicked on will be moved to that
desktop until another mouse button is clicked.


## Requirements

You need `wmctrl` installed. See: https://www.freedesktop.org/wiki/Software/wmctrl/

For Debian/Ubuntu, you can do:

```shell
$ sudo apt install wmctrl
```

Uses my https://git.aweirdimagination.net/perelman/rename-desktop script to avoid the dependency on Xfce of the upstream version. You can install it with
```shell
$ pipx install https://git.aweirdimagination.net/perelman/rename-desktop/archive/main.zip
```

## Installation

```shell
$ sudo cp swap-workspaces.sh /usr/bin/swap-workspaces
```

## Usage

### Swap with specific workspace, by ID

You can swap the current workspace with any other by passing in the target workspace id:

```shell
$ swap-workspaces <target workspace id>
```

NOTE: This expects XFCE workspace numbers, which start from 1.

### Swap with previous or next workspace

This will move the current workspace left or right, by swapping it with the previous or next workspace:

```shell
$ swap-workspace prev
$ swap-workspace next
```

### Insert workspace after the current one

This may take some time as it actually adds a new workspace at the end and
swaps it one-by-one over to the current position.

```shell
$ insert-workspace.sh
```

### Delete the current workspace

As the filename suggests, this will do nothing if there are windows on the
current workspace (ignoring windows that are on all workspaces). It will first
swap the current workspace over to be the last one and then remove it.

```shell
$ delete-empty-workspace.sh
```

### Move some windows to a different workspace

```shell
$ move-to-workspace.sh
```


## Credits

The rename desktop code came from https://github.com/ngeiswei/rename-xfce-workspace