Dell Laptop Won't Suspend When Lid Closed (Ubuntu 20.04.1 LTS)

Since I had the same problem, I thought I might post my solution to it:

Change the content of logind.conf with:

sudo nano /etc/systemd/logind.conf

Specifically, uncomment the following lines and change their values, if needed, to be as follows:

HandleSuspendKey=suspend
HandleHibernateKey=hibernate
HandleLidSwitch=suspend
HandleLidSwitchDocked=suspend

Then restart the service with:

systemctl restart systemd-logind.service

and it should work.

In my case it takes up to 15 seconds until my laptop goes into sleep and doesn`t work with any other configuration.