balena-labs-projects / xserver

A simple X11 server block
Apache License 2.0
15 stars 13 forks source link

Display ID is not always :0 after a reboot #13

Closed aethernet closed 2 years ago

aethernet commented 2 years ago

Sometimes DISPLAY is :0, sometimes :1, sometimes higher.

Seems to be related to reboots of the machine, but might also occurs on service restart. It doesn't happen every time so it's hard to pin down the conditions.

Tested on x86 with service installed from dockerhub.

xserver:
    image: balenablocks/xserver
    restart: always
    privileged: true
    volumes:
      - "x11:/tmp/.X11-unix"
    environment:
      - CURSOR=false

Note that there's always only one entry in /tmp/.X11-unix/ but not always X0

My current workaround is to add this to my service start script :

while [ `ls /tmp/.X11-unix/ | wc -l` == 0 ]; do echo "display not created yet"; sleep 0.5; done; echo "display created";
DISPLAY=`ls /tmp/.X11-unix/ | sed s/X/:/`
export DISPLAY
echo "DISPLAY is set to $DISPLAY"
while ! xset -q; do echo "display doesn't accept connection yet"; sleep 0.5; done; echo "display ready";
mvheimburg commented 2 years ago

I had the same issue. Thank you for this workaround :)

nucleardreamer commented 2 years ago

This should be resolved by #15 now. The default display is set to :0 and you can override however you like!