topen
is a small script to open links on the command line. It's designed to be able to view multimedia content (images, videos, gifs, etc) without the overhead of a web browser. topen
is designed to be used with rtv, but could be useful in other contexts as well.
topen
itself is a very small python script that has a list of regular expressions describing urls, along with a script to deal with the url. Because of this, it's very easy to extend: just add another script to the helpers directory, along with a regexp of sites that it should apply to.
The default browser is w3m
. However, there is explicit support for the following sites and cases:
Site | Notes |
---|---|
Any image link | |
Any mp4 file | |
Imgur | Works with gifvs, single images, and albums |
Gfycat | Any gfycat link |
Dependency | Reason |
---|---|
python |
Main script |
w3m |
Default browser |
curl |
Download images/videos |
feh |
Display images |
mplayer |
Display videos |
youtube-dl |
Download youtube videos |
Beautiful Soup 4 | Download imgur albums |
In order to have topen
play nice with rtv
, the $DISPLAY
environment variable must be set to something that evaluates as false. I use the following alias:
alias rtv='export DISPLAY="";rtv'
topen
will try to autodetect the $DISPLAY
variable and set it back before running any handler scripts.
If you find a site that might benefit from having a script for it, submit an issue with the name of the site (and ideally some example links). Or, even better, submit a PR!