A link to a “similar question” (xdg-open default applications behavior – not obviously related, but some experimentation showed that the behaviour is indeed equivalent to the one of xdg-open
) led me deeper down the rabbit hole. While Firefox does not rely on, or inherit rules from, xdg-open
, it uses the MIME specification files just as xdg-open
does.
On a user basis, the MIME opening behaviour is configured by the specification file ~/.local/share/applications/mimeapps.list
.
For me, this file contains just a few reasonable protocols and HTML (and similar) files connected to userapp-Firefox-??????.desktop
, but you could easily add a line like
application/pdf=evince.desktop
to solve that problem on a per-user basis. If the file does not exist yet, make sure to add a section header, such as
[Default Applications]
application/pdf=evince.desktop
Deeper down, the mime types are defined in /usr/local/share/applications/mimeinfo.cache
(this may be /usr/share/…
if you are not on a FreeBSD system), which does list application/pdf=inkscape.desktop;evince.desktop;
. Both evince.desktop
and inkscape.desktop
in that folder contain MimeType=[…]application/pdf;[…]
.
The mimeinfo.cache
is automatically generated from the mime types listed in the .desktop
files without any well-defined order, so you will have to either remove the PDF mime type from Inkscape and regenerate the cache using update-mime-database
, or generate a mimeapps.list (either globally in /usr/local/share/applications/
, or for your user in ~/.local/share/applications/mimeapps.list
).
Workaround: Open additional pdf files either using the absolute path names or relative path names to the initial pdf file.
So for example
okular foo.pdf &
okular ../foobar.pdf
and
okular foo.pdf &
okular /the/complete/absolute/path/to/foobar.pdf
both work.
//Update:
To automate the workaround, this function can be added to ~/.bashrc.
It simply reads the file's absolute name and passes it to okular via stdin
.
function okular
{
command readlink -f $1 | xargs okular
}
Best Answer
A file manager is responsible for invoking applications to open a file. It has no control over what the application does with the file, and in particular whether the application will open a new window if you open the same file twice.
Having the same file open in multiple windows can be useful, for example when you want to see different sections from the same document. So systematically refusing to open more than one window on the same document would be bad. Which behavior is the default is mostly a matter of taste. Some applications default to opening a new window, others default to focusing the existing window.
Okular defaults to opening a new window. If you start all instances with
okular --unique
, then the second time you run that command, it doesn't open a new window (though it doesn't focus the existing window, at least if you aren't running KDE). Note that the first instance must have been started with--unique
as well as the second one.Evince, the Gnome PDF viewer, defaults to the behavior you want: if you open the same document a second time, it focuses the existing window. It doesn't have a command line option to open a separate window, you have to do this through the GUI (menu “File” → “Open a Copy” or Ctrl+N).