So I was working on this with @craig earlier and this is where I left it… for now:
CMD ["bash", "/usr/src/app/start.sh"]
ENV DISPLAY :0 in Dockerfile and
export DISPLAY=:0 in start.sh both correctly make the DISPLAY variable available. The problem is when running something like:
# Rotate display and touchscreen
xrandr -o right
xinput set-prop "ELAN Touchscreen" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
# Start application
startx /usr/src/app/node_modules/electron/dist/electron /usr/src/app --enable-logging
start.sh, xrandr returns a “Cannot open display at :0” error. This works fine when I ssh into the device, with one caveat that the display rotates but the resolution/window size doesnt seem to adjust properly, cutting off half the screen. That made me think that there might be a problem trying to run xrandr before running
startx (not sure why). So I moved the
xinput commands to a child process spawned by Electron’s main.js and it works great. Both the display and touchscreen rotate and fill the monitor properly.
So right now this way works fine but I’m still not sure why my
start.sh scripts cannot OPEN the display.