re-enable backlight whenever necessary
[lilass.git] / dsl.py
diff --git a/dsl.py b/dsl.py
index d05c4704fbd6c769247bee20973795775a37414b..9bbf45f6f1b2acb866689daf00935ca39809ce8b 100755 (executable)
--- a/dsl.py
+++ b/dsl.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 # DSL - easy Display Setup for Laptops
-# Copyright (C) 2012 Ralf Jung <post@ralfj.de>
+# Copyright (C) 2012-2014 Ralf Jung <post@ralfj.de>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -182,13 +182,13 @@ if __name__ == "__main__":
        try:
                # parse command-line arguments
                parser = argparse.ArgumentParser(description='easy Display Setup for Laptops')
-               parser.add_argument("-f--frontend",
+               parser.add_argument("-f", "--frontend",
                                                        dest="frontend",
                                                        help="The frontend to be used for user interaction")
-               parser.add_argument("-r--relative-position",
+               parser.add_argument("-r", "--relative-position",
                                                        dest="rel_position", choices=('left', 'right', 'external-only'),
                                                        help="Position of external screen relative to internal one")
-               parser.add_argument("-i,--internal-only",
+               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()
@@ -208,7 +208,8 @@ if __name__ == "__main__":
                # check whether we got an external screen or not
                # Check what to do
                usedExternalConnector = findAvailableConnector(externalConnectors, connectors) # *the* external connector which is actually used
-               if not cmdArgs.internal_only and usedExternalConnector is not None:
+               hasExternal = not cmdArgs.internal_only and usedExternalConnector is not None
+               if hasExternal:
                        # there's an external screen connected, we need to get a setup
                        if cmdArgs.rel_position is not None:
                                # use command-line arguments (can we do this relPosition stuff more elegant?)
@@ -236,6 +237,12 @@ if __name__ == "__main__":
                        call += ["--output", name] + connectorArgs[name]
                print("Call that will be made:",call)
                subprocess.check_call(call)
+               
+               # 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"])
        except Exception as e:
                frontend.error(str(e))
                raise