Autostart Chromium Kiosk with the Desktop

I have installed the Gnome Desktop using this guide

apt install task-gnome-desktop
dietpi-software install 6
dietpi-autostart 16

This works fine and automatically boots to the desktop which is great. The reason for Gnome is it is an RPI 4 Touchscreen with CM4 module and Gnome has built in virtual keyboard etc

I would like to also automatically start into chromium app or kiosk mode as well as the desktop, I still need the user to access the desktop etc chromium will just be displaying a Node-Red app etc

If I change and use the dietpi-autostart to start chromium with localhost:1880 it works… but I can no longer get to the desktop or anything, it doesn’t even start.

So I tried to follow a few guides to autostart chromium as seen below, the use a script and custom service:

I keep getting errors related to X server etc… I can’t even start chromium from the terminal.


I get these errors when trying to start chromium from the terminal

[3403:3403:0429/] Missing X server or $DISPLAY
[3403:3403:0429/] The platform failed to initialize.  Exiting.

This is the complete error when trying to run the script from the tutorial

dietpi@fuxaHMI:~/Autostart$ sudo bash
xset:  unable to open display ""
xset:  unable to open display ""
xset:  unable to open display ""
unclutter: could not open display
sed: can't read /home/root/.config/chromium/Default/Preferences: No such file or directory
sed: can't read /home/root/.config/chromium/Default/Preferences: No such file or directory
[4737:4737:0429/] Missing X server or $DISPLAY
[4737:4737:0429/] The platform failed to initialize.  Exiting.

I have spent hours trying to google and search forums etc but no luck

But the purpose of the kiosk mode is to prevent access to the rest of the system, I think this will not gonna work.
Maybe you could create a user account and just give permissions the user need (So I assume almost no permissions)

Hi @Jappe yes I understand the purpose of kiosk mode and that’s why i mentioned app mode or even full screen mode would work for me.
Basically the screen is being used as an industrial HMI which requires users input etc there will also be automated PDF reports which needs to be opened in libre office and printed etc so the need to access the desktop. The biggest issue is I can’t even start chromium from the terminal or script etc

I think you could tweak the script at /var/lib/dietpi/dietpi-software/installed/ to enable app mode instead of kiosk.

From terminal you would probably need to execute startx first.

But I would set the autostart to option 17 : Custom script (foreground, with autologin)
and with the custom script /var/lib/dietpi/dietpi-autostart/ you start chromium in app mode.

Maybe our docu about the Chromium kiosk mode helps: Graphical Desktop Environments and Utilities - Docs
Select the kiosk mode tab.

But I still understood the full desktop is needed because of LibreOffice and some PDF reports. I don’t think this will be working in kiosk and app mode of Chromium.

I guess the way is to start into desktop mode and to launch Chromium there.

@Jappe I have tried to execute startx from the terminal and the desktop disappears leaving just the background displayed. No way to get desktop back. I’m new to DietPi so still learning and reading all the docs etc I did see option 17 but wasn’t sure if it still started the desktop or not.

@Joulinar I can start chromium from the desktop icon fine ( except the stupid keyring keeps coming up asking for the password need to get rid of that ) But for some reason I can not start it from the terminal, if it starts from desktop icon, why not the terminal? I just get the above errors.

I would be happy if I can just get chromium automatically start up in full screen mode and localhost:1880 the user with correct password can then minimize chromium to access the desktop for reports etc I will have button for this on my app ( works with chrome in my dev environment )

EDIT: If I run startx from ssh session I can now see the server x error

X.Org X Server 1.20.11
X Protocol Version 11, Revision 0
Build Operating System: linux Debian
Current Operating System: Linux fuxaHMI 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64
Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1024x600M@60D smsc95xx.macaddr=E4:5F:01:63:DC:7B vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  root=PARTUUID=07e5d50b-02 rootfstype=ext4 rootwait net.ifnames=0 logo.nologo cgroup_enable=memory vt.global_cursor_default=0 quiet loglevel=0 splash consoleblank=0 console=tty3 fbcon=map:2
Build Date: 30 March 2023  01:46:14PM
xorg-server 2:1.20.11-1+rpt3+deb11u6 (
Current version of pixman: 0.40.0
        Before reporting problems, check
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.1.log", Time: Sun Apr 30 10:37:12 2023
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
error: XDG_RUNTIME_DIR not set in the environment.
Xorg: ../../../../dix/privates.c:384: dixRegisterPrivateKey: Assertion `!global_keys[type].created' failed.
(EE) Backtrace:
(EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x188) [0x5555d7c538]
(EE) unw_get_proc_info failed: no unwind info found [-10]
Fatal server error:
(EE) Caught signal 6 (Aborted). Server aborting
Please consult the The X.Org Foundation support
 for help.
(EE) Please also check the log file at "/var/log/Xorg.1.log" for additional information.
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error

I need to restart the system to get the desktop back, have I installed gnome incorrect?

If I set autostart option 17 and just leave the script blank, the system won’t even boot to the desktop.

I have it working now. It seems the terminal was missing from the gnome install

sudo apt install gnome-terminal

I followed the above guide and just changed parameters for pi to dietpi and used the chromium flag --start-fullscreen ( kiosk also works ) I had to add 10 sec delay to my service script to wait for Node-Red to load fully

1 Like