Assume that I am compiling some big project and want to put my laptop on my bag without stopping the compilation process. Closing the lid put my computer in hibernation. What are the options to stop one time (or some amount of time) the suspension ?

I would like something that does not involve restarting systemd-logind.service.

1 Answer 1


Prefix the command you want to run with systemd-inhibit to inhibit various possible actions whilst the command runs. See inhibit. The default actions are idle, sleep, and shutdown. You may want to add handle-lid-switch, i.e.

systemd-inhibit --what handle-lid-switch:idle:sleep:shutdown cmd args

You may need to be privileged.

  1. sleep inhibits system suspend and hibernation requested by (unprivileged) users
  2. shutdown inhibits high-level system power-off and reboot requested by (unprivileged) users
  3. idle inhibits that the system goes into idle mode, possibly resulting in automatic system suspend or shutdown depending on configuration
  4. handle-power-key inhibits the low-level (i.e. logind-internal) handling of the system power hardware key, allowing (possibly unprivileged) external code to handle the event instead
  5. handle-suspend-key inhibits the low-level handling of the system hardware suspend key
  6. handle-hibernate-key inhibits the low-level handling of the system hardware hibernate key
  7. handle-lid-switch inhibits the low-level handling of the systemd hardware lid switch

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .