Überzug image support (#1562)

* Support for Ueberzug backend

* Ueberzug cli argument

* Fixed slight issues according to shellcheck

* Read output suppressed

* --xoffset and --yoffset support

Co-authored-by: dylan <dylan.araps@gmail.com>
This commit is contained in:
Rising Thumb 2020-10-04 13:00:26 +01:00 committed by GitHub
parent 19af3abaee
commit 314a0bc4f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 8 deletions

View File

@ -744,7 +744,8 @@ disk_display="off"
# #
# Default: 'ascii' # Default: 'ascii'
# Values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', 'off', # Values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', 'off',
# 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty' # 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty', 'ueberzug'
# Flag: --backend # Flag: --backend
image_backend="ascii" image_backend="ascii"
@ -3837,13 +3838,14 @@ image_backend() {
"off") image_backend="off" ;; "off") image_backend="off" ;;
"caca" | "catimg" | "chafa" | "jp2a" | "iterm2" | "termpix" |\ "caca" | "catimg" | "chafa" | "jp2a" | "iterm2" | "termpix" |\
"tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot") "tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot", | "ueberzug")
get_image_source get_image_source
[[ ! -f "$image" ]] && { [[ ! -f "$image" ]] && {
to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode." to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode."
return return
} }
[[ "$image_backend" == "ueberzug" ]] && wait=true;
get_window_size get_window_size
@ -4258,6 +4260,24 @@ display_image() {
"$image" "$image"
;; ;;
"ueberzug")
if [ "$wait" = true ];then
wait=false;
else
source "$(ueberzug library)"
ImageLayer 0< <(
ImageLayer::add\
['identifier']="neofetch"\
['x']="$xoffset" ['y']="$yoffset"\
['max_width']="$((width / font_width))"\
['max_height']="$((height / font_height))"\
['path']="$image";
read -rs;
)
fi
;;
"catimg") "catimg")
catimg -w "$((width*catimg_size / font_width))" -r "$catimg_size" "$image" catimg -w "$((width*catimg_size / font_width))" -r "$catimg_size" "$image"
;; ;;
@ -4921,6 +4941,7 @@ IMAGE BACKEND:
--termpix source Shortcut to use 'termpix' backend. --termpix source Shortcut to use 'termpix' backend.
--tycat source Shortcut to use 'tycat' backend. --tycat source Shortcut to use 'tycat' backend.
--w3m source Shortcut to use 'w3m' backend. --w3m source Shortcut to use 'w3m' backend.
--ueberzug source Shortcut to use 'ueberzug' backend
--off Shortcut to use 'off' backend (Disable ascii art). --off Shortcut to use 'off' backend (Disable ascii art).
NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img', NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img',
@ -5136,8 +5157,8 @@ get_args() {
# Image backend # Image backend
"--backend") image_backend="$2" ;; "--backend") image_backend="$2" ;;
"--source") image_source="$2" ;; "--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" |\ "--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" | "--pot" |\
"--pot" | "--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty") "--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty" | "--ueberzug")
image_backend="${1/--}" image_backend="${1/--}"
case $2 in case $2 in
"-"* | "") ;; "-"* | "") ;;
@ -10726,6 +10747,7 @@ main() {
# w3m-img: Draw the image a second time to fix # w3m-img: Draw the image a second time to fix
# rendering issues in specific terminal emulators. # rendering issues in specific terminal emulators.
[[ $image_backend == *w3m* ]] && display_image [[ $image_backend == *w3m* ]] && display_image
[[ $image_backend == *ueberzug* ]] && display_image
# Add neofetch info to verbose output. # Add neofetch info to verbose output.
err "Neofetch command: $0 $*" err "Neofetch command: $0 $*"

View File

@ -235,7 +235,7 @@ Possible values: bar, infobar, barinfo, off
\fB\-\-backend\fR backend \fB\-\-backend\fR backend
Which image backend to use. Which image backend to use.
Possible values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2', Possible values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2',
\&'off', 'sixel', 'tycat', 'w3m', 'kitty' \&'off', 'sixel', 'tycat', 'w3m', 'kitty', 'ueberzug'
.TP .TP
\fB\-\-source\fR source \fB\-\-source\fR source
Which image or ascii file to use. Which image or ascii file to use.
@ -280,6 +280,9 @@ Shortcut to use 'tycat' backend.
\fB\-\-w3m\fR source \fB\-\-w3m\fR source
Shortcut to use 'w3m' backend. Shortcut to use 'w3m' backend.
.TP .TP
\fB\-\-ueberzug\fR source
Shortcut to use 'ueberzug' backend.
.TP
\fB\-\-off\fR \fB\-\-off\fR
Shortcut to use 'off' backend (Disable ascii art). Shortcut to use 'off' backend (Disable ascii art).
.IP .IP
@ -365,11 +368,11 @@ west, center, east, southwest, south, southeast
.TP .TP
\fB\-\-xoffset\fR px \fB\-\-xoffset\fR px
How close the image will be to the left edge of the How close the image will be to the left edge of the
window. This only works with w3m. window. This only works with w3m and ueberzug.
.TP .TP
\fB\-\-yoffset\fR px \fB\-\-yoffset\fR px
How close the image will be to the top edge of the How close the image will be to the top edge of the
window. This only works with w3m. window. This only works with w3m and ueberzug.
.TP .TP
\fB\-\-bg_color\fR color \fB\-\-bg_color\fR color
Background color to display behind transparent image. Background color to display behind transparent image.