The following script lets you select a window , and will keep that window minimized while the script is running. It supports only one windows, so if you open new window of application - that window won't be affected.
You can run it easily like so:
python keep_minimized.py
When the script starts, mouse cursor will turn into a cross. Select the window you want to keep minimized. Now every time that window gains focus (be it via launcher click or Atl+Tab), it will be minimized.
You can obtain the script from here or from github gist
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()