omxplayer: added a shell wrapper to make dbus keybindings work (among others).

This commit is contained in:
Juan RP 2013-11-24 11:54:29 +01:00
parent 2e6f4c8919
commit cfe2638201
3 changed files with 104 additions and 3 deletions

View File

@ -60,6 +60,7 @@ clean:
install:
install -d $(DESTDIR)/usr/bin
install -Dm755 omxplayer.bin $(DESTDIR)/usr/bin/omxplayer
install -Dm755 omxplayer.sh $(DESTDIR)/usr/bin/omxplayer
install -Dm755 omxplayer.bin $(DESTDIR)/usr/bin

View File

@ -0,0 +1,100 @@
#!/bin/bash
#
# OMXPlayer wrapper script. Fixes some common issues.
#
# Author: Sergio Conde <skgsergio@gmail.com>
# License: GPLv2
#
OMXPLAYER_BIN="/usr/bin/omxplayer.bin"
OMXPLAYER_LIBS="/opt/vc/lib:/usr/lib/omxplayer"
refresh_regex='(|.* )(-r|--refresh)( .*|$)'
audio_regex='.*\.(mp3|wav|wma|cda|ogg|ogm|aac|ac3|flac)( .*|$)'
fbset_bin=`which fbset 2>/dev/null`
xset_bin=`which xset 2>/dev/null`
xrefresh_bin=`which xrefresh 2>/dev/null`
if [ -z $NOREFRESH ] || [ "$NOREFRESH" == "0" ]; then
if [[ $@ =~ $refresh_regex ]] && [[ ! $@ =~ $audio_regex ]]; then
check_failed=0
if [ -z $fbset_bin ]; then
echo "WARNING: You are going to run omxplayer with -r/--refresh and you don't have fbset installed, this can cause black screen when it finishes playing."
check_failed=1
fi
if [ ! -z $DISPLAY ]; then
if [ -z $xset_bin ] || [ -z $xrefresh_bin ]; then
echo "WARNING: You are going to run omxplayer with -r/--refresh and you don't have xset installed, this can cause black screen when it finishes playing."
check_failed=1
fi
fi
if [ "$check_failed" == "1" ]; then
read -sn 1 -p "Press any key to continue or Ctrl-C to quit."
echo
fi
fi
fi
OMXPLAYER_DBUS_ADDR=`mktemp -t omxplayer-XXXXX`
OMXPLAYER_DBUS_PID=`mktemp -t omxplayer-XXXXX`
exec 5> $OMXPLAYER_DBUS_ADDR
exec 6> $OMXPLAYER_DBUS_PID
dbus-daemon --fork --print-address 5 --print-pid 6 --session
DBUS_SESSION_BUS_ADDRESS=`cat $OMXPLAYER_DBUS_ADDR`
DBUS_SESSION_BUS_PID=`cat $OMXPLAYER_DBUS_PID`
export DBUS_SESSION_BUS_ADDRESS
export DBUS_SESSION_BUS_PID
LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN "$@"; true
if [ -n "$DBUS_SESSION_BUS_PID" ]; then
kill -2 "$DBUS_SESSION_BUS_PID"
fi
rm -f $OMXPLAYER_DBUS_ADDR
rm -f $OMXPLAYER_DBUS_PID
if [ ! -z $NOREFRESH ] && [ "$NOREFRESH" == "1" ]; then
exit 0
fi
if [[ $@ =~ $audio_regex ]]; then
exit 0
fi
if [[ $@ =~ $refresh_regex ]]; then
if [ ! -z $fbset_bin ]; then
DEPTH2=`$fbset_bin | head -3 | tail -1 | cut -d " " -f 10`
if [ "$DEPTH2" == "8" ]; then
DEPTH1=16
elif [ "$DEPTH2" == "16" ] || [ "$DEPTH2" == "32" ]; then
DEPTH1=8
else
DEPTH1=8
DEPTH2=16
fi
$fbset_bin -depth $DEPTH1 > /dev/null 2>&1
$fbset_bin -depth $DEPTH2 > /dev/null 2>&1
fi
if [ ! -z $xset_bin ] && [ ! -z $xrefresh_bin ]; then
if [ -z $DISPLAY ]; then
DISPLAY=":0"
fi
$xset_bin -display $DISPLAY -q > /dev/null 2>&1
if [ "$?" == "0" ]; then
$xrefresh_bin -display $DISPLAY > /dev/null 2>&1
fi
fi
fi

View File

@ -1,7 +1,7 @@
# Template file for 'omxplayer'
pkgname=omxplayer
_githash=9b52cee
version=20131123
version=20131124
revision=1
short_desc="Commandline OMX player for the Raspberry Pi (git ${_githash})"
maintainer="Juan RP <xtraeme@gmail.com>"
@ -22,7 +22,7 @@ do_fetch() {
}
pre_build() {
cp -f ${FILESDIR}/Makefile* .
cp -f ${FILESDIR}/* .
sed -e 's,/usr/share/fonts/truetype/freefont,/usr/share/fonts/TTF,g' -i omxplayer.cpp
mkdir -p /opt/vc/lib
sed -e "s|@CROSSBASE@|${XBPS_CROSS_BASE}|g" -i Makefile.include