Turn programs on and off with Bluetooth in Ubuntu

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

Tags: , , ,

Sunday, March 15th, 2009 How To, Linux, Scripts

4 Comments to Turn programs on and off with Bluetooth in Ubuntu

  1. how would i get it to run?

  2. Biggs on April 15th, 2009
  3. 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

  4. prupert on May 11th, 2009
  5. 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

  6. Lars Friedrichs on July 23rd, 2009
  7. 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 ;)

  8. prupert on July 31st, 2009

Leave a comment