I will show you in this tutorial how to start the Midori Browser in full screen mode (kiosk mode) automatically after the Raspberry booted. The graphical shell (desktop) of Rapsian will not be required or started.
A pratical applicaton of this would be, for example, an info monitor on an exhibition. In this project, I want to realise a small contol center for FHEM. Therefore, a PiTFT with capacitive touch screen will be used. This, however, is covered in a later tutorial.
Contents
Midori Full Screen Autostart
- Run the following command with the console to update the package list. After that the Midori browser and matchbox will be installed.
sudo apt-get update && sudo apt-get install -y midori matchbox
- Create a new shell script file with the namestartMidori.sh in the home folder and open the Nano text editor. Name and save location can be chosen as you like.
nano startMidori.sh
- Add the following code and exit the Nano text editor
ctr
+x
. To save the changes pressY
andEnter
.#!/bin/sh xset -dpms # disable DPMS (Energy Star) features. xset s off # disable screen saver xset s noblank # don't blank the video device matchbox-window-manager & midori -e Fullscreen -a https://maker-tutorials.com
- Make the script excecutable.
sudo chmod +x startMidori.sh
- You can test the script if you run the following command.
sudo xinit ./startMidori.sh
You can exit the Midori browser with the key combinationCTRL
+ALT
+F1
. In case you called the scriped via SSH, you can exit the script viaCTRL
+c
. - In order to automatically excecute the script when the Raspberry starts we need to edit the rc.local file. This script is excecuted when the Raspberry starts.
sudo nano /etc/rc.local
Add the following code before
exit 0
.For HDMI:
sudo xinit /home/pi/startMidori.sh &
For PiTFT:
FRAMEBUFFER=/dev/fb1 xinit /home/pi/startMidori.sh &
The
&
at the end is important that the subsequent lines are excecuted.You can run the script with a time delay if you sourround the command in brackets and preprend /bin/sleep 10 && schreibst. The 10 means a delay of 10 seconds.
(/bin/sleep 10 && xinit /home/pi/startMidori.sh) &
- Unfortunately, the system needs to sign in automatically to be able to run the script. You can set this up easily if you use Raspbian Jessie using
sudo raspi-config
and the selectingConsole Autologin
under boot options.You need to use the following command to the console if you use and older Raspbian version.
sudo nano /etc/inittab
Search the following line
1:2345:respawn:/sbin/getty 115200 tty1
and comment it with
#
.#1:2345:respawn:/sbin/getty 115200 tty1
After this line add the following command.
1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1
This line enables that the user pi logs in without authentication.
- Now you just need to restart the Raspberry pi …
sudo reboot
… and the Midori browser should open with the desired webpage in full screen mode.
You will exit the Midori Browser usingCTRL
+ALT
+F1
.
Optional: Rotate screen
If you want to show the screen in vertical mode or rotate by 180 degrees you can set this up using the following steps.
-
Open the config.txt file with the Nano editor
sudo nano /boot/config.txt
-
Add the following test at the beginning of the config.txt file.
display_rotate=2
display_rotate=0
Normal
display_rotate=1
90 degrees
display_rotate=2
180 degrees
display_rotate=3
270 degrees
display_rotate=0x10000
Mirror horizontal
display_rotate=0x20000
Mirror vertical - Exit the editing with the shortcut ctrl+x and save the changes with y.
-
After a restart the screen will be shown rotated as you wanted.
sudo reboot
Optional: Hide mouse pointer
- Install the program unclutter.
sudo apt-get install unclutter
- Add
unclutter &
to the startMidori.sh script.sudo nano startMidori.sh
#!/bin/sh xset -dpms # disable DPMS (Energy Star) features. xset s off # disable screen saver xset s noblank # don't blank the video device unclutter & matchbox-window-manager & midori -e Fullscreen -a https://maker-tutorials.com
A detailed article about “Raspberry Pi: Run Applications at System Start”
There’s a bug in Midori that means this guide no longer works. I’ve found if you remove the -a switch it will open fullscreen, it just takes a while for the address bar to disappear.
With pi 4, the rotate screen has to be done through screen configuration, not through /boot/config.txt. Took me a while to find this so i thought i’d share it to save some grief.
How do I disable screen blanking only between certain hours? I tried using sudo crontab -e and adding
10 * * * * xset +dpms
to change the settings every 10 minutes but nothing changes when I do
xset -display :0 q
using ssh from my PC. Is -display :0 correct?
Hi Ben,
Thanx for explaining the whole path how to auto start midori browser in kiosk mode for linux. It really helps people who works in linux environment.