Skip to content

Instantly share code, notes, and snippets.

@LongHairedHacker
Created March 10, 2013 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LongHairedHacker/5130022 to your computer and use it in GitHub Desktop.
Save LongHairedHacker/5130022 to your computer and use it in GitHub Desktop.
omxplayer script for raspberry pi with better signal handling
#!/bin/bash
OMXPLAYER_BIN="/usr/bin/omxplayer.bin"
OMXPLAYER_LIBS="/opt/vc/lib:/usr/lib/omxplayer"
FBSET="/bin/fbset"
if [ -e $FBSET ]; then
DEPTH2=`fbset | head -3 | tail -1 | cut -d " " -f 10`
if [ "$DEPTH2" == "8" ]; then
DEPTH1=16
elif [ "$DEPTH2" == "16" ]; then
DEPTH1=8
elif [ "$DEPTH2" == "32" ]; then
DEPTH1=8
else
DEPTH1=8
DEPTH2=16
fi
fi
LD_LIBRARY_PATH=$OMXPLAYER_LIBS:$LD_LIBRARY_PATH $OMXPLAYER_BIN "$@" &
OMXPID=$!
#echo $OMXPID > /tmp/omxplayer.pid
trap "kill $OMXPID" INT TERM
wait
if [ -e $FBSET ]; then
fbset -depth $DEPTH1 && fbset -depth $DEPTH2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment