Wow this is cool. Works on Nokia 5300 Xpress Music.
Wow this is cool. Works on Nokia 5300 Xpress Music.
First of all: great program, great how-to! Genius idea: locking pc on bluetooth signal strength.
Instead of Amarok, I use Rhythmbox and I got it to work with Rhythmbox as well, so here's a little how-to for Rhythmbox.
- Make bash scripts
To be able to run multiple commands it is preferable to use a bash script. Let's make some, if you don't have already.
- Open up a terminal and execute the commands in the code blocks.
- Let's create a blueproximity directory in your home-dir.
Code:mkdir ~/.blueproximity- Create the bash files.
Code:touch ~/.blueproximity/lock.sh ~/.blueproximity/unlock.sh- Edit the lock file:
Code:gedit ~/.blueproximity/lock.sh- Insert the following code:
Code:#!/bin/bash # Lock the screen (default BlueProximity) gnome-screensaver-command -l # Let's pause Rhythmbox rhythmbox-client --pause --no-start- Save and exit Gedit
- Likewise for the unlock script:
Code:gedit ~/.blueproximity/unlock.sh- Insert the following code:
Code:#!/bin/bash # Unlock the screen (default BlueProximity) gnome-screensaver-command -d # Let's resume Rhythmbox rhythmbox-client --play --no-start- Save and exit Gedit
- Make the bash scripts executable (and readable) for everybody by using the following command
Code:chmod a+r+x ~/.blueproximity/lock.sh ~/.blueproximity/unlock.sh- Let Blueproximity use your bash scripts
- You can now close the terminal and open up the BlueProximity preferences (at tab Locking).
- Use as locking command ~/.blueproximity/lock.sh and likewise for the unlocking command ~/.blueproximity/unlock.sh.
Note: The --no-start option makes sure Rhythmbox does not open an instance when there is none. Otherwise, Rhythmbox will start when (un)locking when no instance is open. See also rhythmbox-client --help.
Other possible options for the rhythmbox-client command, see rhythmbox-client --help.
I can think of lowering the volume and bringing up again, in a for-loop to increase it smoothly. Or not pausing the music when your favourite artist is playing at the moment...
N.B. My phone, Nokia E50 works perfectly, at channel 9.
Last edited by gertvdijk; March 25th, 2008 at 02:25 AM.
Amazing App.. works flawlessly on my p1i.. had to use sdptool browse and find the object push channel which is channel 3 for p1i...
for those whom the application does nothing but change icon from green to red etc.. a simple reboot may or rather does solve the prob..
Great Work in puttin this tut Cheers
Theres no intelligence in the world without a touch of madness
I'm using Hardy beta, and blueproximity is in the universe repos now.
Q: How many ADD kids does it take to screw in a lightbulb?
A: Hey! Let's go ride bikes!
My BlackJack II works on channel 1.
If anyone is worried about cell phone battery life, you just have to turn the bluetooth off when you leave, and on when you get back. Not as "hands free" as it would be to leave it on, but cool none the less.
Is there a way to get this to enable my compiz screensaver? I'd prefer the cube rotating to the gnome screensavers.
Thanks for the tutorial.
Thanks for the scripts. It is a nice idea.
Only thing is that if Amarok is not running there will be a delay and an error message when the scripts interrogate its status.
I solved modifying the script in the following way:
Code:#!/bin/bash # amaroK info conky script amarok_on=`ps aux | grep amarokapp --count` if (($amarok_on > 1)); then stat=`dcop amarok player status` if (( $stat == 2 )); then `dcop amarok player playPause` else if (($stat == 1 ));then `dcop amarok player playPause` else if (($stat == 0 )); then echo amarok nok playing fi fi fi fi
Also, if you use skype you can set blueproximity to change skype status too.
In order to do that you first need to install a skype4Python wrapper from here.
Download the multiplatform tar.gz, uncompress it in a temporary folder then from that folder execute:
This will install the python wrapper. You can now remove that temporary folder.Code:sudo python setup.py install
Now you can download a series of very nice command line python scripts for skype from here.
Place them wherever you like; I chose a subfolder in my home.
Test that everything worked correctly moving to that folder and typing:
Skype will inform you that a third party program is trying to comunicate to him. Tell him to always accept incoming connection from it.Code:./change_availability.py AWAY
Then edit the bp_lock script adding these lines:
and of course the unlock script too:Code:#set skype status away `/home/gg/bp_scripts/skype_scripts/change_availability.py AWAY`
And there you go!Code:#set skype status online `/home/gg/bp_scripts/skype_scripts/change_availability.py ONLINE`
Here's the script I use now. It's a single, monolithic script that handles away, available, status update messages, and proximity "poking". I've put in lines for several audio players (GNOME; I don't use KDE), Twitter, Pidgin, and even a line to update my Out of Office status in Exchange via Outlook Web Access. Most things are in functions, and you can add your own functions and status checks for whatever audio programs or web services you use. It could probably use some further cleanup and tweaking, but it works and has some internal documentation.
Requirements:
purple-remote, to update Pidgin
zenity, for the status update dialog
curl, for sending updates to Twitter and Exchange
Again, I stick this in ~/bin, and set it executable. Oh, and if you run it in a shell with no parameters, it will display some help.
Code:#!/bin/bash # The away message away_msg="I'm testing my status script." # The available message available_msg="I am at my desk." # Send updates to chat programs and external websites? # Highly recommended to use a .netrc file for external websites exchange=1 exch_link="http://barracuda/exchange/NButterworth/?Cmd=options" twitter=1 pidgin=`pgrep pidgin` # stays null if it's not running # Tests for running audio applications. Add yours! if [ `pgrep vlc` ] then audio_player="vlc" elif [ `pgrep banshee` ] then audio_player="banshee" elif [ `pgrep exaile` ] then audio_player="exaile" elif [ `pgrep rhythmbox` ] then audio_player="rhythmbox" fi # Misc. variables DOC_REQUEST=70 : <<DOCUMENTATIONXX This script is used by BlueProximity (http://blueproximity.sourceforge.net/), and allows you to automatically set your current status as away or available. It will: * Toggle pause state of audio playback * Set your current status in Pidgin * Send updates to Twitter * Update your Microsoft Exchange Out-of-Office status via Outlook Web Access * Lock your desktop when away, and unlock it upon your return * Any other status-dependent changes to your desktop or applications It will also poke the screen saver when you're close, to keep it from activating and interrupting your work. Usage: btmon-status <status> where <status> is one of: * help -- This help text * away -- Set your status to away * available -- Set your status to available * update -- Set your status-to-be, when you will be away for a while * poke -- Keep your screen saver from activating --Nelson Butterworth, Apr 3 2008 nelson.butterworth@gmai.com DOCUMENTATIONXX # Function declarations pause_audio () # This function pauses whatever audio player is playing. Add yours! { player=$1 case $player in "vlc") if [ "x`echo status | nc localhost 9000 -q 1 | grep "play state: 1"`" != "x" ] then amixer set PCM 0 # vlc doesn't like to stream playback, at least not via the telnet pipe fi;; "exaile") exaile --play-pause;; *) $player --pause;; esac } resume_audio () # This function resumes whatever audio player is playing. Add yours! { player=$1 case $player in "vlc") if [ "x`echo status | nc localhost 9000 -q 1 | grep "play state: 1"`" != "x" ] then amixer set PCM 70% # vlc doesn't like to stream playback, at least not via the telnet pipe fi;; *) $player --play;; esac } update_status_msg () { # Display dialog to enter status location=`zenity --entry --title="Where am I?" --text="Current location: $1" --entry-text="I'm..."` # If text entry isn't null if [ -n "$location" ] then # Update away-status sed -e "3 s/away_msg=.*/away_msg=\"I\'m $location\.\"/" $0 > tmp mv --update tmp $0 chmod a+x $0 fi } # Connect to the web services of your choice, and set their statuses # Add your own functions for other web services update_twitter () { status="$1" curl --netrc --data status="$status" http://www.twitter.com/statuses/update.xml } update_pidgin () { status="$1" message="$2" purple-remote setstatus?status="$status" purple-remote setstatus?message="$message" } update_exchange () { case $1 in "away") status="1";; "available") status="0";; esac link="$2" message="$3" curl --netrc --ntlm --data OofState="$status" --data OofReply="$message" $link } case $1 in "away") # I've moved away if [ -n "$audio_player" ] then pause_audio "$audio_player" fi if [ $pidgin ] then update_pidgin "away" "$away_msg" fi if [ $twitter ] then update_twitter "$away_msg" fi if [ $exchange ] then update_exchange "away" "$exch_link" "$away_msg" fi # Lock desktop gnome-screensaver-command --activate ;; "available") # I'm back # Unlock desktop and wake monitor(s) gnome-screensaver-command --deactivate gnome-screensaver-command --poke if [ $exchange ] then update_exchange "available" "$exch_link" "$available_msg" fi if [ $pidgin ] then update_pidgin "available" "$available_msg" fi if [ $twitter ] then update_twitter "$available_msg" fi if [ "x$audio_player" != "x" ] then resume_audio "$audio_player" fi ;; "update") # Update my away status update_status_msg "$away_msg" ;; "poke") # Keep things awake when close-by gnome-screensaver-command --poke ;; *) # How to use echo sed --silent -e '/DOCUMENTATIONXX$/,/^DOCUMENTATIONXX$/p' "$0" | sed -e '/DOCUMENTATIONXX$/D' exit $DOC_REQUEST;; esac
Last edited by red_five; April 3rd, 2008 at 04:21 PM.
Hi red_five,
the script looks cool. I don't know how many people are using blueproximity so I don't know if it would be worth developing a gui to these additional functions. I am short of time at the moment anyway but I think I'll catch on later with this.
Thanks for contributing this nice script.
Bye
Lars
Doubt there would be much point cos its already simple enough. I would love to properly use this script but I just don't have any reason to....Maybe its good in an office environment but at home when the computer is off when I'm not on it, there's no reason for this.
Bookmarks