Created
July 12, 2016 20:32
-
-
Save SergKolo/f642c2e12bd1df6611ce1921002bc5fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 gi.repository import GdkX11,Gdk | |
import subprocess | |
import time | |
def run_sh(cmd): | |
# run shell commands | |
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) | |
out = p.stdout.read().strip() | |
return out | |
def get_window_xid(): | |
for item in run_sh("xwininfo -int").split("\n"): | |
if "Window id" in item: | |
return item.split()[3] | |
user_selection = get_window_xid() | |
screen = Gdk.Screen.get_default() | |
while True : | |
time.sleep(0.25) | |
active_window = screen.get_active_window() | |
if int(active_window.get_xid()) == int(user_selection): | |
active_window.iconify() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment