mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-15 05:21:06 +01:00
emacs: extend startWithUserSession to start after graphical session (#3010)
This commit is contained in:
parent
fa720861b5
commit
f714b17031
4 changed files with 75 additions and 6 deletions
|
|
@ -81,14 +81,14 @@ in {
|
|||
enable = mkEnableOption "systemd socket activation for the Emacs service";
|
||||
};
|
||||
|
||||
startWithUserSession = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
startWithUserSession = mkOption {
|
||||
type = with types; either bool (enum [ "graphical" ]);
|
||||
default = !cfg.socketActivation.enable;
|
||||
defaultText =
|
||||
literalExpression "!config.services.emacs.socketActivation.enable";
|
||||
example = true;
|
||||
example = "graphical";
|
||||
description = ''
|
||||
Whether to launch Emacs service with the systemd user session.
|
||||
Whether to launch Emacs service with the systemd user session. If it is <literal>true</literal>, Emacs service is started by default.target. If it is <literal>"graphical"</literal>, Emacs service is started by graphical-session.target.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -116,6 +116,11 @@ in {
|
|||
Documentation =
|
||||
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
|
||||
|
||||
After = optional (cfg.startWithUserSession == "graphical")
|
||||
"graphical-session.target";
|
||||
PartOf = optional (cfg.startWithUserSession == "graphical")
|
||||
"graphical-session.target";
|
||||
|
||||
# Avoid killing the Emacs session, which may be full of
|
||||
# unsaved buffers.
|
||||
X-RestartIfChanged = false;
|
||||
|
|
@ -156,8 +161,15 @@ in {
|
|||
ExecStopPost =
|
||||
"${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
|
||||
};
|
||||
} // optionalAttrs (cfg.startWithUserSession) {
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
} // optionalAttrs (cfg.startWithUserSession != false) {
|
||||
Install = {
|
||||
WantedBy = [
|
||||
(if cfg.startWithUserSession == true then
|
||||
"default.target"
|
||||
else
|
||||
"graphical-session.target")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue