From 7c6f0b614e4e68acf44109e7b9fed6fa8b45ed26 Mon Sep 17 00:00:00 2001 From: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Date: Fri, 6 Aug 2021 09:16:00 -0300 Subject: [PATCH] wm should handle window swallowing --- .config/qtile/config.py | 21 +++++++++++++++++++++ .config/ranger/rifle.conf | 2 -- .zshrc | 4 ---- 3 files changed, 21 insertions(+), 6 deletions(-) delete mode 100644 .config/ranger/rifle.conf diff --git a/.config/qtile/config.py b/.config/qtile/config.py index 1a481a4..4235df6 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -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) diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf deleted file mode 100644 index 484f452..0000000 --- a/.config/ranger/rifle.conf +++ /dev/null @@ -1,2 +0,0 @@ -mime ^video|^audio, has mpv, X, flag f = devour mpv -- "$@" -mime ^image, has sxiv,X, flag f = devour sxiv -- "$@" diff --git a/.zshrc b/.zshrc index e7561d5..6bc3d11 100644 --- a/.zshrc +++ b/.zshrc @@ -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