Skip to content

Instantly share code, notes, and snippets.

@wturnerharris
Created January 20, 2015 20:35
Show Gist options
  • Save wturnerharris/7acd8fffa41d4c759d59 to your computer and use it in GitHub Desktop.
Save wturnerharris/7acd8fffa41d4c759d59 to your computer and use it in GitHub Desktop.
X initialization script. This configures matchbox, resets chrome profile data, instructs the framebuffer to conform to explicit configuration, and starts an instance of chromium.
#!/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;
echo "Chrome and Matchbox terminated";
sleep 2;
killall -9 chromium 2>/dev/null;
killall -9 matchbox-window-manager 2>/dev/null;
echo "Final termination of Chrome and Matchbox";
# Clean out existing profile information
echo "Removing old pi config...";
rm -rf /home/pi/.cache;
rm -rf /home/pi/.config;
rm -rf /home/pi/.pki;
# Generate the bare minimum to keep Chromium happy!
echo "Generating Chomium config...";
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
echo "Starting xset with opts...";
xset -dpms
xset s off
# Reset the framebuffer's colour-depth
echo "Resetting the framebuffer's 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)
echo "Moving cursor to bottom right...";
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)
echo "Starting matchbox...";
matchbox-window-manager -use_titlebar no -use_cursor no &
# Start the browser (See http://peter.sh/experiments/chromium-command-line-switches/)
echo "Starting chromium...";
# The url to your kiosk web app
chromium --app=http://www.google.com/
done;
@wturnerharris
Copy link
Author

Note that the url at the end of the script should be your own web app url, which should at least be accessible via your Pi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment