Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
window resize script for XFCE (Xubuntu), depends on wmctrl
#!/usr/bin/env python3
import subprocess
import sys
arg = sys.argv[1]
WA_correction = 48
def get(command):
return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8")
def execute(command):
subprocess.Popen(["/bin/bash", "-c", command])
xprop_data = get("xprop -root").split()
w_id = xprop_data[xprop_data.index("_NET_ACTIVE_WINDOW(WINDOW):")+4].replace(",", "")
frontmost = w_id[:2]+"0"+w_id[2:]
w_data = [l for l in get("wmctrl -lG").splitlines() if frontmost in l][0].split()
new_G = w_data[2:6]
new_G[1] = str(int(int(new_G[1])-WA_correction))
if arg == "left":
new_G[2] = str(int(int(new_G[2])/2))
elif arg == "right":
new_G[0] = str(int(int(new_G[0])+int(new_G[2])/2))
new_G[2] = str(int(int(new_G[2])/2))
elif arg == "up":
new_G[3] = str(int(int(new_G[3])/2))
elif arg == "down":
new_G[1] = str(int(int(new_G[1]) + int(new_G[3])/2))
new_G[3] = str(int(int(new_G[3])/2))
execute("wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz")
execute("wmctrl -ir "+frontmost+" -e 0,"+(",").join(new_G))

This comment has been minimized.

Copy link
Owner Author

@Jacob-Vlijm Jacob-Vlijm commented Jan 25, 2015

see description here: on Askubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment