Calibre always opens the PDF file in FileManager instead of default application

When I click on PDF from Calibre’s main window or click on View it opens up my Dolphin file-manager and shows the following dialog on top of the folder:

Trying to open a file as a folder:'file:///home/shuvashish76/Calibre/Main/Author_name/Book_title.pdf'

from there (file-manager) if I click on the PDF it opens up my default Okular application.
I’ve already set “File Association” for PDF to open in Okular + Okular as default “PDF viewer” application from system settings.

[If I use Calibre’s “Open with” external-plugin then it does work, so I guess something is misconfiguration on my side. Is it somewhat related file:// URI here?]

How to fix it so that it’ll always open in my default application with Calibre’s View option?

  • Calibre: v9.14 (isolated installation as instructed at official documentation)
  • OS: EndeavourOS x86_64
  • Kernel: Linux 6.18.48-1-lts
  • DE: KDE Plasma 6.7.4
  • WM: KWin (Wayland)
  • Dolphin: v26.08.0
  • KDE Frameworks: 6.29.0 | Qt: Using 6.11.2 and built against 6.11.1

I asked about this at Calibre’s forum and according to the developer it’s something related to xdg-open.

What happens when you try to open the file with xdg-open from command line / terminal ?

like xdg-open 'filepath.pdf' ? It just opens up the Dolphin with the same message as shown in my OP screenshot, from there clicking “Open as file” works as expected in Okular.

Please check in file associations (“kcmshell6 kcm_filetypes” or system settings) if Okular is at the top of the list (see 3 at the pic below)

Did you try :

  • Right clic mouse on the pdf (in Calibre)
  • Select ‘View’ and ‘View with the Calibre eBook Viewer’

It works for me.

I’ve already set “File Association” for PDF to open in Okular + Okular as default “PDF viewer” application from system settings. It does open in default app Okular when I click on PDF from Dolphin but not from Calibre. Doesn’t help :frowning:

If you Calibre’s “Preference > Use internal viewer for > PDF” then it’ll open directly in Calibre Viewer when you simply click on Calibre’s “Cover Browser”.

But I’ve disabled that as I don’t want to use Calibre’s Viewer.
When disabled it used to open in whatever app set for default “File Association”, but not anymore so I guess it’s something related to recent QT or xdg-open changes.

Also as I mentioned in Calibre’s forum, it works as expected if I switch to Niri WM that confirms it’s related to QT/xdg-open.

xdg-open is a shell script. It tries to find which desktop you use and then decides which tool to use to display the file.

Please check the output of env | egrep "(KDE|XDG)_" if XDG_CURRRENT_DESKTOP and KDE_SESSION_VERSION is set properly.

Please also check kfmclient exec pathAndFileName.pdf .

XDG_CURRENT_DESKTOP=KDE
KDE_SESSION_VERSION=6

bash: kfmclient: command not found

Hmm, do I need some extra package? kfmclient package not available on Arch repo.

In this case xdg-open select kde-open to handle the opening. You can also try to call kde-open file.pdf.

Does it make a difference if you call xdg-open with file as parameter or url:

  • xdg-open ~/Documents/file.pdf
  • xdg-open file:///home/user/Documents/file.pdf

(you can try it with kde-open as well)

No. It is the tool xdg-open falls back, when the env variables (see above) are not set. It’s a old tool from the time Konqueror was the default file manager in KDE.

Please try also xdg-mime query default x-scheme-handler/file

When I set this mime-type to org.kde.dolphin.desktop, xdg-open opens both - Dolphin and Okular :astonished_face: