op_bluetooth.sh, op_cpusettings.sh, op_cpuspeed.sh: Added notice that these won't...
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_bluetooth.sh
1 #!/bin/sh
2 #
3 # Released under the GPL
4
5 INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
6 LOCK=".op_btenabled"
7 cd "$HOME"
8
9 if [ "$1" = "startup" ]; then
10         [ -f "$LOCK" ] && sudo /usr/sbin/hciconfig "$INTERFACE" up pscan 1>/dev/null && sudo /usr/sbin/bluetoothd || echo "Bluetooth: User has not enabled Bluetooth." 
11
12 else    
13         # Figure out if Bluetooth is running or not
14         
15         if hciconfig "$INTERFACE" | grep UP &>/dev/null
16         then
17                 notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000
18                 sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
19                 rm -f "$LOCK"
20         else
21              kernel_major=`uname -r | cut -c 1`
22              if [ "$kernel_major" = "3" ]; then
23                 zenity --info --title="Bluetooth not supported" --text "Sorry, the experimental kernel does not support Bluetooth (yet).\n\nIt could not be enabled."
24               exit 1
25              else
26                 pgrep bluetoothd
27                 echo $INTERFACE
28                 if [ $? -ne 1 ]; then
29                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000
30                         sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
31                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null
32                         sudo /usr/sbin/bluetoothd 1>/dev/null
33                         touch "$LOCK"
34
35                 fi
36         fi
37     fi
38 fi