Jaro
https://github.com/isamert/jaro
Jaro is a sane alternative to xdg-open with easy bindings written in Scheme.
1. Setup
Download this file https://github.com/isamert/jaro/blob/master/data/mimeapps.list to /.config
to redirect all xdg-open
requests to jaro
and create the needed jaro desktop file https://github.com/isamert/jaro/blob/master/data/jaro.desktop in ~/.local/share/applications/
so xdg-open
doesn’t get mad.
2. Config
~/.config/associations
2.1. Open images with sxiv
(assoc #:pattern "image/.*" #:program "sxiv %f")
2.2. Open youtube links with mpv (notice it has to go before the librewolf one)
(assoc #:pattern "^https?://(www.)?youtube.com/watch\\?.*v=" #:program "mpv %f")
2.3. Open http/https with librewolf
(assoc #:pattern "^https?://.*" #:program "librewolf %f")
2.4. Open text files with nvim, if needed create a floating terminal and open it there
(assoc #:pattern "^text/.*" #:program "nvim %f" #:term "alacritty -o window.dimensions.lines=34 -o window.dimensions.columns=120 --title scratchpad --class scratchpad -e")
2.5. Open dirs with lf, if needed create a floating terminal and open it there
(assoc #:pattern "inode/directory" #:program "lf %f" #:term "alacritty -o window.dimensions.lines=34 -o window.dimensions.columns=120 --title scratchpad --class scratchpad -e")
2.6. Open pdfs with zathura
(assoc #:pattern "application/(x-)?(pdf)$" #:program "zathura %f")
2.7. List zip content1
(assoc #:pattern "application/zip" #:program "zipinfo %f" #:term "alacritty -o window.dimensions.lines=34 -o window.dimensions.columns=120 --title scratchpad --class scratchpad -e")
2.8. List rar content 1
(assoc #:pattern "application/x-rar-compressed" #:program "unrar l %f" #:term "alacritty -o window.dimensions.lines=34 -o window.dimensions.columns=120 --title scratchpad --class scratchpad -e")
Put each association in your config file and check it with xdg-open ...
or jaro ...
Configure xdg-open
to pass request to jaro
as browsers usually open with xdg-open (you can replace it too or do whatever you want).
Footnotes:
1
I don’t like autoextracting