LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 09-15-2011, 04:35 AM   #1
devdol
Member
 
Registered: Dec 2005
Distribution: debian (testing/unstable)
Posts: 47

Rep: Reputation: 17
Smile Firefox/Iceweasel workaround: "Open containing folder" with user defined filemanager


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:
Code:
 PATH=~/bin:$PATH
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.
 
Old 09-16-2011, 04:51 AM   #2
Cultist
Member
 
Registered: Feb 2010
Location: Chicago, IL
Distribution: Slackware64 14.1
Posts: 775

Rep: Reputation: 101Reputation: 101
why go to all this trouble when you can just use edit > preferences > applications to select your preferred file manager?
 
Old 09-16-2011, 06:04 AM   #3
devdol
Member
 
Registered: Dec 2005
Distribution: debian (testing/unstable)
Posts: 47

Original Poster
Rep: Reputation: 17
Question

For those two major reasons:

* I would expect these to work in the browsers web context , but not in the "open containing folder" dialog, which is somewhat separate (other words: browsing the web, not the local filesystem). If it was not, I would expect the usual "open with <select...>"-Option, which is missing, too.

* There is no entry for "folder", "directory", "inode", "file" (or the respective localized phrases). However, if a file browser could be configured, and nautilus was just a default, I would expect an entry for nautilus. Which isn't there.

Anyhow, have you managed to do so?
 
Old 09-16-2011, 02:32 PM   #4
Cultist
Member
 
Registered: Feb 2010
Location: Chicago, IL
Distribution: Slackware64 14.1
Posts: 775

Rep: Reputation: 101Reputation: 101
If you're talking about when you right-click a download and it says Open Folder, you just go to that menu and pick your file manager next to the File entry (choosing Use Other if necessary to find the executable for your file manager).

I might be misunderstanding what you're trying to do with this though, or maybe its fixing an issue that isn't present in Slackware (guessing that you use debian).
 
Old 09-19-2011, 06:30 AM   #5
devdol
Member
 
Registered: Dec 2005
Distribution: debian (testing/unstable)
Posts: 47

Original Poster
Rep: Reputation: 17
> ... and it says Open Folder, you just go to that menu and pick your file manager next to the File entry ...


You are right: There is *no* such "Other"option available or "Open with...", just "Öffnen" ("Open", which starts an application associated with a certain file type), "Beinhaltenden Ordner anzeigen" ("Open containing folder", which obviously is a hard coded call to nautilus on Linux versions of Firefox) and four further, but not relevant context menu items.

For further clarification, I'll attach screenshots from Debian, openSuSE and Ubuntu 11-4.

(The only way you use do is: open a containing folder in nautilus, go to its parent folder, "open" this by "with..." (using nautilus' own context menu) with e.g. konqueror, close nautilus and re-enter the subfolder you came from in konqueror. But that's a quite toilsome procedure, isn't it?)
Attached Images
File Type: png DownloadsContextMenu-debian.png (9.8 KB, 6 views)
File Type: png DownloadsContextMenu-openSuSE.png (9.6 KB, 4 views)
File Type: png DownloadsContextMenu-Ubuntu.png (26.8 KB, 4 views)
 
Old 12-08-2011, 02:04 PM   #6
studpenguin
Member
 
Registered: Nov 2003
Location: Pacific Northwest United States
Posts: 262

Rep: Reputation: 32
Quote:
Member

Registered: Feb 2010
Location: I'm not even sure.
Distribution: Slackware64 13.37 multilib
Posts: 570

Rep: Reputation: 52

why go to all this trouble when you can just use edit > preferences > applications to select your preferred file manager?

Because I've also discovered after going
Quote:
edit > preferences > applications
I have to click on the
Quote:
[Content Type]
column until I find
Quote:
"file"
and then click
Quote:
"use nautilus"
under the
Quote:
[Action type]
column.

Last edited by studpenguin; 12-08-2011 at 02:23 PM.
 
  


Reply

Tags
downloads, file manager, firefox, iceweasel, nautilus


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one "zip" a folder with Linux .? How does Windows user "unzip" same ? brjoon1021 Linux - Software 5 12-19-2010 12:10 AM
[SOLVED] Firefox's "Open Containing folder" option not working ! RazorT4 Linux - Software 8 10-03-2010 07:36 AM
Application select for firefox "open folder containing" Jeff91 Linux - Software 1 07-07-2009 01:14 PM
Iceweasel 3.0.5 hotmail not working until changing "general.useragent.extra.firefox" jimdaworm Debian 7 05-06-2009 07:26 PM
firefox "offsite is not defined"?? wezhousheng Linux - Software 2 10-08-2005 09:16 PM


All times are GMT -5. The time now is 04:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration