Ad Code

How to: Make Raspberry Pi to Automatically Launch a Website When Booted Up and Lock Everything Else?

To make a Raspberry Pi automatically launch a website in full-screen "kiosk mode" and lock down the interface, you need to configure it to boot to the desktop, autostart Chromium with specific flags, and disable screen blanking.

Here is the step-by-step guide based on current Raspberry Pi OS (Bookworm/Wayfire) methods.
Phase 1: Initial Setup
  1. Open Terminal and ensure your Pi is updated:
    bash
    sudo apt update
    sudo apt full-upgrade -y
    
  2. Configure Boot Options: Run sudo raspi-config.
    • Navigate to System Options > Boot / Auto Login.
    • Select Desktop Autologin (this skips login and opens the desktop automatically).
    • Optional: Navigate to Display Options > Screen Blanking and select No.
  3. Install Necessary Tools: Install unclutter to hide the mouse cursor when not in use:
    bash
    sudo apt-get install unclutter -y
    
Phase 2: Create the Kiosk Script
Create a shell script that tells Chromium to run in full-screen, locks the website, and disables error messages.
  1. Create the script file:
    bash
    nano /home/pi/run_kiosk.sh
    
  2. Add the following code (replace https://google.com with your website):
    bash
    #!/bin/bash
    # Hide mouse cursor
    unclutter -idle 0.1 -root &
    # Open Chromium
    chromium-browser --kiosk --noerrdialogs --disable-infobars --start-maximized https://google.com &
    
  3. Save and exit (Ctrl+X, then Y, then Enter).
  4. Make it executable:
    bash
    chmod +x /home/pi/run_kiosk.sh
    
Phase 3: Autostart the Kiosk at Boot
For modern Raspberry Pi OS (Bookworm), you must edit the Wayfire configuration.
  1. Edit the autostart file:
    bash
    nano /home/pi/.config/wayfire.ini
    
  2. Find the [autostart] section and add the following lines (add it to the end if the section doesn't exist):
    ini
    [autostart]
    kiosk = /home/pi/run_kiosk.sh
    screensaver = false
    dpms = false
    
  3. Save and exit (Ctrl+X, then Y, then Enter).
Phase 4: Final Lockdown (Optional but Recommended)
To prevent users from closing the browser:
  • Disable Key Combinations: The ---kiosk flag prevents traditional F11 exiting, but users can still use Alt+F4 to close the app.
  • Prevent Access to Desktop: By using Desktop Autologin and running only the script, the user only sees the browser.
  • Alternative Method (Hard Lockdown): Use openbox instead of the full desktop environment to prevent desktop icons or panels from loading.
Reboot the Pi:
bash
sudo reboot
Troubleshooting
  • Browser not opening: The script might be running before the network is ready. Add sleep 10 at the beginning of run_kiosk.sh to add a 10-second delay.
  • Exit Kiosk: Press Alt+F4 to close the browser, or Ctrl+Alt+F2 to switch to a terminal to fix configurations

Post a Comment

0 Comments