#!/bin/bash

BAT=0

BAT=`hcitool lq $1 2> /dev/null |awk -F: 'BEGIN {RS="\n";FS=":"} /Link/{printf $2}' |sed -e s/\ //g`

scriptpath=`echo $0 |sed -e s/get_bt_ico//`


if [ "$BAT" = "Not connected." ] || [ "$BAT" = "" ]; then
		# may be disabled
		# not loaded
		# not connected
		hciname=`hcitool dev 2> /dev/null |awk -F: 'BEGIN {RS="\n";FS=" "} /hci/ {printf $1}'`
		#echo  ${scriptpath}get_bt_enabled

	if [ "$hciname" = "" ]; then
			# ok not loaded or disabled
			hciany=`hciconfig 2> /dev/null`
			if [ "$hciany" = "" ]; then
				echo "bluetooth_none"
			else
				echo "bluetooth_hci0_off"
			fi
			
			exit
		else
			# enabled:
		echo bluetooth_${hciname}
		exit
	fi
fi
	
	if  test  $BAT -gt 220 ; then
		if  test  $BAT -gt 230 ; then
			if  test  $BAT -gt 240 ; then
				if  test  $BAT -gt 250 ; then
						echo "bluetooth_100"
				else
						echo "bluetooth_75"
				fi
			else
						echo "bluetooth_50"
				fi
		else
						echo "bluetooth_25"
		fi
	else
						echo "bluetooth_00"
	fi

