I trying out fedora 40, it’s awesome so far.
I usually close my laptop’s lid and let Youtube video or podcast play in the background.
I can’t do that anymore, when the lid is closed the laptop goes to suspended state.
I can’t prevent that anymore, I used to uncomment directives in /etc/systemd/logind.conf
That config file doesn’t even exist in F40 so I had to make it and add the following:
Like it is mentioned here That solution doesn’t work anymore.
I tried out sudo systemctl mask suspend.target it works, but it’s not ideal, I want to be able to put my laptop to suspend state when It need to be. Not disable that option completely.
There also another option which works temporarily: systemd-inhibit --what=handle-lid-switch zenity --info --text='Lid switch suspend blocked while open' --ok-label=Close
This is not ideal as well. I have to use the terminal each time I want to prevent laptop doing to suspended state when I close the lid.
Also, I couldn’t find the gsettings in F40 that control the lid action mentioned here
Is there simple user friendly solution in fedora 40 to prevent the laptop doing to suspended state when the lid is closed?
I believe that config file was moved to /usr/lib/systemd/logind.conf.
I don’t have a laptop to test currently, but you should be able to do this by changing the #HandleLidSwitch=suspend line in that file to HandleLidSwitch=ignore.
Thank you very much for your speedy reply!
I found that config file in the location you mentioned, did the modification, reboot but didn’t seem to work.
What worked is that I copied that file logind.conf into a folder I created in/etc/systemd/logind.conf.d/ This procedure is mentioned in config file itself.
I find it a bit complicated for a simple functionality. I Hope there would be a simple gui to do this!
This kinda of tinkering is what put some people off Linux adoption.
i have done everything written here but my laptop still just goes on suspend when the lid is closed. help.
fedora workstation 40
edit: false alarm. it works fine if you also remove the hashes.
I don’t know the source of this, but thank you for sharing. This is very useful and I have created this script:
#!/bin/sh
WHAT=handle-lid-switch
PID=$(systemd-inhibit --list | grep $WHAT | sed "s/.*$USER//" | cut -d ' ' -f 2)
if [ -z $PID ]; then
systemd-inhibit --what=$WHAT zenity --info --text='Lid suspend blocked while open' --ok-label=Close &
echo Started suspend prevention process $!
else
echo Killing suspend prevention process $PID
kill $PID
fi
I have assigned a custom keyboard shortcut to run this with Ctrl-Atl-S so I am able to simply press that key-combination and then close the lid without the laptop suspending:
When I re-open the lid and login (laptop would be locked), I immediately just press the key-combo again to turn off the “prevent suspend” behaviour (or simply press the OK button on the zenity dialog).
I actually think this would be a nice feature for the Caffeine extension so I have suggested this in in the open feature request issue. I would then simply use Caffeine to do this… (it already has a keyboard shortcut assignment configuration option).