From 77b2957c5f393c856f7f93e37642598285a9f51e Mon Sep 17 00:00:00 2001 From: Matt Schreiber Date: Mon, 14 Aug 2023 09:56:19 -0400 Subject: [PATCH] fix: gather closeness score for all outputs defined in a given profile. --- autorandr.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autorandr.py b/autorandr.py index 805b781..7eab8df 100755 --- a/autorandr.py +++ b/autorandr.py @@ -763,6 +763,7 @@ def find_profiles(current_config, profiles): missing_output_names = [] fingerprint_mismatch = [] + closeness_scores = [] profile_output_names = config.keys() for name in profile_output_names: @@ -777,6 +778,11 @@ def find_profiles(current_config, profiles): elif not output.fingerprint_equals(current_config[name]): fingerprint_mismatch.append(name) + closeness = max(match_asterisk(output.edid, current_config[name].edid), match_asterisk( + current_config[name].edid, output.edid)) + + closeness_scores.append(closeness) + if len(fingerprint_mismatch) > 0: continue elif len(missing_output_names) > 0: @@ -788,8 +794,9 @@ def find_profiles(current_config, profiles): percent_present_in_profile = len(possible_output_names) / len(current_output_names) percent_present_in_current_config = len(profile_output_names) / len(possible_output_names) - closeness = max(match_asterisk(output.edid, current_config[name].edid), match_asterisk( - current_config[name].edid, output.edid)) + closeness = 1 + for closeness_score in closeness_scores: + closeness *= closeness_score score = percent_present_in_profile * percent_present_in_current_config * closeness