Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check EDID only for load config #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions autorandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def from_config_file(cls, edid_map, configuration):
options[line[0]] = line[1] if len(line) > 1 else None

edid = None
errors = []

if options["output"] in edid_map:
edid = edid_map[options["output"]]
Expand All @@ -413,12 +414,12 @@ def from_config_file(cls, edid_map, configuration):
if fuzzy_output in fuzzy_edid_map:
edid = edid_map[list(edid_map.keys())[fuzzy_edid_map.index(fuzzy_output)]]
elif "off" not in options:
raise AutorandrException("Failed to find an EDID for output `%s' in setup file, required as `%s' "
"is not off in config file." % (options["output"], options["output"]))
errors.append(options["output"])

output = options["output"]
del options["output"]

return XrandrOutput(output, edid, options)
return errors, XrandrOutput(output, edid, options)

def edid_equals(self, other):
"Compare to another XrandrOutput's edid and on/off-state, taking legacy autorandr behaviour (md5sum'ing) into account"
Expand Down Expand Up @@ -541,9 +542,11 @@ def load_profiles(profile_path):

config = {}
buffer = []
errors = []
for line in chain(open(config_name).readlines(), ["output"]):
if line[:6] == "output" and buffer:
config[buffer[0].strip().split()[-1]] = XrandrOutput.from_config_file(edids, "".join(buffer))
_e, config[buffer[0].strip().split()[-1]] = XrandrOutput.from_config_file(edids, "".join(buffer))
errors.extend(_e)
buffer = [line]
else:
buffer.append(line)
Expand All @@ -553,6 +556,7 @@ def load_profiles(profile_path):
del config[output_name]

profiles[profile] = {
"errors": errors,
"config": config,
"path": os.path.join(profile_path, profile),
"config-mtime": os.stat(config_name).st_mtime,
Expand Down Expand Up @@ -1339,6 +1343,15 @@ def main(argv):
load_profile = options["--default"]

if load_profile:
if bool(profiles[load_profile]['errors']) and "--force" not in options:
msg = 'An error was detected when load profile %s. Monitor(s) %s ' \
+ 'was not found in configuration. Use --force for load ' \
+ 'this profil and turn off this monitor(s).'
print(
msg %
(load_profile, ','.join(profiles[load_profile]['errors']))
)
sys.exit(1)
if load_profile in profile_symlinks:
if "--debug" in options:
print("'%s' symlinked to '%s'" % (load_profile, profile_symlinks[load_profile]))
Expand Down