I have recently moved to using systemd
to manage power control.
In order to get my screen to be locked when returning from suspend, I created /etc/systemd/system/i3lock.service
with these contents
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=fommil
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000
[Install]
WantedBy=sleep.target
and then ran systemctl enable i3lock.service
.
But this means the lock is always for the fommil
user.
How does one set up a service that will run the screen locker as the user who currently owns the X session?
DISPLAY
environment variable is another one.