Skip to content

Instantly share code, notes, and snippets.

@frap129
Created November 28, 2022 17:18
Show Gist options
  • Save frap129/48f4040be925f2eea3cd7d43e3c1b21a to your computer and use it in GitHub Desktop.
Save frap129/48f4040be925f2eea3cd7d43e3c1b21a to your computer and use it in GitHub Desktop.
i3/sway mark, swap, unmark with a single command using i3ipc-python
#!/usr/bin/env python3
from i3ipc import Connection
mark = "swapTarget"
con = Connection()
try:
# Swap marked target with focus, unmark
swapTarget = con.get_tree().find_marked(mark)[0]
con.command("swap container with mark %s" % mark)
con.command("unmark %s" % mark)
except Exception:
# Mark focus if none are marked
con.command("mark %s" % mark)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment