Page 1 of 1

How to Lock my laptop when I close the lid? (Solved)

Posted: Sun Sep 27, 2020 2:35 pm
by m1k3
What's the best way to go about getting my laptop to activate xlock when I close the lid and it suspends? I thought maybe adding xlock to /etc/acpi/actions/suspend.sh would do the trick but that didn't work for me.

Re: How to Lock my laptop when I close the lid?

Posted: Mon Sep 28, 2020 12:37 pm
by jamesbond
1. Make sure you have xlock configured properly. If not you will have to hard-reboot your machine.
2. Add this as the last line in /etc/acpi/action/suspend.sh

Code: Select all

export DISPLAY=:0
/usr/local/bin/xlock-gui -locknow

Re: How to Lock my laptop when I close the lid?

Posted: Mon Sep 28, 2020 1:02 pm
by user1111
Beat me to it James. I was just about to suggest trying /etc/acpi/action/suspend.sh editted to have ...

Code: Select all

#suspend
su - `whoami` -c '
export DISPLAY=:0
xlock &
'
echo mem > /sys/power/state

Re: How to Lock my laptop when I close the lid?

Posted: Mon Sep 28, 2020 2:34 pm
by m1k3
Thank you both! I ended up going with rufwoof's implementation because for some reason xlock-gui wouldn't use the "atunnels" visualization even though I configured it. I checked .xlock-gui in the root directory just to be sure. So, I'm using xlock -mode atunnels instead.

:thumbup: