X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=gopher.sh;h=c026b9c9839226c14ce2a7f7f706b40c2ec10a1f;hb=5afd6400c9976e720f90bf8860f7b9e877ce4282;hp=73256524e15020fcc0244ca330078f8bd42d712d;hpb=7f7487a64b9f441fcf38eb6e43a908a154ceb910;p=gofetch.git diff --git a/gopher.sh b/gopher.sh index 7325652..c026b9c 100755 --- a/gopher.sh +++ b/gopher.sh @@ -11,6 +11,7 @@ # download: fake mode to download the result without changes # ENV variables: +# LESS: will be used with 'less' (think: "export LESS=-r") # LINK_COLOR: escape sequences colour (def: 2) # - : means no escape sequence # 1 : means colour 1 @@ -46,7 +47,7 @@ if [ "$LINK_COLOR" != "-" ]; then EL="`tput init`"; fi -PREFIX="[0-9h]" +PREFIX="[0-9hIg]" # $0 [FILE] # Display a gopher menu for the given resource @@ -90,9 +91,10 @@ getsel() { cat "$1" | grep "^$PREFIX" | tail -n+"$2" | head -n 1 | cut -f"$3" } +# Save page content to 'tmp' file tmp="`mktemp -t gofetch.current_page.XXXXXX`" finish() { - rm -rf "$tmp" + rm -rf "$tmp" "$tmp.jpg" } trap finish EXIT @@ -102,6 +104,7 @@ else echo "$SELECTOR" | nc "$SERVER" "$PORT" > "$tmp" fi +# Process page content case "$MODE" in download) # Special, fake mode, only from top-level @@ -138,6 +141,24 @@ download) 9) echo "" | less ;; +g|I) + if img2aa --help >/dev/null 2>&1; then + img2aa --mode=DITHERING \ + --width=74 "$tmp" | less + elif jp2a -h >/dev/null 2>&1; then + if convert -h >/dev/null 2>&1; then + convert "$tmp" "$tmp.jpg" + jp2a --border --chars=" .-+=o8#"\ + --width=74 "$tmp.jpg" | less + else + echo "required program not found to view images: convert" \ + | less + fi + else + echo "required program not found to view images:" \ + jp2a or img2aa | less + fi +;; *) echo "unknwon selector mode: <$MODE>" | less exit 3