site  contact  subhomenews

ROX-Filer dynamic handling of mimetypes

September 19, 2019 — BarryK

ROX is an old application, but still keeps getting better old wine.

Mid-2018, a system for automatic generation of right-click "Open with" apps, appropriate for the file being right-clicked-on, was implemented in WoofQ:

Not for ROX, but related, late in 2017, don570 reported that 'update-desktop-database' needs to be run for correct "Open with" in some applications, such as Mypaint:

...that utility creates /usr/share/applications/mimeinfo.cache. WoofQ runs that utility in 3buildeasydistro, and in a running easyOS runs /usr/local/petget/ when the package manager installs a package.

When you left-click on a file in a ROX window, it will automatically open the file in an appropriate application. Right-click gives you a choice, left-click will open immediately in the number-1 app for that mimetype (which may be one of the /usr/local/bin/default* scripts, see "Default Chooser" in Setup menu).

The way this left-click opening works, is there are scripts in /root/Choices/MIME-types, or can be elsewhere, such as /etc/xdg/ These scripts are manually created, one for each mimetype. This means there are going to be gaps.

Puppy forum member mistfire has devised a dynamic system, that does not required the manually-created scripts:

This is really great, simple and works. I have put it into WoofQ. From the v1.3 PET, have populated rootfs-skeleton/etc/xdg/, and copied 'rox-xdg-open' and 'sync-rox-icons' to rootfs-skeleton/usr/sbin (not usr/bin, as want to be consistent with some other scripts that are in usr/sbin).

Then in the '3buildeasydistro' script, have this:

#190919 previously had manually-created files in /root/Choices/MIME-types
#dynamic system created by mistfire, ref:
#a rox-filer pet may have brought stuff with it...
mkdir -p rootfs-complete/etc/xdg/
rm -f roofs-complete/etc/xdg/* 2>/dev/null
[ -d rootfs-complete/root/Choices/MIME-types ] && rm -f rootfs-complete/root/Choices/MIME-types/* 2>/dev/null
cp -a ../rootfs-skeleton/etc/xdg/* roofs-complete/etc/xdg/

That should be enough documentation so that the woof-CE developers can also implement it. 

EDIT 2019-09-20:
Stop the press! I have discovered problems with this new system:

Mistfire's work has been good for me, as have rethought how the rox mime handling works. However, the end result is removal of mistfire's system. I have reverted to the old system, except for one change, fallbacks.

That is, have created scripts 'audio', 'image' and 'video' in /etc/xdg/ These are fallbacks. For example a PNG image, there is script 'image_png', which rox will run. But what if 'image_png' is not there, then rox will fallback to running 'image'.

The above changes to '3buildeasydistro' have been kept, to override whatever the rox pet has.

This is enough, I don't have a need for mistfire's "dynamic" solution.  However, I have kept his 'rox-xdg-open' script in WoofQ, just in case may want to use it sometime. 

EDIT 2019-09-21:
Have done a general tidy-up and refinement of mimetype handling for rox, for both the left-click and right-click on a file.

With left-click, the app to run is determined by scripts in /etc/xdg/, and I have greatly reduced the number of these scripts, due to 'audio', 'video', 'text' and 'image' scripts handling most cases.

With right-click, the apps to run are determined by entries in /etc/xdg/ There is a popup menu, which will offer a choice of which app to run. For example, for a png file, the choices might be 'mtPaint', 'Gpicview' and 'GIMP'. There are also two levels, at the top-level of the menu are choices that are an exact mimetype match, then in the "Open with..." submenu there are all choices that are capable of opening a png file, for example 'mtPaint', 'Gpicview', 'GIMP', 'Inkscape' and 'LibreOffice-Draw'. 
This handling has been improved, and expanded to more filetypes. Note, there is a script, /usr/sbin/build-rox-sendto, that is called every time a package is installed, to populate

Tags: easy