Skip to content

Commit 3ad23d4

Browse files
Update Automatic Screen Lock (#476)
Co-authored-by: Heki <heki@heki.me>
1 parent a248c39 commit 3ad23d4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

source/components/nitrokeys/features/misc/automatic-screen-lock.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Automatic Screen Lock at Removal
22
================================
33

4-
.. product-table:: all
4+
.. product-table:: nk3 hsm pro storage
55

66
.. contents:: :local:
77

@@ -15,8 +15,6 @@ Requirements
1515
- Ubuntu 20.04 or Debian 10 (Buster), both with `Gnome Display
1616
Manager <https://wiki.gnome.org/Projects/GDM>`__ installed.
1717

18-
- Nitrokey Pro 2, Nitrokey Storage 2, or Nitrokey HSM 2
19-
2018
Configuration
2119
~~~~~~~~~~~~~
2220

@@ -33,14 +31,15 @@ Add the following line to the file
3331

3432
.. code-block:: bash
3533
36-
ACTION=="remove", ENV{PRODUCT}=="20a0/4108/101" RUN+="/usr/local/bin/gnome-screensaver-lock"
34+
ACTION=="remove", ENV{PRODUCT}=="20a0/4108/101" RUN+="/bin/bash -c '/usr/local/bin/gnome-screensaver-lock'"
3735
3836
Save the file and quit the editor.
3937

4038
This file sets up a new hardware rule that executes the ``gnome-screensaver-lock`` at removal of the Nitrokey device.
4139

4240
You should change the configuration according to the device you are using as following:
4341

42+
- Nitrokey 3: ``ENV{PRODUCT}=="20a0/42b2/107"``
4443
- Nitrokey Pro: ``ENV{PRODUCT}=="20a0/4108/101"``
4544
- Nitrokey HSM: ``ENV{PRODUCT}=="20a0/4230/101"``
4645
- Nitrokey Storage: ``ENV{PRODUCT}=="20a0/4109/101"``
@@ -64,10 +63,10 @@ Add the following text
6463

6564
.. code-block:: bash
6665
67-
user=`ps axo user:30,comm | egrep "gdm-(wayland|x)" | awk '{print $1}'`
66+
user=`ps axo user:30,comm | grep -E "gdm-(wayland|x)" | awk '{print $1}'`
6867
6968
if [ -n $user ]; then
70-
su $user -c "/usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock"
69+
su $user -c "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock"
7170
fi
7271
7372
In the first step, this script looks for the user-name of the gnome session, i.e. ``user``.

0 commit comments

Comments
 (0)