- Create a file
sudo vim /etc/systemd/logind.conf.d/00-laptop.conf
- Append this content in it
[Login] HandleLidSwitch=ignore HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore
- Restart the service:
sudo systemctl restart systemd-logind
Or run these commands directly:
#!/usr/bin/env bash
mkdir -p /etc/systemd/logind.conf.d
cat <<< "[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
" > /etc/systemd/logind.conf.d/00-laptop.conf
systemctl restart systemd-logind.service