I use xautolock to lock the screen and suspend my laptop after a given amount of time of inactivity. This works fine. This is how xautolock is started from .xsessionrc:xautolock -time 60 -detectsleep -locker '~/bin/lockscreen --suspend' &The ~/bin/lockscreen script does, among other things, ssh-add -D to remove all SSH keys from the running SSH agent. This, however does not work when xautolock is spawned from .xsessionrc - the ssh-add -D command complains that it cannot talk to the authentication agent.However, I can ssh-add -D from my terminal just fine, and if I pkill xautolock and then run the xautolock command from my .xsessionrc in a terminal, everything works as expected.Why can't the ssh-add -D process spawned from xautolock spawned from .xsessionrc talk to the SSH agent, but ssh -D spawned from xautolock spawned from a regular terminal can?ps auf shows this tree:root     24126  0.0  0.1 105812  5032 tty1     Ss   18:34   0:00 /bin/login --        andreas  24132  0.0  0.1  40232  4956 tty1     S    18:34   0:00  \_ -zshandreas  24140  0.0  0.0   4328  1576 tty1     S+   18:34   0:00    \_ /bin/sh /usr/bin/startxandreas  24162  0.0  0.0  15944  1952 tty1     S+   18:34   0:00      \_ xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -auth /tmp/serverauth.afXu0ohTRzroot     24163  1.4  0.5 165868 20048 tty1     S    18:34   0:02        \_ /usr/bin/X -nolisten tcp :0 vt1 -auth /tmp/serverauth.afXu0ohTRzandreas  24169  0.0  0.2 113572 10600 tty1     S    18:34   0:00        \_ x-window-managerandreas  24203  0.0  0.7 489436 26380 tty1     Sl   18:34   0:00          \_ nm-appletandreas  24204  0.0  0.0  20140  2700 tty1     S    18:34   0:00          \_ xautolock -time 60 -detectsleep -locker ~/bin/lockscreen --suspendandreas  24209  0.0  0.0  22196  2680 tty1     S    18:34   0:00          \_ /usr/bin/unclutter -idle 1 -rootandreas  24212  0.0  0.0  10688   340 ?        Ss   18:34   0:00          \_ /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session x-window-managerMy only working theory is that because xautolock is started before the SSH agent, the forked ssh-add command doesn't know about the agent's existence, but that seems very odd to me.
xautolock/ssh-add can't interact with ssh-agent if launched from .xsessionrc
x11;xorg;ssh agent;xautolock
The X window manager is started through the command ssh-agent dbus-launcher --exit-with-session i3, which means that the SSH agent is started right before the window manager. However, Debian sources .xsessionrc before this happens, so when xautolocker gets started, the SSH agent hasn't started and the environment variables needed for ssh-add to talk to the agent haven't been set.One solution is to modify .xinitrc to start the agent before sourcing .xresources:if command -v 'ssh-agent' >/dev/null 2>&1; then    eval $(ssh-agent -s)fi[ -e $HOME/.xsessionrc ] && . $HOME/.xsessionrcx-window-managerif command -v 'ssh-agent' >/dev/null 2>&1; then    ssh-agent -kfi