Turn programs on and off with Bluetooth in Ubuntu

15 03 2009

Having recently been messing around with ZoneMinder for home security, I wanted to turn on and off the program using Bluetooth. Basically, the idea being that when I am around, the server will sense my presence (no Darth Vadar jokes please ;)) via the Bluetooth on my phone and turn off ZoneMinder. Then, if I leave the location of the server, it will no longer be able to sense Bluetooth on my phone and thus will turn on ZoneMinder.

So, I hunted around for such a program, I came across bluemon and BlueProximity, but they both only worked on proximity, i.e. they relied on you being near by, as far as I could tell, there was no option of running an action when the phone was completely unavailable.

So, I decided to write my own script to do what I wanted. Now, bear in mind I have very little skill when it comes to Bash and scripting and what I wrote was a result of trial and error. It all revolves around a tool called hcitool that can be used in Linux to control Bluetooth connections.

The first attempt at my script can be found here and with another link below.

It is only designed to work with ZoneMinder and there isn’t much advice within the code, but I shall update it as time goes by to make it more useful ๐Ÿ˜‰

Here is the full link to the script:

bluetoothscan

Advertisements

Actions

Information

4 responses

15 04 2009
Biggs

how would i get it to run?

11 05 2009
prupert

If the file is saved as say bluetoothscan.sh and then saved in say /home/user/bluetoothscan.sh then to run the file, you first navigate to the folder where the file is, via the command line, so type in a Terminal:

cd /home/user

Then to run the script, you need to type the following in a Terminal:

./bluetoothscan.sh

You might need superuser privalages to run it, so in this case you type:

sudo ./bluetoothscan.sh

You can also set up a cron job to run it every five minutes or so, by editing /etc/crontab

23 07 2009
Lars Friedrichs

Hi,

I am somewhat puzzled that you cannot do what you describe with BlueProximity. There are “lock” and “unlock” commands.

As I am the author I would like to know what my program is missing so I can make it better.

Bye
Lars

31 07 2009
prupert

Hey Lars

Thanks for dropping by. To be honest, it might have been a case of BlueProximity being TOO good. It was a while ago now, but I think I found that the program had too many options, most of them seemed to relate to the proximity of the phone, rather than simply there being an simple On/Off choice. I guess I just found the interface and options a little confusing and couldn’t work out how to do exactly what I wanted to do with it. This was most likely me being dumb, rather than any problems with your program. And in any case, it gave me an excuse to learn a little bit more about Bash, something I have been keen to learn for a long while, so it was a good learning experience for me.

So, in the end, your program is very powerfull, but it did too many things. I just wanted to do one simple thing, run a command if the phone is not found, and then run another when it is.

Hope that sheds some light on the reasons for my little script ๐Ÿ˜‰

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s