New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify file associations #103
Comments
Hi @rhbvkleef! Let's recap how to achieve this on different platforms:
|
Cool! Well, here ya go ;-)
Luckily, it doesn't. You can simply place the mime-type into the desktop file: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.5.html#mime-types |
As a starting point here the snippet i added to the [Registry]
; create file associations
\#define MyAppName "${info.name}"
\#define MyFileExtension "FILENAMESUFFIXHERE"
\#define MyFileDescription "Human readable file type description here (what Windows Explorer will show)"
Root: HKCU; Subkey: "Software\Classes\.{#MyFileExtension}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}File"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\Classes\Mime\Database\Content Type\application/xml"; ValueType: string; ValueName: "Extension"; ValueData: ".{#MyFileExtension}"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\Classes\{#MyAppName}File"; ValueType: string; ValueName: ""; ValueData: "{#MyFileDescription}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Classes\{#MyAppName}File\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppName}"" ""%1""" |
Thanks!! |
Hi @rhbvkleef! |
I've been trying to associate extensions/mime-types to apps on Linux, but I'm not able to do it.
It doesn't work just trying what is explained here. What if I want to associate a custom file format? e.g. ".hello" files. Heeelp!!! 😓 |
Yes, you have to register a custom mime-type first. Example for opus-files:
You see there a file pattern (can be more than one). More here: https://wiki.debian.org/MimeTypesSupport |
Hi @commi! But when I specify <fileAssociations>
<fileAssociation>
<description>HelloWorld File</description>
<extension>hello</extension>
<mimeType>application/hello</mimeType>
</fileAssociation>
</fileAssociations> I'm creating a file like this in <?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/hello">
<comment>HelloWorld File</comment>
<glob pattern="*.hello"/>
</mime-type>
</mime-info> The following file in [Desktop Entry]
Name=HelloWorld
GenericName=HelloWorld
Comment=My HelloWorld sample app
Exec=/opt/HelloWorld/HelloWorld %U
Icon=/opt/HelloWorld/HelloWorld.png
Terminal=false
Type=Application
StartupNotify=true
MimeType=application/hello;
and yes, you are right, these system changes are triggered after installing a .deb. but it doesn't work. |
Oh! Great!!! I thought that this command was triggered after installing a DEB file ... so, do I have to include an after-install script including this command?
I'm testing on a LinuxMint 20.1 (Mate), with |
Afaik Maybe i can test den DEB you created here? can you upload it somewhere? |
I've just installed my DEB file: $ sudo dpkg -i HelloWorldMaven_1.0.0.deb
Seleccionando el paquete helloworldmaven previamente no seleccionado.
(Leyendo la base de datos ... 278851 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../HelloWorldMaven_1.0.0.deb ...
Desempaquetando helloworldmaven (1.0.0) ...
Configurando helloworldmaven (1.0.0) ...
Procesando disparadores para gnome-menus (3.36.0-1ubuntu1) ...
Procesando disparadores para desktop-file-utils (0.24+linuxmint1) ...
Procesando disparadores para mime-support (3.64ubuntu1) ...
Procesando disparadores para shared-mime-info (1.15-1) ... You can see here that Then, I did some checks: $ xdg-mime query default application/hello
HelloWorldMaven.desktop
$ xdg-mime query filetype prueba.hello
text/plain and ... what!?! Then, I executed Here you have a link to my deb. Thanks so much!!! |
🤯 |
It's a freshly installed virtual machine ... I'll have to do some research about this.
No, because I'd like that the file associations was only by the file extension, not by the content. |
Hi @rhbvkleef! At the moment, file associations are implemented for GNU/Linux and Windows (only Setup installer, still need to implement for MSI installer), so you can already test it. Thanks! |
Hi @rhbvkleef! Sorry for being so late. I hope you haven't lost faith in JavaPackager 😞 |
I write this information here for those who may be useful: When we double click a file on Windows and GNU/Linux, the path of the file is passed to the executable as an argument. But, on Mac OS X, it's a bit different. I put a link here with explanations about how to access a file open from the system in Mac OS X: https://openjfx-dev.openjdk.java.narkive.com/emgVmZMH/how-to-handle-file-open-requests-on-macos |
Example on how to handle open files by double clicking on Mac OS X: |
Branch issue-103 merged into master |
Changes will be released in v1.6.0 asap. |
JavaPackager v1.6.0 released to Maven Central |
I'm submitting a…
Short description of the issue/suggestion:
We are able to specify file associations in jpackage (through the
--file-associations
switch). I would like to have the ability to do this too, using this plugin. I read through the source, and I cannot find how to do this. In fact, it appears that we are entirely unable to specify file associations.What is the expected behavior?
Have a
configuraiton
property namedfileAssociations
in which we are able to specify these associations.What is the current behavior?
There´s no way to specify these associations.
What is the motivation / use case for changing the behavior?
It is sometimes desired to register the java application to open certain files.
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: