we_display.sh 1.0 KB

12345678910111213141516171819
  1. #!/bin/bash
  2. # starts the isolated GPU display :98 (headless weston + Xwayland, private XDG_RUNTIME_DIR) if it isn't running
  3. # :0 is the real desktop, weston's own xwayland module would try it first, so Xwayland is started here instead
  4. S=${WE_LIVE_DIR:-$HOME/.local/share/we_live}
  5. R=$S/run
  6. mkdir -p $R && chmod 700 $R
  7. [ -f $S/weston.ini ] || printf '[core]\nxwayland=false\n[output]\nname=headless\nmode=1920x1080\n' > $S/weston.ini
  8. if ! pgrep -x weston >/dev/null; then
  9. rm -f $R/we-wl*
  10. env -u WAYLAND_DISPLAY -u DISPLAY XDG_RUNTIME_DIR=$R setsid nohup weston --backend=headless --renderer=gl \
  11. --width=1920 --height=1080 --socket=we-wl --config=$S/weston.ini --log=$R/weston.log >/dev/null 2>&1 &
  12. sleep 3
  13. fi
  14. if ! pgrep -f "Xwayland :98" >/dev/null; then
  15. env -u DISPLAY XDG_RUNTIME_DIR=$R WAYLAND_DISPLAY=we-wl setsid nohup Xwayland :98 -geometry 1920x1080 -nolisten tcp \
  16. > $R/xwayland.log 2>&1 &
  17. sleep 3
  18. fi
  19. DISPLAY=:98 xdpyinfo >/dev/null 2>&1 && echo ":98 ready" || { echo ":98 failed, see $R"; exit 1; }