X-Git-Url: https://git.ralfj.de/lilass.git/blobdiff_plain/8d8ac3226f3669f8524eef50161ae7241a808d7e..012442b93e9c29f03b0fd1af417e8b681a42673b:/dsl.py diff --git a/dsl.py b/dsl.py index 606809c..13a97f8 100755 --- a/dsl.py +++ b/dsl.py @@ -192,23 +192,22 @@ def classifyConnectors(allConnectors): # if we run top-level if __name__ == "__main__": + # parse command-line arguments + parser = argparse.ArgumentParser(description='easy Display Setup for Laptops') + parser.add_argument("-f", "--frontend", + dest="frontend", + help="The frontend to be used for user interaction") + parser.add_argument("-r", "--relative-position", + dest="rel_position", choices=RelativeScreenPosition.__names__.keys(), + help="Position of external screen relative to internal one") + parser.add_argument("-i", "--internal-only", + dest="internal_only", action='store_true', + help="Enable internal screen, disable all the others (as if no external screen was connected") + cmdArgs = parser.parse_args() + + # load frontend + frontend = getFrontend(cmdArgs.frontend) try: - # parse command-line arguments - parser = argparse.ArgumentParser(description='easy Display Setup for Laptops') - parser.add_argument("-f", "--frontend", - dest="frontend", - help="The frontend to be used for user interaction") - parser.add_argument("-r", "--relative-position", - dest="rel_position", choices=RelativeScreenPosition.__names__.keys(), - help="Position of external screen relative to internal one") - parser.add_argument("-i", "--internal-only", - dest="internal_only", action='store_true', - help="Enable internal screen, disable all the others (as if no external screen was connected") - cmdArgs = parser.parse_args() - - # load frontend - frontend = getFrontend(cmdArgs.frontend) - # load connectors and classify them connectors = getXrandrInformation() (internalConnector, externalConnectors) = classifyConnectors(connectors) @@ -253,9 +252,12 @@ if __name__ == "__main__": # make sure the internal screen is really, *really* turned on if there is no external screen if not hasExternal: - backlight = float(subprocess.check_output(["xbacklight", "-get"]).strip()) - if backlight == 0: # it's completely turned off, we better enable it - subprocess.check_call(["xbacklight", "-set", "100"]) + try: + backlight = float(subprocess.check_output(["xbacklight", "-get"]).strip()) + if backlight == 0: # it's completely turned off, we better enable it + subprocess.check_call(["xbacklight", "-set", "100"]) + except FileNotFoundError: + print("xbacklight has not been found, unable to turn your laptop backlight on.") except Exception as e: frontend.error(str(e)) raise