How to stop Arch Linux laptop using systemd from sleeping when lid closed

Jeff Wintersinger
by Jeff Wintersinger
July 06, 2013

My primary work system is a laptop running Arch Linux, which I use in conjunction with an external monitor, keyboard, and mouse. I often find myself wanting to close the system lid while working, thereby protecting the screen from airborne objects and freeing desk space by allowing me to place items on top of the laptop. In the default Arch systemd configuration, the system will enter sleep mode when the lid is closed and awaken when it is opened. To prevent this, simply run the following command:

systemd-inhibit --what=handle-lid-switch sleep 2592000

This will instruct systemd to ignore lid close or open events, so long as the command remains running. Note that it can be run as an unprivileged (non-root) user. The sleep 2592000 command can be any long-running command; in this case, I simply run sleep for one month (i.e., 2592000 seconds). If you kill the sleep process (e.g., via CTRL+C) while the laptop lid is closed, the system will immediately enter sleep mode.

Post navigation