X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=recipes%2Fpandora-system%2Fpandora-scripts%2Fop_bluetooth.sh;h=b63fe7601f43d722623527ed9e341916badac4a8;hb=d58ccf64c590090e5e8fae75f71f005147c6e3e2;hp=25fc72f913497ef8982627e60347b5e89bbcf901;hpb=2118d8379a1fd258f923ef79081bac15f9915ef7;p=openpandora.oe.git diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth.sh b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh index 25fc72f..b63fe76 100644 --- a/recipes/pandora-system/pandora-scripts/op_bluetooth.sh +++ b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh @@ -2,35 +2,36 @@ # # Released under the GPL -#if [ $1 ]; then -# startup = "$1" -# echo $ -# echo $1 -#fi - INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`" +LOCK=".op_btenabled" +cd "$HOME" -if [ ${1} = "startup" ]; then - [ -f ~/.op_btenabled ] && sudo /usr/sbin/hciconfig ${INTERFACE} up pscan && sudo /usr/sbin/bluetoothd ||echo "Bluetooth: User has not enabled Bluetooth." -else - +if [ "$1" = "startup" ]; then + [ -f "$LOCK" ] && sudo /usr/sbin/hciconfig "$INTERFACE" up pscan 1>/dev/null && sudo /usr/sbin/bluetoothd || echo "Bluetooth: User has not enabled Bluetooth." + +else # Figure out if Bluetooth is running or not - if [ "`hciconfig ${INTERFACE} | grep UP`" ] + if hciconfig "$INTERFACE" | grep UP &>/dev/null then - notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png - sudo /usr/sbin/hciconfig ${INTERFACE} down - rm ~/.op_btenabled + notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000 + sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null + sudo /usr/pandora/scripts/op_bluetooth_work.sh 0 + rm -f "$LOCK" else + if ! sudo /usr/pandora/scripts/op_bluetooth_work.sh 1; then + notify-send -u normal "Bluetooth" "Bluetooth error" -i blueman -t 3000 + exit 1 + fi + pgrep bluetoothd echo $INTERFACE if [ $? -ne 1 ]; then - notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png - sudo /usr/sbin/hciconfig ${INTERFACE} down - sudo /usr/sbin/hciconfig ${INTERFACE} up pscan - sudo /usr/sbin/bluetoothd - rm ~/.op_btenabled - echo true > ~/.op_btenabled + notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000 + sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null + sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null + sudo /usr/sbin/bluetoothd 1>/dev/null + touch "$LOCK" fi fi fi