Although many proposals can be found to be able to open download folders with a file manager of user's choice (e.g. via "xdg-open file:///path/to/the/dir/" ),
nautilus still seems hard coded in the linux versions of Firefox (a.k.a. "Iceweasel" in Debian).
You may find dozens of clues, how someone at some time managed to achieve that ... ranging from
gconf-editor over
mimeTypes.rdf and/or
defaults.list (each of them on system or per user level),
mimeinfo.cache to
about:config. But at present (Firefox 6.0.2) none of them works, apart from the most brutal workaround, which replaces /usr/bin/nautilus by a link to /usr/bin/konqueror.
But at least in a multi-user environments that is inflexible, too, and above all will only work until the next update.
Therefore, as long as Mozilla won't change anything, it seems preferable to prepend $PATH with some user defined folder. For example. in ~/.bashrc define:
In that folder, (~/bin in the example above) create a textfile, name it (exactly) "
nautilus" and don't forget to make it executable, e.g. by
Code:
chmod u+x ~/bin/nautilus
From now on, for your account this script will be invoked instead of /usr/bin/nautilus. This way it is able to check each time, whether it runs "on behalf of firefox", and if so, start a file manager of your choice, else the real /usr/bin/nautilus. Apart from what one might expect, in the first case the process ID (PID) from the calling (parent) process (which is easily available as $PPID) is not firefox's PIS, but "1" - hence we don't even have to find out the browser's PID. Firefox's requests for nautilus are additionally distinct by including a "--no-desktop" option. However, in particular on a machine with a non-GNOME-desktpo where nautilus is unlikely to be run by the user, this should not need further testing ,-)
Then we just have to extract the "containing folder", which shows up by the user defined "%c" and replace any enquoted blanks and special characters, as most file managers won't deal with them. Fortunately again, bash can to that for us even without external tools (like
sed).
Finally, nothing detains us from opening the download folder with a file manager of our own choice; as a user of KDE this is likely to be dolphin, konqueror or krusader. Konqueror can even be forced into a certain layout using the "--profile" option (called "downloads" in the example below).
At last, now for the example,
~/bin/nautilus:
Code:
#!/bin/bash
PARENTNAME=$(ps -eo "%p %c" | grep $PPID | cut -f2 --delimiter=" ")
if [ "$PPID" -eq "1" ]
then
PARENTFOLDER=$(ps -eo "%p %a" | grep nautilus | grep no-desktop | head -n1 | sed 's/^.*file:\/\///') # This is likely to contain URL-encoded strings
PARENTFOLDER="$(echo -ne ${PARENTFOLDER//%/\\x})" # ${STRING//search/replace} replaces URL-Encoded strings (%xx) by their respective \xHH notation, which "echo -e" replaces with the appropriate character
konqueror "$PARENTFOLDER" --profile downloads &
else
/usr/bin/nautilus &
fi
Have fun! And any improvement suggestions will be appreciated below.