#! /bin/sh

# Description:              Manage a Wiimote
#
# Depend: wminput, bluetooth
#
# $1: Wiimote mode
#   ir:  infrared
#   acc: accelerometer
#   off: turn off

# Wiimote MAC's address
mac="00:21:BD:07:A9:B1"

case "${1}" in
  ir )
    sudo /etc/init.d/bluetooth restart
    sudo wminput -c ir_ptr ${mac}
    echo "Activation of Wiimote in InfraRed";;

  acc )
    sudo /etc/init.d/bluetooth restart
    echo "Activation of Wiimote in accelerometer";;

  off )
    sudo /etc/init.d/bluetooth stop
    echo "by =)";;

  * )
    echo "Bad argument"
    echo "use, wiimote [ir, acc, off]"
    exit 1;;
esac

exit 0