I writing a script that mounts and unmounts several USB devices quickly. When a new device is mounted, Ubuntu, by default, opens up a file browser window for that device. That behavior gets very annoying when it is mounting multiple devices.
I looked online, and found a tutorial explaining how to disable that feature through the gui (http://www.liberiangeek.net/2010/09/disableenable-auto-mount-ubuntu-10-0410-10-maverick-meerkat/) , but I wish to find a way to do that from within the script.
This is how I am currently mounting the devices:
def mount_all(self):
paths = self._get_partitions()
vfat_path = paths[0][0]
vfat = self.sysbus.get_object(SD.udisks_bus, vfat_path)
vfat_props = dbus.Interface(vfat, dbus_interface=SD.prop_bus)
if vfat_props.Get(vfat_path, 'DeviceIsMounted'):
self.fat = vfat_props.Get(vfat_path, 'DeviceMountPaths')[0]
else:
while True:
try:
self.fat = vfat.FilesystemMount('vfat', {}, dbus_interface=SD.device_bus)
break
except dbus.exceptions.DBusException:
time.sleep(0.1)
This turned out to be way simpler than I had thought. You can edit the .gconf properties with the tool
gconftool-2as explained here