Raspberry Pi Full Screen Browser Customization (2020-05-27-raspios-buster)

TL;DR

This is a follow up to Raspberry Pi Full Screen Browser (2020-05-27-raspios-buster). How to remove the boot messages, icons, customize the boot splash image and background desktop. Also, how to add scripts to control reboot, shutdown, refresh of screens, switch tabs and turn the display(s) on and off without shutting down the Raspberry Pi.

Assumptions

The following instructions assume you have install Raspberry Pi OS (formerly Raspbian) desktop and have set up a fullscreen browser similar to the configuration in Raspberry Pi Full Screen Browser (2020-05-27-raspios-buster).

Scripts Directory

The following instructions reference a directory called /opt/scripts, this directory is used to store the custom scripts.

By default this directory does not exist, to create it and set permissions, run:

sudo mkdir /opt/scripts
sudo chown pi.pi /opt/scripts

Custom Image

The following instructions reference a custom image called custom-image.png, that is used for the splash image and desktop background.

If you have an image that is accessible over the Internet, a quick way to get it on the Raspberry Pi is to use wget:

wget https://i.imgur.com/XTPF0ne.png -O custom-image.png

Move the image to /opt/scripts:

mv custom-image.png /opt/scripts

Disable the Raspberry Icons and Boot Text

At device start there are Raspberry icons that represent the number of cpu cores. This will disable these icons.

Additionally during start up there is a boot kernel log, this will hide that output as well.

This change can be done before installing the SD card in the Raspberry Pi.

Hiding the boot kernel log will also mean that any error messages will not be visible. If you have boot issues and want to reverse the changes, edit the cmdline.txt in a different computer.

Edit cmdline.txt:

sudo vi /boot/cmdline.txt

There should be one line of text, append quiet logo.nologo to the end of the line.

It should look like:

console=serial0,115200 console=tty1 root=PARTUUID=9fb1957f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles quiet logo.nologo

Disable the Rainbow Image

At start, there is a rainbow image that appears to test the colour range. This will disable the rainbow image.

This change can be done before installing the SD card in the Raspberry Pi.

Edit config.txt:

sudo vi /boot/config.txt

Add the following to the end of the file:

# ADDED
disable_splash=1

Disable “Welcome to Raspberry Pi” Application

This will prevent the “Welcome to Raspberry Pi” application from starting on first boot, delete piwiz.desktop:

sudo rm /etc/xdg/autostart/piwiz.desktop

Custom GUI Splash Image

At desktop start, there is a splash image that appears, this will replace that with a custom image.

Copy the custom-image.png over the existing splash.png image to replace it:

sudo cp /opt/scripts/custom-image.png /usr/share/plymouth/themes/pix/splash.png

Custom Desktop Wallpaper

This will replace the wallpaper image with a custom image.

This will use the image at /opt/scripts/custom-image.png

Create folder, if necessary:

mkdir -p ~/.config/pcmanfm/LXDE-pi

Edit the configuration file desktop-items-0.conf to set the wallpaper to custom image:

vi ~/.config/pcmanfm/LXDE-pi/desktop-items-0.conf

Add/change:

[*]
wallpaper_mode=center
wallpaper_common=1
wallpaper=/opt/scripts/custom-image.png
desktop_bg=#000000000000
desktop_fg=#e8e8e8e8e8e8
desktop_shadow=#000000000000
desktop_font=PibotoLt 12
show_wm_menu=0
sort=mtime;ascending;
show_documents=0
show_trash=0
show_mounts=0

If there is a second screen, edit the configuration file desktop-items-1.conf :

vi ~/.config/pcmanfm/LXDE-pi/desktop-items-1.conf

Add/change:

[*]
wallpaper_mode=center
wallpaper_common=1
wallpaper=/opt/scripts/custom-image.png
desktop_bg=#000000000000
desktop_fg=#e8e8e8e8e8e8
desktop_shadow=#000000000000
desktop_font=PibotoLt 12
show_wm_menu=0
sort=mtime;ascending;
show_documents=0
show_trash=0
show_mounts=0

Scripts

The scripts listed are a helpful way of centralizing control of the Raspberry Pi. Either called by a crontab entry to do a nightly reboot, or by a keyboard or IR remote control to turn off the display.

By having the commands as independent scripts, it is possible to call them in different ways and have the same results.

Application Focus and Input

Most of the following scripts blindly send a keypress to the app that has the current focus.

On Raspberry Pi with a single screen this is the foreground app. With multiple screens, it is not so clear.

It may be necessary to send an Alt+Tab key press combination to bring the desired app foreground or set focus.

A better approach is to use the xdotool to send a mouse click to a location where the app appears to set focus. For an example of this see Refresh Two Chromium Browsers on Two Screens.

To install the xdotool run:

sudo apt-get install xdotool -y

Reboot Script

This script will reboot the Raspberry Pi. The /sbin/shutdown command will also turn off the device if the --reboot is removed.

Create a create a file called remote-reboot.sh:

sudo vi /opt/scripts/remote-reboot.sh
#!/bin/bash
sudo /sbin/shutdown --reboot now

Change ownership and make executable:

