Search code examples
bashchromiumsystemd

Running Chromium in kiosk mode as a service with permissions to webcam


I have an app that I need to open on boot to kiosk mode in chromium. The script works fine when run manually but through systemd the webcam is blank and never asks for any permissions. I have tried forcing the data dir to no avail. Below is my small script and systemd config.

I have tried to set default permission on the user in chromium but it never looks at the profile when run through systemd even though the user is correct.

#!/bin/bash 

# Function to launch Chromium in kiosk mode
launch_browser() {
    echo "🌍 Launching Chromium in kiosk mode..."
    chromium-browser http://localhost:3000 --kiosk --start-fullscreen --incognito --disable-infobars --noerrdialogs --disable-cursor --overscroll-history-navigation=0 --disable-features="TouchpadOverscrollHistoryNavigation" --use-fake-ui-for-media-stream &
}
[Unit]
Description=Launch Chromium in Kiosk Mode
PartOf=graphical-session.target
After=graphical-session.target

[Service]
ExecStart=/bin/bash -c '/home/EB/EBSYNC/EcoTouch_Flask_API/chromium.sh; tail -f /dev/null'
Restart=always
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/1000
User=EB
Group=EB

[Install]


Solution

  • I moved away from systemd to xdg autostart instead which executes the script as the correct user allowing permissions to be set by default

    /etc/xdg/autostart

    [Desktop Entry]
    Type=Application
    Exec=/home/EB/EBSYNC/app/chromium.sh
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name=Chromium Kiosk
    Comment=Launch Chromium in kiosk mode