I regularly change physical setup (work from home and office) and need a flexible and quick way of changing workspace form monitor to monitor.
There are a number of ways to do this.
Use the command line:
$ i3-msg move workspace to output left
[{"success":true}]
$ i3-msg move workspace to output right
[{"success":true}]
$ i3-msg move workspace to output next
[{"success":true}]
Add bindsym
binds in your i3 config file as per other answers (for regolith users here is a good example).
Use python:
#!/usr/bin/env python3
# pip install --user i3-py rich
import i3
import rich
DEBUG = False
outputs = i3.get_outputs()
workspaces = i3.get_workspaces()
focused_workspace = [w for w in workspaces if w["focused"] == True][0]
active_outputs = [o for o in outputs if o["active"] == True]
other_output = [o for o in active_outputs if o["name"] != focused_workspace["output"]][
0
]
if DEBUG:
print("outputs:")
rich.print(outputs)
print("workspaces:")
rich.print(workspaces)
print("focused_workspace:")
rich.print(focused_workspace)
print("active_outputs:")
rich.print(active_outputs)
print("other_workspace:")
rich.print(other_output)
# Send current workspace to other output
i3.command("move", "workspace to output " + other_output["name"])
See this gist for other versions.
When using i3-msg
or i3.command
possible syntax is move workspace to output left|right|down|up|current|primary|<output>
.