Omarchy

How-To: See and Change What Your Linux Laptop Does When You Close the Lid

Leave a comment

The next Omarchy fixes the lid-open wake-up for plugged-in laptops, which got me checking what my own lid settings actually are. On any systemd distro, logind decides what happens when you close the lid, and it uses different settings for battery, AC power and docked. Steps 1-3 are read-only.

1. What logind will do right now

for p in HandleLidSwitch HandleLidSwitchExternalPower HandleLidSwitchDocked; do
  printf '%s: ' "$p"
  busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
    org.freedesktop.login1.Manager "$p"
done

Common values are suspend, lock, ignore and hibernate. Omarchy sets ExternalPower to ignore and locks the session itself.

2. Where those settings come from

systemd-analyze cat-config systemd/logind.conf | grep -iE '^\s*#?\s*HandleLid|^# /'

That shows the main file plus every drop-in, in the order they apply, so you can see which file wins.

3. Watch lid events happen

busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager LidClosed
journalctl -b -u systemd-logind | grep -i lid | tail -n 10

4. Change it with a drop-in

Don’t edit the main file. Add your own drop-in instead:

sudo mkdir -p /etc/systemd/logind.conf.d
sudo tee /etc/systemd/logind.conf.d/50-lid.conf >/dev/null <<'EOF'
[Login]
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=lock
HandleLidSwitchDocked=ignore
EOF

Reboot to apply it. Restarting systemd-logind in a live session can log you out. Then run step 1 again to confirm. If your distro or Omarchy already ships a lid drop-in, give yours a higher number so it’s read last, and remember your desktop may add its own lock-on-lid behavior on top of this.

God Bless, and May the Source Be with You!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.