From e5f5ef0d17ca5191b5014781942eb747dbff012d Mon Sep 17 00:00:00 2001 From: Jonas Strassel Date: Wed, 27 Oct 2021 23:08:18 +0200 Subject: [PATCH] feat(greetd): add greetd to displaymanagers --- .../displaymanager/displaymanager.conf | 1 + .../displaymanager/displaymanager.schema.yaml | 2 +- src/modules/displaymanager/main.py | 70 ++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/modules/displaymanager/displaymanager.conf b/src/modules/displaymanager/displaymanager.conf index 7175c112d..0fd2af163 100644 --- a/src/modules/displaymanager/displaymanager.conf +++ b/src/modules/displaymanager/displaymanager.conf @@ -23,6 +23,7 @@ displaymanagers: - mdm - lxdm - kdm + - greetd # Enable the following settings to force a desktop environment # in your displaymanager configuration file. This will attempt diff --git a/src/modules/displaymanager/displaymanager.schema.yaml b/src/modules/displaymanager/displaymanager.schema.yaml index fc28fd66d..89d657a3b 100644 --- a/src/modules/displaymanager/displaymanager.schema.yaml +++ b/src/modules/displaymanager/displaymanager.schema.yaml @@ -10,7 +10,7 @@ properties: type: array items: type: string - enum: [slim, sddm, lightdm, gdm, mdm, lxdm, kdm] + enum: [slim, sddm, lightdm, gdm, mdm, lxdm, kdm, greetd] minItems: 1 # Must be non-empty, if present at all defaultDesktopEnvironment: type: object diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 5fb228682..1fd6a26ca 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -17,7 +17,7 @@ import abc import os -import re +import toml import libcalamares import configparser @@ -835,6 +835,74 @@ class DMsddm(DisplayManager): pass +class DMgreetd(DisplayManager): + name = "greetd" + executable = "greetd" + config_data = {} + + def os_path(self, path): + return os.path.join(self.root_mount_point, path) + + def config_path(self): + return self.os_path("etc/greetd/config.toml") + + def environments_path(self): + return self.os_path("etc/greetd/environments") + + def config_load(self): + self.config_data = toml.loads(self.config_path()) + + def config_write(self): + toml.dump(self.config_data, self.config_path()) + + def basic_setup(self): + if libcalamares.utils.target_env_call( + ['getent', 'group', 'greetd'] + ) != 0: + libcalamares.utils.target_env_call( + ['groupadd', 'greetd'] + ) + + if libcalamares.utils.target_env_call( + ['getent', 'passwd', 'greeter'] + ) != 0: + libcalamares.utils.target_env_call( + ['useradd', + '-c', '"Greeter User"', + '-g', 'greetd', + '-s', '/bin/bash', + 'greeter' + ] + ) + self.config_load() + self.config_data['terminal']['vt'] = "next" + self.config_write() + + def desktop_environment_setup(self, default_desktop_environment): + with open(self.environments_path(), 'w') as envs_file: + envs_file.write(default_desktop_environment) + + def greeter_setup(self): + pass + + def set_autologin(self, username, do_autologin, default_desktop_environment): + self.config_load() + + if (os.path.exists(self.os_path("usr/bin/tuigreet"))): + tuigreet_base_cmd = "tuigreet --remember --time --issue --asterisks --cmd " + self.config_data['default_session']['command'] = tuigreet_base_cmd + default_desktop_environment + else: + print("no greeter detected") + + if (do_autologin == True): + self.config_data['initial_session'] = {} + self.config_data['initial_session']['command'] = default_desktop_environment + self.config_data['initial_session']['user'] = username + + self.config_write() + + + class DMsysconfig(DisplayManager): name = "sysconfig" executable = None