You are not logged in.
Pages: 1
Hi,
I would like to lock the screen when I close the lid of my laptop (on Gnome).
What I did is as follows.
In '/etc/systemd/logind.conf' I set:
HandleLidSwitch=lock
I installed 'slock', the locker itself.
I installed 'xss-lock', which to my understanding listens to the 'lock' event.
Following this thread, I issued
$ xss-lock slock
to inform xss-lock which locker I would like to use. At this step I get the error:
** (xss-lock:4385): WARNING **: 22:57:23.238: Error getting current session: GDBus.Error:org.freedesktop.login1.NoSessionForPID: PID 4385 does not belong to any known session
and the screen does not lock upon closing the lid.
In addition I tried:
In '/etc/systemd/logind.conf' if I set:
HandleLidSwitch=poweroff
it works like a charm; it powers off the laptop...
'slock' itself also works nicely.
Google-ing the error; I did not find anything relevant.
Any ideas how to handle the error? Thanks.
Last edited by zoltansz (2018-08-31 23:07:14)
Offline
Note: before the 'xss-lock' adventure I tried systemd-lock-handler. Here, after installing python-txdbus and systemd-lock-handler I followed the recipe at the url.
I edited '/etc/systemd/logind.conf' and set
HandleLidSwitch=lock
followed by
$ systemctl --user enable --now systemd-lock-handler.service
=>
Created symlink /home/zoltan/.config/systemd/user/default.target.wants/systemd-lock-handler.service → /usr/lib/systemd/user/systemd-lock-handler.service.
Since the screen lock still did not take effect upon lid close I went for
$ cat /usr/lib/systemd/user/systemd-lock-handler.service
which produces
[Unit]
Description=Logind lock event to systemd target translation
Documentation=https://github.com/hobarrera/systemd-lock-handler
[Service]
ExecStart=/usr/bin/systemd-lock-handler
[Install]
WantedBy=default.target
Thus, I issued
$ /usr/bin/systemd-lock-handler
which gives
Traceback (most recent call last):
File "/usr/bin/systemd-lock-handler", line 5, in <module>
from twisted.internet import defer, reactor
ModuleNotFoundError: No module named 'twisted'
but 'python-txdbus' installed 'python-twisted'.
Last edited by zoltansz (2018-08-30 23:21:11)
Offline
I supose that you want to suspend or hibernate when you close the lid, in this case yo should type
"HandleLidSwitch=suspend" or "HandleLidSwitch=hibernate"
and clean any other change that you made.
If you only want to lock the screen and let the computer on, maybe there is a key like XF86LidSwitch key (in xorg) that lets you made a shortcut with xbindkeys and xdotool.
Last edited by tejonaco (2018-08-31 21:22:56)
Offline
Thanks for the quick feedback. I am interested in locking only by lid closing (no suspend, ...).
Last edited by zoltansz (2018-08-31 21:34:38)
Offline
In arch wiki lock appears like a valid option in logind.conf, maybe you have to install gnome-screensaver.
Offline
I managed to find a solution via acpid and this thread. Summary:
Install slock, the (picked) screen locker.
Set in '/etc/systemd/logind.conf':
HandleLidSwitch=ignore
Install acpid, who will handle the 'lid close' event.
Enable and start 'acpid' immediately:
# systemctl enable --now acpid
Set the action in '/etc/acpi/handler.sh' (thread: $1=button/lid, $3=close) to
DISPLAY=:0 su -c - zoltan /usr/bin/slock
Last edited by zoltansz (2018-08-31 23:14:59)
Offline
Pages: 1