made aspect ratio accurate
[lilass.git] / lilass
diff --git a/lilass b/lilass
index 49dbeea61d24fa251af53a6702de379c495e43a6..85ccc99be2687a32d5a9fa8057047290f2f4185b 100755 (executable)
--- a/lilass
+++ b/lilass
@@ -16,9 +16,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-import argparse, sys, os, re, subprocess
+import argparse, sys, os, os.path, shutil, re, subprocess
 from enum import Enum
-import gui, screen
+import gui, screen, util
 frontend = gui.getFrontend("cli") # the fallback, until we got a proper frontend. This is guaranteed to be available.
 
 
@@ -30,7 +30,6 @@ def commonInternalConnectorNames():
         for suffix in commonInternalConnectorSuffices:
             yield prefix+suffix
 
-
 # Load a section-less config file: maps parameter names to space-separated lists of strings (with shell quotation)
 def loadConfigFile(filename):
     import shlex
@@ -106,7 +105,14 @@ if __name__ == "__main__":
         frontend = gui.getFrontend(cmdArgs.frontend)
         
         # load configuration
-        config = loadConfigFile(os.getenv('HOME') + '/.lilass.conf')
+        legacyConfigFilePath = os.getenv('HOME') + '/.lilass.conf'
+        configDirectory = util.getConfigDirectory()
+        configFilePath = os.path.join(configDirectory, "lilass.conf")
+        if os.path.isfile(legacyConfigFilePath) and not os.path.isfile(configFilePath):
+            # looks like we just upgraded to a new version of lilass
+            util.mkdirP(configDirectory)
+            shutil.move(legacyConfigFilePath, configFilePath)
+        config = loadConfigFile(configFilePath)
         
         # see what situation we are in
         situation = situationByConfig(config)
@@ -135,7 +141,7 @@ if __name__ == "__main__":
                 if setup is None: sys.exit(1) # the user canceled
         else:
             # use first resolution of internal connector
-            setup = screen.ScreenSetup(intResolution = situation.internalResolutions()[0], extResolution = None)
+            setup = screen.ScreenSetup(intResolution = situation.internalConnector.getResolutionList()[0], extResolution = None)
         
         # call xrandr
         xrandrCall = situation.forXrandr(setup)
@@ -146,4 +152,5 @@ if __name__ == "__main__":
         if setup.extResolution is None:
             turnOnBacklight()
     except Exception as e:
+        raise e
         frontend.error(str(e))