From 6e720c0c08224ad5ac91dc6cf7ba13fbfc60d7f7 Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Wed, 11 Mar 2020 18:09:52 +0100 Subject: [PATCH] setup tuir --- README.org | 4 ++- tuir/.local/bin/sxiveh | 10 ++++++ tuir/.mailcap | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 tuir/.local/bin/sxiveh create mode 100644 tuir/.mailcap diff --git a/README.org b/README.org index 34ce9a5..127fd9f 100644 --- a/README.org +++ b/README.org @@ -39,15 +39,16 @@ A repository of my personal configuration files. - [[https://github.com/baskerville/bspwm][bspwm]] - [[https://github.com/caffeine-ng/caffeine-ng][caffeine-ng]] - [[https://the.exa.website/][exa]] +- [[https://fishshell.com/][fish]] - [[https://github.com/junegunn/fzf][fzf]] - [[https://git-scm.com/][git]] - [[https://github.com/cylgom/ly][Ly]] +- [[https://github.com/internalfx/mailcap][mailcap]] - [[https://mpv.io/][mpv]] - [[https://github.com/dylanaraps/pfetch][pfetch]] - [[https://github.com/dylanaraps/pywal][pywal]] - [[http://www.gnu.org/software/stow/][stow]] - [[https://www.python.org/][Python]] -- [[https://fishshell.com/][fish]] - [[https://github.com/baskerville/sxhkd][sxhkd]] - [[https://github.com/stoeckmann/xwallpaper][xwallpaper]] ** LSP Backends @@ -80,6 +81,7 @@ A repository of my personal configuration files. - [[http://jonls.dk/redshift/][redshift]] - [[https://github.com/baskerville/sxhkd][sxhkd]] - [[https://tmux.github.io/][tmux]] +- [[https://gitlab.com/ajak/tuir][tuir]] - [[https://vifm.info/][vifm]] - [[https://weechat.org/][weechat]] diff --git a/tuir/.local/bin/sxiveh b/tuir/.local/bin/sxiveh new file mode 100755 index 0000000..e798257 --- /dev/null +++ b/tuir/.local/bin/sxiveh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +case $@ in +http*://*) + curl -o sxivimage -s "$@" + sxiv sxivimage + rm sxivimage + ;; +*) sxiv "$@" ;; +esac diff --git a/tuir/.mailcap b/tuir/.mailcap new file mode 100644 index 0000000..05708a8 --- /dev/null +++ b/tuir/.mailcap @@ -0,0 +1,71 @@ +# Example mailcap file for Terminal UI for Reddit +# https://gitlab.com/ajak/tuir/ +# +# Copy the contents of this file to {HOME}/.mailcap, or point to it using $MAILCAPS +# Then launch TUIR using the --enable-media flag. All shell commands defined in +# this file depend on external programs that must be installed on your system. +# +# HELP REQUESTED! If you come up with your own commands (especially for OS X) +# and would like to share, please post an issue on the GitHub tracker and we +# can get them added to this file as references. +# +# +# Mailcap 101 +# - The first entry with a matching MIME type will be executed, * is a wildcard +# - %s will be replaced with the image or video url +# - Add ``test=test -n "$DISPLAY"`` if your command opens a new window +# - Add ``needsterminal`` for commands that use the terminal +# - Add ``copiousoutput`` for commands that dump text to stdout + +############################################################################### +# Commands below this point will open media in a separate window without +# pausing execution of TUIR. +############################################################################### + +# Feh is a simple and effective image viewer +# Note that tuir returns a list of urls for imgur albums, so we don't put quotes +# around the `%s` +# image/x-imgur-album; feh -g 640x480 -. %s; test=test -n "$DISPLAY" +image/gif; mpv '%s' --loop=inf; test=test -n "$DISPLAY" +# image/*; feh -g 640x480 -. '%s'; test=test -n "$DISPLAY" +image/*; sxiveh '%s'; test=test -n "$DISPLAY" + +# Youtube videos are assigned a custom mime-type, which can be streamed with +# vlc or youtube-dl. +# video/x-youtube; vlc '%s' --width 640 --height 480; test=test -n "$DISPLAY" +video/x-youtube; mpv '%s'; test=test -n "$DISPLAY" + +# Mpv is a simple and effective video streamer +video/*; mpv '%s' --loop=inf; test=test -n "$DISPLAY" + +############################################################################### +# Commands below this point will attempt to display media directly in the +# terminal when a desktop is not available (e.g. inside of an SSH session) +############################################################################### + +# View images directly in your terminal with iTerm2 +# curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash +# image/*; bash -c '[[ "%s" == http* ]] && (curl -s %s | ~/.iterm2/imgcat) || ~/.iterm2/imgcat %s' && read -n 1; needsterminal + +# View true images in the terminal, supported by rxvt-unicode, xterm and st +# Requires the w3m-img package +# image/*; w3m -o 'ext_image_viewer=off' '%s'; needsterminal + +# Don't have a solution for albums yet +image/x-imgur-album; echo + +# 256 color images using half-width unicode characters +# Much higher quality that img2txt, but must be built from source +# https://github.com/rossy/img2xterm +image/*; curl -s '%s' | convert -resize 80x80 - jpg:/tmp/tuir.jpg && img2xterm /tmp/tuir.jpg; needsterminal; copiousoutput + +# Display images in classic ascii using img2txt and lib-caca +image/*; curl -s '%s' | convert - jpg:/tmp/tuir.jpg && img2txt -f utf8 /tmp/tuir.jpg; needsterminal; copiousoutput + +# Full motion videos - requires a framebuffer to view +video/x-youtube; mpv -vo drm -quiet '%s'; needsterminal +video/*; mpv -vo drm -quiet '%s'; needsterminal + +# Ascii videos +# video/x-youtube; youtube-dl -q -o - '%s' | mplayer -cache 8192 -vo caca -quiet -; needsterminal +# video/*; wget '%s' -O - | mplayer -cache 8192 -vo caca -quiet -; needsterminal