Back in the GNOME 2.x days, device hotplug management was done entirely by Nautilus; you know, those dialogs that pop up when you plug your photo camera or your USB drive. This worked fine, as Nautilus was always running in the session, being it also the process drawing the desktop. The desktop itself provided a way to eject the devices, by right clicking on their icon and selecting the appropriate menu action.
In the 3.0 era Nautilus moved away from being a central component of the user experience, and if you used GNOME 3, you will have seen we actually dropped the desktop metaphor by default already; that unfortunately left us with no place to access the list of devices plugged into our machine; in fact, in 3.0 you have to open Nautilus manually to eject an USB drive. Also, the code for handling autorun notifications was moved to gnome-settings-daemon, which will trigger the old-style GTK+ dialog when a device is plugged in.
Clearly, we could do a lot better. A while ago I started a design whiteboard page to analyse the current state of the art in this area, and last week I finally sat with Jon thinking about the user experience we want to achieve here. You can read more about it in the tentative design section of the whiteboard page.
We decided to implement the feature with using notifications in gnome-shell
When a new device is plugged, the shell will trigger a notification (after having consulted the settings from the ‘Removable Media’ panel in gnome-control-center) containing a list of applications suitable for handling that device. This is similar to what we used to have in 2.x; if you plug in a blank optical disc, you will find “CD/DVD Creator” (Brasero) in that list, if you plug an iPod we’ll show “Rhythmbox” or your default music player, if you plug your photo camera Shotwell will be shown…you get the idea; you can also eject the device directly from the notification.
After you dismiss the notification, you will be able to access the list of your devices from the message tray, which will grow a ‘Removable Devices’ item as long as there’s at least one device connected to the system.
From this menu you can still activate the default autorun action by clicking on the device name/icon, or you can eject it, by clicking on the button on the right hand side. If the device cannot unmount, due to a file still open on it, we will show a nice dialog from where you can get to the application directly, or force unmount if you prefer.
One problem the 2.x implementation didn’t really tackle is what to do when generic drives (like, say, an external hard disk, or a random USB pendrive) were attached. I believe the default was just to run Nautilus in those cases, or worse, we would show a meaningless autorun dialog with no choices inside it.
In my new implementation, I wrote a small crawler program that gets DBus-activated by the mounter process (in this case the shell) and tries to gather as much information as it can about the content type of the files in the device. Of course, we don’t want to hammer your 2TB drive with a full scan, so the crawler has a hard time-limit not to do I/O for more than a fixed amount of time (I empirically found 1.5 seconds is a good value for this). The crawler doesn’t care about the specific mime type of the files (say, FLAC vs OGG) but rather what the file is about (say, Music vs. Video), so it will return a list of up to three “generic” mimetypes for the drive content, ordered by relevance; applications that claim to handle those generic mimetypes will appear in the notification. As a last fallback, if we don’ t have any of these applications available, we will show an entry to open the drive in Nautilus from the notification. This aims to integrate with the upcoming application design for Finding and Reminding.
I need to post my current iteration of the patchset for review, but I already have some further improvements and polish planned in the pipeline:
- we need to handle password-protected volumes (e.g. encrypted USB sticks) directly from the notification, e.g. having an entry there to unlock the device directly
- we probably want to show an entry in the device list if the laptop is plugged into a docking station. Clicking the eject button there would be equivalent to pushing the hardware button on the dock itself.
- we need to find a good story for fallback mode. I think we can just keep the current gnome-settings-daemon plugin in place, and activate it only if fallback mode is detected, but this is currently not implemented.