From 0825e282cdfeefa42a2e6292580c38f8c0834253 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 10 Jun 2016 17:58:24 +1000 Subject: [PATCH] Add terminology support --- neofetch | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index a0ac4f44..34582c17 100755 --- a/neofetch +++ b/neofetch @@ -2277,23 +2277,41 @@ getimage () { stty -echo if [ -n "$TMUX" ]; then printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\" + + elif [ "$image_backend" == "tycat" ]; then + printf "%b%s" "\033}qs\000" + else printf "%b%s" "\033[14t\033[c" fi # The escape code above prints the output AFTER the prompt so this - # loop below reads it as input. wtf xterm - read -t 1 -d c -s -r term_size + # loop below reads it as input. wtf xterm / terminology + if [ "$image_backend" == "tycat" ]; then + read -t 1 -s -r term_size + else + read -t 1 -d c -s -r term_size + fi stty echo # Split the string - term_size=${term_size//'['} - term_size=${term_size/';'} - term_size=${term_size/$'\E4'} - term_size=${term_size/t*} - term_height=${term_size/';'*} - term_width=${term_size/*';'} - + if [ "$image_backend" == "tycat" ]; then + lines=${term_size%%';'*} + columns=${term_size%';'*';'*} + columns=${columns#*';'} + font_height=${term_size##*';'} + font_weight=${term_size#*';'*';'} + font_weight=${font_weight%';'*} + term_height=$((font_height * columns)) + term_width=$((font_weight * lines)) + else + term_size=${term_size//'['} + term_size=${term_size/';'} + term_size=${term_size/$'\E4'} + term_size=${term_size/t*} + term_height=${term_size/';'*} + term_width=${term_size/*';'} + fi # If $img isn't a file or the terminal doesn't support xterm escape sequences, # fallback to ascii mode. @@ -3287,6 +3305,10 @@ if [ "$image" != "off" ]; then # If iterm2 is detected use iterm2 backend. if [ -n "$ITERM_PROFILE" ]; then image_backend="iterm2" + + elif [ ! -z "$(tycat 2>/dev/null)" ]; then + image_backend="tycat" + else image_backend="w3m" fi @@ -3311,6 +3333,10 @@ if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then "iterm2") printf "%b%s\a\n" "\033]1337;File=width=${width}px;height=${height}px;inline=1:$(base64 < "$img")" ;; + + "tycat") + tycat "$img" + ;; esac fi