Decide what happens when your Linux laptop lid closes — suspend (the default) or keep running with the screen off. In "stay" mode your processes, WiFi, and any long-running job (a build, a download, an SSH session, an AI coding agent, ...) keep going while you carry the laptop around; only the display turns off.
It's a small, dependency-light toggle around systemd-logind. No daemon, no config
editing by hand.
Closing the lid is handled by systemd-logind. By default it suspends the machine
(suspend-to-RAM / S3), which freezes every process.
lidmode flips behavior at runtime by holding a handle-lid-switch inhibitor
(block mode) inside a per-user transient systemd unit:
- Stay mode → the inhibitor is held → logind does not suspend on lid close.
- Normal mode → the inhibitor is released → the lid suspends as usual.
Because it's just a held lock, Stay mode reverts to Normal on reboot — you can't accidentally leave your laptop permanently non-suspending.
A one-time lidmode setup writes a drop-in with LidSwitchIgnoreInhibited=no so that
logind actually honors the inhibitor (the systemd default is to ignore it for the lid).
The screen turning off on lid close is done by your compositor/desktop (sway/wlroots, GNOME, KDE, ...), not by lidmode. Most do this automatically.
- A
systemd-based Linux distribution (systemd-logind,systemd-inhibit,systemd-run) — Arch, Fedora, Debian/Ubuntu, openSUSE, etc. whiptail(optional) for the interactive panel. Without it, the CLI still works.sudoaccess for the one-time setup only.
git clone https://github.com/anycodef/lidmode.git
cd lidmode
make install # copies lidmode to ~/.local/bin
lidmode setup # one time, asks for sudoMake sure ~/.local/bin is on your PATH. To install system-wide:
sudo make install PREFIX=/usr/local.
lidmode # open the interactive panel
lidmode stay # Stay mode (lid closed = screen off only, machine runs)
lidmode normal # Normal mode (lid closed = suspend)
lidmode toggle # switch between the two
lidmode status # show the current mode
lidmode setup # one-time configuration (needs sudo)Typical flow: before walking away with work running, lidmode stay (or open the
panel), close the lid, and go. Back at your desk, lidmode normal — or just reboot.
lidmode stay- In a terminal, start a ticking clock:
while true; do date +%T; sleep 1; done - Close the lid for ~15 seconds, then open it.
- If the clock kept advancing with no gap, it did not suspend. A large jump in time means it suspended.
You can also check the journal for suspend events after closing the lid:
journalctl -b -g "Suspending|PM: suspend" --no-pagermake uninstall
sudo rm /etc/systemd/logind.conf.d/lidmode.conf
sudo systemctl reload systemd-logind- Heat: keeping heavy CPU/GPU work running with the lid closed (especially in a bag) restricts airflow. Fine for light workloads; be mindful for sustained load.
- Battery: in Stay mode the machine runs normally, so it draws normal power.
- Stay mode does not persist across reboots by design (fail-safe).
MIT — see LICENSE.