Skip to content

Instantly share code, notes, and snippets.

@gbishop
Last active June 6, 2026 12:24
Show Gist options
  • Select an option

  • Save gbishop/cddcab347859c4ad90e604fc60c6338a to your computer and use it in GitHub Desktop.

Select an option

Save gbishop/cddcab347859c4ad90e604fc60c6338a to your computer and use it in GitHub Desktop.
Make Gnome suspend when docked and the lid is closed

I have a cheap USB-C dock that I use to both charge my Carbon X1 and connect it to an external monitor. When I close the laptop lid, I want it to suspend. The developers of Gnome disagree. I tried several hacks before finding this one using ACPI.

This hack grabs the lid switch event before Gnome can get to it.

Put force_lid_suspend in /etc/acpi/events/ and force_lid_suspend.sh in /etc/acpi/

sudo chmod +x /etc/acpi/force_lid_suspend.sh
sudo systemctl enable acpid
sudo systemctl restart acpid
event=button/lid.*
action=/etc/acpi/force_lid_suspend.sh
#!/bin/sh
# Check the system file where the kernel logs the physical lid state
grep -q closed /proc/acpi/button/lid/*/state
# If the text "closed" is found, immediately force a system-level suspend
if [ $? -eq 0 ]; then
systemctl suspend
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment