AppImageCommunity / libappimage

Implements functionality for dealing with AppImage files
https://appimage.org
Other
46 stars 29 forks source link

Can't find the corresponding `Open With` entry to associate an appimage with the file it can open. #166

Closed hongyi-zhao closed 2 years ago

hongyi-zhao commented 2 years ago

On Ubuntu 20.04.3 LTS, I installed AppImageLauncher as follows:

$ sudo gdebi appimagelauncher_2.2.0-travis995.0f91801.bionic_amd64.deb 

Then I generated launcher with it for CAJViewer as follows:

werner@X10DAi-00:~/Applications$ ls
CAJViewer-x86_64-buildubuntu1604-210401_2ebaf269a2df7ca41a95632bc9095d69.AppImage

$ ls .local/share/applications/appimagekit_e4bfcabe13873ad0cf19fecf8ae7e621-CAJViewer.desktop 
.local/share/applications/appimagekit_e4bfcabe13873ad0cf19fecf8ae7e621-CAJViewer.desktop

Now, I want to associate the CAJViewer appimage with the file it can open, i.e., the caj file, so that the file can be opened automatically by double-clicking on it. But I can't find the corresponding Open With entry to complete this operation, as shown below:

image

Any hints for fixing this problem?

Regards, HZ

hongyi-zhao commented 2 years ago

Got it. Based on the comment here and documentation here, append a white space and %F to Exec fixes the problem:

$ sed -Ei 's,^(Exec=[^ ]+)$,\1 %F,'  ~/.local/share/applications/appimagekit_e4bfcabe13873ad0cf19fecf8ae7e621-CAJViewer.desktop
$ grep -m1 ^Exec ~/.local/share/applications/appimagekit_e4bfcabe13873ad0cf19fecf8ae7e621-CAJViewer.desktop 
Exec=/home/werner/Applications/CAJViewer-x86_64-buildubuntu1604-210401_2ebaf269a2df7ca41a95632bc9095d69.AppImage %F

image

TheAssassin commented 2 years ago

That "fix" is just temporary. Make sure to inform the vendor of the AppImage to include the %F upstream as well.

hongyi-zhao commented 2 years ago

Do you mean the Desktop file comes from the AppImage instead of being created by AppImageLauncher from scratch?

TheAssassin commented 2 years ago

The desktop file is extracted from the AppImage, then modified by AppImageLauncher respectively libappimage to point to the AppImage (along with some other features). AppImageLauncher contains code to ensure AppImages will be reintegrated when a new version is installed to make sure changes in its code, or, e.g., libappimage, are applied. When the AppImage is reintegrated, modifications like yours on the integrated desktop files will be lost. They are not supposed to be edited by the user.