Skip to content

Instantly share code, notes, and snippets.

@PeronGH
Created February 25, 2026 03:11
Show Gist options
  • Select an option

  • Save PeronGH/0a46d3f93accd7cd2f24c61a0a4aa460 to your computer and use it in GitHub Desktop.

Select an option

Save PeronGH/0a46d3f93accd7cd2f24c61a0a4aa460 to your computer and use it in GitHub Desktop.
Prevent Sleep on Lid Close — Fedora (GNOME/GDM)

Prevent Sleep on Lid Close — Fedora (GNOME/GDM)

Tested on Fedora 43 with GNOME Shell 49.4. Two layers need to be configured: systemd-logind (the system) and GDM's gsd-power (the greeter), because GDM runs its own GNOME settings daemon that suspends independently.

1. Tell systemd-logind to ignore the lid switch

sudo mkdir -p /etc/systemd/logind.conf.d

sudo tee /etc/systemd/logind.conf.d/lid.conf << 'EOF'
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
EOF

2. Stop GDM from suspending on idle

GDM's gsd-power will suspend the system when the greeter session goes idle — which happens immediately when the lid closes. This requires three files:

sudo mkdir -p /etc/dconf/db/gdm.d/locks

# Profile — tells GDM to read the system dconf database
sudo tee /etc/dconf/profile/gdm << 'EOF'
user-db:user
system-db:gdm
file-db:/usr/share/gdm/greeter-dconf-defaults
EOF

# Setting — disable idle suspend on AC and battery
sudo tee /etc/dconf/db/gdm.d/00-power.conf << 'EOF'
[org/gnome/settings-daemon/plugins/power]
sleep-inactive-ac-type='nothing'
sleep-inactive-battery-type='nothing'
EOF

# Lock — prevent the user-db layer from overriding
sudo tee /etc/dconf/db/gdm.d/locks/power << 'EOF'
/org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type
/org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-type
EOF

sudo dconf update

3. Reboot

sudo reboot

Verification

# logind should say "ignore"
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
  org.freedesktop.login1.Manager HandleLidSwitch

# GDM should say "nothing" — DCONF_PROFILE=gdm is required
sudo -u gdm DCONF_PROFILE=gdm dbus-run-session \
  gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 2>/dev/null

Why both layers?

Layer What it does Without it
logind drop-in Tells the system to ignore lid events System suspends via systemd
GDM dconf override Disables GDM greeter's idle suspend GDM's gsd-power suspends when greeter goes idle after lid close

Files created

/etc/systemd/logind.conf.d/lid.conf
/etc/dconf/profile/gdm
/etc/dconf/db/gdm.d/00-power.conf
/etc/dconf/db/gdm.d/locks/power

All under /etc/, all survive dnf upgrade.

Undo

sudo rm /etc/systemd/logind.conf.d/lid.conf
sudo rm /etc/dconf/profile/gdm
sudo rm /etc/dconf/db/gdm.d/00-power.conf
sudo rm /etc/dconf/db/gdm.d/locks/power
sudo rmdir /etc/dconf/db/gdm.d/locks /etc/dconf/db/gdm.d 2>/dev/null
sudo dconf update
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment