pandora-scripts and pandora-configtray: Moved Bluetooth into Wifi-packages as well
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts-wifi / 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         if [ -f "$LOCK" ]; then
11                 sudo /usr/pandora/scripts/op_bluetooth_work.sh 1
12                 INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
13                 sudo /usr/sbin/hciconfig "$INTERFACE" up pscan 1>/dev/null && sudo /usr/sbin/bluetoothd
14         else
15                 echo "Bluetooth: User has not enabled Bluetooth." 
16         fi
17 else    
18         # Figure out if Bluetooth is running or not
19         
20         if hciconfig "$INTERFACE" | grep UP &>/dev/null
21         then
22                 notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000
23                 sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
24                 sudo /usr/pandora/scripts/op_bluetooth_work.sh 0
25                 rm -f "$LOCK"
26         else
27                 if ! sudo /usr/pandora/scripts/op_bluetooth_work.sh 1; then
28                         notify-send -u normal "Bluetooth" "Bluetooth error" -i blueman -t 3000
29                         exit 1
30                 fi
31
32                 pgrep bluetoothd
33                 echo $INTERFACE
34                 if [ $? -ne 1 ]; then
35                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000
36                         sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
37                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null
38                         sudo /usr/sbin/bluetoothd 1>/dev/null
39                         touch "$LOCK"
40                 fi
41         fi
42 fi