Systemd/logind: Difference between revisions

From NixOS Wiki
Klinger (talk | contribs)
Unabomberlive (talk | contribs)
Make page translatable
Line 1: Line 1:
{{Systemd/breadcrumb}}
{{Systemd/breadcrumb}}
<translate>
<code>logind</code> is systemd’s login manager.
<code>logind</code> is systemd’s login manager.
 
</translate>
<translate>
Its main manual page is <code>systemd-logind.service(8)</code>. Its configuration options are described in <code>logind.conf(5)</code>.
Its main manual page is <code>systemd-logind.service(8)</code>. Its configuration options are described in <code>logind.conf(5)</code>.
 
</translate>
 
<translate>
== Handling of power keys ==
== Handling of power keys ==
 
</translate>
<translate>
<code>logind</code> handles power and standby hardware switches. The Arch wiki has a [https://wiki.archlinux.org/index.php/Power_management#ACPI_events good overview of which ACPI events are handled].
<code>logind</code> handles power and standby hardware switches. The Arch wiki has a [https://wiki.archlinux.org/index.php/Power_management#ACPI_events good overview of which ACPI events are handled].
 
</translate>
<translate>
=== Don’t shutdown on power button press ===
=== Don’t shutdown on power button press ===
 
</translate>
<translate>
When you use a laptop, often you don’t want an accidental short press of the power button to shut down your system. You can add the following snippet to your <code>logind</code> config:
When you use a laptop, often you don’t want an accidental short press of the power button to shut down your system. You can add the following snippet to your <code>logind</code> config:
 
</translate>
  <nowiki>services.logind.extraConfig = ''
<translate>
<syntaxhighlight lang="nix">
services.logind.extraConfig = ''
     # don’t shutdown when power button is short-pressed
     # don’t shutdown when power button is short-pressed
     HandlePowerKey=ignore
     HandlePowerKey=ignore
   '';</nowiki>
   '';
 
</syntaxhighlight>
</translate>
<translate>
Long-pressing your power button (5 seconds or longer) to do a hard reset is handled by your machine’s BIOS/EFI and thus still possible.
Long-pressing your power button (5 seconds or longer) to do a hard reset is handled by your machine’s BIOS/EFI and thus still possible.
 
</translate>
<translate>
=== Ignore hardware keys when using <code>systemd-inhibit</code> ===
=== Ignore hardware keys when using <code>systemd-inhibit</code> ===
 
</translate>
<translate>
<code>systemd-inhibit</code> allows you to put a lock on e.g. shutdown or sleep that is in place as long the given process is running. By default, the hardware key actions configured in <code>logind</code> override such inhibits.
<code>systemd-inhibit</code> allows you to put a lock on e.g. shutdown or sleep that is in place as long the given process is running. By default, the hardware key actions configured in <code>logind</code> override such inhibits.
 
</translate>
<translate>
Say you want your laptop to stay awake when closing the lid in some circumstances, for example if you want to listen to music. If you start your lock screen with an inhibit on the lid switch
Say you want your laptop to stay awake when closing the lid in some circumstances, for example if you want to listen to music. If you start your lock screen with an inhibit on the lid switch
 
</translate>
  systemd-inhibit --what=handle-lid-switch lock-screen-tool
<code>
 
systemd-inhibit --what=handle-lid-switch lock-screen-tool
</code>
<translate>
<code>logind</code> logind still overrides that user decision. For it to work, you need to tell logind to ignore the lid switch in your system config:
<code>logind</code> logind still overrides that user decision. For it to work, you need to tell logind to ignore the lid switch in your system config:
 
</translate>
  <nowiki>services.logind.extraConfig = ''
<translate>
    # want to be able to listen to music while laptop closed
<syntaxhighlight lang="nix">
    LidSwitchIgnoreInhibited=no
services.logind.extraConfig = ''
  '';</nowiki>
  # want to be able to listen to music while laptop closed
 
  LidSwitchIgnoreInhibited=no
'';
</syntaxhighlight>
</translate>
[[Category:Applications]]
[[Category:Applications]]
[[Category:systemd]]
[[Category:systemd]]

Revision as of 10:35, 6 August 2024

logind is systemd’s login manager. Its main manual page is systemd-logind.service(8). Its configuration options are described in logind.conf(5).

Handling of power keys

logind handles power and standby hardware switches. The Arch wiki has a good overview of which ACPI events are handled.

Don’t shutdown on power button press

When you use a laptop, often you don’t want an accidental short press of the power button to shut down your system. You can add the following snippet to your logind config:

services.logind.extraConfig = ''
    # don’t shutdown when power button is short-pressed
    HandlePowerKey=ignore
  '';

Long-pressing your power button (5 seconds or longer) to do a hard reset is handled by your machine’s BIOS/EFI and thus still possible.

Ignore hardware keys when using systemd-inhibit

systemd-inhibit allows you to put a lock on e.g. shutdown or sleep that is in place as long the given process is running. By default, the hardware key actions configured in logind override such inhibits. Say you want your laptop to stay awake when closing the lid in some circumstances, for example if you want to listen to music. If you start your lock screen with an inhibit on the lid switch systemd-inhibit --what=handle-lid-switch lock-screen-tool logind logind still overrides that user decision. For it to work, you need to tell logind to ignore the lid switch in your system config:

services.logind.extraConfig = ''
  # want to be able to listen to music while laptop closed
  LidSwitchIgnoreInhibited=no
'';