i3 &
I3_PID="$!"

# Running `i3 --get-socketpath` seems to interfere with the startup of the `i3`
# running in the background.
# while ! i3 --get-socketpath > '/dev/null'
while ! [ -e '/run/user/1000/i3/ipc-socket.'* ]
do
  if ! [ "$(ps -p "$I3_PID" -o pid=)" ]
  then
    wait "$I3_PID"
    exit $?
  fi
done
