Systemd unit for locking on sleep

Issue #18 new
Vladimir-csp created an issue

Hi. I would like to share something I use myself:

it is possible to utilize loginctl to issue generic session lock event.

The following systemd unit may take care of that:

[Unit]
Description=Lock sessions before sleep
Before=sleep.target

[Service]
Type=oneshot
ExecStart=-/bin/loginctl lock-sessions
ExecStartPost=/bin/sleep 1

[Install]
WantedBy=sleep.target

Also, a sample XDG autostart entry to utilize this unit on the user session's side (i3lock variant):

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=xss-lock
GenericName=Screen lock daemon
GenericName[ru]=Демон блокировки экрана
Comment=Provides screen locking
Comment[ru]=Предоставляет блокировку экрана
Exec=xss-lock -- i3lock -n

An offtopic side note, there is a new tool for brightness control that works better than xbacklight when it comes to newer video drivers: https://github.com/Hummer12007/brightnessctl It is already in Debian.

Comments (0)

  1. Log in to comment