To change what closing the lid of your Laptop does in Ubuntu 20.04 LTS:
sudo nano /etc/systemd/logind.conf
Change “HandleLidSwitch=” to one of the following options:
- ignore: Do nothing
- poweroff: Poweroff the computer
- reboot: Reboot the computer
- halt: Halt the computer (shut down, but keep power on)
- kexec: directly boot into a new kernel
- suspend: Suspend the computer
- hibernate: Hibernate the computer
- hybrid-sleep: Put the computer into hybrid-sleep
- suspend-then-hibernate: Suspend the computer, and then hibernate
- lock: all running sessions will be screen-locked
Note: If you just want to blank your screen, “lock” is the option you are looking for. (You’ll still have to unlock your screen.)
When you’re done,
sudo systemctl restart systemd-logind.service
Note that the above line may kill your current GUI session. Try Ctrl+Alt+F3 to get back to your desktop.