Merge branch 'master' of git://git.openpandora.org/openpandora.oe
[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
7 if [ ${1} = "startup" ]; then
8         [ -f ~/.op_btenabled ] && sudo /usr/sbin/hciconfig ${INTERFACE} up pscan && sudo /usr/sbin/bluetoothd ||echo "Bluetooth: User has not enabled Bluetooth." 
9 else
10         
11         # Figure out if Bluetooth is running or not
12         
13         if [ "`hciconfig ${INTERFACE} | grep UP`" ]
14         then
15                 notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png
16                 sudo /usr/sbin/hciconfig ${INTERFACE} down
17                 rm ~/.op_btenabled
18         else
19                 pgrep bluetoothd
20                 echo $INTERFACE
21                 if [ $? -ne 1 ]; then
22                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png
23                         sudo /usr/sbin/hciconfig ${INTERFACE} down
24                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan
25                         sudo /usr/sbin/bluetoothd
26                         rm ~/.op_btenabled
27                         echo true > ~/.op_btenabled
28                 fi
29         fi
30 fi