Created
November 28, 2022 17:18
-
-
Save frap129/48f4040be925f2eea3cd7d43e3c1b21a to your computer and use it in GitHub Desktop.
i3/sway mark, swap, unmark with a single command using i3ipc-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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