rkd77 / elinks

Fork of elinks
Other
349 stars 38 forks source link

How to configure elinks to run certain program on specific file type/extension? #216

Closed ZaxonXP closed 1 year ago

ZaxonXP commented 1 year ago

Hi,

I am using elings for a long time for reading the news as there is excellent handling of events which allows to clean up article from the trash leaving only text of the article (with Perl script). :)

However I would like to listen to the modules form http://modarchive.org. I was able to set up .mailcap file to handle the application/octet-stream: openmpt123 %s, but each time I hit the Download link it pops up the window with What to do? where I have to select [ ] Block the terminal and then I can click on Open.

Is there a way to always have the Block the terminal option selected? Is there a way to bypass that screen when the downloaded file has predefined file extensions (like XM MOD S3M)?

Kind regards, Piotr

rkd77 commented 1 year ago

Hi, there are following options in elinks.conf with sample values: set mime.mailcap.enable = 1 set mime.mailcap.path = "~/.mailcap"

Ask before using the handlers defined by mailcap.

set mime.mailcap.ask = 0

Enable mime.types support.

set mime.mimetypes.enable = 1

The search path for mime.types files. Colon-separated list of files.

set mime.mimetypes.path = "~/.mime.types:/etc/mime.types:/usr/etc/mime.types:/usr/local/etc/mime.types:/usr/share/mime.types:/usr/share/misc/mime.types"

Usually mods have different mime type than application/octet-stream. I guess it can be configured in ~/.mime.types Second issue in ~/.mailcap the semicolon is the separator, not the colon. Third, players have quiet option, so they do not need to trash terminal. Fourth option is to modify follow_url_hook . By default when follow link , files are downloaded. In follow_url you can run player directly and return '' to avoid download. Some players, for example mpv, are able to play from url.

ZaxonXP commented 1 year ago

Thanks @rkd77 for suggestion, but I think I found better solution for my use case. :)

I need to configure a shortcut for Pass URI of current link to external command (it is in the Keybinding manager). In my case I choose Alt+o for opening the link.

Then in the Option Manager -> Document -> URI passing define the program with command name and select 1 for foreground.

With that setup pressing Alt+o passes currently selected URI to the external command.

There are some pages which also explains how to setup some things: Arch Wiki ELinks: Web-browsing Made Fun