Thunar & browsing bluetooth devices

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
twolf

Thunar & browsing bluetooth devices

Post by twolf »

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 :wink:
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

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":

Code: Select all

<entry name="browse_command" mtime="1346626746" type="string">
		<stringvalue>thunar %d</stringvalue>
and replace it with the path where you saved the script (don't drop the final "%d"):

Code: Select all

<entry name="browse_command" mtime="1346626746" type="string">
		<stringvalue>/path/to/script %d</stringvalue>
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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Hi. I had this error:
/bin/fusermount: entry for /home/andres/Bluetooth-[B0:79:94:D3:D1:4C] not found in /etc/mtab
I can't see the device's files on the folder, which is empty.

Please help me! Thank you. Andres
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

Hi
When you click on "browse files on device", as soon as the new thunar window opens (if it does), please open a terminal and post the result of the following commands.

Code: Select all

mount

cat /etc/mtab

df

ls -l /home/andres/Bluetooth*

hcitool con

hcitool dev

cat /tmp/*.errors

dmesg
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Code: Select all

andres@Graziani-Lenovo ~ $ mount
/dev/sda7 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
/dev/sda8 on /home type ext4 (rw)
gvfsd-fuse on /run/user/andres/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=andres)

Code: Select all

andres@Graziani-Lenovo ~ $ cat /etc/mtab
/dev/sda7 / ext4 rw,errors=remount-ro 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev devtmpfs rw,mode=0755 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
tmpfs /run tmpfs rw,noexec,nosuid,size=10%,mode=0755 0 0
none /run/lock tmpfs rw,noexec,nosuid,nodev,size=5242880 0 0
none /run/shm tmpfs rw,nosuid,nodev 0 0
none /run/user tmpfs rw,noexec,nosuid,nodev,size=104857600,mode=0755 0 0
/dev/sda8 /home ext4 rw 0 0
gvfsd-fuse /run/user/andres/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,user=andres 0 0

Code: Select all

andres@Graziani-Lenovo ~ $ df
S.ficheros     1K-bloques    Usado Disponible Uso% Montado en
/dev/sda7        46445552  4604960   39481296  11% /
udev              1811400        4    1811396   1% /dev
tmpfs              728244     1100     727144   1% /run
none                 5120        0       5120   0% /run/lock
none              1820600      832    1819768   1% /run/shm
none               102400       12     102388   1% /run/user
/dev/sda8       120867996 16466028   98262220  15% /home

Code: Select all

andres@Graziani-Lenovo ~ $ ls -l /home/andres/Bluetooth*
ls: no se puede acceder a /home/andres/Bluetooth*: No existe el archivo o el directorio

Code: Select all

andres@Graziani-Lenovo ~ $ hcitool con
Connections:
	> ACL B0:79:94:D3:D1:4C handle 11 state 1 lm SLAVE AUTH ENCRYPT

Code: Select all

andres@Graziani-Lenovo ~ $ hcitool dev
Devices:
	hci0	7C:E9:D3:C3:6D:51

Code: Select all

andres@Graziani-Lenovo ~ $ cat /tmp/*.errors
cat: /tmp/*.errors: No existe el archivo o el directorio
dmesg: nothing about the device, the last line is about the web browser

the .errors file:
mkdir: falta un operando
Pruebe `mkdir --help' para más información.
fuse: missing mountpoint parameter

I also had problems using Nautilus, so I guess the trouble is my device.
Thank you. The codes are in spanish.
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

It seems the script fails from the start as no bluetooth device is mounted .

How did you set the variables filemanager and mountpoint at the beginning of the script ?

Bye
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

Sorry, also please post:

Code: Select all

cat $HOME/*.errors
Bye
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Hi. About the script, i did it just like you posted it.
#!/bin/bash
# Bluetooth browser
# Used by blueman according to ~/.gconf/apps/blueman/transfer/%gconf.xml
#

filemanager="/usr/bin/thunar"         # your file mamanger
mountpoint="/home/andres/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
And about the .errors file, I pasted it in the previous entry.

Code: Select all

cat $HOME/*.errors
mkdir: falta un operando
Pruebe `mkdir --help' para más información.
fuse: missing mountpoint parameter
(It's in Spanish)

Thank you!
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

Very strange...it seems to miss the variable $mountpoint in the mkdir command :shock:
Please insert:

Code: Select all

echo $1
echo $mountpoint
in the script just before the line "mkdir $mountpoint", try again and then post again $HOME/*.errors.

Please also post:

Code: Select all

cat $HOME/.gconf/apps/blueman/transfer/%gconf.xml
Bye
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Code: Select all

B0:79:94:D3:D1:4C

mkdir: falta un operando
Pruebe `mkdir --help' para más información.
fuse: missing mountpoint parameter

Code: Select all

cat $HOME/.gconf/apps/blueman/transfer/%gconf.xml
<?xml version="1.0"?>
<gconf>
	<entry name="opp_accept" mtime="1370153153" type="bool" value="true"/>
	<entry name="browse_command" mtime="1370384752" type="string">
		<stringvalue>/home/andres/bluetooth-thunar %d</stringvalue>
	</entry>
	<entry name="ftp_allow_write" mtime="1370384758" type="bool" value="false"/>
	<entry name="shared_path" mtime="1370385384" type="string">
		<stringvalue>/home/andres/Público</stringvalue>
	</entry>
	<entry name="ftp_enabled" mtime="1346088731" type="bool" value="true"/>
	<entry name="opp_enabled" mtime="1346088731" type="bool" value="true"/>
</gconf>
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

Very strange, the $1 variable (your bluetooth device id) is correctly evaluated while $mountpoint, based on $1, is not and is null, for some misterious bad sintax interpretation :shock:
I can only suggest to try to code it in different ways and then run the script again (keeping the echo commands and posting every time the errors).
First try to code it in the exact way I do, with bash command substitution, as it works fine with me:

Code: Select all

mountpoint="/home/`whoami`/Bluetooth-$1"
Then you could also try:

Code: Select all

mountpoint="/home/andres/Bluetooth"-$1
(I moved the " )

In the end you can try to use no variable. This is less smart as you can't browse more devices together, but is the cleanest way to code the mountpoint:

Code: Select all

mountpoint="/home/andres/Bluetooth"
Let me know.
Bye
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Hi. With `whoami`:

Code: Select all

B0:79:94:D3:D1:4C

mkdir: falta un operando
Pruebe `mkdir --help' para más información.
fuse: missing mountpoint parameter
With the second line:

Code: Select all

B0:79:94:D3:D1:4C

mkdir: falta un operando
Pruebe `mkdir --help' para más información.
fuse: missing mountpoint parameter
I think it is the same error code.

Then, the same thing happens with the last code.

Thanks for help, but I think the problem is my device. I just tried Linux Mint 15, and I could browse it with Nautilus.
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

Maybe...
Anyway I'm happy you solved your issue.
If you want to try again by Thunar (I don't like Nautilus) let me know, I had another card to play.
Bye
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Yes, I want to use Thunar. I did't install the new Mint 15 because I want the XFCE version. I think I'll wait for now :(

I can't access the mass storage of my phone neither.
twolf

Re: Thunar & browsing bluetooth devices

Post by twolf »

We could try doing step by step what my script should do to understand where exactly the problem is.
So open a terminal and do as in my followng example.

1) Try to see if your device is visible. My phone in this example has id FC:E5:57:67:B7:DF :

Code: Select all

wolf@wolf-laptop ~ $ hcitool scan
Scanning ...
	FC:E5:57:67:B7:DF	Wolf
2) You should be able to set up the device (if not already done): click on Blueman applet icon and select "Setup new Device", associate it and then make it trusted, you should finally have the "safe" and "star" icons near it.

3) Now make a directory in your home folder using your device id and check the permissions:

Code: Select all

wolf@wolf-laptop ~ $ mkdir /home/`whoami`/Bluetooth-FC:E5:57:67:B7:DF
wolf@wolf-laptop ~ $ ls -l | grep tooth
drwxr-xr-x  2 wolf wolf  4096 giu 17 23:14 Bluetooth-FC:E5:57:67:B7:DF
4) Find the channel. In my example is 10.

Code: Select all

wolf@wolf-laptop ~ $ sdptool search --bdaddr "FC:E5:57:67:B7:DF" FTP | awk '/Channel:/ {print $2}'
10
5) Give the obexfs command using your device id, your channel and your directory and then check if the device is connected:

Code: Select all

wolf@wolf-laptop ~ $ /usr/bin/obexfs -b FC:E5:57:67:B7:DF -B 10 -- /home/`whoami`/Bluetooth-FC:E5:57:67:B7:DF
wolf@wolf-laptop ~ $ hcitool con
Connections:
	< ACL FC:E5:57:67:B7:DF handle 11 state 1 lm MASTER AUTH ENCRYPT
6) Finally I explore the device:

Code: Select all

wolf@wolf-laptop ~ $ thunar /home/`whoami`/Bluetooth-FC:E5:57:67:B7:DF
Tell me which step fails and why.

To disconnect correctly after this procedure:

Code: Select all

wolf@wolf-laptop ~ $ /bin/fusermount -u -z /home/`whoami`/Bluetooth-FC:E5:57:67:B7:DF
Bye
AndresG

Re: Thunar & browsing bluetooth devices

Post by AndresG »

Thanks for the reply, but I've just installed Linux Mint 15 and now I have no problem with my device. I don't know why.... Maybe it was that my device was not supported by the previous edition, or maybe the kernel.

Anyway, thank you.
Locked

Return to “Xfce”