Here's what I did:
I created a file /etc/acpi/events/lm_lid and wrote into it:


I created a file /etc/acpi/lid.sh and wrote into it:

gnome-screensaver-command --lock

The good news are that this script is being executed when I close the lid. The bad news are that it doesn't lock the system. Any other command I put in the script is executed when I close the lid except the lock itself. When I run the script manually from command line the system locks.

What did I miss?

  • 1
    I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you. – Henrik Dec 24 '18 at 12:38
  • @JothamB Have you solved the problem? – Dhruva May 12 at 5:55
  • I moved from Ubuntu 18.04 to Mint. Solved this problem and more. Much better distro. – JothamB May 13 at 10:09

I'm using Debian and faced similar problem, first, i wont recommend script because it doesn't work in lock screen.

if you are using gnome install gnome-tweaks and it has a option.

alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.

this worked for me.

  • Thanks. I can suspend the system but I want to lock it. – JothamB Dec 24 '18 at 16:28
  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off. – Kushagra Karira Dec 25 '18 at 17:23

Try downloading gnome-tweaks and there should be an option about locking when closing the lid.

To download gnome -tweaks do: sudo apt install gnome-tweaks-tool

You can also use this for tweaking things like right clicking and left clicking.

  • It only has an option to suspend. I want to lock without suspending. – JothamB Dec 27 '18 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.