4

I have Okular configured that when it's already running and I open a pdf from the command line, it should open the new file as a new tab in Okular.

However, if this new file is in another directory than the other one, Okular fails to open the document and only displays an empty tab with the file name and the error message

Could not open /path/to/bar.pdf

Short example:

okular foo.pdf &
okular bar.pdf

works the way I would expect it to.

okular foo.pdf &
cd ..
okular foobar.pdf

would only open foo.pdf correctly, but fail to display foobar.pdf.

The Okular version I'm working with is 0.19.3.

//Edit: Maybe I should mention: If I open the same combination of files from a file manager (in my case Dolphin), Okular behaves as expected. I only have issues using the command line.

//Edit: I just tried the same thing on another computer using Okular 0.23.2. It worked fine, so I guess the bug has been taken care of already.

3
  • 2
    What if you specify the full path to okular? opkular "$PWD/foobar.pdf" (I imagine your file browser also gives the full path).
    – muru
    Feb 7, 2016 at 12:05
  • I think you should file a bug report then. I'd say okular should use the full path when sending the filename to the running instance, instead of relying on the user to do so.
    – muru
    Feb 7, 2016 at 12:26
  • Post your workaround as a answer, then accept it. And if you file a bug report, give the link there. Feb 7, 2016 at 12:36

1 Answer 1

1

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
}
3
  • This solution works for me only if I call okular from the same directory as the initial file. This is the format of the answer. However, the format of the question tried to open okular from a different directory, and this is normally how I would open files as well. I'm sure the same is true of others. (I use Ubuntu 14.04 LTS and tcsh.)
    – Russ Lyons
    Feb 18, 2016 at 22:26
  • Ok..That's exactly what the solution does for me. I open one pdf, move to another directory and then open the next one there. However, I'm using bash. So to make my solution work for you, you'd have to add the function to your .tcshrc, I suppose. But I think you'd have to change it up first, because tcsh doesn't support functions. (Disclaimer: I'm not very familiar with tcsh)
    – karpfen
    Feb 18, 2016 at 22:52
  • This does not work for me in bash either. If it does not work on the command line, then I don't think it will work with a function, no matter the shell.
    – Russ Lyons
    Feb 18, 2016 at 23:01

You must log in to answer this question.

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