sudo chown pi.pi /opt/scripts/remote-reboot.sh
sudo chmod u+x /opt/scripts/remote-reboot.sh
sudo chmod +x /opt/scripts/remote-reboot.sh

Add the user nobody to the list of users who can reboot without a password:

sudo visudo
# ADDED
nobody ALL =NOPASSWD: /sbin/shutdown*

Run:

/opt/scripts/remote-reboot.sh

Chromium Switch Tab

This script will send a Control+Shift+Tab key press combination to the foreground app, if this is Chromium it will switch tabs.

This is typically used with a two tabs configured at start up of the Chromium browser. This could be called by a crontab entry to switch the content of the browser on a schedule.

Create the script:

sudo vi /opt/scripts/chromium-switch-tab.sh
#!/bin/bash

export DISPLAY=:0.0
export XAUTHORITY=/home/pi/.Xauthority
/usr/bin/xdotool key Ctrl+Shift+Tab

Update the permissions

sudo chown pi.pi /opt/scripts/chromium-switch-tab.sh
sudo chmod u+x /opt/scripts/chromium-switch-tab.sh
sudo chmod +x /opt/scripts/chromium-switch-tab.sh

Run:

/opt/scripts/chromium-switch-tab.sh

Refresh One Chromium Browsers on One Screen

This script will send a F5 key press to the foreground app, if this is Chromium, it will refresh the page.

Create the script:

sudo vi /opt/scripts/chromium-refresh.sh
#!/bin/bash

export DISPLAY=:0.0
export XAUTHORITY=/home/pi/.Xauthority
/usr/bin/xdotool key F5

Update the permissions

sudo chown pi.pi /opt/scripts/chromium-refresh.sh
sudo chmod u+x /opt/scripts/chromium-refresh.sh
sudo chmod +x /opt/scripts/chromium-refresh.sh

Run:

/opt/scripts/chromium-refresh.sh

Refresh Two Chromium Browsers on Two Screens

Script to send a mouse click to a coordinate to establish focus, send aF5 key press, send a second mouse click to a different coordinate and send a F5 key press. The intent is to send F5 to two browsers at the different screen locations.

Requires xdotool, to install:

sudo apt-get install xdotool -y

Assumes second browser is at 1930,10

Create the script:

sudo vi /opt/scripts/chromium-refresh-two-browsers.sh
#!/bin/bash

export DISPLAY=:0.0
export XAUTHORITY=/home/pi/.Xauthority

# Screen/browser 1
/usr/bin/xdotool mousemove 10 10 click 1
/usr/bin/xdotool key F5

# Screen/browser 2
/usr/bin/xdotool mousemove 1930 10 click 1
/usr/bin/xdotool key F5

Update the permissions:

sudo chown pi.pi /opt/scripts/chromium-refresh-two-browsers.sh
sudo chmod u+x /opt/scripts/chromium-refresh-two-browsers.sh
sudo chmod +x /opt/scripts/chromium-refresh-two-browsers.sh

Run:

/opt/scripts/chromium-refresh-two-browsers.sh

Screen Control

This script will turn the screens on and off without shutting down the Raspberry Pi.

Create the script:

sudo vi /opt/scripts/screen-control.sh
#!/bin/bash
#
# version 2.0
#
# Updates
#
# - Using `vcgencmd display_power` to control screens
# - Support for dual displays via `vcgencmd display_power`

# NOTE: Using the first screen to determine STATE
STATE=`/usr/bin/vcgencmd display_power -1`

if [ ! -z "$1" ] && [ $1 = "toggle" ]; then

  echo `date` "Toggling screen."

  if [[ $STATE == *"display_power=0"* ]]; then

    echo `date` "Screen is off, turning on."

    /usr/bin/vcgencmd display_power 1

  else

    echo `date` "Screen is on, turning off."

    # Turn off all screens
    /usr/bin/vcgencmd display_power 0

    # Screen is off, no need to refresh

  fi

elif [ ! -z "$1" ] && [ $1 = "on" ]; then

  if [[ $STATE == *"display_power=0"* ]]; then

    echo `date` "Screen is off, turning on."

    /usr/bin/vcgencmd display_power 1

  else

    echo `date` "Screen is on, doing nothing."

    # Screen is off, no need to refresh

  fi

elif [ ! -z "$1" ] && [ $1 = "off" ]; then

  if [[ $STATE == *"display_power=0"* ]]; then

    echo `date` "Screen is off, doing nothing."

    # Screen is off, no need to refresh

  else

    echo `date` "Screen is on, turning off."

    /usr/bin/vcgencmd display_power 0

    # Screen is off, no need to refresh

  fi

else

  # Print usage
  echo
  echo usage:
  echo $0 on
  echo $0 off
  echo $0 toggle

fi

Update the permissions

sudo chown pi.pi /opt/scripts/screen-control.sh
sudo chmod u+x /opt/scripts/screen-control.sh
sudo chmod +x /opt/scripts/screen-control.sh

Run:

/opt/scripts/screen-control.sh on
/opt/scripts/screen-control.sh off
/opt/scripts/screen-control.sh toggle

Conclusion

That is it, there are ways of combining the scripts so that when used with keyboard input can be an effective way of managing digital displays.

Leave a Reply

You must be logged in to post a comment.