Xss-lock crashes on i3wm (using i3lock)

I am running i3lock to lock my i3 session, executed with xss-lock. Relevant i3 config:

exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
exec_always --no-startup-id xset dpms 0 0 300 &

When I initially login to a new session, the lock works once or twice but then stops running. Checking the relevant logs reveals that xss-lock is crashing:

journalctl | grep xss

<many other crashes truncated...>
Oct 24 19:38:27 peters-fedora-desktop xss-lock[5085]: X connection lost; exiting.
Oct 24 19:38:27 peters-fedora-desktop kernel: traps: xss-lock[5085] trap int3 ip:7f766898de51 sp:7fff0a030320 error:0 in libglib-2.0.so.0.7200.3[7f7668951000+91000]
Oct 24 19:38:27 peters-fedora-desktop audit[5085]: ANOM_ABEND auid=1000 uid=1000 gid=1000 ses=5 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 pid=5085 comm="xss-lock" exe="/usr/bin/xss-lock" sig=5 res=1
Oct 24 19:38:29 peters-fedora-desktop systemd-coredump[204350]: Process 5085 (xss-lock) of user 1000 dumped core.
                                                                Module xss-lock with build-id b18779abda13812e3a54ae5ce7c28a9a10985b38
                                                                Metadata for module xss-lock owned by FDO found: {
                                                                        "name" : "xss-lock",
                                                                #2  0x000055aef978c4f5 screensaver_event_cb (xss-lock + 0x44f5)
                                                                #3  0x000055aef978cd4d xcb_event_dispatch (xss-lock + 0x4d4d)
                                                                #7  0x000055aef978be68 main (xss-lock + 0x3e68)
                                                                #10 0x000055aef978c025 _start (xss-lock + 0x4025)
Oct 24 19:38:44 peters-fedora-desktop abrt-notification[204484]: Process 5668 (xss-lock) crashed in screensaver_event_cb()

Any ideas what the problem could be? Thanks

I’m no expert, but it looks like xss-lock is designed to fail that way when it loses its connection to the X server.

I guess a workaround would be to put it in a loop so it restarts when that happens? Maybe something like the following (untested).

bash -c 'while (true); do xss-lock --transfer-sleep-lock -- i3lock --nofork; done'

Assuming that xss-lock doesn’t background of course (I don’t know, I’m not familiar with it).

P.S. There is also an issue filed saying it shouldn’t exit that way. But it doesn’t look like that patch has been applied.