b195a7d38c2a7c4944936ccbcd2978e0e7d64e29
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_bluetooth.sh
1 #!/bin/sh
2 #
3 # Released under the GPL
4
5 STARTUP=0
6
7 if [ ${1} = startup ]; then
8  STARTUP=1
9 fi
10
11 INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
12
13 if [ ${STARTUP} = 1 ]; then
14         [ -f ~/.op_btenabled ] && sudo /usr/sbin/hciconfig ${INTERFACE} up pscan && sudo /usr/sbin/bluetoothd ||echo "Bluetooth: User has not enabled Bluetooth." 
15 else
16
17         # Figure out if Bluetooth is running or not
18         
19         if [ "`hciconfig ${INTERFACE} | grep UP`" ]
20         then
21                 notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i /usr/share/icons/hicolor/32x32/apps/bluetooth.png
22                 sudo /usr/sbin/hciconfig ${INTERFACE} down
23                 rm ~/.op_btenabled
24         else
25                 pgrep bluetoothd
26                 if [ $? -ne 1 ]; then
27                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i /usr/share/icons/hicolor/32x32/apps/bluetooth.png
28                         sudo /usr/sbin/hciconfig ${INTERFACE} down
29                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan
30                         sudo /usr/sbin/bluetoothd
31                         rm ~/.op_btenabled
32                         echo true > ~/.op_btenabled
33                 fi
34         fi
35 fi