Skip to content

Commit

Permalink
feat(session): init (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeitorAugustoLN authored Nov 3, 2024
1 parent 6cb0aed commit 2936685
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
./kwin.nix
./panels.nix
./powerdevil.nix
./session.nix
./shortcuts.nix
./spectacle.nix
./startup.nix
Expand Down
60 changes: 60 additions & 0 deletions modules/session.nix
Original file line number Diff line number Diff line change
@@ -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;
})
];
}

0 comments on commit 2936685

Please sign in to comment.