Under the impression of loosing some really important data because of a damaged partition table
on a USB flash drive I am developing a backup strategy for my system.
I know myself and so I decided that I need to automate this. While trying to figure out how
one can run a script as soon as a specific drive is mounted, I came across
DeviceKit. It’s the planned
replacement of HAL and is used in
Ubuntu Karmic. Udev is not an option for me, because I don’t want to mess around with
mounting myself (and I hate running stuff as root…).
So here is what I found out about using DBus and DeviceKit in Python:
The DBus API of DeviceKit is documented here.
Now we want to be notified when a drive is mounted:
A typical output when a flash drive is plugged in looks like this:
Device /org/freedesktop/DeviceKit/Disks/devices/sdc was added
Device /org/freedesktop/DeviceKit/Disks/devices/sdc1 was added
Device /org/freedesktop/DeviceKit/Disks/devices/sdc1 was changed
With this knowledge I’m currently working on a little python script that runs in background
and executes a shell script when a file system is mounted. I’ll post it, when it’s finished :-)