├── img ├── dm.jpg └── header.png ├── autostart ├── start.sh ├── README.md ├── start_x86.sh ├── Dockerfile.template └── Dockerfile.raspberrypi3 /img/dm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balena-io-examples/x11-window-manager/HEAD/img/dm.jpg -------------------------------------------------------------------------------- /img/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balena-io-examples/x11-window-manager/HEAD/img/header.png -------------------------------------------------------------------------------- /autostart: -------------------------------------------------------------------------------- 1 | @lxpanel --profile LXDE-pi 2 | @pcmanfm --desktop --profile LXDE-pi 3 | @xscreensaver -no-splash 4 | 5 | matchbox-keyboard -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | rm /tmp/.X0-lock &>/dev/null || true 4 | 5 | export DISPLAY=:0 6 | export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket 7 | echo "Starting X in 2 seconds" 8 | sleep 2 9 | startx 10 | 11 | while : 12 | do 13 | echo "startx failed, so we will just wait here while you debug!" 14 | sleep 30 15 | done 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Running a full desktop in a container 2 | 3 | Example project on how to run a desktop manager with [balenaCloud](https://balena.io) to run GUI applications. 4 | ![](https://raw.githubusercontent.com/balena-io-playground/x11-window-manager/master/img/dm.jpg) 5 | 6 | ### Follow the complete project post at [**https://www.balena.io/blog/running-a-desktop-manager-with-balena/**](https://www.balena.io/blog/running-a-desktop-manager-with-balena/). 7 | -------------------------------------------------------------------------------- /start_x86.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | export DISPLAY=:0.0 4 | export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket 5 | 6 | # rotate screen if env variable is set [normal, inverted, left or right] 7 | if [[ ! -z "$ROTATE_DISPLAY" ]]; then 8 | echo "YES" 9 | (sleep 3 && DISPLAY=:0 xrandr -o $ROTATE_DISPLAY) & 10 | fi 11 | 12 | # start desktop manager 13 | echo "STARTING X" 14 | startx 15 | 16 | # uncomment to start x without mouse cursor 17 | # startx -- -nocursor 18 | 19 | # uncomment to open an application instead of the desktop 20 | # startx xterm 21 | -------------------------------------------------------------------------------- /Dockerfile.template: -------------------------------------------------------------------------------- 1 | FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:stretch-run 2 | 3 | # Install XORG 4 | RUN install_packages xserver-xorg=1:7.7+19 \ 5 | xserver-xorg-input-evdev \ 6 | xinit \ 7 | xfce4 \ 8 | xfce4-terminal \ 9 | x11-xserver-utils \ 10 | dbus-x11 \ 11 | matchbox-keyboard \ 12 | xterm 13 | 14 | 15 | # Disable screen from turning it off 16 | RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \ 17 | && echo "" >> /etc/X11/xinit/xserverrc \ 18 | && echo 'exec /usr/bin/X -s 0 dpms' >> /etc/X11/xinit/xserverrc 19 | 20 | # Setting working directory 21 | WORKDIR /usr/src/app 22 | 23 | COPY . ./ 24 | 25 | ENV UDEV=1 26 | 27 | # Avoid requesting XFCE4 question on X start 28 | ENV XFCE_PANEL_MIGRATE_DEFAULT=1 29 | 30 | CMD ["bash", "start_x86.sh"] -------------------------------------------------------------------------------- /Dockerfile.raspberrypi3: -------------------------------------------------------------------------------- 1 | FROM balenalib/raspberrypi3:buster 2 | 3 | # Install desktop environment 4 | RUN install_packages xserver-xorg-core \ 5 | xinit lxsession desktop-file-utils \ 6 | raspberrypi-ui-mods rpd-icons \ 7 | gtk2-engines-clearlookspix \ 8 | matchbox-keyboard 9 | 10 | # disable lxpolkit popup warning 11 | RUN mv /usr/bin/lxpolkit /usr/bin/lxpolkit.bak 12 | 13 | RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \ 14 | && echo "" >> /etc/X11/xinit/xserverrc \ 15 | && echo 'exec /usr/bin/X -s 0 dpms -nolisten tcp "$@"' >> /etc/X11/xinit/xserverrc 16 | 17 | # Setting working directory 18 | WORKDIR /usr/src/app 19 | 20 | COPY start.sh start.sh 21 | 22 | # Adding things to autostart will cause them to be launchd automatically on starup 23 | # COPY autostart /etc/xdg/lxsession/LXDE-pi/autostart 24 | 25 | ENV UDEV=1 26 | 27 | CMD ["bash", "start.sh"] 28 | --------------------------------------------------------------------------------