[displaymanager] Handle variations in config file

- GDM3 uses a different config file than previous GDM
This commit is contained in:
Adriaan de Groot 2019-08-23 03:40:10 -04:00
parent 1c61181624
commit 383bd97a9c

View File

@ -248,25 +248,33 @@ class DMmdm(DisplayManager):
class DMgdm(DisplayManager): class DMgdm(DisplayManager):
name = "gdm" name = "gdm"
executable = "gdm" executable = "gdm"
config = None # Set by have_dm()
def have_dm(self): def have_dm(self):
""" """
GDM exists with different executable names, so search GDM exists with different executable names, so search
for one of them and use it. for one of them and use it.
""" """
for executable in ( "gdm", "gdm3" ): for executable, config in (
( "gdm", "etc/gdm/custom.conf" ),
( "gdm3", "etc/gdm3/daemon.conf" )
):
bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, executable) bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, executable)
sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable) sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable)
if os.path.exists(bin_path) or os.path.exists(sbin_path): if os.path.exists(bin_path) or os.path.exists(sbin_path):
# Keep the found-executable name around for later # Keep the found-executable name around for later
self.executable = executable self.executable = executable
self.config = config
return True return True
return False return False
def set_autologin(self, username, do_autologin, default_desktop_environment): def set_autologin(self, username, do_autologin, default_desktop_environment):
if self.config is None:
raise ValueError( "No config file for GDM has been set." )
# Systems with GDM as Desktop Manager # Systems with GDM as Desktop Manager
gdm_conf_path = os.path.join(self.root_mount_point, "etc/gdm/custom.conf") gdm_conf_path = os.path.join(self.root_mount_point, self.config)
if os.path.exists(gdm_conf_path): if os.path.exists(gdm_conf_path):
with open(gdm_conf_path, 'r') as gdm_conf: with open(gdm_conf_path, 'r') as gdm_conf: