diff --git a/run-and-position.py b/run-and-position.py new file mode 100755 index 0000000..0f3efd5 --- /dev/null +++ b/run-and-position.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import subprocess +import time +import sys + +app = sys.argv[1] + +get = lambda x: subprocess.check_output(["/bin/bash", "-c", x]).decode("utf-8") +ws1 = get("wmctrl -lp"); t = 0 +subprocess.Popen(["/bin/bash", "-c", app]) + +while t < 30: + ws2 = [w.split()[0:3] for w in get("wmctrl -lp").splitlines() if not w in ws1] + procs = [[(p, w[0]) for p in get("ps -e ww").splitlines() \ + if app in p and w[2] in p] for w in ws2] + if len(procs) > 0: + w_id = procs[0][0][1] + cmd1 = "wmctrl -ir "+w_id+" -b remove,maximized_horz" + cmd2 = "wmctrl -ir "+w_id+" -b remove,maximized_vert" + cmd3 = "xdotool windowsize --sync "+procs[0][0][1]+" "+sys.argv[4]+"% "+sys.argv[5]+"%" + cmd4 = "xdotool windowmove "+procs[0][0][1]+" "+sys.argv[2]+" "+sys.argv[3] + for cmd in [cmd1, cmd2, cmd3, cmd4]: + subprocess.call(["/bin/bash", "-c", cmd]) + break + time.sleep(0.5) + t = t+1 diff --git a/window_arrange.py b/window_arrange.py old mode 100644 new mode 100755