Skip to content

Commit

Permalink
fix monitor name resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Feb 4, 2024
1 parent 12717ec commit d72eb21
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pyprland/plugins/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit d72eb21

Please sign in to comment.