Sway script that renames numeric workspaces so that there are no gaps
./compact-workspaces.py
Suppose you start with these workspaces:
[1] [2] [4] [5] [9] [firefox] [term]
After running the script it will look like this:
[1] [2] [3] [4] [5] [firefox] [term]