diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 3b2394b52..11b4c0b41 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -495,26 +495,21 @@ class DMlightdm(DisplayManager): text = lightdm_conf.readlines() # Check to make sure [SeatDefaults] or [Seat:*] is in the config, # otherwise we'll risk malforming the config - if not '[SeatDefaults]' in text and not '[Seat:*]' in text: - addseat = True + addseat = '[SeatDefaults]' not in text and '[Seat:*]' not in text with open(lightdm_conf_path, 'w') as lightdm_conf: if addseat: - # Append Seat line to start of file rather than leaving it without one + # Prepend Seat line to start of file rather than leaving it without one # This keeps the config from being malformed for LightDM text = ["[Seat:*]\n"] + text - loopcount = 0 for line in text: if 'autologin-user=' in line: if do_autologin: line = "autologin-user={!s}\n".format(username) else: line = "#autologin-user=\n" - text[loopcount] = line - loopcount += 1 - lightdm_conf.write("".join(text)) - loopcount = 0 + lightdm_conf.write(line) else: try: # Create a new lightdm.conf file; this is documented to be