op_tvout: never use zero width/height
[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                 sudo /usr/pandora/scripts/op_bluetooth_work.sh 0
20                 rm -f "$LOCK"
21         else
22                 if ! sudo /usr/pandora/scripts/op_bluetooth_work.sh 1; then
23                         notify-send -u normal "Bluetooth" "Bluetooth error" -i blueman -t 3000
24                         exit 1
25                 fi
26
27                 pgrep bluetoothd
28                 echo $INTERFACE
29                 if [ $? -ne 1 ]; then
30                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000
31                         sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
32                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null
33                         sudo /usr/sbin/bluetoothd 1>/dev/null
34                         touch "$LOCK"
35                 fi
36         fi
37 fi