+def update_profiles_edid(profiles, config):
+ edid_map = {}
+ for c in config:
+ if config[c].edid is not None:
+ edid_map[config[c].edid] = c
+
+ for p in profiles:
+ profile_config = profiles[p]["config"]
+
+ for edid in edid_map:
+ for c in profile_config.keys():
+ if profile_config[c].edid != edid or c == edid_map[edid]:
+ continue
+
+ print("%s: renaming display %s to %s" % (p, c, edid_map[edid]))
+
+ tmp_disp = profile_config[c]
+
+ if edid_map[edid] in profile_config:
+ # Swap the two entries
+ profile_config[c] = profile_config[edid_map[edid]]
+ profile_config[c].output = c
+ else:
+ # Object is reassigned to another key, drop this one
+ del profile_config[c]
+
+ profile_config[edid_map[edid]] = tmp_disp
+ profile_config[edid_map[edid]].output = edid_map[edid]
+
+