summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2022-03-18 15:20:41 +0100
committerJulian T <julian@jtle.dk>2022-03-18 15:20:41 +0100
commit911d1c59186304be83d7302905a0a7bbf7de1d99 (patch)
treee363f488cb0d466bc706bef351d4eec3968d8db2 /scripts
parent13ba3fc359deb79fa2bf30164bf0549b40f7b625 (diff)
Add open_rel script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/Scripts/open_rel36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/Scripts/open_rel b/scripts/Scripts/open_rel
new file mode 100755
index 0000000..06f246d
--- /dev/null
+++ b/scripts/Scripts/open_rel
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import re
+import subprocess as sp
+
+
+def get_window_title() -> str:
+ command = ["xdotool", "getactivewindow", "getwindowname"]
+ ret = sp.run(command, capture_output=True)
+
+ return ret.stdout.decode("utf-8")[:-1]
+
+
+def launch_term(command=None, directory=None):
+ run = ["i3-sensible-terminal"]
+ if command:
+ run.extend(["-e", command])
+ if directory:
+ run.extend(["-d", directory])
+
+ print("Running:", run)
+ sp.run(run)
+
+
+def decide_and_run(title: str):
+ print(title)
+ if title.startswith("fish "):
+ launch_term(directory=title[5:])
+ elif (m := re.search(".*client\d*@\[(\d*)\] - Kakoune", title)):
+ id = m.group(1)
+ launch_term(command=f"kak -c {id}")
+
+
+if __name__ == "__main__":
+ title = get_window_title()
+ decide_and_run(title)