2

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

event=button/lid.* action=/etc/acpi/lid.sh 

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

#!/bin/sh 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?

3
  • 2
    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. Commented Dec 24, 2018 at 12:38
  • @JothamB Have you solved the problem? Commented May 12, 2019 at 5:55
  • I moved from Ubuntu 18.04 to Mint. Solved this problem and more. Much better distro. Commented May 13, 2019 at 10:09

2 Answers 2

1

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.

2
  • Thanks. I can suspend the system but I want to lock it. Commented Dec 24, 2018 at 16:28
  • 1
    @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. Commented Dec 25, 2018 at 17:23
0

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.

1
  • 1
    It only has an option to suspend. I want to lock without suspending. Commented Dec 27, 2018 at 11:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.