#!/bin/sh
#
# Fix repeating on Dreambox 7025 so that it works with Logitech Harmony One.
#   -- Sami Haahtinen <ressu@ressukka.net>
# 
# Script is distibuted under Creative Commons Attribution-Noncommercial 1.0
# Finland license.
#  http://creativecommons.org/licenses/by-nc/1.0/fi/
#
#  You should be able to find the most recent version from
#  http://ressukka.net/2009/01/fix-repeat
#
# <2009-01-25 10:00>

# Repeat time (ms)
REPEAT=1150
REPEATHEX=$(printf %x $REPEAT)

case "$1" in
  start)
	echo $REPEATHEX > /proc/stb/ir/rc/repeat
	CUR=$(cat /proc/stb/ir/rc/repeat)
	CURI=$(printf "%d" 0x$CUR)
  	echo "Set repeat setting to: $CUR ($CURI ms)"
	;;
  stop)
  	# Do nothing
  	;;
  status)
	CUR=$(cat /proc/stb/ir/rc/repeat)
	CURI=$(printf "%d" 0x$CUR)
  	echo "Repeat is set to: $CUR ($CURI ms)"
  	;;
  install)
        if [ -e /proc/stb/ir/rc/repeat ]; then
	  cp $0 /etc/init.d/fix-repeat
	  chmod a+x /etc/init.d/fix-repeat
	  update-rc.d fix-repeat defaults
	  /etc/init.d/fix-repeat start
	else
	  echo "Your image doesn't have the required interface, sorry.."
	  echo "Neither does mine anymore either :("
	  exit 1
	fi
  	;;
  uninstall)
  	rm /etc/init.d/fix-repeat
  	update-rc.d fix-repeat remove
  	;;
  *)
  	echo "Usage: $0 start|stop|install|uninstall"
  	exit 1;
  	;;
esac
