The interface to my node application is a web-application. So I wantet do have the web-application started and running, whenever the pi is running. I am using a PiTFT 3.5" as interface to my pi.
Based on this article:
I use cromium because it is fully html5 compatible and it has a 'kiosk' mode.
Login as pi, and run the following commands to update and install chromium and tools:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install matchbox chromium-browser x11-xserver-utils ttf-mscorefonts-installer xwit sqlite3 libnss3
sudo reboot
Open /boot/config.txt:
sudo nano /boot/config.txt
Insert at the end of the file:
# 1900x1200 at 32bit depth, DMT mode disable_overscan=1 framebuffer_width=1900 framebuffer_height=1200 framebuffer_depth=32 framebuffer_ignore_alpha=1 hdmi_pixel_encoding=1 hdmi_group=2
Save and exit editor.
Open /etc/rc.local
sudo nano /etc/rc.local
Add to the file before "exit 0":
# Wait for the TV-screen to be turned on... while ! $( tvservice --dumpedid /tmp/edid | fgrep -qv 'Nothing written!' ); do bHadToWaitForScreen=true; printf "===> Screen is not connected, off or in an unknown mode, waiting for it to become available...\n" sleep 10; done; printf "===> Screen is on, extracting preferred mode...\n" _DEPTH=32; eval $( edidparser /tmp/edid | fgrep 'preferred mode' | tail -1 | sed -Ene 's/^.+(DMT|CEA) \(([0-9]+)\) ([0-9]+)x([0-9]+)[pi]? @.+/_GROUP=\1;_MODE=\2;_XRES=\3;_YRES=\4;/p' ); printf "===> Resetting screen to preferred mode: %s-%d (%dx%dx%d)...\n" $_GROUP $_MODE $_XRES $_YRES $_DEPTH tvservice --explicit="$_GROUP $_MODE" sleep 1; printf "===> Resetting frame-buffer to %dx%dx%d...\n" $_XRES $_YRES $_DEPTH fbset --all --geometry $_XRES $_YRES $_XRES $_YRES $_DEPTH -left 0 -right 0 -upper 0 -lower 0; sleep 1;
if [ -f /boot/xinitrc ]; then ln -fs /boot/xinitrc /home/pi/.xinitrc; su - pi -c 'startx' & fi
Save an exit file.
Create new file /boot/xinitrc
sudo nano /boot/xinitrc
Insert the following:
#!/bin/sh while true; do # Clean up previously running apps, gracefully at first then harshly killall -TERM chromium 2>/dev/null; killall -TERM matchbox-window-manager 2>/dev/null; sleep 2; killall -9 chromium 2>/dev/null; killall -9 matchbox-window-manager 2>/dev/null; # Clean out existing profile information rm -rf /home/pi/.cache; rm -rf /home/pi/.config; rm -rf /home/pi/.pki; # Generate the bare minimum to keep Chromium happy! mkdir -p /home/pi/.config/chromium/Default sqlite3 /home/pi/.config/chromium/Default/Web\ Data "CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); INSERT INTO meta VALUES('version','46'); CREATE TABLE keywords (foo INTEGER);"; # Disable DPMS / Screen blanking xset -dpms xset s off # Reset the framebuffer's colour-depth fbset -depth $( cat /sys/module/*fb*/parameters/fbdepth ); # Hide the cursor (move it to the bottom-right, comment out if you want mouse interaction) xwit -root -warp $( cat /sys/module/*fb*/parameters/fbwidth ) $( cat /sys/module/*fb*/parameters/fbheight ) # Start the window manager (remove "-use_cursor no" if you actually want mouse interaction) matchbox-window-manager -use_titlebar no -use_cursor no & # Start the browser (See http://peter.sh/experiments/chromium-command-line-switches/) chromium --app=http://URL.of.your/choice.html done;
Save and exit editor.
Reboot
sudo reboot