15 May 2010

Accessing Obex Mobile Device with KDE4 file manager

Categories:  Mobile  Gentoo  KDE  Linux

How to force KDE4 file managers to access mobile device via bluetooth using Obex protocol

In KDE 3.5 we had a great feature which was letting us easily access the mobile phone file system and browse and copy any file to it and from it using Bluetooth and Obex protocol. Unfortunately this feature is not available for kbluetooth standard KDE4 bluetooth access tool, mostly because the kioslaves for obex are not available for KDE4 file managers. As kbluetooth is still in heavy development I'm sure sooner or later this feature will be added, unfortunately I need it now. The simplest way to solve this problem would be install part of GNOME environment including nautilus file manager which has this support. I don't like GNOME and I don't want half of it on my computer just to perform such a trivial task. I found a better solution and I will try to share it here.

My solution requires you to install obex userspace filesystem utility. All the instructions, here were tested and performed by me on my Gentoo Linux system, but they should be applicable to any Linux distribution. All you need to change is use your distribution specific install command instead of Gentoo Linux emerge. I didn't have any problems accessing my mobile devices this way but I can not guarantee your mobile devices will work the same, so if you are following me remember you are doing this on your own risk. I assume you have bluetooth services and device properly configured on your Linux if not visit a bluetooth how to for your distribution. I hope you will find belows information useful.

First thing we need to do is to install obex userspace filesystem support. If you don't have userspace filesystem utilities (it's hard to believe you don't have it) they will be pulled as dependencies. In Gentoo Linux we would install them these way:

emerge -av sys-fs/obexfs

Those utilities will let you mount any bluetooth device filesystem with simple command. Instead of calling the command by hand we will write a simple script witch will do the job for us. I named the script obex_mount.sh

View the script source
  1. #!/bin/sh
  2. MOUNTPOINT="/tmp/${USER}-${1}"
  4. #Create mount directory
  5. mkdir ${MOUNTPOINT}
  6. #Mount the device
  7. obexfs -b ${1} ${MOUNTPOINT}
  8. sleep 5
  9. /usr/bin/krusader --left ${HOME} --right ${MOUNTPOINT}
  10. #/usr/bin/dolphin ${MOUNTPOINT}
  11. #Unmount the device
  12. fusermount -u ${MOUNTPOINT}
  13. sleep 5
  14. #Remove mount directory
  15. rmdir ${MOUNTPOINT}

As you can see the script is quite simple. You should save the script somewhere from where you will be able to easily call it. I copied the script to /usr/local/bin. You need to make sure that script is executable, you can do it like these:

chmod +x /usr/local/bin/obex_mount.sh

The script is accepting one parameter which is bluetooth device address. Here you can see example of usage:

./obex_mount.sh 1C:DC:EA:43:C1:41

When you will call the script the script will create a mount directory with the name cobined of your user name and bluetooth device address. Next it will mount the device using obexfs command. As you can see I'm using sleep command to make sure the mount process will finish. Then the script is calling krusader twin panel file manager which should opened your home catalog in left panel and device mount directory in right one. If you don't have krusader installed and you don't want to use it you can comment this line and uncoment the line calling dolphin instead. In fact you can create your own file manager command if you like to. When you will finish working with the device and you close the file manager, the script will unmout the device wait a moment to make sure the unmounting process will finish and in the end it will delete the mount catalog.

We can call the script when we like from the command line but I found a better way to do it. Why because checking and passing the bluetooth device hardware address to script is quite painful. Instead of using the script directly I use a simple bluetooth GUI manager called Blueman. It's a GTK application but fortunately not highly depended on GNOME graphical desktop environment. At the moment this application is offering better features then the kbluetooth application. If you don't have blueman in your system you should installed it. In Gentoo we would do this this way:

echo net-wireless/blueman >> /etc/portage/package.keywords
emerge -av  net-wireless/blueman

When you will start up the blueman in your system you should see it's icon in the system tray, right click it and choose Local Services. Consult the belows screenshot:

Blueman Local Services

When the Local Services Settings window will open expand the Advanced in Transfer Settings and provide call to our script in the text field like this:

/usr/local/bin/obex_mount.sh %d

Make sure you will save the settings before leaving the window, if you are unsure consult the belows screenshot:

Blueman Local Services

Now you should be able to browse your mobile device filesystem in your favorite filemanager just by right clicking on it's icon in Blueman device browser utility. Now the access is easy isn't it. You can take a look at belows screenshot to see the prove that this is working.

Blueman Device Manager

As a last thing I will add a warning don't try to open the files (photos, movies or sound files) directly from your mobile. I would recommend you to copy them to your computer before opening. This should prevent problems. Remember not all bluetooth connections are fast enough to let you view your files directly.

Script I use is also available on my svn server, you can access it by following this link.


If you have found something wrong with the information provided above or maybe you just want to speak your mind about it, feel free to leave a comment.
All comments will show up on page after being approved. Sorry for such policy but I want to make sure that my site will be free of abusive or vulgar content. I don't mind being criticized just do it using right words.

Leave a comment