diff --git a/stages/04.configure-desktop-env/02.vnc-server/files/adi-xserver.sh b/stages/04.configure-desktop-env/02.vnc-server/files/adi-xserver.sh new file mode 100755 index 0000000000..d8048fdff5 --- /dev/null +++ b/stages/04.configure-desktop-env/02.vnc-server/files/adi-xserver.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# +# kuiper2.0 - Embedded Linux for Analog Devices Products +# +# Copyright (c) 2024 Analog Devices, Inc. +# Author: Larisa Radu + +# Check if the system has a display output +if dmesg | grep -q "\[drm\]"; then + # Remove dummy display + rm -f /usr/share/X11/xorg.conf.d/xorg.conf +else + # Enable dummy display + enable_dummy_display.sh + + # Start an X server as user 'analog' + sudo -u analog startx -- :0 + + # Export the display port + export DISPLAY=:0 +fi diff --git a/stages/04.configure-desktop-env/02.vnc-server/files/xorg.conf b/stages/04.configure-desktop-env/02.vnc-server/files/xorg.conf deleted file mode 100644 index dc47cf8f4f..0000000000 --- a/stages/04.configure-desktop-env/02.vnc-server/files/xorg.conf +++ /dev/null @@ -1,21 +0,0 @@ -Section "Device" - Identifier "Configured Video Device" - Driver "dummy" -EndSection - -Section "Monitor" - Identifier "Configured Monitor" - HorizSync 31.5-48.5 - VertRefresh 50-70 -EndSection - -Section "Screen" - Identifier "Default Screen" - Monitor "Configured Monitor" - Device "Configured Video Device" - DefaultDepth 24 - SubSection "Display" - Depth 24 - Modes "1280x720" - EndSubSection -EndSection diff --git a/stages/04.configure-desktop-env/02.vnc-server/files/xserver.service b/stages/04.configure-desktop-env/02.vnc-server/files/xserver.service new file mode 100644 index 0000000000..1ad8ac308d --- /dev/null +++ b/stages/04.configure-desktop-env/02.vnc-server/files/xserver.service @@ -0,0 +1,11 @@ +[Unit] +Description=ADI X Server +Wants=display-manager.service +After=display-manager.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/adi-xserver.sh + +[Install] +WantedBy=multi-user.target diff --git a/stages/04.configure-desktop-env/02.vnc-server/run.sh b/stages/04.configure-desktop-env/02.vnc-server/run.sh index 77389c61ef..af33a510a6 100644 --- a/stages/04.configure-desktop-env/02.vnc-server/run.sh +++ b/stages/04.configure-desktop-env/02.vnc-server/run.sh @@ -6,21 +6,16 @@ # Copyright (c) 2024 Analog Devices, Inc. # Author: Larisa Radu -HELP="To enable VNC on a board that has a display port, you only need to install the service. This is the default approach in the script. \ - \nTo enable VNC on a board that doesn't have a display port, you need to install the xorg.conf file that contains a dummy display. \ - \nYou can do this by uncommenting line 21. \ - \nOnce you have installed the dummy display, your desktop environment might not start if you switch to a board that has a display port. \ - \nIn order to go back to the initial configuration, you only need to delete /usr/share/X11/xorg.conf.d/xorg.conf file and reboot. \ - \n \ - \nThe VNC password is: analog" - if [ "${CONFIG_DESKTOP}" = y ]; then # Add x11vnc service install -m 644 "${BASH_SOURCE%%/run.sh}"/files/x11vnc.service "${BUILD_DIR}/lib/systemd/system/" -# Add dummy display -#install -m 644 "${BASH_SOURCE%%/run.sh}"/files/xorg.conf "${BUILD_DIR}/usr/share/X11/xorg.conf.d/" +# Add xserver service +install -m 644 "${BASH_SOURCE%%/run.sh}"/files/xserver.service "${BUILD_DIR}/lib/systemd/system/" + +# Add xserver script +install -m 755 "${BASH_SOURCE%%/run.sh}"/files/adi-xserver.sh "${BUILD_DIR}/usr/bin/" install -d "${BUILD_DIR}/home/analog/.vnc" @@ -29,8 +24,12 @@ chroot "${BUILD_DIR}" << EOF x11vnc -storepasswd analog /home/analog/.vnc/passwd chmod 644 /home/analog/.vnc/passwd - # Enable VNC service to run automatically at every boot + # Allow anybody to start the X server + sed -i "s/allowed_users=console/allowed_users=anybody/g" /etc/X11/Xwrapper.config + + # Enable VNC and xserver services to run automatically at every boot systemctl enable x11vnc + systemctl enable xserver EOF else