vinayakaraju46 / lxsession

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running Raspberry Pi in Kiosk Mode

This tutorial will guide you on how to configure a Raspberry Pi to boot directly into a web page or application without a desktop environment.

Requirements

  • Raspberry Pi 4 with the latest OS installed

Steps

  1. Create an lxsession Directory: If it doesn't already exist, create using the following command:

    mkdir -p ~/.config/lxsession/LXDE-pi
  2. Create an Autostart File: Create an autostart file (e.g., autostart) in the ~/.config/lxsession/LXDE-pi/ directory:

    nano ~/.config/lxsession/LXDE-pi/autostart
  3. Add Startup Programs: Add the programs you want to start automatically to this file. For example, in this case I'm opening a browser with application url, you can add a line like this:

    @/usr/bin/firefox <your-application-url>

    Replace <your-application-url> with the URL of your web application(http://localhost:3000/test).

    Save and Exit: Save the file by pressing Ctrl + X, then Y, and finally Enter.

  4. Configuring Crontab: Starting your server on boot

    • Create a bash script named start-app.sh and include the following code:

      #!/bin/bash
      
      export DISPLAY=:1
      cd /root/Desktop/nodeserver && node index.js
      
    • Open crontab:

      sudo nano /etc/crontab
      

      Include your start script here image

  5. Reboot: Reboot your Raspberry Pi to apply the changes:

    sudo reboot

Your Raspberry Pi should now start with your application open in the Firefox browser.

image

About