Step 1: Edit logind.conf
Open a terminal.
Edit the logind configuration file with a text editor, e.g.:
bash
Copy
Edit
sudo nano /etc/systemd/logind.conf
Find (or add) the following lines, and set them like this:
ini
Copy
Edit
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
HandleLidSwitchExternalPower=ignore
This tells systemd-logind not to suspend or power down the system when the lid is closed, including when docked or on external power.
Save and exit the file (in nano, press Ctrl+O, then Enter, then Ctrl+X).
Step 2: Restart systemd-logind
Apply the changes without rebooting:
bash
Copy
Edit
sudo systemctl restart systemd-logind
⚠️ This might log you out or restart your session. Save your work beforehand.