Wednesday 26 September 2007

Sending files in Gnome via bluetooth

Gnome's bluetooth support is still a "work in progress"! To send files via bluetooth, you may or may not have a menu option. If not, heres a quick script to drop in your nautilus-scripts folder.
#!/bin/sh

TMPFILE=`/bin/mktemp`

hcitool scan | grep -v Scanning > ${TMPFILE}
if [ $? -eq 1 ]; then
zenity --error --text="Couldn't scan for devices"
rm ${TMPFILE}
exit
fi

zenity --list --text="Choose a recipient" --column Address --column Name `cat ${TMPFILE}` > ${TMPFILE}

DEST=`cat ${TMPFILE}`

if [ -z ${DEST} ]; then
zenity --error --text="No recipient selected"
rm ${TMPFILE}
exit
fi

for i in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
gnome-obex-send -d `cat ${TMPFILE}` "$i"
done

rm ${TMPFILE}

  • Make this directory, if it doesn't exist:
    mkdir -p ~/.gnome2/nautilus-scripts
  • Save the text above into a file "~/.gnome2/nautilus-scripts/send-via-bluetooth"
  • make it executable:
    chmod u+x ~/.gnome2/nautilus-scripts/send-via-bluetooth
  • Now right-click on any file (or group of files) in nautilus, and you should see a scripts> option. Under scripts, select "send-via-bluetooth"
Notes:
  • You will need hcitool (part of bluez-utils)
  • You need zenity (a gnome package)
  • When sending lots of files, the "Sending" dialog keeps popping up under your mouse. Not ideal!
Feel free to email me if you have any questions or improvements.

No comments:

 
Copyright 2009 Another Blog. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan