the-cavalry / light-locker

A simple session-locker for lightdm
GNU General Public License v2.0
224 stars 22 forks source link

Allow starting from the user systemd #145

Open muff1nman opened 5 years ago

muff1nman commented 5 years ago

Given light-locker is setup as a user-based systemd unit:

[Unit]
Description=Light Locker Daemon
PartOf=graphical-session.target

[Service]
ExecStart=/usr/bin/bash -c 'echo XDG_SESSION_PATH: $XDG_SESSION_PATH && /usr/bin/light-locker --debug --late-locking'
Restart=always

[Install]
WantedBy=xmonad.target

I'd like light locker to start correctly. However, the process dumps with:

bash[2573]:  PID 2573 does not belong to any known session
light-locker[2573]: session_id is not set, is /proc mounted with hidepid>0?

I think this is because a process started from the user systemd instance does not have a session id associated. This can be seen with another process (compton) that is correctly working from the user systemd instance:

  CGroup: /
           ├─user.slice
           │ └─user-1001.slice
           │   ├─session-2.scope
           │   │ ├─2221 gpg-agent --homedir /home/ademaria/.gnupg --use-standard-socket --daemon
           │   │ └─3122 scdaemon --multi-server
           │   ├─user@1001.service
           │   │ ├─dbus\x2d:1.2\x2dca.desrt.dconf.slice
           │   │ │ └─dbus-:1.2-ca.desrt.dconf@0.service
           │   │ │   └─1813 /usr/libexec/dconf-service
           │   │ ├─dbus-broker.service
           │   │ │ ├─1746 /usr/bin/dbus-broker-launch --scope user
           │   │ │ └─1749 dbus-broker --log 4 --controller 11 --machine-id 39accfde5dfd474a9933d254be437571 --max-bytes 100000000000000 --max-fds 250000000000>
           │   │ ├─dbus\x2d:1.11\x2dorg.a11y.atspi.Registry.slice
           │   │ │ └─dbus-:1.11-org.a11y.atspi.Registry@1.service
           │   │ │   └─5677 /usr/libexec/at-spi2-registryd --use-gnome-session
           │   │ ├─dbus\x2d:1.2\x2dorg.gnome.GConf.slice
           │   │ │ └─dbus-:1.2-org.gnome.GConf@0.service
           │   │ │   └─1803 /usr/libexec/gconfd-2
           │   │ ├─gvfs-daemon.service
           │   │ │ ├─2154 /usr/libexec/gvfsd
           │   │ │ └─2159 /usr/libexec/gvfsd-fuse /run/user/1001/gvfs -f -o big_writes
           │   │ ├─init.scope
           │   │ │ ├─1723 /usr/lib/systemd/systemd --user
           │   │ │ └─1725 (sd-pam)
           │   │ ├─at-spi-dbus-bus.service
           │   │ │ ├─1814 /usr/libexec/at-spi-bus-launcher
           │   │ │ ├─1821 /usr/bin/dbus-broker-launch --config-file=/usr/share/defaults/at-spi2/accessibility.conf --scope user
           │   │ │ └─1822 dbus-broker --log 4 --controller 9 --machine-id 39accfde5dfd474a9933d254be437571 --max-bytes 100000000000000 --max-fds 6400000 --max>
           │   │ └─compton.service
           │   │   └─8244 /usr/bin/compton --backend glx --vsync opengl-swc -C -f -D 5
           │   └─session-8.scope
           │     ├─ 5585 lightdm --session-child 14 22
           │     ├─ 5614 /usr/bin/gnome-keyring-daemon --daemonize --login
           │     ├─ 5617 /usr/bin/sh /usr/bin/xmonad-start
           │     ├─ 5635 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "xmonad-start"
           │     ├─ 5669 /home/ademaria/.xmonad/xmonad-x86_64-linux
           │     ├─ 5705 mate-terminal

and with ps:

$ ps -eo pid,cmd,lsession  | grep compton
 8244 /usr/bin/compton --backend  -
$ ps -eo pid,cmd,lsession  | grep xmonad
 5617 /usr/bin/sh /usr/bin/xmonad 8
 5669 /home/ademaria/.xmonad/xmon 8

This all stems from the fact that my window manager, xmonad, doesn't really do anything with things in /etc/xdg/autostart. My hope was to use a systemd user instance instead for autostarting, and hence running into this issue.