@@ -403,6 +403,7 @@ def from_config_file(cls, edid_map, configuration):
403403 options [line [0 ]] = line [1 ] if len (line ) > 1 else None
404404
405405 edid = None
406+ errors = []
406407
407408 if options ["output" ] in edid_map :
408409 edid = edid_map [options ["output" ]]
@@ -413,12 +414,12 @@ def from_config_file(cls, edid_map, configuration):
413414 if fuzzy_output in fuzzy_edid_map :
414415 edid = edid_map [list (edid_map .keys ())[fuzzy_edid_map .index (fuzzy_output )]]
415416 elif "off" not in options :
416- raise AutorandrException ( "Failed to find an EDID for output `%s' in setup file, required as `%s' "
417- "is not off in config file." % ( options [ "output" ], options [ "output" ]))
417+ errors . append ( options [ " output" ])
418+
418419 output = options ["output" ]
419420 del options ["output" ]
420421
421- return XrandrOutput (output , edid , options )
422+ return errors , XrandrOutput (output , edid , options )
422423
423424 def edid_equals (self , other ):
424425 "Compare to another XrandrOutput's edid and on/off-state, taking legacy autorandr behaviour (md5sum'ing) into account"
@@ -541,9 +542,11 @@ def load_profiles(profile_path):
541542
542543 config = {}
543544 buffer = []
545+ errors = []
544546 for line in chain (open (config_name ).readlines (), ["output" ]):
545547 if line [:6 ] == "output" and buffer :
546- config [buffer [0 ].strip ().split ()[- 1 ]] = XrandrOutput .from_config_file (edids , "" .join (buffer ))
548+ _e , config [buffer [0 ].strip ().split ()[- 1 ]] = XrandrOutput .from_config_file (edids , "" .join (buffer ))
549+ errors .extend (_e )
547550 buffer = [line ]
548551 else :
549552 buffer .append (line )
@@ -553,6 +556,7 @@ def load_profiles(profile_path):
553556 del config [output_name ]
554557
555558 profiles [profile ] = {
559+ "errors" : errors ,
556560 "config" : config ,
557561 "path" : os .path .join (profile_path , profile ),
558562 "config-mtime" : os .stat (config_name ).st_mtime ,
@@ -1339,6 +1343,15 @@ def main(argv):
13391343 load_profile = options ["--default" ]
13401344
13411345 if load_profile :
1346+ if bool (profiles [load_profile ]['errors' ]) and "--force" not in options :
1347+ msg = 'An error was detected when load profile %s. Monitor(s) %s ' \
1348+ + 'was not found in configuration. Use --force for load ' \
1349+ + 'this profil and turn off this monitor(s).'
1350+ print (
1351+ msg %
1352+ (load_profile , ',' .join (profiles [load_profile ]['errors' ]))
1353+ )
1354+ sys .exit (1 )
13421355 if load_profile in profile_symlinks :
13431356 if "--debug" in options :
13441357 print ("'%s' symlinked to '%s'" % (load_profile , profile_symlinks [load_profile ]))
0 commit comments