How to Open selected file in Right-Clicked Specified Application? Solved

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
mikeslr
Posts: 2851
Joined: Mon Jul 13, 2020 11:08 pm
Has thanked: 173 times
Been thanked: 861 times

How to Open selected file in Right-Clicked Specified Application? Solved

Post by mikeslr »

AFAIK (almost?) any application can be added to Rox's Right-Click Menu and associated with a particular file-type. Some 'builtin' applications already are. For example (Left-) clicking a '.png' file will opened it in the default image-viewer, Right-Clicking the same file will open the Right-Click Menu and offer to open that file in mtpaint. Selecting mtpaint from the Right-Click Menu will open mtpaint AND the '.png' file in mtpaint.

I know how to 'customize' the Right-Click Menu (or think I do). I've been able to add gimp or lazpaint to it. And while selecting gimp or lazpaint from the Right-Click menu, will open that application it does NOT open the selected file in that application.

Once the application is opened, the selected file can be dragged/dropped into it. But how to avoid having to do so? Would specifying mime-types in the application's desktop file with it help? Something else?

What am I missing? Or does that depend on the application? if so, I'm particularly interested in graphic applications.

moderator, feel free to move this question to a Section you think is more appropriate.

Solved. See my post following HerrBert's

Last edited by mikeslr on Sat Dec 10, 2022 10:03 pm, edited 1 time in total.
HerrBert
Posts: 340
Joined: Mon Jul 13, 2020 6:14 pm
Location: Germany, NRW
Has thanked: 17 times
Been thanked: 114 times

Re: How to Open selected file in Right-Clicked Specified Application?

Post by HerrBert »

From what i recall Rox' right-click menu can handle items from /root/.config/rox.sourceforge.net/OpenWith/.<FILETYPE> directories and
on newer Puppies the MimeType entry from a .desktop file.
Example:

Code: Select all

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name[de]=mtPaint Bildbearbeitung
Name=mtPaint
GenericName=Image Editor
Comment[de]=Bilder bearbeiten
Comment=Painting program to create pixel art and manipulate digital photos
TryExec=mtpaint
Exec=mtpaint
Icon=mtpaint.png
Terminal=false
Categories=RasterGraphics
MimeType=image/bmp;image/x-bmp;image/x-ms-bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/x-pcx;image/png;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/svg;image/svg+xml;image/x-tga;image/tiff;image/xbm;image/x-xbm;image/x-xbitmap;image/xpm;image/x-xpm;image/x-xpixmap;

In the latter case one has to update the desktop-database /usr/share/applications/mimeinfo.cache for changes to take effect.

Code: Select all

/usr/bin/update-desktop-database /usr/share/applications

And don't forget to remove any of the %U %S %F at the end of the Exec= line in the .desktop file

User avatar
mikeslr
Posts: 2851
Joined: Mon Jul 13, 2020 11:08 pm
Has thanked: 173 times
Been thanked: 861 times

Re: How to Open selected file in Right-Clicked Specified Application? Solved

Post by mikeslr »

Thanks HerrBert for the guidance.

I'm working with Slacko/S15Pup 64, https://www.forum.puppylinux.com/viewto ... 125#p74125. Other Puppys may differ. But I examined mtpaint's desktop file in /usr/share/applications. That file had potentially important entries:
Exec=mtpaint %F and
MimeType=image/bmp;image/x-bmp;image/x-ms-bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/x-pcx;image/png;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/svg;image/svg+xml;image/x-tga;image/tiff;image/xbm;image/x-xbm;image/x-xbitmap;image/xpm;image/x-xpm;image/x-xpixmap;

I'm pretty sure the MimeType= entry is NOT needed. I was able to have files open in Lazpaint from the Right-Click menu, both vector and raster graphics, without specifying vector mime-types in the desktop file. But the %F argument isn't as destructive as I previously thought.

The problem I encountered is that I had not called the executable directly. Lazpaint is available as a tar.gz download, which expanded reveals what appears to be some sort of an AppImage with associated files. I had built the application by placing the entire extracted contents in /opt --which is not 'on the path'-- linking the 'AppImage' to 'the path' by a bash-script in /root/my-applications/bin. Including the %F either in that script or in the desktop's Exec= argument generated an error. But once I called the AppImage directly from the Exec argument which included the %F argument that error evaporated. To wit:

Exec=/opt/lazpaint/lazpaint %F

Still, while lazpaint opened, the selected file didn't. I had to serially create entries in /root/.config/rox.sourceforge.net/OpenWith by Right-Clicking a file of each desired type, selecting 'customize menu', and linking lazpaint's desktop into the GUI which opened. I ended up with the files in the '...OpenWith' folder as shown by the following screenshot:

handling mime-types.png
handling mime-types.png (87.99 KiB) Viewed 283 times

Well, the PITA I was trying to avoid. :( But it might have been worse. ;) Fortunately, I could run pfind>Current Directory, Search for text with the argument lazpaint which identified all such files. pfind's copy option allowed me to copy all of them in one 'fell swoop' into the corresponding OpenWith folder of the lazpaint I was rebuilding.

All thanks to all those who have taken the time to create Right-Click OpenWith options before publishing an application.

HerrBert
Posts: 340
Joined: Mon Jul 13, 2020 6:14 pm
Location: Germany, NRW
Has thanked: 17 times
Been thanked: 114 times

Re: How to Open selected file in Right-Clicked Specified Application? Solved

Post by HerrBert »

I'll continue with your lazpaint .pet here, if i may?
Kind of cleanup - no offense intended

1. lazpaint did not appear in JWM menu in an downloaded earlier today version
Remove the TryExec= line from /usr/share/applications/lazpaint.desktop

2. remove /opt/.DirIcon
Should not be there

3. remove symlink /root/my-applications/bin/lazpaint.png
Should not be there

4. remove /root/.config/rox.sourceforge.net/openwith
It does nothing because it is written in wrong case...

MimeType=image/bmp;image/x-bmp;image/x-ms-bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/x-pcx;image/png;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/svg;image/svg+xml;image/x-tga;image/tiff;image/xbm;image/x-xbm;image/x-xbitmap;image/xpm;image/x-xpm;image/x-xpixmap;

I'm pretty sure the MimeType= entry is NOT needed. I was able to have files open in Lazpaint from the Right-Click menu, both vector and raster graphics, without specifying vector mime-types in the desktop file.

5. The MimeType= should be MimeType=application/lzp;image/bmp;image/jpeg;image/png;image/gif;image/tiff;image/x-tga;image/vnd.microsoft.icon;image/svg+xml;image/x-adobe-dng;image/x-nikon-nef;image/x-sony-arw;image/x-canon-cr2;image/webp
https://github.com/bgrabitmap/lazpaint/ ... 79647bf009

Have fun and stay curious ;)

Post Reply

Return to “Programming”