From c150c61c5946a2fb974013b984cb6fec2312aa23 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 10 Jul 2017 09:26:17 -0400 Subject: [PATCH] LightDM: if lightdm.conf doesn't exist (for autologin), create it FIXES #568 --- src/modules/displaymanager/main.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 467f54d57..18705b597 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -285,12 +285,23 @@ def set_autologin(username, lightdm_conf.write(line) else: - return ( - "Cannot write LightDM configuration file", - "LightDM config file {!s} does not exist".format( - lightdm_conf_path + try: + # Create a new lightdm.conf file; this is documented to be + # read last, after aeverything in lightdm.conf.d/ + with open(lightdm_conf_path, 'w') as lightdm_conf: + if do_autologin: + lightdm_conf.write( + "autologin-user={!s}\n".format(username)) + else: + lightdm_conf.write( + "#autologin-user=\n") + except FileNotFOundError: + return ( + "Cannot write LightDM configuration file", + "LightDM config file {!s} does not exist".format( + lightdm_conf_path + ) ) - ) if "slim" == displaymanager: # Systems with Slim as Desktop Manager