#!/bin/bash #=========================================================================== # File playlastpi.sh # usage ./playlastpi.sh # Checks if files exist, and if so plays last compiled 12 note tune # generated by serialrpi.sh # Can be run in LXDE terminal with ./playlastpi.sh # Or from a remote ssh connection # Option quitbrowser FALSE or TRUE to control whether browser is shut at the end # Option prefbrowser selects browser to use, midori or netsurf # Written by Robin Newman, Aug 2013 #=========================================================================== quitbrowser=TRUE #forces browser to quit at end of script TRUE/FALSE prefbrowser=midori #select midori or netsurf #check if Desktop is running if [[ `pidof lxsession` = "" ]] then echo 'no desktop running on the Pi.startx & from this terminal, then rerun' exit else export DISPLAY=:0 #set display fi echo prefbrowser is $prefbrowser web=/tmp/tonerow.html midifile=/tmp/tonerow.midi if [ -f $web ] #check if webpage exists then if [ "$(pidof $prefbrowser)" ] #first kill existing browser if running then killall $prefbrowser fi echo Starting Web Browser if [ $prefbrowser = midori ] then $prefbrowser -e Fullscreen -a $web & else $prefbrowser file://$web & fi sleep 4 #allow time for web browser to open echo Playing midi file sleep 2 timidity $midifile &> /dev/null #play midi file #wait before killing browser sleep 2 if [ $quitbrowser = TRUE ] #then force browser to quit then killall $prefbrowser echo browser killed fi else echo "No $web so can't run" fi echo "Finished!" #------------ end of script -------------