Skip to content

Instantly share code, notes, and snippets.

@neilbags
Created October 16, 2022 00:17
Show Gist options
  • Save neilbags/b95a74b879b1bda260a8b5f00f7c383b to your computer and use it in GitHub Desktop.
Save neilbags/b95a74b879b1bda260a8b5f00f7c383b to your computer and use it in GitHub Desktop.
Move i3 container to next empty workspace, and follow
#!/usr/bin/python3
import json, subprocess
output = subprocess.check_output(['i3-msg', '-t', 'get_workspaces'])
workspaces = json.loads(output)
next_num = next(i for i in range(1, 100) if not [ws for ws in workspaces if ws['num'] == i])
subprocess.call(['i3-msg', f'move container to workspace number {next_num}; workspace {next_num}'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment