Clagrange
TUI version of Lagrange
I've been playing about with clagrange for a couple of days and it's been quite fun using all the keyboard shorcuts. It feels much quicker to use than the gui, zipping through the tabs is a breeze.
The biggest downsidde with using it is the lack of media support, so I had to roll up my sleeves and finally learn about mimehooks.
Mimehooks for media
Mimehooks are scripts that are run whenever lagrange encounters resources that match spectified mimetypes such as audio/mpeg. They can manipulate the incoming resource before lagrange displays it. We don't care about the manipulation part for now, instead we are just focused on pipeing those media files to a different application.
Trying to find resources on how to use mimehooks was a bit of a pain but found this article by skyjake:
You're going to need at least two files; a 'mimetypes.txt' and a script file.
mimehooks.txt
From Skyjake:
Each hook is specified as three lines:
* A human-readable label
* MIME type/parameter regular expression
* Command to execute, plus additional arguments each separated with semicolons
Based on the above I ended up with the following in ~/.config/lagrange/mimehooks.txt:
Pass audio to mpv audio/* /usr/bin/env;sh;/home/corscada/.config/lagrange/hooks/mpv.sh Pass video to mpv video/* /usr/bin/env;sh;/home/corscada/.config/lagrange/hooks/mpv.sh Pass image to imv image/* /usr/bin/env;sh;/home/corscada/.config/lagrange/hooks/imv.sh
my scripts
My mpv.sh script for handling audio and video (with the loop flag it can also be used for images):
#!/usr/bin/env sh echo "20 text/gemini\r" echo "sent to external viewer" /usr/bin/mpv --loop-file --player-operation-mode=pseudo-gui -
My imv.sh script for handling images
#!/usr/bin/env sh echo "20 text/gemini\r" echo "sent to external viewer" /usr/bin/imv -
Other examples of mimehooks I found
If you want more inspiration on what mimehooks can do do checkout these:
Ainet, Data consumption tracking for gemtext files
Cthulhu, Syntax highlighting in code blocks
Source