Thunar & browsing bluetooth devices
Posted: Wed Jan 02, 2013 9:12 pm
The aim of this post is helping some newbies to save their time in solving the following issue in a fast and instant way, avoiding my efforts.
As known, XFCE edition comes with Thunar as the file manager and Blueman as the bluetooth applet.
As less known, trying to browse files on a bluetooth device will fail because the obex protocol is NOT supported by Thunar.
So you have two options:
a) installing and using a supported file manager, for example Nautilus, but you might not want it if we suppose you love XFCE edition also because of Thunar
b) using a lighter homemade workaround. The core is using fuse-obexfs and the web is generous of ideas about it, but you have to "assemble" them all to build a quick and friendly solution, which I didn't find. So here is mine:
1) Save somewhere and make executable my homemade script:
2) Set Blueman to use that script instead of the usual file manager: opening with a text editor the file ~/.gconf/apps/blueman/transfer/%gconf.xml search the following entry named "browse_command":
and replace it with the path where you saved the script (don't drop the final "%d"):
The script uses fusermount tool to mount the chosen device in your home directory in a new folder called using the device bluetooth adress (for example "Bluetooth-00:80:98:24:15:6D") and opens it in a new file manager window.
Then once a minute a check is done if the device is still connected/accessible: if not, unmount and folder removal are performed.
Errors, if any, are reported in a text file called (for example) 00:80:98:24:15:6D.errors in your home folder.
Hoping it will be useful, any better solutions and comments are welcome.
Long live the penguin.
As known, XFCE edition comes with Thunar as the file manager and Blueman as the bluetooth applet.
As less known, trying to browse files on a bluetooth device will fail because the obex protocol is NOT supported by Thunar.
So you have two options:
a) installing and using a supported file manager, for example Nautilus, but you might not want it if we suppose you love XFCE edition also because of Thunar
b) using a lighter homemade workaround. The core is using fuse-obexfs and the web is generous of ideas about it, but you have to "assemble" them all to build a quick and friendly solution, which I didn't find. So here is mine:
1) Save somewhere and make executable my homemade script:
Code: Select all
#!/bin/bash
# Bluetooth browser
# Used by blueman according to ~/.gconf/apps/blueman/transfer/%gconf.xml
#
filemanager="/usr/bin/thunar" # your file mamanger
mountpoint="/home/`whoami`/Bluetooth-$1" # mount point for bluetooth device
cat /dev/null > /tmp/$1.log
(
[[ -d $mountpoint ]] && /bin/fusermount -u -z $mountpoint && rmdir $mountpoint
mkdir $mountpoint
channel=`/usr/bin/sdptool search --bdaddr "$1" FTP | /usr/bin/awk '/Channel:/ {print $2}'`
/usr/bin/obexfs -b $1 -B $channel -- $mountpoint && $filemanager $mountpoint
) >> /tmp/$1.log 2>&1
[[ `cat /tmp/$1.log | wc -l` -gt 0 ]] && cp /tmp/$1.log ~/$1.errors
while [ "`/usr/bin/hcitool con | grep $1 | wc -l`" -gt 0 ]
do
sleep 60
done
/bin/fusermount -u -z $mountpoint && rmdir $mountpoint
Code: Select all
<entry name="browse_command" mtime="1346626746" type="string">
<stringvalue>thunar %d</stringvalue>
Code: Select all
<entry name="browse_command" mtime="1346626746" type="string">
<stringvalue>/path/to/script %d</stringvalue>
Then once a minute a check is done if the device is still connected/accessible: if not, unmount and folder removal are performed.
Errors, if any, are reported in a text file called (for example) 00:80:98:24:15:6D.errors in your home folder.
Hoping it will be useful, any better solutions and comments are welcome.
Long live the penguin.