Allow operation as systemd user unit [Clarification needed]
I'd like to run xss-lock as a systemd user unit. I added the following unit file:
# /home/foo.config/systemd/user/xss-lock-i3lock.service
[Unit]
Description=Run xss-lock with i3lock
[Service]
ExecStart=/usr/bin/xss-lock -- /usr/bin/i3lock
and everything seems to work, but I'm getting the following log output:
xss-lock[17367]: Error getting current session: GDBus.Error:org.freedesktop.login1.NoSessionForPID: PID 17367 does not belong to any known session
I tried to look at the source, but couldn't figure out what the impact of that error is.
Comments (8)
-
-
reporter I'm not very familiar with either session management or systemd, but it seems that this issue discussed that exact problem: https://github.com/systemd/systemd/issues/2356
-
xss-lock already does that. Unfortunately, that only works when running within a session and systemd services don't run within any session.
-
The C function would be
sd_uid_get_display
. -
I am coming way after the battle but my fork can take the session in argument. My graphical session id is exported in an environment variable on
systemd --user
then used byxss-lock.service
. -
Account Deleted I'm also running into this. Is this issue benign? Is there any workaround?
Thanks!
-
@joweill My fork can lock any x session. My systemd unit file looks like:
[Unit] Description=Auto lock PartOf=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/xss-lock -l -s ${XDG_SESSION_ID} -- ${HOME}/.i3/lock.sh [Install] WantedBy=graphical-session.target
I just need to export XDG_SESSION_ID (of my X session) to systemd user
-
Account Deleted Thanks @xdbob looks like your fork indeed addresses the issue. However, I'm currently the xss-lock pacman package and I prefer to keep using a package from the official repos rather than maintaining my own package. At least unless there is a very good reason to switch. If I understand correctly, in this case, the only issue is log spam , but the locker actually works. Did I understand correctly?
- Log in to comment
xss-lock uses its PID to figure out which session it belongs to. To run as a systemd unit, it would have to fallback on the user's
Display
property (found in/org/freedesktop/login1/user/self
) to find the default display.