2

I have set up a Raspberry Pi 4 to starts as kiosk mode with these settings (kiosk.sh):

#!/bin/bash

xset s noblank
xset s off
xset -dpms

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
 
/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk http://localhost/ &

and (kiosk.service):

[Unit]
Description=Chromium Kiosk
Wants=graphical.target
Requires=sound.target
After=graphical.target
After=sound.target

[Service]
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Type=simple
ExecStart=/bin/bash /home/pi/kiosk.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target

These settings open the browser at startup in fullscreen mode and show the page. The page plays sounds periodically, but there is no sound. Even interacting with the page no sound is played.

Exiting kiosk mode and openning Chromium manualy in the same page, the sound works. Journal output:

(...)
Jan 24 08:53:04 raspberrypi systemd[627]: Started Multimedia Service.
Jan 24 08:53:04 raspberrypi systemd[627]: Starting Sound Service...
Jan 24 08:53:04 raspberrypi systemd[627]: Started D-Bus User Message Bus.
Jan 24 08:53:04 raspberrypi pipewire[651]: Failed to receive portal pid: org.freedesktop.DBus.Error.Na>
Jan 24 08:53:05 raspberrypi pulseaudio[652]: Failed to find a working profile.
Jan 24 08:53:05 raspberrypi pulseaudio[652]: Failed to load module "module-alsa-card" (argument: "devi>
Jan 24 08:53:05 raspberrypi systemd[627]: Started Sound Service.
(...)

Is it possible to start Chromium in kiosk mode and have audio without user interaction? Thanks in advance.

2
  • 1
    are you sure that you are outputting to the correct audio device as default when running kiosk? - hdmi vs audio jack.
    – Abel
    Jan 25, 2022 at 2:36
  • You right. The sound is played in audio jack, but just after interact with the page. How to change the output default to HDMI? There is how to avoid user interactive to play sounds?
    – RenanStr
    Jan 25, 2022 at 18:52

2 Answers 2

0

appears we must have followed the same guide when we set up our kiosks.

I ran into the same issue (similar). people started to want to run videos from the digital signage, but no audio as you described.

I tried just about every solution I could find. forcing hdmi_drive=2

I tried loading audio into systemd with sound.target (I may have not been doing this part right)

My solution was to eliminate the systemd part of it since that seemed to be where the issue was coming from. The audio plays just fine if I load up the browser in not kiosk mode from the device.

instead I put my chromium start into /etc/xdg/lxsession/LXDE-pi/autostart

my autostart file looked like this when i was finished

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash

@xset s off
@xset -dpms
@xset s noblank

@chromium-browser --kiosk --autoplay-policy=no-user-gesture-required http://localhost

This does eliminate the ability for you to easily stop and start a service to kill the signage, but I found we are typically managing them through SSH anyhow.

I hope this helps!

0

For my setup, setting the environment variable XDG_RUNTIME_DIR solved the problem. (Tested on Raspberry Pi OS Bullseye)

Here is my systemd file:

[Unit]
Description=Chromium browser on boot
PartOf=graphical-session.target

[Service]
User=pi
Group=pi
Type=simple
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/1000
ExecStart=/usr/bin/chromium-browser --start-fullscreen --kiosk http://localhost/
Restart=on-failure

[Install]
WantedBy=user@.service

Please note that XDG_RUNTIME_DIR=/run/user/1000 should match the user ID. The default user ID for the pi user is 1000 in Raspberry Pi OS. If you are using a different user, you need to change the number. To check the user ID, you can use the "id" command in the console.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.