#!/bin/sh

# A very conservative approach to setting bluetooth input on/off

user=`whoami`
if [ $user != "root" ]; then
   echo "You need to run this as root."
   exit 1
fi
 
case "$1" in
on)
   sed 's/network,input,hal/network,hal/' /etc/bluetooth/main.conf > /etc/bluetooth/main-input-on.conf
#   cp /etc/bluetooth/main.conf /etc/bluetooth/main.conf~
   mv /etc/bluetooth/main-input-on.conf /etc/bluetooth/main.conf
   stop bluetoothd
   start bluetoothd
   ;;
off)
   sed 's/network,hal/network,input,hal/' /etc/bluetooth/main.conf > /etc/bluetooth/main-input-off.conf
#   cp /etc/bluetooth/main.conf /etc/bluetooth/main.conf~
   mv /etc/bluetooth/main-input-off.conf /etc/bluetooth/main.conf
   stop bluetoothd
   start bluetoothd
   ;;
*)
   echo "Usage: $0 {on|off}"
   exit 1
   ;;
esac