Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lidmode

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.

How it works

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.

Requirements

  • 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.
  • sudo access for the one-time setup only.

Install

git clone https://github.com/anycodef/lidmode.git
cd lidmode
make install           # copies lidmode to ~/.local/bin
lidmode setup          # one time, asks for sudo

Make sure ~/.local/bin is on your PATH. To install system-wide: sudo make install PREFIX=/usr/local.

Usage

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.

Verify it works (without walking away)

  1. lidmode stay
  2. In a terminal, start a ticking clock: while true; do date +%T; sleep 1; done
  3. Close the lid for ~15 seconds, then open it.
  4. 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-pager

Uninstall

make uninstall
sudo rm /etc/systemd/logind.conf.d/lidmode.conf
sudo systemctl reload systemd-logind

Notes & caveats

  • 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).

License

MIT — see LICENSE.

About

Toggle what happens when your Linux laptop lid closes: suspend, or keep running with the screen off (WiFi and processes stay alive).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages