|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Managed to resolve the issues with, but will leave this here anyway, as its a good fallback |
| 4 | +CHROME_STARTED=`ps -ef | grep google-chrome | grep -v "grep" | wc -l` |
| 5 | +if [ $CHROME_STARTED -gt 0 ]; then |
| 6 | + exit 1; |
| 7 | +fi |
| 8 | + |
| 9 | +# lets find out if irxevent and xdotool actually exist before we try to call them. |
| 10 | +command -v irxevent >/dev/null 2>&1 |
| 11 | +IRXEVENT=$? |
| 12 | +command -v xdotool >/dev/null 2>&1 |
| 13 | +XDOTOOL=$? |
| 14 | + |
| 15 | +if [ $IRXEVENT -eq 0 ]; then |
| 16 | + killall irxevent >/dev/null 2>&1 |
| 17 | +fi |
| 18 | + |
| 19 | +# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in |
| 20 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 21 | + |
| 22 | +if [ $# -eq 2 ]; then |
| 23 | + url="https://www.netflix.com/SwitchProfile?tkn=$2&nextpage=https%3A%2F%2Fwww.netflix.com%2FWiPlayer%3Fmovieid%3D$1" |
| 24 | +else |
| 25 | + url="http://www.netflix.com/WiPlayer?movieid=$1" |
| 26 | +fi |
| 27 | + |
| 28 | +# notice the ampersand to send google chrome into back ground so that the script continues and we execute the xdotool below |
| 29 | +/usr/bin/google-chrome --start-maximized --disable-translate --disable-new-tab-first-run --no-default-browser-check --no-first-run --kiosk "$url" & |
| 30 | +CHROME_PID=$! |
| 31 | + |
| 32 | +if [ $IRXEVENT -eq 0 ]; then |
| 33 | + # run irxevent as a daemon so that we can call xdotool |
| 34 | + irxevent -d $DIR/netflix.lirc & |
| 35 | +else |
| 36 | + echo "irxevent is not installed, can't do remote control" |
| 37 | +fi |
| 38 | + |
| 39 | +if [ $XDOTOOL -eq 0 ]; then |
| 40 | + # no point sleeping if xdotool is not installed. |
| 41 | + sleep 5 |
| 42 | + xdotool mousemove 9999 9999 click 1 |
| 43 | +else |
| 44 | + echo "xdotool is not installed, can't remove cursor" |
| 45 | +fi |
| 46 | + |
| 47 | +# wait for google-chrome to be killed before killing irxevent below. This only works if we execute irxevent as a daemon, otherwise |
| 48 | +# the script would never finish. |
| 49 | +wait $CHROME_PID |
| 50 | + |
| 51 | +if [ $IRXEVENT -eq 0 ]; then |
| 52 | + killall irxevent >/dev/null 2>&1 |
| 53 | +fi |
0 commit comments