Allow operation as systemd user unit [Clarification needed]

Issue #13 new
Simon Kohlmeyer created an issue

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)

  1. Steven Allen

    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.

  2. Steven Allen

    xss-lock already does that. Unfortunately, that only works when running within a session and systemd services don't run within any session.

  3. Antoine Damhet

    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 by xss-lock.service.

  4. Former user Account Deleted

    I'm also running into this. Is this issue benign? Is there any workaround?

    Thanks!

  5. Antoine Damhet

    @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

  6. Former 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?

  7. Log in to comment