From d72eb2108a90ea139486e98f7c4668579489fc8c Mon Sep 17 00:00:00 2001 From: fdev31 Date: Sun, 4 Feb 2024 20:55:57 +0100 Subject: [PATCH] fix monitor name resolution --- pyprland/plugins/monitors.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pyprland/plugins/monitors.py b/pyprland/plugins/monitors.py index e4aab44..8d7ff5e 100644 --- a/pyprland/plugins/monitors.py +++ b/pyprland/plugins/monitors.py @@ -188,16 +188,16 @@ def _get_mon_by_pat(self, pat, database): "rightendof": "leftendof", } - def _get_rules(self, mon_description): + def _get_rules(self, mon_name, placement): "build a list of matching rules from the config" - for pattern, config in self.config["placement"].items(): - matched = pattern in mon_description + for pattern, config in placement.items(): + matched = pattern == mon_name for position, descr_list in config.items(): if isinstance(descr_list, str): descr_list = [descr_list] for descr in descr_list: lp = clean_pos(position) - if matched or mon_description in descr: + if matched or descr == mon_name: yield ( lp if matched else self._flipped_positions[lp], descr, @@ -216,13 +216,15 @@ def _place_single_monitor( self._clear_mon_by_pat_cache() matched = False - for place, other_screen, rule in self._get_rules(mon_info["description"]): - main_mon = mon_info + cleaned_config = self.resolve_names(monitors) + for place, other_screen, rule in self._get_rules( + mon_info["name"], cleaned_config + ): other_mon = self._get_mon_by_pat(other_screen, monitors_by_descr) - if other_mon and main_mon: + if other_mon and mon_info: matched = True - pos = get_XY(place, main_mon, other_mon) + pos = get_XY(place, mon_info, other_mon) if pos: x, y = pos self.log.info("Will place %s @ %s,%s (%s)", mon_name, x, y, rule)