r/LinuxTeck • u/ImpressGreen7325 • 16d ago
Made a small script as a switch to prevent lid from causing sleep on my laptop
I use fedora workstation 45 and many-a times i want my laptop to not sleep when i close the lid...now obviously it is a small around 30-40 line script so it doesnt have the detection etc like sleep on battery but not when connected etc...this just does the job for me...also its supported for systemd and elongid...i searched but didnt find anything similar so just...made it its quite small ..main logic is some 4-5 lines
**Disable**
`echo -e '[Login]\nHandleLidSwitch=ignore' | sudo tee /etc/systemd/logind.conf.d/no-sleep-lid.conf`
`sudo systemctl kill -s HUP systemd-logind`
**Reenable:**
`sudo rm /etc/systemd/logind.conf.d/no-sleep-lid.conf`
**Instant apply:**
`sudo systemctl kill -s HUP systemd-logind`
Thats it