Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Überzug image support #1562

Merged
merged 6 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,8 @@ disk_display="off"
#
# Default: 'ascii'
# Values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', 'off',
# 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty'
# 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty', 'ueberzug'

# Flag: --backend
image_backend="ascii"

Expand Down Expand Up @@ -3837,13 +3838,14 @@ image_backend() {
"off") image_backend="off" ;;

"caca" | "catimg" | "chafa" | "jp2a" | "iterm2" | "termpix" |\
"tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot")
"tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot", | "ueberzug")
get_image_source

[[ ! -f "$image" ]] && {
to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode."
return
}
[[ "$image_backend" == "ueberzug" ]] && wait=true;

get_window_size

Expand Down Expand Up @@ -4258,6 +4260,24 @@ display_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 -w "$((width*catimg_size / font_width))" -r "$catimg_size" "$image"
;;
Expand Down Expand Up @@ -4921,6 +4941,7 @@ IMAGE BACKEND:
--termpix source Shortcut to use 'termpix' backend.
--tycat source Shortcut to use 'tycat' backend.
--w3m source Shortcut to use 'w3m' backend.
--ueberzug source Shortcut to use 'ueberzug' backend
--off Shortcut to use 'off' backend (Disable ascii art).

NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img',
Expand Down Expand Up @@ -5135,9 +5156,9 @@ get_args() {

# Image backend
"--backend") image_backend="$2" ;;
"--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" |\
"--pot" | "--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty")
"--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" | "--pot" |\
"--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty" | "--ueberzug")
image_backend="${1/--}"
case $2 in
"-"* | "") ;;
Expand Down Expand Up @@ -10726,6 +10747,7 @@ main() {
# w3m-img: Draw the image a second time to fix
# rendering issues in specific terminal emulators.
[[ $image_backend == *w3m* ]] && display_image
[[ $image_backend == *ueberzug* ]] && display_image

# Add neofetch info to verbose output.
err "Neofetch command: $0 $*"
Expand Down
9 changes: 6 additions & 3 deletions neofetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Possible values: bar, infobar, barinfo, off
\fB\-\-backend\fR backend
Which image backend to use.
Possible values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2',
\&'off', 'sixel', 'tycat', 'w3m', 'kitty'
\&'off', 'sixel', 'tycat', 'w3m', 'kitty', 'ueberzug'
.TP
\fB\-\-source\fR source
Which image or ascii file to use.
Expand Down Expand Up @@ -280,6 +280,9 @@ Shortcut to use 'tycat' backend.
\fB\-\-w3m\fR source
Shortcut to use 'w3m' backend.
.TP
\fB\-\-ueberzug\fR source
Shortcut to use 'ueberzug' backend.
.TP
\fB\-\-off\fR
Shortcut to use 'off' backend (Disable ascii art).
.IP
Expand Down Expand Up @@ -365,11 +368,11 @@ west, center, east, southwest, south, southeast
.TP
\fB\-\-xoffset\fR px
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
\fB\-\-yoffset\fR px
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
\fB\-\-bg_color\fR color
Background color to display behind transparent image.
Expand Down