Skip to content

Instantly share code, notes, and snippets.

@ineentho
Forked from 97-109-107/cycle-workspace.py
Last active April 21, 2022 23:49
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ineentho/66e1cc382c86026164d248dc27e1cf6f to your computer and use it in GitHub Desktop.
Save ineentho/66e1cc382c86026164d248dc27e1cf6f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# cycle-workspace
# Moves the currently active workspace to the next active display
# Depends on i3-py (`pip install i3-py`)
import i3
# figure out what is on, and what is currently on your screen.
focused_workspace = list(filter(lambda s: s['focused'], i3.get_workspaces()))[0]
outputs = list(filter(lambda s: s['active'], i3.get_outputs()))
# find the index of the currently focused workspace
currentIndex = 0
for i, output in enumerate(outputs):
if output['name'] == focused_workspace['output']:
currentIndex = i
break
# find the next workspace
nextIndex = currentIndex + 1
if nextIndex >= len(outputs):
nextIndex = 0
other_workspace = outputs[nextIndex]
# send current to the no-active one
i3.command('move', 'workspace to output '+other_workspace['name'])
@slavabez
Copy link

Awesome, thanks for this!

@ineentho
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment