Bug 503029 - Okular MacOS "Open With" not working
Summary: Okular MacOS "Open With" not working
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-19 20:27 UTC by Janek
Modified: 2025-07-04 10:30 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janek 2025-04-19 20:27:06 UTC
Nightly Version 25.07.70

SUMMARY
When I use okular to open a PDF from finder, okular pops up but does not open the PDF

EXPECTED RESULT
Okular opens the PDF so that I can use it as default PDF application - if that is fixed it will really be a handy tool to reduce bloat from proprietary PDF applications on mac devices

Seems related to https://bugs.kde.org/show_bug.cgi?id=456058
Comment 1 jmot205 2025-05-05 01:37:43 UTC
Also running in to this bug, and an update to the latest version does not fix it either. Following the thread on the previously linked post, someone has figured out the code to pass to get files opening correctly:
> /Applications/okular.app/Contents/MacOS/okular PATH_TO_FILE

I've tried this with a local pdf file and it works. Is it possible for the devs to change the opening code to run this instead?
Comment 2 jmot205 2025-05-05 02:14:58 UTC
Adding this as a workflow quick action in Automator seems to work for opening a pdf from the right-click menu:

>on run {input, parameters}
>    set filePath to POSIX path of (item 1 of input)
>    set okularCommand to "/Applications/okular.app/Contents/MacOS/okular " & quoted form of filePath
>    do shell script okularCommand
>    return input
>end run
Comment 3 John Kizer 2025-05-09 05:29:55 UTC
Hi - merging with the report you mentioned to help keep investigation and status updates coordinated, as they appear to be the same issue. Thanks!

*** This bug has been marked as a duplicate of bug 456058 ***
Comment 4 jmot205 2025-05-12 05:44:51 UTC
Saving the following in AppleScript as an app will allow you to set the default pdf application to this new app as a workaround. So that means that we can now open files in a more native way without the right-click menu.

>on open droppedFiles
>	repeat with f in droppedFiles
>		set filePath to POSIX path of f
>		do shell script "/Applications/okular.app/Contents/MacOS/okular " & quoted form of filePath & " >/dev/null 2>&1 &"
>	end repeat
>end open
Comment 5 Andreas Joss 2025-05-12 10:49:29 UTC
(In reply to jmot205 from comment #4)
> Saving the following in AppleScript as an app will allow you to set the
> default pdf application to this new app as a workaround. So that means that
> we can now open files in a more native way without the right-click menu.
> 
> >on open droppedFiles
> >	repeat with f in droppedFiles
> >		set filePath to POSIX path of f
> >		do shell script "/Applications/okular.app/Contents/MacOS/okular " & quoted form of filePath & " >/dev/null 2>&1 &"
> >	end repeat
> >end open

Thanks, I have followed this instruction and I am able to open a PDF using the newly created AppleScript app (which opens Okular). But I am unable to change the default app for opening PDFs to this AppleScript app. The following error message is produced: 

You can’t change the item “xxx.pdf” to always open in the selected application.
The item is either locked or damaged, or in a folder you don’t have permission to modify (error code 13).

After having read some forums, it seemed the location of the AppleScript app could be the culprit (saved by default in iCloud folder). I then copied the app to my regular Applications folder, deleted the original, tried again and I still get the aforementioned error message.
Comment 6 jmot205 2025-05-13 00:48:23 UTC
(In reply to Andreas Joss from comment #5)
> (In reply to jmot205 from comment #4)
> > Saving the following in AppleScript as an app will allow you to set the
> > default pdf application to this new app as a workaround. So that means that
> > we can now open files in a more native way without the right-click menu.
> > 
> > >on open droppedFiles
> > >	repeat with f in droppedFiles
> > >		set filePath to POSIX path of f
> > >		do shell script "/Applications/okular.app/Contents/MacOS/okular " & quoted form of filePath & " >/dev/null 2>&1 &"
> > >	end repeat
> > >end open
> 
> Thanks, I have followed this instruction and I am able to open a PDF using
> the newly created AppleScript app (which opens Okular). But I am unable to
> change the default app for opening PDFs to this AppleScript app. The
> following error message is produced: 
> 
> You can’t change the item “xxx.pdf” to always open in the selected
> application.
> The item is either locked or damaged, or in a folder you don’t have
> permission to modify (error code 13).
> 
> After having read some forums, it seemed the location of the AppleScript app
> could be the culprit (saved by default in iCloud folder). I then copied the
> app to my regular Applications folder, deleted the original, tried again and
> I still get the aforementioned error message.

That's weird; I don't think I did any further steps on my end. My .app is saved into the /Applications folder as well. FWIW I set it as default via right-click > Get Info > Open with > select .app > Change All
(as opposed to the right-click > open with ... method)
Comment 7 Andreas Joss 2025-05-13 12:34:25 UTC
Ahh (In reply to jmot205 from comment #6)
> (In reply to Andreas Joss from comment #5)
> > (In reply to jmot205 from comment #4)
> > > Saving the following in AppleScript as an app will allow you to set the
> > > default pdf application to this new app as a workaround. So that means that
> > > we can now open files in a more native way without the right-click menu.
> > > 
> > > >on open droppedFiles
> > > >	repeat with f in droppedFiles
> > > >		set filePath to POSIX path of f
> > > >		do shell script "/Applications/okular.app/Contents/MacOS/okular " & quoted form of filePath & " >/dev/null 2>&1 &"
> > > >	end repeat
> > > >end open
> > 
> > Thanks, I have followed this instruction and I am able to open a PDF using
> > the newly created AppleScript app (which opens Okular). But I am unable to
> > change the default app for opening PDFs to this AppleScript app. The
> > following error message is produced: 
> > 
> > You can’t change the item “xxx.pdf” to always open in the selected
> > application.
> > The item is either locked or damaged, or in a folder you don’t have
> > permission to modify (error code 13).
> > 
> > After having read some forums, it seemed the location of the AppleScript app
> > could be the culprit (saved by default in iCloud folder). I then copied the
> > app to my regular Applications folder, deleted the original, tried again and
> > I still get the aforementioned error message.
> 
> That's weird; I don't think I did any further steps on my end. My .app is
> saved into the /Applications folder as well. FWIW I set it as default via
> right-click > Get Info > Open with > select .app > Change All
> (as opposed to the right-click > open with ... method)

Ah fantastic that worked, many thanks. I previously used the right-click > open with method, which did not work. Just glad your method works.