Use Okular (flatpak) as default pdf reader

I am using okular as my default pdf reader. I had the rpm version installed and I had set it as the default app.
Now I uninstalled the rpm and installed the flatpak version and would like to set it as the default, but it doesn’t show up in the Properties/Open with list.
How do I set Okular flatpak as the default pdf reader?

I created a custom .desktop file with the following Exec line:

Exec=flatpak run org.kde.okular %U

I don’t know why a .desktop file was not created when I installed Okular from the Software centre.

installing from flathub (command line) I have a desktop file in /var/lib/flatpak/exports/share/applications

Do you know if you are using flathub or Fedora for flatpaks?
flatpak remotes
should list them

1 Like

I installed Okular from flathub

flatpak info org.kde.okular

Did you install as user vice system, desktop file would be in ~/.local/share/flatpak/exports

Can you also check echo $XDG_DATA_DIRS

Mine looks like

echo $XDG_DATA_DIRS
/home/grumpey/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/

I installed it with Gnome Software as user.
The ~/.local/share/flatpak/exports folder doesn’t exist on my system.
echo $XDG_DATA_DIRS is equivalent to yours.

Did you check for a desktop file in:
/var/lib/flatpak/exports/share

You could also manually set it:

xdg-mime default desktopfile.desktop application/pdf

and you can check that with
xdg-mime query default application/pdf

I had a custom okular.desktop under ~/.local/share/appllications and it took precedence over the one found in /var/lib/flatpak/exports/share/applications. I removed the custom file (which I don’t need anymore) and, after I logged out and in again, okular appeared in the list of apps and can be chosen as default app.

1 Like