Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Beginners • Re: Kiosk issues have me pulling my hair out.

$
0
0
Note: the script assume you will be using the chrome browser and will install it.
you can modify the script according to your specific needs.

Here are some assumptions:
System:
Be on a Raspberry Pi 4 running Raspberry Pi OS with the Desktop environment installed.

Login: Be logged in (graphically or via SSH) as the user account you want Chromium to autostart for (usually the default pi user). This user needs sudo privileges.

Internet: Ensure the Raspberry Pi has an active internet connection (for downloading packages).
Edit URL: Crucially, copy the script code into a text editor first and change the placeholder TARGET_URL="https://www.google.com" line to the actual webpage URL you need.

Terminal: Open a Terminal window on the Raspberry Pi.

Code:

#!/bin/bash# --- Configuration ---# !!! IMPORTANT: Change this URL to your desired page !!!TARGET_URL="https://www.google.com"# ---------------------# Stop script on any errorset -eecho ">>> Updating packages and installing Chromium + Unclutter..."sudo apt updatesudo apt install -y chromium-browser unclutterecho ">>> Disabling screen blanking & hiding idle cursor..."# Define the LXDE session autostart file pathLXDE_AUTOSTART_FILE="$HOME/.config/lxsession/LXDE-pi/autostart"# Ensure the parent directory existsmkdir -p "$(dirname "$LXDE_AUTOSTART_FILE")"# Ensure the file existstouch "$LXDE_AUTOSTART_FILE"# Add settings if they are not already presentgrep -qxF '@xset s noblank' "$LXDE_AUTOSTART_FILE" || echo '@xset s noblank' >> "$LXDE_AUTOSTART_FILE"grep -qxF '@xset s off' "$LXDE_AUTOSTART_FILE" || echo '@xset s off' >> "$LXDE_AUTOSTART_FILE"grep -qxF '@xset -dpms' "$LXDE_AUTOSTART_FILE" || echo '@xset -dpms' >> "$LXDE_AUTOSTART_FILE"grep -qxF '@unclutter -idle 5 -root' "$LXDE_AUTOSTART_FILE" || echo '@unclutter -idle 5 -root' >> "$LXDE_AUTOSTART_FILE"echo ">>> Creating autostart directory..."mkdir -p "$HOME/.config/autostart"echo ">>> Creating Chromium autostart file (using URL: $TARGET_URL)..."# Create the .desktop file using a Here Documentcat << EOF > "$HOME/.config/autostart/chromium-kiosk.desktop"[Desktop Entry]Type=ApplicationName=Chromium KioskComment=Launch Chromium in Kiosk mode on startup# Start Chromium in kiosk mode, disable errors/infobars, use incognito, load target URLExec=/usr/bin/chromium-browser --kiosk --noerrdialogs --disable-infobars --incognito $TARGET_URLTerminal=falseEOFecho ""echo ">>> Setup Complete <<<"echo "Please reboot your Raspberry Pi 4 for changes to take effect."echo "You can reboot now by running: sudo reboot"

Statistics: Posted by Henderson Hood — Mon Apr 07, 2025 1:46 am



Viewing all articles
Browse latest Browse all 8609

Trending Articles