diff --git a/README.md b/README.md index c5a06317..f3a47b1b 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ At the moment `plasma-manager` supports configuring the following: - Screen locker (via the `kscreenlocker` module) - Fonts (via the `fonts` module) - Window Rules (via the `window-rules` module) +- Session (via the `session` module) - KDE apps (via the `apps` module). In particular the following kde apps have modules in `plasma-manager`: - ghostwriter diff --git a/modules/default.nix b/modules/default.nix index 8b40fb37..03bf03fc 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -13,6 +13,7 @@ ./kwin.nix ./panels.nix ./powerdevil.nix + ./session.nix ./shortcuts.nix ./spectacle.nix ./startup.nix diff --git a/modules/session.nix b/modules/session.nix new file mode 100644 index 00000000..21c0cc36 --- /dev/null +++ b/modules/session.nix @@ -0,0 +1,60 @@ +{ config, lib, ... }: +let + cfg = config.programs.plasma; +in +{ + options.programs.plasma.session = { + general = { + askForConfirmationOnLogout = lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + description = "Whether to ask for confirmation when shutting down, restarting or logging out"; + }; + }; + sessionRestore = { + restoreOpenApplicationsOnLogin = + let + options = { + onLastLogout = "restorePreviousLogout"; + whenSessionWasManuallySaved = "restoreSavedSession"; + startWithEmptySession = "emptySession"; + }; + in + lib.mkOption { + type = with lib.types; nullOr (enum (builtins.attrNames options)); + default = null; + example = "startWithEmptySession"; + description = '' + Controls how applications are restored on login: + - "onLastLogout": Restores applications that were open during the last logout. + - "whenSessionWasManuallySaved": Restores applications based on a manually saved session. + - "startWithEmptySession": Starts with a clean, empty session each time. + ''; + apply = option: if option == null then null else options.${option}; + }; + excludeApplications = lib.mkOption { + type = with lib.types; nullOr (listOf str); + default = null; + example = [ + "firefox" + "xterm" + ]; + description = "List of applications to exclude from session restore"; + apply = apps: if apps == null then null else builtins.concatStringsSep "," apps; + }; + }; + }; + + config.programs.plasma.configFile."ksmserverrc".General = lib.mkMerge [ + (lib.mkIf (cfg.session.general.askForConfirmationOnLogout != null) { + confirmLogout = cfg.session.general.askForConfirmationOnLogout; + }) + (lib.mkIf (cfg.session.sessionRestore.excludeApplications != null) { + excludeApps = cfg.session.sessionRestore.excludeApplications; + }) + (lib.mkIf (cfg.session.sessionRestore.restoreOpenApplicationsOnLogin != null) { + loginMode = cfg.session.sessionRestore.restoreOpenApplicationsOnLogin; + }) + ]; +}