Firefox 'Open Containing Folder' not working

firefox
#1

Hello,

recently I have switched to Manjaro i3. On the way to producing the configuration that suits me the best I have come a long way, however there is a small thing that I can not get to work.
Background: Manjaro i3 comes with two terminal emulators pre installed, namely xterm and urxvt. Im not sure why, but firefox by default used ranger in xterm to ‘Open Containing Folder’ (the folder button that appears after opening the download dialog box). To make my whole system more consistent I simply decided to uninstall xterm, however clicking the above mentioned button now does not do anything. I guessed that firefox uses xdg-open to open the folder, however setting the correct application here did not resolve the issues. There was no way for me to find any hook that I could use to use ranger in urxvt to open the directory.

I assume that other people experienced this issue as well and since it is somewhat distro-specific, I decided to ask this here and not in some firefox forum. How can i configure firefox to open the containing folder using ranger in urxvt?

Many thanks in advance, Martin

#2

can you test if xdg-open somedir works like expected? (e.g. xdg-open / opens / in ranger-urxvt?)

because I tried with chromium and firefox (and from terminal), while it works like expected with chromium and terminal, firefox still uses pcmanfm. So maybe its a setting inside firefox?

#3

Yes, xdg-open . opens properly in ranger. However, obviously im calling this from within urxvt already, i.e. i would never expect this to not work. All I did to use ranger as my defaule directory opener is add

inode/directory=ranger.desktop;

to my mimeapps.list. I have no idea whether firefox actually uses the xdg standard…
I’m guessing this can (?) be configured from within firefox yes, however an extensive web search didn’t get me any applicable results.

#4

you could add a .desktop file in ~/.local/share/applications and in Exec line something like /usr/bin/urxvt -e /usr/bin/ranger (or just use urxvt -e ranger) and set this desktop file for inode/directory to ensure urxvt is always used.

firefox:
maybe you can add a “directory” filetype to applications (inside firefox settings) ?

#5

You are completely right - specifying urxvt explicitly does solve the problem. However, if i use xdg-open on a directory from inside my urxvt now, i obviously spawn a new window of urxvt. I will try to see whether this is an actual problem, since usually one would not type xdg-open to open a directory from within a terminal but rather use ranger directly. I will use this configuration and see whether this does have any unwanted side effects for the moment. Im still somewhat curious why firefox used xterm before… Where was this set?

Thank you!

#6

in your firefox directory (~/.mozilla) should be a file called handlers.json (use find ), maybe you can add inode/directory entry there (try first with the “ask” option).

But backup the file before you make changes (also bookmarks and other stuff you dont want to lose in case firefox breaks and only way to restore is .mozilla dir)

Also, in firefox about:config are mime_types specified (one global and one private), maybe inode/directory MIME type must be specified in one of these files (e.g. I dont have a private mime_type file and in /etc/mime.types is no inode/directory)

#7

As far as I know Firefox doesn’t use xdg-open for handling MIME types, instead it uses the GIO library (provided by the glib2 package) and its gio open command (gio open ~/Downloads).

GIO is trying to detect terminals in the system in the order described here.
It tries the following:

gnome-terminal -x
nxterm -e
color-xterm -e
rxvt -e
dtterm -e
xterm -e

(note that it doesn’t try urxvt -e)

That’s probably why it used xterm in the first place.
That’s also why nothing happened after you uninstalled xterm and prior to editing the Exec entry in the .desktop file in ~/.local/share/applications/ (it didn’t find any terminal in the system to use).

1 Like
#8

Well it has to be somehow aware of mimeapps.list because what I did is add an additional custom entry (“ranger-dir-opener.desktop”) in my applications folder and in mimeapps.list to open directories with. So i didnt edit any existing entries, and how else, other than mimeapps.list, i.e. xdg-open, would it know to open it using this specific .desktop entry? Maybe one has to differentiate between opening actual files from the download menu, for which it might use gio (thanks for the insight) and clicking the “open containing folder” button. Anyways, I am currently happy with the way it functions now. Thanks.

#9

Both xdg-open and gio rely on the mimeapps.list file to get information about the default applications in your system.
The issue in your case is due to the fact that Ranger is a text-based file manager and has to be opened in a terminal. gio uses a different approach than xdg-open towards that direction.

If you open the default .desktop file of Ranger in /usr/share/applications/, you’ll see the line Terminal=true. This tells gio to look for a terminal in the system in order to launch Ranger (see my previous post).
That’s why @vetzki suggested to use the command urxvt -e ranger in your custom .desktop file. This way gio is forced to use urxvt.

You can confirm this if you add the line Terminal=true in the file ~/.local/share/applications/ranger-dir-opener.desktop and select in Firefox to open the containing folder of a downloaded file. The result will be Ranger not opening.
To revert back, delete the above mentioned line or change it to Terminal=false.

The xdg-open script on the other hand launches Ranger in the terminal you already use to run xdg-open, using the executable file /usr/bin/ranger.
You can see how the xdg-open script works if you run sh -x $(which xdg-open) ~/Downloads in a terminal window.

Hope this helps.

closed #10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.