Merge pull request #227628 from m-bdf/logind-handle-keys
nixos/logind: Add key handling options
This commit is contained in:
commit
76d668fae7
|
@ -11,64 +11,145 @@ let
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options.services.logind = {
|
||||||
services.logind.extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
example = "IdleAction=lock";
|
example = "IdleAction=lock";
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Extra config options for systemd-logind. See
|
Extra config options for systemd-logind.
|
||||||
[
|
See [logind.conf(5)](https://www.freedesktop.org/software/systemd/man/logind.conf.html)
|
||||||
logind.conf(5)](https://www.freedesktop.org/software/systemd/man/logind.conf.html) for available options.
|
for available options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logind.killUserProcesses = mkOption {
|
killUserProcesses = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Specifies whether the processes of a user should be killed
|
Specifies whether the processes of a user should be killed
|
||||||
when the user logs out. If true, the scope unit corresponding
|
when the user logs out. If true, the scope unit corresponding
|
||||||
to the session and all processes inside that scope will be
|
to the session and all processes inside that scope will be
|
||||||
terminated. If false, the scope is "abandoned" (see
|
terminated. If false, the scope is "abandoned"
|
||||||
[systemd.scope(5)](https://www.freedesktop.org/software/systemd/man/systemd.scope.html#)), and processes are not killed.
|
(see [systemd.scope(5)](https://www.freedesktop.org/software/systemd/man/systemd.scope.html#)),
|
||||||
|
and processes are not killed.
|
||||||
|
|
||||||
See [logind.conf(5)](https://www.freedesktop.org/software/systemd/man/logind.conf.html#KillUserProcesses=)
|
See [logind.conf(5)](https://www.freedesktop.org/software/systemd/man/logind.conf.html#KillUserProcesses=)
|
||||||
for more details.
|
for more details.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logind.lidSwitch = mkOption {
|
powerKey = mkOption {
|
||||||
|
default = "poweroff";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the power key is pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
powerKeyLongPress = mkOption {
|
||||||
|
default = "ignore";
|
||||||
|
example = "reboot";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the power key is long-pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
rebootKey = mkOption {
|
||||||
|
default = "reboot";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the reboot key is pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
rebootKeyLongPress = mkOption {
|
||||||
|
default = "poweroff";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the reboot key is long-pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
suspendKey = mkOption {
|
||||||
default = "suspend";
|
default = "suspend";
|
||||||
example = "ignore";
|
example = "ignore";
|
||||||
type = logindHandlerType;
|
type = logindHandlerType;
|
||||||
|
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Specifies what to be done when the laptop lid is closed.
|
Specifies what to do when the suspend key is pressed.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logind.lidSwitchDocked = mkOption {
|
suspendKeyLongPress = mkOption {
|
||||||
|
default = "hibernate";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the suspend key is long-pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
hibernateKey = mkOption {
|
||||||
|
default = "hibernate";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the hibernate key is pressed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
hibernateKeyLongPress = mkOption {
|
||||||
default = "ignore";
|
default = "ignore";
|
||||||
example = "suspend";
|
example = "suspend";
|
||||||
type = logindHandlerType;
|
type = logindHandlerType;
|
||||||
|
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Specifies what to be done when the laptop lid is closed
|
Specifies what to do when the hibernate key is long-pressed.
|
||||||
and another screen is added.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logind.lidSwitchExternalPower = mkOption {
|
lidSwitch = mkOption {
|
||||||
|
default = "suspend";
|
||||||
|
example = "ignore";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the laptop lid is closed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
lidSwitchExternalPower = mkOption {
|
||||||
default = cfg.lidSwitch;
|
default = cfg.lidSwitch;
|
||||||
defaultText = literalExpression "services.logind.lidSwitch";
|
defaultText = literalExpression "services.logind.lidSwitch";
|
||||||
example = "ignore";
|
example = "ignore";
|
||||||
type = logindHandlerType;
|
type = logindHandlerType;
|
||||||
|
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Specifies what to do when the laptop lid is closed and the system is
|
Specifies what to do when the laptop lid is closed
|
||||||
on external power. By default use the same action as specified in
|
and the system is on external power. By default use
|
||||||
services.logind.lidSwitch.
|
the same action as specified in services.logind.lidSwitch.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
lidSwitchDocked = mkOption {
|
||||||
|
default = "ignore";
|
||||||
|
example = "suspend";
|
||||||
|
type = logindHandlerType;
|
||||||
|
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Specifies what to do when the laptop lid is closed
|
||||||
|
and another screen is added.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -94,9 +175,17 @@ in
|
||||||
"systemd/logind.conf".text = ''
|
"systemd/logind.conf".text = ''
|
||||||
[Login]
|
[Login]
|
||||||
KillUserProcesses=${if cfg.killUserProcesses then "yes" else "no"}
|
KillUserProcesses=${if cfg.killUserProcesses then "yes" else "no"}
|
||||||
|
HandlePowerKey=${cfg.powerKey}
|
||||||
|
HandlePowerKeyLongPress=${cfg.powerKeyLongPress}
|
||||||
|
HandleRebootKey=${cfg.rebootKey}
|
||||||
|
HandleRebootKeyLongPress=${cfg.rebootKeyLongPress}
|
||||||
|
HandleSuspendKey=${cfg.suspendKey}
|
||||||
|
HandleSuspendKeyLongPress=${cfg.suspendKeyLongPress}
|
||||||
|
HandleHibernateKey=${cfg.hibernateKey}
|
||||||
|
HandleHibernateKeyLongPress=${cfg.hibernateKeyLongPress}
|
||||||
HandleLidSwitch=${cfg.lidSwitch}
|
HandleLidSwitch=${cfg.lidSwitch}
|
||||||
HandleLidSwitchDocked=${cfg.lidSwitchDocked}
|
|
||||||
HandleLidSwitchExternalPower=${cfg.lidSwitchExternalPower}
|
HandleLidSwitchExternalPower=${cfg.lidSwitchExternalPower}
|
||||||
|
HandleLidSwitchDocked=${cfg.lidSwitchDocked}
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue