I have built toy application as a learning project that opens files in
Finder as a default app. I haven't worked on it in a while, so I may be
forgetting some things, but I'll report what I remember. It is a #lang
racket/gui program, built by `raco setup` in response to
`gracket-launcher-libraries` and `gracket-launcher-names` fields, so things
may be different if you're writing some other kind of program.

I believe the hook for getting files passed from Finder at program startup
is `application-file-handler
<http://docs.racket-lang.org/gui/Windowing_Functions.html?q=#%28def._%28%28lib._mred%2Fmain..rkt%29._application-file-handler%29%29>`.
(It also works with Windows.)

There are also some auxiliary files you want to create to configure certain
things for `raco setup`'s implicit use of `build-aux-from-path
<http://docs.racket-lang.org/raco/exe.html?q=aux-from#%28def._%28%28lib._launcher%2Flauncher..rkt%29._build-aux-from-path%29%29>`
and `extract-aux-from-path
<http://docs.racket-lang.org/raco/exe.html?q=aux-from#%28def._%28%28lib._launcher%2Flauncher..rkt%29._extract-aux-from-path%29%29>`.
I believe the key one is a ".filetypes" file. There is more documentation
on the format under `create-embedding-executable
<http://docs.racket-lang.org/raco/exe.html?q=aux-from#%28def._%28%28lib._compiler%2Fembed..rkt%29._create-embedding-executable%29%29>`.
Mine is:
Sapientia:freecell philip$ cat freecell.filetypes
((("CFBuncleTypeName"
   "Freecell Game")
  ("CFBundleTypeRole"
   "Viewer")
  ("CFBundleTypeExtensions"
   (array "freecell"))
  ("CFBundleTypeIconFile" "file-icon")
 ))
The "CFBundleTypeIconFile" entry directs `raco setup` to use
"file-icon.icns" as the icon for files opened by the application.

Hope this helps!

-Philip

P.S.: I'll also mention that I recently started working on a Racket library
to write .icns icon files instead of shelling out to Apple's `sips` to
convert them from some other format. Pull requests are welcome! The code is
at https://github.com/LiberalArtist/icns and the docs are at
https://docs.racket-lang.org/icns/index.html


On Wed, Sep 5, 2018 at 12:53 PM Lehi Toskin <lehi.tos...@gmail.com> wrote:

> I've been messing around with getting a test application to open files
> from Finder in OS X as a default app. The program appears to be operating
> properly, except for the part where it tells me information about the file
> I double-clicked. I modified the app a little so that it would print out
> any args that were passed to it into an editor-canvas, but all that showed
> up was an empty vector. Is there something weird with how Finder passes
> files to apps, like some URI schema that my test app doesn't recognize? Or
> is it something going on with how the `racket/cmdline` library operates
> that is incompatible with Finder?
>
> P.S. Running my test app from the terminal allows it to work properly, so
> I wonder what's the issue.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to