Raspberry Pi. Automatically open browser to full screen on startup.

Set the browser to open full screen when the system boots into the GUI. Incognito mode is needed because of the way some web sites change between modes. Failure to go incognito may prompt for a user response.

Use systemd autostart configuration for the browser.
cd ~/.config/autostart
sudo nano browser.desktop
[Desktop Entry]
Type=Application
Name=browser
Exec=/usr/bin/chromium-browser --start-fullscreen --incognito http://yoursite

Check https://peter.sh/experiments/chromium-command-line-switches/ for correct style if in doubt

To display a web page with mixed secure and unsecure content.
add the switch. --allow-running-insecure-content 

Note: Advanced settings in chrome allow mixing secure and unsecure content from specific websites. Privacy and Security > Site Settings > Additional content settings > Insecure content > Allow > add
However, this is not applied when starting from a command line in the autostart

You can now disconnect the keyboard and mouse. The unit will boot into a full screen display of the web site and the users cannot modify the settings. You can remote in and change the display easily.

Raspberry pi, automatically refresh browser

To schedule an automatic browser refresh, you’ll need to create a script file and schedule it as a CRON job. The script uses xdotool to send an F5 keypress which refreshes the browser window. There are some gottchas that are easily missed.

The file should contain the following:

#! /bin/bash
export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0
xdotool search –onlyvisible –class chromium windowfocus key F5

Note: depending on browser the doubledash may appear as a single long dash.

I named it refresh.sh then use chmod u+x filename to make it executable and chown to make sure it’s owned by pi and not root for execution.

If you’re not sure which the Xauthority file is being used, just run ‘xauth’ on the command line and it will tell you.

The name of the class is important. If you are using chromium, you have to say chromium; chrome finds chrome browsers not chromium browsers.

To schedule the job for every 5 minutes use:
crontab -e
*/5 * * * * /home/pi/refresh.sh >/dev/null 2>&1
The job sends an email every time it runs. The dev/null sends it to the bit bucket instead of filling up your mail inbox.


To check if the job has run:
cat /var/log/syslog | grep refresh.sh

To list and print all crontabs on the box:
must be root to work
this will list all users in the passwd file including mail, games, sys, sync and so on down the list
sudo su
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done