Closed mikehearn closed 1 year ago
URL handlers can be done in Conveyor 4 using some custom config. Future releases will simplify the configuration required, but that isn't strictly necessary. See here for how:
https://conveyor.hydraulic.dev/4.0/configs/os-integration/#url-handlers
I tried the custom config parameters to get file associations (double click) working
The MSIX extension also works for file associations
app.windows.manifests.msix.extensions-xml = """
<uap:Extension Category="windows.fileTypeAssociation">
<uap3:FileTypeAssociation Name="textfile" Parameters="%1">
<uap:SupportedFileTypes>
<uap:FileType>.txt</uap:FileType>
</uap:SupportedFileTypes>
</uap3:FileTypeAssociation>
</uap:Extension>
"""
The macOS documentation is unfortunately terrible, but I got it to work with the settings below. Some links that ended up being helpful:
Minimal for double click support
app.mac.info-plist.CFBundleDocumentTypes = [
{
// Minimal settings to allow opening
CFBundleTypeRole = Viewer
CFBundleTypeExtensions = [txt]
}
]
Using a custom type with icon
app.mac.info-plist.CFBundleDocumentTypes = [
{
CFBundleTypeRole = Viewer
CFBundleTypeExtensions = [extension]
// Custom type definition
CFBundleTypeName = "My Type Name"
CFBundleTypeIconFile = app.icns
LSHandlerRank = Owner
LSTypeIsPackage = false
}
]
I'm not sure about Linux, but after selecting the application it worked. To map it directly after install it probably needs a custom mime type and a registration in the postinstall script.
app.linux.desktop-file."Desktop Entry" {
Exec = ${app.linux.install-path}/bin/${app.fsname} %f
MimeType = application/octet-stream // or x-${app.fsname} for custom ones
}
%f
-> single file per invocation%F
-> one or more files%u
-> one url/file%U
-> one or more urls/filesThe actual file handling on macOS is not straight forward though. Windows and Linux supply the file name as the first argument, but macOS needs to integrate with a native library.
I found several issues for it (e.g. How to handle file open requests on MacOS), but there still does not seem to be a fully supported/working way for JavaFX. Swing got the setOpenFileHandler added to java.awt.Desktop
in Java 9, but there may be some caveats (JDK-8239590) when using it from JavaFX.
Yes, that looks right. We're adding native support for file associations at the moment. It won't be in the next feature release, probably the one after that. It boils down to what you're saying plus some code to handle Linux.
Re: JavaFX. Yes, it needs some more work on the native side to do the equivalent for AWT.
File associations have been released!
Nice 👍 Is there a way to bundle icons too?
At the moment per-file type icons aren't supported. Is it so common to create dedicated icons for files these days? A surprising number of our users are using the auto-generated icons already.
I didn't see icons mentioned in the docs, so I wasn't sure what it does without doing a sample project. Registering the application icon makes sense and would work well enough for me 👍
Yep, the icon used is the application icon.
Fyi, I just replaced my previous hacks and it works like a charm 👍
The only issue I ran into was that Ubuntu 20.04 does not show the icon for the mime-type, in case it should be doing that.
Vote for this if you need packaged apps to support registering file associations and URL handlers.