5

Whenever I want to upload a file via Chromium or Firefox a dialog to select files will pop up.

Open file dialog

Is it possible to replace this dialog with ranger --choosefiles in a new terminal window?

ranger manpage: https://ranger.github.io/ranger.1.html

Ubuntu 18.04. My window manager is i3.

3 Answers 3

4

Yes, it is possible - at least for Firefox.

A new standard has been developed to allow arbitrary program to use the current desktop environment's "default" file dialogs without needing to know about the specific implementation. This is called the xdg-desktop-portal protocol and it was developed for desktop containers, but Firefox has recently added support for it (see below for details).

If you can create a new xdg-desktop-portal implementation for Ranger (there are already implementations for KDE and GTK file dialogs), then you can use these under Firefox.

Chrome has a different mechanism (it chooses correctly KDE or GTK file dialogs depending if running under Plasma or GNOME), but I'm not sure if it can be overriden to support another implementation.

1
  • Just checked, Chrome has specific implementation for GTK and KDE: codereview.chromium.org/7885002/patch/11002/11003 , so there's no way to add another option without patching Chrome (which you can't - contrary to what @vanadium say. You can patch Chromium, but that will not help you if you want to use Chrome and its additional feature).
    – Guss
    Jan 18, 2019 at 10:18
4

This gist seems to show how to create a kdialog script which, by running chrome as XDG_CURRENT_DESKTOP=KDE chrome(best done with an additional wrapper which passes on additional options), you can trick chrome into thinking is the official kdialog application.

The kdialog script in question is a simple wrapper around ranger, and the gist also provides a python plugin for ranger which also enables the "open file in chrome" function from ranger(with custom mappings).

1

Is it possible? Probably yes. It is all open source software, after all. Will it be trivial? Most likely not.

Applications can provide their own "open file" dialog, but more frequently call upon the common dialog provided by the toolbox that the application uses, e.g. GTK3 or QT5, to provide consistency between different applications that use the same toolkit. That is also what Chromium or Firefox do. Replacing these calls to the system dialogs with your custom dialog would require to "hack" the API of the specific toolkit such that a call to that dialog returns your custom dialog instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .