Digital Signage/Displays: Difference between revisions
(Created initial page) |
m (→Prerequisites) |
||
(24 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
= Prerequisites = | = Prerequisites = | ||
You will need a few prerequisites before this will work: | You will need a few prerequisites before this will work: | ||
* A TV/Monitor ( | * A TV/Monitor (preferably mounted) to display content | ||
* A RaspberryPi or similar SBC (I've also used LibreComputer LePotato SBC running Armbian) | * A RaspberryPi or similar SBC (I've also used LibreComputer LePotato SBC running Armbian) | ||
* A webserver to serve up the content you want to show ( | * A webserver to serve up the content you want to show (preferably external to the SBC) | ||
=== | === Basic Display=== | ||
This is the most basic configuration you can use to turn a RaspberryPi/SBC into a digital sign/display that serves up a web page when started. | |||
==== Software ==== | ==== Software ==== | ||
You will need to install the following packages: | You will need to install the following packages: | ||
Line 19: | Line 20: | ||
Do the following to setup the device to display the URL of your choice. | Do the following to setup the device to display the URL of your choice. | ||
===== /etc/xdg/openbox/autostart ===== | ===== /etc/xdg/openbox/autostart ===== | ||
Replace the contents of this file with the following: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# Disable any form of screen saver / screen blanking / power management | # Disable any form of screen saver / screen blanking / power management | ||
Line 52: | Line 53: | ||
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.50 $URL | #chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.50 $URL | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== Add kiosk user ===== | ===== Add kiosk user ===== | ||
We will add a user called kiosk that will autologin and display the web page we defined in the script above. | We will add a user called kiosk that will autologin and display the web page we defined in the script above. | ||
Line 60: | Line 62: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== Turn on autologin ===== | ===== Turn on autologin ===== | ||
1. Create the required directory with | 1. Create the required directory with: | ||
<syntaxhighlight lang="bash"> | |||
mkdir /etc/systemd/system/getty@tty1.service.d | |||
</syntaxhighlight> | |||
2. Create the '''''autologin.conf''''' file in /etc/systemd/system/getty@tty1.service.d and add the contents below. | 2. Create the '''''autologin.conf''''' file in the newly created '''''/etc/systemd/system/getty@tty1.service.d''''' directory and add the contents below. | ||
Note: Change '''''kiosk''''' below to the username that will be used for autologin if you are using something different (root is not recommended) | Note: Change '''''kiosk''''' below to the username that will be used for autologin if you are using something different (root is not recommended) | ||
Line 77: | Line 82: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Ensure this is enabled with | Ensure this is enabled with: | ||
<syntaxhighlight lang="bash"> | |||
systemctl status getty@tty1 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Line 93: | Line 101: | ||
└─776 /sbin/agetty -o "-p -- \\u" --noclear - linux | └─776 /sbin/agetty -o "-p -- \\u" --noclear - linux | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Run the following command if the service isn't enabled: | |||
<syntaxhighlight lang="bash"> | |||
systemctl enable getty@tty1 | |||
</syntaxhighlight> | |||
===== Set kiosk user .profile ===== | ===== Set kiosk user .profile ===== | ||
Change /home/kiosk/.profile to the contents below: | Change '''''/home/kiosk/.profile''''' to the contents below: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 144: | Line 158: | ||
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor | #[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== First Time Startup ==== | ==== First Time Startup ==== | ||
Now restart the SBC and it should automatically login as your kiosk user and stop at the command prompt. | Now restart the SBC and it should automatically login as your kiosk user and stop at the command prompt. | ||
===== Additional Configuration ===== | ===== Additional Configuration ===== | ||
If you need to do additional configuration for Chromium (install an autorefresh or other extension(s), change screen size, etc). then start the browser with | If you need to do additional configuration for Chromium (install an autorefresh or other extension(s), change screen size, etc). then start the browser with: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
startx | startx | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This will start the Chromium browser showing the address bar and menu where you can make the necessary adjustments. Once finished, press | This will start the Chromium browser displaying the URL you specified and showing the address bar and menu where you can make the necessary adjustments. Once finished, press '''''CTRL+ALT+BACKSPACE''''' to exit back to the command line. | ||
===== Finalize Configuration ===== | ===== Finalize Configuration ===== | ||
# Edit '''''/etc/xdg/openbox/autostart''''', commenting out the first instance of chromium and uncomment one of the lines that launches chromium in kiosk mode. | |||
# Edit '''''/home/kiosk/.profile''''' and uncomment the last line of the file. | |||
# Reboot. | |||
The SBC will boot up and launch Chromium to show the web page you specified. | The SBC will boot up and launch Chromium to show the web page you specified. | ||
=== Display with Remote Management=== | |||
This builds off the Display 1 setup with some additional features: | |||
* VNC using NOVNC. This allows remote control of the display via a web browser. | |||
* Loading message and time displayed. This uses OSDSH for the overlay. | |||
==== Software ==== | |||
Install the following additional packages: | |||
* osdsh | |||
* novnc | |||
* python3-websockify | |||
* python3-numpy | |||
* tigervnc-scraping-server | |||
* tigervnc-standalone-server | |||
* tightvncpasswd | |||
* tightvncserver | |||
* tigervnc-tools | |||
==== Setup ==== | |||
Make the following changes | |||
===== /etc/xdg/openbox/autostart ===== | |||
Replace the contents of this file with the following: | |||
Note: change '''''<URL TO VISIT>''''' to webserver URL you want to display. | |||
<syntaxhighlight lang="bash"> | |||
# | |||
# These things are run when an Openbox X Session is started. | |||
# You may place a similar script in $HOME/.config/openbox/autostart | |||
# to run user-specific things. | |||
# | |||
# If you want to use GNOME config tools... | |||
# | |||
#if test -x /usr/lib/aarch64-linux-gnu/gnome-settings-daemon >/dev/null; then | |||
# /usr/lib/aarch64-linux-gnu/gnome-settings-daemon & | |||
#elif which gnome-settings-daemon >/dev/null 2>&1; then | |||
# gnome-settings-daemon & | |||
#fi | |||
# If you want to use XFCE config tools... | |||
# | |||
#xfce-mcs-manager & | |||
#Start x0vncserver and serve up VNC on port localhost:5900 | |||
/usr/bin/x0vncserver -passwordfile /home/kiosk/.vnc/passwd -display :0 | |||
# If you want to use XFCE config tools... | |||
# | |||
#xfce-mcs-manager & | |||
# Disable any form of screen saver / screen blanking / power management | |||
xset s off | |||
xset s noblank | |||
xset -dpms | |||
# Allow quitting the X server with CTRL-ATL-Backspace | |||
setxkbmap -option terminate:ctrl_alt_bksp | |||
#Start websockify to proxy novnc to port 6080 using self-signed SSL cert and vnc on localhost:5900 | |||
/usr/bin/websockify -D --web=/usr/share/novnc/ --cert=/home/kiosk/novnc.pem --ssl-only 6080 localhost:5900 | |||
#Start OSDSH | |||
/usr/bin/osdsh -p 1 -a 1 -n 20 -c blue | |||
chromium-browser --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.25 '<URL TO VISIT>' & | |||
#Display to give a 15 second delay for initial page loading/rendering | |||
/usr/bin/osdctl -e "dset(f,helvetica)" | |||
/usr/bin/osdctl -e "dset(C,dark red)" | |||
dload="DISPLAY LOADING - ONE MOMENT" | |||
for LSET in 10 20 30 40 50 60 70 80 90 | |||
do | |||
/usr/bin/osdctl -b "$dload,$LSET" | |||
sleep 2 | |||
done | |||
/usr/bin/osdctl -b "LOADING DONE,100" | |||
sleep 5 | |||
#Set default color to cyan | |||
/usr/bin/osdctl -e "dset(C,cyan)" | |||
#Set clock to bottom of screen | |||
/usr/bin/osdctl -e "sclk(b)" | |||
#Set clock to center of screen | |||
/usr/bin/osdctl -e "sclk(c)" | |||
#set clock color to blue | |||
/usr/bin/osdctl -e "sclk(C,blue)" | |||
#Set clock font to courier new | |||
/usr/bin/osdctl -e "sclk(f,courier new)" | |||
#Set clock format | |||
/usr/bin/osdctl -e "clkf(%a %b %d %Y - %l : %M : %S %p)" | |||
sleep 1 | |||
#Run clock indefinitely | |||
/usr/bin/osdctl -c 1 | |||
#Loop to pause then press F5 in chromium for page refresh | |||
while true; do | |||
sleep 90 | |||
osdctl -s "Screen will refresh in 5 seconds" | |||
sleep 5 | |||
xdotool key F5 | |||
done | |||
</syntaxhighlight> | |||
===== Generate SSL certificate ===== | |||
* Navigate to the '''''/home/kiosk''''' user directory | |||
* Run the following command to generate a self-signed SSL certificate with a 10 year life span: | |||
<syntaxhighlight lang="bash"> | |||
openssl req -x509 -nodes -newkey rsa:3072 -keyout novnc.pem -out novnc.pem -days 3650 | |||
</syntaxhighlight> | |||
===== Generate VNC Password File ===== | |||
Run the following command to create the vnc password file (make note of this for later): | |||
<syntaxhighlight lang="bash"> | |||
vncpasswd | |||
</syntaxhighlight> | |||
===== Firewall ===== | |||
Edit (or create) the '''''/etc/rc.local''''' file and add/replace the contents with the following: | |||
<syntaxhighlight lang="bash"> | |||
#!/bin/bash | |||
#Firewall rules to block VNC to all but localhost for NOVNC access | |||
iptables -F log-and-drop | |||
iptables -X log-and-drop | |||
iptables -N log-and-drop | |||
# Specific chain used for logging packets before blocking them | |||
iptables -A log-and-drop -j LOG --log-prefix "[IPTables] Drop " | |||
iptables -A log-and-drop -j DROP | |||
iptables -A INPUT -p tcp --dport 5900 -j ACCEPT --src localhost | |||
iptables -A INPUT -p udp --dport 5900 -j ACCEPT --src localhost | |||
iptables -A INPUT -p tcp --dport 5900 -j log-and-drop | |||
iptables -A INPUT -p udp --dport 5900 -j log-and-drop | |||
</syntaxhighlight> | |||
* Enable systemd service to run rc.local at start | |||
<syntaxhighlight lang="bash"> | |||
systemctl enable rc-local | |||
</syntaxhighlight> | |||
* Make script executable | |||
<syntaxhighlight lang="bash"> | |||
chmod a+x /etc/rc.local | |||
</syntaxhighlight> | |||
==== First Time Startup ==== | |||
Restart the SBC to make sure it will boot up and start Chromium. | |||
==== Remote Access via NOVNC ==== | |||
You can manage the device by pointing a web browser at '''''https://<device IP>:6080''''' | |||
* When prompted accept the invalid certificate | |||
* Login to NOVNC using the password you created using vncpasswd | |||
= Miscellaneous = | |||
Sometimes things happen and the display will "get stuck" or lose internet connectivity. When this happens you have a few options: | |||
# Setup a nightly reboot event via crontab or systemd timers | |||
# Setup a watchdog to look for lost network connectivity and restart the system |
Latest revision as of 02:36, 23 February 2025
You can turn a RaspberryPi/Single Board Compter (SBC) into "digital signage" using open source tools and a few scripts.
Prerequisites
You will need a few prerequisites before this will work:
- A TV/Monitor (preferably mounted) to display content
- A RaspberryPi or similar SBC (I've also used LibreComputer LePotato SBC running Armbian)
- A webserver to serve up the content you want to show (preferably external to the SBC)
Basic Display
This is the most basic configuration you can use to turn a RaspberryPi/SBC into a digital sign/display that serves up a web page when started.
Software
You will need to install the following packages:
- openbox
- xdg (may already be installed, check for /etc/xdg/autostart)
- unclutter
- xinit
- xdotool
- chromium browser
- chromium driver
Setup
Do the following to setup the device to display the URL of your choice.
/etc/xdg/openbox/autostart
Replace the contents of this file with the following:
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms
# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp
# Start Chromium in kiosk mode
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
#comment this line below once chromium auto-refresh plugin is configured (requires menus hidden by code below), see also /home/pi/.proflie
#Change the '''''<url to display>''''' in the line below to the URL that you want shown
URL='<url to display>'
#First launch of Chromium to install extensions, adjust screen size, etc. Command out after first launch.
chromium $URL
#Uncomment one of the three options below once chromium auto-refresh plugin is configured
#Show URL page with 1.25x zoom
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.40 $URL
#Show URL page with (1.45x zoom):
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.45 $URL
#Show URL page 1.5x zoom
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.50 $URL
Add kiosk user
We will add a user called kiosk that will autologin and display the web page we defined in the script above.
Note: You can set the password to anything you want here since it will be ignored by the autologin configuration.
adduser kiosk
Turn on autologin
1. Create the required directory with:
mkdir /etc/systemd/system/getty@tty1.service.d
2. Create the autologin.conf file in the newly created /etc/systemd/system/getty@tty1.service.d directory and add the contents below.
Note: Change kiosk below to the username that will be used for autologin if you are using something different (root is not recommended)
[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin kiosk %I $TERM
[Install]
After=network-online.target
Wants=network-online.target
WantedBy=multi-user.target
Ensure this is enabled with:
systemctl status getty@tty1
● getty@tty1.service - Getty on tty1
Loaded: loaded (/lib/systemd/system/getty@.service; enabled; preset: enabled)
Active: active (running) since Wed 2025-02-19 17:07:45 PST; 29min ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
https://0pointer.de/blog/projects/serial-console.html
Main PID: 776 (agetty)
Tasks: 1 (limit: 2306)
Memory: 212.0K
CPU: 12ms
CGroup: /system.slice/system-getty.slice/getty@tty1.service
└─776 /sbin/agetty -o "-p -- \\u" --noclear - linux
Run the following command if the service isn't enabled:
systemctl enable getty@tty1
Set kiosk user .profile
Change /home/kiosk/.profile to the contents below:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
#
# Wait up to 30 seconds for network to come online before continuing for IP address
count=0
mcount=30
while [ "$(hostname -I)" = "" ]; do
echo -e "\e[1A\e[KNo network: $(date)"
sleep 1
let "count+=1"
[[ ${count} -gt ${mcount} ]] && exit 1
done
echo "* Network is online"
sleep 3
#Uncomment this line once chromium auto-refresh plugin is configured or if no additional configuration is needed.
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
First Time Startup
Now restart the SBC and it should automatically login as your kiosk user and stop at the command prompt.
Additional Configuration
If you need to do additional configuration for Chromium (install an autorefresh or other extension(s), change screen size, etc). then start the browser with:
startx
This will start the Chromium browser displaying the URL you specified and showing the address bar and menu where you can make the necessary adjustments. Once finished, press CTRL+ALT+BACKSPACE to exit back to the command line.
Finalize Configuration
- Edit /etc/xdg/openbox/autostart, commenting out the first instance of chromium and uncomment one of the lines that launches chromium in kiosk mode.
- Edit /home/kiosk/.profile and uncomment the last line of the file.
- Reboot.
The SBC will boot up and launch Chromium to show the web page you specified.
Display with Remote Management
This builds off the Display 1 setup with some additional features:
- VNC using NOVNC. This allows remote control of the display via a web browser.
- Loading message and time displayed. This uses OSDSH for the overlay.
Software
Install the following additional packages:
- osdsh
- novnc
- python3-websockify
- python3-numpy
- tigervnc-scraping-server
- tigervnc-standalone-server
- tightvncpasswd
- tightvncserver
- tigervnc-tools
Setup
Make the following changes
/etc/xdg/openbox/autostart
Replace the contents of this file with the following:
Note: change <URL TO VISIT> to webserver URL you want to display.
#
# These things are run when an Openbox X Session is started.
# You may place a similar script in $HOME/.config/openbox/autostart
# to run user-specific things.
#
# If you want to use GNOME config tools...
#
#if test -x /usr/lib/aarch64-linux-gnu/gnome-settings-daemon >/dev/null; then
# /usr/lib/aarch64-linux-gnu/gnome-settings-daemon &
#elif which gnome-settings-daemon >/dev/null 2>&1; then
# gnome-settings-daemon &
#fi
# If you want to use XFCE config tools...
#
#xfce-mcs-manager &
#Start x0vncserver and serve up VNC on port localhost:5900
/usr/bin/x0vncserver -passwordfile /home/kiosk/.vnc/passwd -display :0
# If you want to use XFCE config tools...
#
#xfce-mcs-manager &
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms
# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp
#Start websockify to proxy novnc to port 6080 using self-signed SSL cert and vnc on localhost:5900
/usr/bin/websockify -D --web=/usr/share/novnc/ --cert=/home/kiosk/novnc.pem --ssl-only 6080 localhost:5900
#Start OSDSH
/usr/bin/osdsh -p 1 -a 1 -n 20 -c blue
chromium-browser --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.25 '<URL TO VISIT>' &
#Display to give a 15 second delay for initial page loading/rendering
/usr/bin/osdctl -e "dset(f,helvetica)"
/usr/bin/osdctl -e "dset(C,dark red)"
dload="DISPLAY LOADING - ONE MOMENT"
for LSET in 10 20 30 40 50 60 70 80 90
do
/usr/bin/osdctl -b "$dload,$LSET"
sleep 2
done
/usr/bin/osdctl -b "LOADING DONE,100"
sleep 5
#Set default color to cyan
/usr/bin/osdctl -e "dset(C,cyan)"
#Set clock to bottom of screen
/usr/bin/osdctl -e "sclk(b)"
#Set clock to center of screen
/usr/bin/osdctl -e "sclk(c)"
#set clock color to blue
/usr/bin/osdctl -e "sclk(C,blue)"
#Set clock font to courier new
/usr/bin/osdctl -e "sclk(f,courier new)"
#Set clock format
/usr/bin/osdctl -e "clkf(%a %b %d %Y - %l : %M : %S %p)"
sleep 1
#Run clock indefinitely
/usr/bin/osdctl -c 1
#Loop to pause then press F5 in chromium for page refresh
while true; do
sleep 90
osdctl -s "Screen will refresh in 5 seconds"
sleep 5
xdotool key F5
done
Generate SSL certificate
- Navigate to the /home/kiosk user directory
- Run the following command to generate a self-signed SSL certificate with a 10 year life span:
openssl req -x509 -nodes -newkey rsa:3072 -keyout novnc.pem -out novnc.pem -days 3650
Generate VNC Password File
Run the following command to create the vnc password file (make note of this for later):
vncpasswd
Firewall
Edit (or create) the /etc/rc.local file and add/replace the contents with the following:
#!/bin/bash
#Firewall rules to block VNC to all but localhost for NOVNC access
iptables -F log-and-drop
iptables -X log-and-drop
iptables -N log-and-drop
# Specific chain used for logging packets before blocking them
iptables -A log-and-drop -j LOG --log-prefix "[IPTables] Drop "
iptables -A log-and-drop -j DROP
iptables -A INPUT -p tcp --dport 5900 -j ACCEPT --src localhost
iptables -A INPUT -p udp --dport 5900 -j ACCEPT --src localhost
iptables -A INPUT -p tcp --dport 5900 -j log-and-drop
iptables -A INPUT -p udp --dport 5900 -j log-and-drop
- Enable systemd service to run rc.local at start
systemctl enable rc-local
- Make script executable
chmod a+x /etc/rc.local
First Time Startup
Restart the SBC to make sure it will boot up and start Chromium.
Remote Access via NOVNC
You can manage the device by pointing a web browser at https://<device IP>:6080
- When prompted accept the invalid certificate
- Login to NOVNC using the password you created using vncpasswd
Miscellaneous
Sometimes things happen and the display will "get stuck" or lose internet connectivity. When this happens you have a few options:
- Setup a nightly reboot event via crontab or systemd timers
- Setup a watchdog to look for lost network connectivity and restart the system