Skip to content

Instantly share code, notes, and snippets.

@MvRens
Forked from saper-2/.xsessionrc
Last active March 4, 2022 10:36
Show Gist options
  • Save MvRens/cb9313984e8ef8b5cb9326fe19a281db to your computer and use it in GitHub Desktop.
Save MvRens/cb9313984e8ef8b5cb9326fe19a281db to your computer and use it in GitHub Desktop.
Kiosk mode in Rasberry Pi (raspbian/raspberry pi os)
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
#Disable DPMS. (power save/blanking mode for display)
xset -dpms
xset s off
xset s noblank
#Lets remove a lock file that could be caused due to a crash.
rm /home/pi/.config/chromium/SingletonLock
while true; do
# Clean up previously running apps, gracefully at first then harshly
# firefox
#killall -TERM firefox 2>/dev/null;
# chromium
killall -TERM chromium-browser 2>/dev/null;
killall -TERM matchbox-window-manager 2>/dev/null;
sleep 2;
# firefox
#killall -9 firefox 2>/dev/null;
# chromium
killall -9 chromium-browser 2>/dev/null;
killall -9 matchbox-window-manager 2>/dev/null;
# Launch window manager without title bar.
# exec matchbox-window-manager -use_titlebar no -use_cursor no -theme bluebox &
exec matchbox-window-manager -use_titlebar no -theme bluebox &
# Run unclutter - hide cursor
# unclutter &
# Launch browser.
# chromium
chromium-browser --incognito --kiosk --noerrdialogs --disable-default-apps --disable-single-click-autofill --disable-translate-new-ux --disable-translate --disable-cache --disk-cache-dir=/dev/null --disk-cache-size=1 --reduce-security-for-testing --app=http://THE_URL_TO_LOAD/LOAD/LOAD.HTML
# firefox:
#firefox -kiosk -private-window http://THE_URL_TO_LOAD/LOAD/LOAD.HTM
done;

0. init

Update system first (apt update && apt upgrade)

1. Prereq

Install evdev for resistive touch panel on SPI support - might be ommited. Next install matchbox desktop, and remove lxde, and cleanup unused packaged

apt install xserver-xorg-input-evdev
apt install matchbox-common matchbox-panel matchbox-panel-manager matchbox-themes-extra matchbox-window-manager
apt remove lxde lxpanel lxdm lxde-common
apt autoremove 

2. raspi-config

run raspi-config set: autologin to console (menu: 1 -> S5 -> B2 )

3. If used "-lite" version of Rapsberry Pi os

You need to install X server too:

sudo apt --no-install-recommends install xserver-xorg xserver-xorg-video-fbdev xinit pciutils xinput xfonts-100dpi xfonts-75dpi xfonts-scalable

chromium-browser:

and chromium-browser , or if you want firefox then skip this and go for "firefox":

sudo apt install chromium-browser

firefox:

sudo apt install firefox-esr

4. changes in files

At end ~/.bashrc add startx line:

if [ -z "${SSH_TTY}" ]; then
        startx -- -nocursor
fi
# ...I do an else tmux attach for SSH here

5a. start chromium script

now create file ".xsessionrc" , replace THE_URL_TO_LOAD/LOAD/LOAD.HTML with your url path what page you want for chromium to load to.

5b. start Firefox

You need to uncommnet firefox releated lins, and comment out chromium-releated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment