[email protected]
[Top] [All Lists]

Re: A way to run applications by extension/remember default applications

Subject: Re: A way to run applications by extension/remember default applications?
From:
Date: Thu, 27 Sep 2007 22:14:18 -0500 CDT
On Thu, 27 Sep 2007, Andreas Jantvik Gyllenlid wrote:

> Hello,
>
> I was wondering if it is possible to configure MC to run certain 
> applications with specific applications. I do not know how MC runs 
> things at all.
>
> With MPG files Mplayer just fires out automagically when I just <enter> 
> the file. When trying to run an m2v file, Mplayer doesn't run, MC spits 
> out:
>
> bash: ./a.good.music.video.m2v: cannot execute binary file
>
> I can press F2 and "Do something ..." and just type mplayer, and it 
> works.. And I can type mplayer C-<enter> in the command line below.
>
> How do I make MC do this automatically for me? For example I also want 
> iso-files to be run with vlc per default. Is there something like 
> Gentoo's config somewhere?
>
> Thanks!

Hi,

I am not one of the developers of MC, but I am a long-time (and very 
appreciative) user. Please let me make the suggestion to do the following:

Go to the dropdown menus on top of the MC window (xterm or in a text 
terminal, either one). Go to the menu which is named "Command" and open 
it. Choose the option "Edit extension file" and fire away at it.

Some other details and practical advice:

To open up the dropdown menus, use F9 and the arrow keys to pick the one I 
said, then hit Enter. Or click on the inscription "Command" at the top of 
the screen or xterm window.

If you want to know where the extension file is, then look in your home 
directory for the directory called .mc, and look inside that. You will see 
a file called "bindings" and inspection of that file should convince you 
that it is the same as what MC is opening with the above-described 
sequence. So you can also edit that file by hand and then re-start MC (not 
even sure if you need to restart; maybe you don't). You can also do a 
backup of that file before messing with it, in case you are afraid of 
messing something up. I highly recommend making such a backup. Then you 
can be as adventurous as you want to and you do not have to be afraid of 
messing up anything at all.

As a small example:

# TeX
regex/\.([Tt][Ee][Xx])$
#       Open=%var{EDITOR:vi} %f
        Open=m %f

This says what to do with a TEX or tEX or TeX or tex or ...

(anyway, the funny construction is intended to make upper-lower case 
irrelevant here)

The original file says that to "open" a TeX file means, open it for 
editing and use vi. Well, so I changed that.

The command "m" is short for "menu" which is a home-written script file. 
What it does is to create several other script files.

One of the created scripts, called "f" for "file" says to edit the file in 
question with JOE, not with vi. It also saves the directory in front of 
the filename, so that the file can be opened for editing with the command 
"f" no matter where you are in the computer. It also incorporates options 
for opening the file to a given line number (valuable if one has a TeX 
compile error message) and an option for opening the original file and 
another file in a split window.

A second created script file is "l" which means run latex on the file 
(which file? that file, the one you loaded up, and again you can be 
anywhere in the computer's directory tree and still do this). Moreover, 
if the file is plain TeX and not LaTeX then "l" will be clever enough to 
understand that and will run tex instead of latex.

So you might not be interested in TeX at all, but the point is that you 
can even write your own stuff and tell MC to use it.

You will also notice that on several occasions in the extension file there 
is a choice made between whether you are in the terminal or in an xterm. 
What app you use to open a file might be dependent upon that, so that 
little matter can be taken care of here, invisibly once you have done it.

One last thing:

Sometimes it will probably happen to you that the executable which the 
extension file says to use is not present on your system. As an example,

include/image
#       Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (gqview %f &); fi
        Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (/usr/bin/display 
%f &);
#       Open=display %f.
        View=%view{ascii} identify %f
        #View=%view{ascii} asciiview %f

What happened in the above is that I do not have the program called 
"gqview" which if I am not mistaken is a GNOME application and I am 
running Slackware which has pretty much dropped GNOME several versions 
ago. Thus, instead of trying to install the app which would probably also 
require me to install numerous libraries, too, I have asked the "display" 
program from ImageMagick to be used to open images.

Hope this helps.

Theodore Kilgore
_______________________________________________
Mc mailing list
http://mail.gnome.org/mailman/listinfo/mc

<Prev in Thread] Current Thread [Next in Thread>