Created
March 5, 2020 14:19
-
-
Save KennethNielsen/098584c272f92fc70f190396cca21af0 to your computer and use it in GitHub Desktop.
wmctrl fix for mailspring wrong screen
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
from time import sleep | |
from subprocess import CalledProcessError, check_output, check_call | |
mailspring_pid = None | |
while True: | |
try: | |
output = check_output(("wmctrl", "-l", "-p", "-G")).decode("UTF-8") | |
except CalledProcessError: | |
pass | |
print(".", end="", flush=True) | |
for line in output.split("\n"): | |
if line == "": | |
continue | |
# Substitute user-HOST with your actual username and HOST as it appears in the wmctrl output | |
first_part, name = line.split(" user-HOST ") | |
id_, _, pid, x, y, _, _ = first_part.split() | |
if pid == mailspring_pid and int(x) < 2000: | |
id_int = int(id_, base=16) | |
new_x = 2270 + int(x) | |
args = ["wmctrl", "-e", f"0,{new_x},-1,-1,-1", "-i", "-r", id_] | |
try: | |
return_value = check_call(args) | |
except CalledProcessError: | |
continue | |
print("Corrected") | |
sleep(1) | |
if name.startswith("Mailspring") and not mailspring_pid: | |
mailspring_pid = pid | |
print("Found mailspring", mailspring_pid) | |
sleep(0.4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment