mirror of
https://github.com/GRFreire/dotfiles.git
synced 2026-01-10 04:19:38 +00:00
wm should handle window swallowing
This commit is contained in:
parent
a0d0a1cc50
commit
7c6f0b614e
@ -8,6 +8,7 @@
|
||||
import time
|
||||
import os
|
||||
import subprocess
|
||||
import psutil
|
||||
from typing import List # noqa: F401
|
||||
|
||||
from libqtile import bar, layout, widget, qtile, hook
|
||||
@ -379,6 +380,26 @@ def autostart():
|
||||
subprocess.call([autostart_script])
|
||||
|
||||
|
||||
@hook.subscribe.client_new
|
||||
def swallow(window):
|
||||
pid = window.window.get_net_wm_pid() # Window PID
|
||||
ppid = psutil.Process(pid).ppid() # Parent Window PID
|
||||
cpids = {c.window.get_net_wm_pid(): wid for wid, c in window.qtile.windows_map.items()} # All Windows PIDs
|
||||
for _ in range(len(cpids)):
|
||||
if not ppid:
|
||||
return
|
||||
if ppid in cpids:
|
||||
parent = window.qtile.windows_map.get(cpids[ppid])
|
||||
parent.minimized = True
|
||||
window.parent = parent
|
||||
return
|
||||
ppid = psutil.Process(ppid).ppid()
|
||||
|
||||
@hook.subscribe.client_killed
|
||||
def unswallow(window):
|
||||
if hasattr(window, 'parent'):
|
||||
window.parent.minimized = False
|
||||
|
||||
@hook.subscribe.client_new
|
||||
def try_regroup_window(client):
|
||||
time.sleep(0.01)
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
mime ^video|^audio, has mpv, X, flag f = devour mpv -- "$@"
|
||||
mime ^image, has sxiv,X, flag f = devour sxiv -- "$@"
|
||||
Loading…
Reference in New Issue
Block a user