wm should handle window swallowing

This commit is contained in:
Guilherme Rugai Freire 2021-08-06 09:16:00 -03:00
parent a0d0a1cc50
commit 7c6f0b614e
No known key found for this signature in database
GPG Key ID: 0F9FE41723A8A297
3 changed files with 21 additions and 6 deletions

View File

@ -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)

View File

@ -1,2 +0,0 @@
mime ^video|^audio, has mpv, X, flag f = devour mpv -- "$@"
mime ^image, has sxiv,X, flag f = devour sxiv -- "$@"

4
.zshrc
View File

@ -52,10 +52,6 @@ alias ls="exa --color=always --group-directories-first"
# Alias to nvim instead of vim
alias vim="nvim"
# Window swallowing with devour
alias mpv="devour mpv"
alias sxiv="devour sxiv"
export EDITOR=nvim
# This loads nvm