git://git.nikiroo.be
/
gofetch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7f7487a
)
gopher.sh: support jp2a to display images
author
Niki Roo
<roo.niki@gmail.com>
Fri, 6 Apr 2018 12:28:14 +0000
(14:28 +0200)
committer
Niki Roo
<roo.niki@gmail.com>
Fri, 6 Apr 2018 12:28:14 +0000
(14:28 +0200)
gopher.sh
patch
|
blob
|
blame
|
history
diff --git
a/gopher.sh
b/gopher.sh
index 73256524e15020fcc0244ca330078f8bd42d712d..6b16f264bed62a596d1feefe2f826639f0e0cab7 100755
(executable)
--- a/
gopher.sh
+++ b/
gopher.sh
@@
-11,6
+11,7
@@
# download: fake mode to download the result without changes
# ENV variables:
# 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
# LINK_COLOR: escape sequences colour (def: 2)
# - : means no escape sequence
# 1 : means colour 1
@@
-90,9
+91,10
@@
getsel() {
cat "$1" | grep "^$PREFIX" | tail -n+"$2" | head -n 1 | cut -f"$3"
}
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() {
tmp="`mktemp -t gofetch.current_page.XXXXXX`"
finish() {
- rm -rf "$tmp"
+ rm -rf "$tmp"
"$tmp.jpg"
}
trap finish EXIT
}
trap finish EXIT
@@
-102,6
+104,7
@@
else
echo "$SELECTOR" | nc "$SERVER" "$PORT" > "$tmp"
fi
echo "$SELECTOR" | nc "$SERVER" "$PORT" > "$tmp"
fi
+# Process page content
case "$MODE" in
download)
# Special, fake mode, only from top-level
case "$MODE" in
download)
# Special, fake mode, only from top-level
@@
-138,6
+141,22
@@
download)
9)
echo "<BINARY FILE>" | less
;;
9)
echo "<BINARY FILE>" | less
;;
+g|I)
+ if convert -h >/dev/null 2>&1; then
+ if jp2a -h >/dev/null 2>&1; then
+ convert "$tmp" "$tmp.jpg"
+ # not supported: --chars=" ░▒▓█"
+ jp2a --border --colors --chars=" .-+=o8#"\
+ --width=74 "$tmp.jpg" | less
+ else
+ echo "required program not found to view images: jp2a" \
+ | less
+ fi
+ else
+ echo "required program not found to view images: convert" \
+ | less
+ fi
+;;
*)
echo "unknwon selector mode: <$MODE>" | less
exit 3
*)
echo "unknwon selector mode: <$MODE>" | less
exit 3