Created
January 25, 2015 18:52
-
-
Save Jacob-Vlijm/f969af5201840df3bb17 to your computer and use it in GitHub Desktop.
window resize script for XFCE (Xubuntu), depends on wmctrl
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 | |
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see description here: http://askubuntu.com/a/576694/72216 on Askubuntu