Difference between revisions of "Slock"

From ArchWiki
Jump to navigation Jump to search
(→‎Lock on suspend: make it an instantiated unit)
Line 36: Line 36:
 
WantedBy=sleep.target}}
 
WantedBy=sleep.target}}
  
[Enable]] the {{ic|slock@''user''.service}} systemd unit for it to take effect for the username ''user''.
+
[[Enable]] the {{ic|slock@''user''.service}} systemd unit for it to take effect for the username ''user''.
  
 
=== Block VT switching and prevent killing X ===
 
=== Block VT switching and prevent killing X ===

Revision as of 13:47, 6 April 2017

Slock is the "Simple X display locker" [1].

Installation

Install the slock or slock-gitAUR package.

Configuration

Configuration is done by editing the config.h header file and then recompiling the package. After configuration you should create a package.

Usage

Simply run slock to lock the screen. You can also provide an argument to be run after the screen has been locked:

$ slock cmd [arg ...]

Tips and tricks

Lock on suspend

Create the following service which turns off the monitor and locks the screen.

/etc/systemd/system/slock@.service
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target

[Service]
User=%i
Environment=DISPLAY=:0
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock

[Install]
WantedBy=sleep.target

Enable the slock@user.service systemd unit for it to take effect for the username user.

Block VT switching and prevent killing X

slock recommends blocking VT switching so that the screen lock cannot be bypassed. For the same reason, slock recommends preventing users from killing the X server. See Xorg#Block TTY access and Xorg#Prevent a user from killing X.

See also