copyright 1998-2018 by Mark Verboom
ipv6 ready RSS Feed Schakel naar Nederlands

Go back to What's new

Rox-filer automatic media mount

To blog index

Friday, 14 January, 2011

Rox-filer automatic media mount

I really like a desktop that uses as few resources as possible, but has most of the features I use. I've been using Rox-filer for quite a few years now. I don't use it much as a file manager, but I do like it when folders appear on my desktop when I insert a removable device. However, that doens't work out of the box with Rox-filer.

There can be some information found on the web on how to do this. I've put my version that I use below.

As all other articles, this is based on a Debian system, but will probably work fine on other distribution. You will need halevt to process the mount events and pmount to allow the user to mount the devices.

sudo apt-get install halevt pmount

Add you username to the plugdev group.

sudo usermod -G plugdev <your username>

In your homedirectory make a .halevt directory.

mkdir .halevt

You need to add two files to it. The xml file describes which action to take when a device is mounted. There is an action added to call an extra script to do some work. The other file is called icons. Basically it is a placeholder for the administration of which icons are displayed on the desktop and at what position. Download both files below.

<a href="20110114.0/halevt.xml">halevt.xml</a>
<a href="20110114.0/icons">icons</a>

Next you need two scripts. The first one is run when a new device is added and is called rox-plug. It will update the administration on where the icon should be placed on the desktop and instruct Rox-filer to place the icon on the desktop. The second script is the eject command, which will try to eject the requested device and if successful remove the icon from the desktop through the rox-plug script.

The rox-plug script has a few variable which control the script. They are:

  • BASEX and BASEY
These are the coordinates on the screen where the first icon is placed.

  • AXIS
This is either x or y and indicates the axis on which the following icons will be placed. So either a vertical or horizontal row of icons.

  • XSPACING or YSPACING
The space to use (in pixels) between the icons. Ofcourse the variable used depends on the value of AXIS.

I put both scripts in a bin directory in my homedir. Scripts can be downloaded below.

<a href="20110114.0/rox-plug">rox-plug</a>
<a href="20110114.0/eject">eject</a>

What I usually do is start halevt from my .xsession script which takes care of all the other stuff I need running for a session. The following lines should suffice.

if [ "`pgrep -u $USERNAME halevt`" = "" ]
then
PATH=~/bin:$PATH halevt > /dev/null 2>&1
fi

There is one more thing you might want to check. On Debian the system wide halevt.xml configuration tries to do a chown all files to the user halevt. If you don't like this (I don't) edit the system wide config file and remove the chown parts.

sudo vi /etc/halevt/halevt.xml

If you have changed the system wide configuration, restart halevt to activate the configuration.

sudo /etc/init.d/halevt restart

Now start halevt under your userid. You can either login again or start it manually.

halevt

Test it out by plugging in a removable device. I tested this with my WD Passport, and see the following icons appear.

You can now click the icon (or double click depending on your Rox-filer configuration) and browse the disk.

Ofcourse you can also use a terminal to go to the specific mountpoint :).

If you right click the icon you can choose eject to unmount the partition. If there are any problems unmounting (for example device is busy because someone is still using the filesystem) and error window will appear.

Basically that's it. Pretty straightforward and lightweight :)