Install Instructions

 Kiosk

**Instructions for Pi 3B+ that has 1GB of RAM**

Install the stock Raspian Image (Current Version: 2018-10-09-raspbian-stretch aka "Raspbian Stretch with Desktop")

Enable SSH, Change  Overscan, Increase video RAM options

sudo raspi-config
Interfacing Options > SSH > YES > OK
Advanced Options > Expand Filesystem > Select [*press Enter*] > OK
Advanced Options > Overscan > NO > OK
Advanced Options > Memory Split > 512 > OK
Finish > YES to Reboot 

From console type "ip addres" to get the pi's current address then run the rest of the commands from a remote SSH connection. 

Installation
sudo apt -y --purge remove libreoffice* python-pygame minecraft-pi emacs emacs24 geany scratch scratch2 sonic-pi wolfram-engine
sudo apt -y clean
sudo apt -y autoremove
sudo apt update
sudo apt upgrade -y
sudo apt -y install nmap whois rsync screen minicom unclutter xdotool
sudo rpi-update
sudo reboot

Kiosk Mode:

Image:

wget https://www.iconfinder.com/icons/416410/download/png/512 -O /home/pi/Pictures/advertising-icon.png

Browser:
Open the browser and disable all extensions which may cause an issue with Kiosk mode. 

Settings (three vertical dots) > More tools > Extensions > Uncheck all Enable boxes

Startup Scripts:

Open the configuration file pertaining to the GUI display manager and turn off the screen sleep. Add to the [Seat:*] section.

sudo nano /etc/lightdm/lightdm.conf     
xserver-command=X -s 0 -dpms

Declare the required variables in the session environment of the picked user(s). Add to the end of the file. 
sudo nano /home/pi/.bashrc

sudo echo -e "\nexport DISPLAY=:0 \nexport XAUTHORITY=/home/pi/.Xauthority" >> /home/pi/.bashrc

Back to CLI, edit the file responsible for automatic command/process submission upon boot (for the user(s) of your choice)
mkdir -p /home/pi/.config/lxsession/LXDE-pi
nano /home/pi/.config/lxsession/LXDE-pi/autostart


@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@chromium-browser --kiosk --incognito http://front.mjns.it
@xset s noblank
@xset s off
@xset -dpms
@unclutter -idle 0
 One liner, just replace the address "front.mjns.it"
echo -e "@lxpanel --profile LXDE-pi\n@pcmanfm --desktop --profile LXDE-pi\n@xscreensaver-no-splash\n@point-rpi\n@chromium-browser --kiosk --incognito http://front.mjns.it\n@xset s noblank\n@xset s off\n@xset -dpms\n@unclutter -idle 0" > /home/pi/.config/lxsession/LXDE-pi/autostart

* FROM THIS POINT ON FOR BEST RESULTS RUN ALL "ONE LINERS" AS ROOT USER *

Desktop Launcher: https://www.iconfinder.com/icons/416410/ad_ads_advertisement_advertising_icon 

sudo nano /etc/xdg/menus/frontstreet-applications.menu

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
  <!-- Front Street -->
  <Menu>
    <Name>Front Street Tools</Name>
    <Directory>frontstreet.directory</Directory>
    <Include>
       <Category>frontstreet</Category>
    </Include>
  </Menu> 
  <!-- End Front Street -->

 One liner, just replace the address "front.mjns.it"
sudo echo -e '<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"\n"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">\n<!-- Front Street -->\n<Menu>\n<Name>Front Street Tools</Name>\n<Directory>frontstreet.directory</Directory>\n<Include>\n<Category>frontstreet</Category>\n</Include>\n</Menu> \n<!-- End Front Street -->\n' > /etc/xdg/menus/frontstreet-applications.menu

sudo nano /usr/share/desktop-directories/frontstreet.directory

[Desktop Entry]
Name=Front Street Tools
Icon=/home/pi/Pictures/advertising-icon.png
Type=Directory
 One liner
sudo echo -e '[Desktop Entry]\nName=Front Street Tools\nIcon=/home/pi/Pictures/advertising-icon.png\nType=Directory' > /usr/share/desktop-directories/frontstreet.directory

sudo nano /usr/share/applications/frontstreet-dashboard.desktop

[Desktop Entry]
Type=Application
Name=Front Street Kiosk
Exec=/usr/bin/chromium-browser --kiosk --incognito http://front.mjns.it
Icon=/home/pi/Pictures/advertising-icon.png
Terminal=false
StartupNotify=false
Type=Application
Categories=frontstreet
Comment=Launch Front Street
 One liner
