Ticket #2965 (new defect) — at Initial Version

Opened 11 years ago

Last modified 4 years ago

The ext.d/*sh construction to open a file from MC is overcomplicated

Reported by: covex Owned by:
Priority: minor Milestone:
Component: mc-core Version: 4.8.7
Keywords: Cc: gotar@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

I am somehow missing the reasoning for the existing way of opening files from mc.

Now we do not have only mc.ext with the definitions of actions, which is system wide configurable in /etc/mc/mc.ext, but we also have a shell constructions in /usr/libexec/mc/ext.d, which is not configurable anymore. The purpose is probably only to select either some app or xdg-open for an open action.

Setting the MC_XDG_OPEN=false makes no sense as the app to open the file is only present in ext.d/*.sh file, which you should not change, so you have to change the mc.ext anyway.

This makes the process of file opening slow as many shell script code needs to be interpreted to get as simple thing as file open in desired app and pain to understand what is going on as the xdg-open itself is quite complicated - it uses either /usr/share/application/default.list or ~/.local/share/applications/mimeapps.list

Let's see the mc.ext e.g. for images:

---
type/PBM

Include=image


type/PGM

Include=image


type/PPM

Include=image


type/Netpbm

Include=image


shell/.xcf

Open=/usr/libexec/mc/ext.d/image.sh open xcf


shell/.xbm

Open=/usr/libexec/mc/ext.d/image.sh open xbm


shell/i/.svg

View=%view{ascii} /usr/libexec/mc/ext.d/image.sh view svg
Open=/usr/libexec/mc/ext.d/image.sh open svg

include/image

Open=/usr/libexec/mc/ext.d/image.sh open ALL_FORMATS
View=%view{ascii} /usr/libexec/mc/ext.d/image.sh view ALL_FORMATS

---

here we see we can simply share the common app thru include, no need for another image.sh.

Now what is in image.sh?

---
do_open_action() {

filetype=$1

case "${filetype}" in
xbm)

bitmap "${MC_EXT_FILENAME}"
;;

xcf)

(gimp "${MC_EXT_FILENAME}" &)
;;

svg)

(inkscape "${MC_EXT_FILENAME}" &)
;;

*)

if [ -n "$DISPLAY" ]; then

(gqview "${MC_EXT_FILENAME}" &)

elif see >/dev/null 2>&1; then

(see "${MC_EXT_FILENAME}" &)

else

zgv "${MC_EXT_FILENAME}"

fi
;;

esac

}
---

It just acts on the same kind of file type but thru a shell case construction and hardcodes the apps that should be used. If xdg-open is used, then it starts another shell script, that based on the file type (again) uses the default app from either system wide unconfigurable setting or local user definition.

Overall this all is a mess. Please keep this as simple as possible. If you want to relay on xdg-open, just use xdg-open in the mc.ext and let user simply reconfigure it instead of digging around another shell scripts.

Note: See TracTickets for help on using tickets.