How can I configure my laptop to suspend when I close the lid and an external monitor is attached?

I’m using GNOME 50 on Fedora 44. Whenever I close the laptop lid without an external monitor attached, the laptop suspends as expected. However, if an external monitor is attached, the laptop doesn’t suspend, and the external monitor remains active. Even though I understand this can be useful in some scenarios, that’s not my case, I would like the system to suspend regardless of having an external monitor attached.

I tried configuring systemd-login with

[Login]
# disables "clamshell mode" (keeping the display alive when the lid is closed)
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=suspend
LidSwitchIgnoreInhibited=yes

But it didn’t have any effect. Gemini is suggesting I configure a udev rule to trigger when the lid state changes, but I would expect GNOME would allow me to handle this in a more direct way.

Is there any hidden property I can use to achieve the intended behavior?

The reason your logind.conf changes don’t take effect is that GNOME installs a systemd inhibitor for suspend so it could have its own policy. There used to be a setting for enabling suspend on lid close when an external monitor is connected, either in gnome-tweaks, or in gnome-control-center, but I couldn’t find it in GNOME 50 after a brief search.

In dconf it was /org/gnome/settings-daemon/plugins/power/lid-close-suspend-with-external-monitor (a boolean, defaulting to false), and I still see it. I cannot say whether it is still used. The description in the schema at least doesn’t say that it’s deprecated or obsolete.

Thanks @mgedmin , indeed I forgot to mention I had checked and gsd-power appears explicitly as an inhibitor for handle-lid-switch:

❯ systemd-inhibit --list | rg lid
costa          1000 costa 4985 gsd-power      handle-lid-switch                                        External monitor attached or configuration changed recently block

However, /org/gnome/settings-daemon/plugins/power/lid-close-suspend-with-external-monitor doesn’t appear for me in dconf-editor :thinking:

❯ dconf dump /org/gnome/settings-daemon/plugins/power/
[/]
ambient-enabled=false
power-button-action='suspend'
sleep-inactive-ac-timeout=1200
sleep-inactive-ac-type='suspend'

I was hoping it would be easier to configure this behavior :downcast_face_with_sweat:

dconf-editor and dconf dumpare different. Essentially, dconf dump shows only those settings that you (or some program on your machine) has changed from the default value. dconf-editor (as well as gsettings) also show their default values loaded from gsettings schema files.

Thanks @mgedmin I wasn’t fully aware of how these tools work. Still, dconf-editor doesn’t show the key you mentioned (should it?):