You are not logged in.

#1 2009-06-08 19:50:20

keegan
Member
Registered: 2009-05-12
Posts: 54

Listing bluetooth devices for conky

I've been working on a script for my conky to display a list of connected bluetooth devices. I'm very new to scripting and it took me all night to get this working. It will only display the first 3 devices connected, by name, using hcitool. Is there an easier way to accompolish this? I'm worried my script wastes a lot of cycles, and i think the command 'hcitool name' causes quite a bit of traffic, possibly using more power than it should. Here's the script I have so far:

#/bin/sh
mac=$(hcitool con|sed -n /[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]/p | awk '{print $3}')
mac1=$(echo $mac | awk '{print $1}')
mac2=$(echo $mac | awk '{print $2}')
mac3=$(echo $mac | awk '{print $3}')

if [ "$mac1" != "" ] ; then
echo "Bluetooth devices:"
hcitool name $mac1
#hcitool rssi $mac1 | awk '{print $4}'
fi

if [ "$mac2" != "" ] ; then
hcitool name $mac2
#hcitool rssi $mac2 | awk '{print $4}'
fi

if [ "$mac3" != "" ] ; then
hcitool name $mac3
#hcitool rssi $mac3 | awk '{print $4}'
fi

Offline

Board footer

Powered by FluxBB