From e8e5b7a42afb30724aecbc39b3c33ab8aed62b97 Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Mon, 2 Oct 2023 20:18:14 +0200 Subject: [PATCH] feat: improve nmaster behavior upon closing windows --- modules/desktop/qtile/config/xmonadcustom.py | 22 ++++++++++++++------ modules/desktop/qtile/home.nix | 7 +++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/modules/desktop/qtile/config/xmonadcustom.py b/modules/desktop/qtile/config/xmonadcustom.py index 923ecfd..60dbc0d 100644 --- a/modules/desktop/qtile/config/xmonadcustom.py +++ b/modules/desktop/qtile/config/xmonadcustom.py @@ -251,6 +251,12 @@ class MonadTall(_SimpleLayoutBase): def remove(self, client: Window) -> Window | None: "Remove client from layout" self.do_normalize = True + index = self.clients.index(client) + if index < self.master_length: + self.decrease_nmaster(False) + elif len(self.clients) - self.master_length - 1 == 0: + self.decrease_nmaster(False) + return self.clients.remove(client) @expose_command() @@ -789,20 +795,24 @@ class MonadTall(_SimpleLayoutBase): self.group.focus(self.clients.current_client) @expose_command() - def decrease_nmaster(self): + def decrease_nmaster(self, normalize=True): self.master_length -= 1 if self.master_length <= 0: self.master_length = 1 - self.group.layout_all() - self.normalize() + + if normalize: + self.group.layout_all() + self.normalize() @expose_command() - def increase_nmaster(self): + def increase_nmaster(self, normalize=True): self.master_length += 1 if self.master_length >= len(self.clients): self.master_length = len(self.clients) - 1 - self.group.layout_all() - self.normalize() + + if normalize: + self.group.layout_all() + self.normalize() @expose_command def focus_first(self): diff --git a/modules/desktop/qtile/home.nix b/modules/desktop/qtile/home.nix index da62a00..85bdea0 100644 --- a/modules/desktop/qtile/home.nix +++ b/modules/desktop/qtile/home.nix @@ -15,6 +15,9 @@ let cargoHash = "sha256-7S8TXqtKWR4utBeUe9Q7RrmHgJg5lqkLdmo9b+MTRGg="; hash = "sha256-7S8TXqtKWR4utBeUe9Q7RrmHgJg5lqkLdmo9b+MTRGg="; }; + + currentDirectory = builtins.toString ./.; + rootConfigDirectory = builtins.toString ./../../../.; in { # services.udev.extraRules = # ''ACTION=="change", SUBSYSTEM=="drm", RUN+="${pkgs.autorandr}/bin/autorandr -c"''; @@ -107,8 +110,8 @@ in { from string import Template import os -setupLocationRef = Template("${location}") -configLocationRef = Template("${location}/modules/desktop/qtile/config") +setupLocationRef = Template("${rootConfigDirectory}") +configLocationRef = Template("${currentDirectory}/modules/desktop/qtile/config") setupLocation = setupLocationRef.substitute(os.environ) configLocation = configLocationRef.substitute(os.environ) -- 2.48.1