I have always been confused why the file manager in Linux cannot stop applications from opening a single file twice at the same time?Specifically, I want to stop the PDF file reader Okular from opening the file A.pdf again when I have already opened it. I need to get an warning or just show me the opened copy of the file A.pdf.More generally, I would like this to happen with any application, not just Okular. I want to make the document management behavior in Linux the same as in Windows.
If I open the same file twice in Okular, switch to the existing window
kde;open files;file opening;okular
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).