sudo echo -e '[Desktop Entry]\nType=Application\nName=Front Street Kiosk\nExec=/usr/bin/chromium-browser --kiosk --incognito http://front.mjns.it\nIcon=/home/pi/Pictures/advertising-icon.png\nTerminal=false\nStartupNotify=false\nType=Application\nCategories=frontstreet\nComment=Launch Front Street' > /usr/share/applications/frontstreet-dashboard.desktop

Desktop Icon: sudo nano /home/pi/Desktop/frontstreet-dashboard.desktop

[Desktop Entry]
Type=Link
Name=Front Street Kiosk
Icon=/home/pi/Pictures/advertising-icon.png
URL=/usr/share/applications/frontstreet-dashboard.desktop
 One liner
sudo echo -e "[Desktop Entry]\nType=Link\nName=Front Street Kiosk\nIcon=/home/pi/Pictures/advertising-icon.png\nURL=/usr/share/applications/frontstreet-dashboard.desktop" > /home/pi/Desktop/frontstreet-dashboard.desktop

As the root user (sudo -i) Edit /boot/config.txt and add

echo -e "\n#Disable Warning Overlays and allow turbo mode\navoid_warnings=2" >> /boot/config.txt

Just in case the Pi does not turn off or reboots we refresh the screen as if we pressed ctrl+f5 using xdotool

* AS "pi" USER

nano /home/pi/refresh.sh

#!/bin/bash
export DISPLAY=":0"
WID=$(xdotool search --onlyvisible --class chromium|head -1)
xdotool windowactivate ${WID}
xdotool key ctrl+F5
 One liner
echo -e '#!/bin/bash\nexport DISPLAY=":0"\nWID=$(xdotool search --onlyvisible --class chromium|head -1)\nxdotool windowactivate ${WID}\nxdotool key ctrl+F5' > /home/pi/refresh.sh

Edit your crontab to make this auto-magic:

crontab -e

0 */12 * * * DISPLAY=:0 /home/pi/refresh.sh
chmod +x /home/pi/refresh.sh

Modify System Menu

cd /usr/share/applications 
sudo rm Thonny* sense_emu_gui.desktop idle* display-im6.q16.desktop rp_prefapps.desktop debian-reference-common.desktop
cd /usr/share/raspi-ui-overrides/applications/
sudo rm magpi.desktop idle* python-games.desktop debian-reference-common.desktop geany.desktop raspi_getstart.desktop help.desktop raspi_resources.desktop python-games.desktop
  • Set desktop background: *MUST BE DONE FROM THE CONSOLE TERMINAL AS "pi" USER NOT A REMOTE TERMINAL CONNECTION* 
  • YOU MAY NEED TO USE THE "exit" COMMAND
pcmanfm -w /home/pi/Pictures/advertising-icon.png --wallpaper-mode=center

Change system password from its default by using the passwd" command.

 Local Web Server

I host all ads on a local web server that shares the same network as the kiosk/display (raspberry pi) and Roku TV. This makes it faster to download on first load and saves bandwidth. Along with this I use a script ran from a cron job to turn the screens on and off at a specified time. 

**For some reason I dont want to research now. The first line will uninstall the GUI.** 

sudo apt -y install apache2 php7.1 php-memcache php-curl php7.1-sqlite3 libapache2-mod-php php-cli php-json apache2-utils git-all
apt install dbus-user-session gvfs gvfs-backends gvfs-daemons gvfs-fuse libpam-systemd lightdm lxde lxde-core lxpolkit lxsession lxsession-logout openbox-lxde-session packagekit pi-package pi-package-session pipanel piwiz policykit-1 raspberrypi-ui-mods rp-prefapps systemd-sysv udisks2
cd /var/www/html
sudo git clone https://github.com/mjnshosting/FrontStreet.git
sudo chown www-data:www-data -R /var/www/html/FrontStreet
sudo nano /etc/apache2/sites-available/000-default.conf
sudo service apache2 restart

Change DocumentRoot to the following:

DocumentRoot /var/www/html/FrontStreet/interface

In browser go to <server name/IP>/8_4o

Example: htp://localhost/8_4o


cd ~
mkdir -p .local/bin

nano .local/bin/roku_power_cycle.sh

#!/bin/bash
Pn='PowerOn'
Pf='PowerOff'
#Array of devices by ip address
declare -a arr=("192.168.2.6" "192.168.2.7")

for devices in "${arr[@]}"
       do (
                TV="http://$devices:8060/keypress/"
                case $1 in
                        -po)
                                curl -d '' $TV$Pn
                                ;;
                        -pf)
                                curl -d '' $TV$Pf
                                ;;
                esac
        )
        done
PATH=/home/mjns/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#On at 7AM
0 7 * * * roku_power_cycle.sh -po
#Off at 11PM
0 23 * * * roku_power_cycle.sh -pf