Sixel > Ueberzug

This commit is contained in:
agryphus 2023-12-05 22:01:16 -05:00
parent f10c0a019b
commit 13a81221ad
2 changed files with 13 additions and 18 deletions

View file

@ -9,6 +9,7 @@ set ifs "\n"
set scrolloff 10 set scrolloff 10
set icons # Use icons set icons # Use icons
set period 1 # Poll directory status every X seconds set period 1 # Poll directory status every X seconds
set sixel true
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set cleaner '~/.config/lf/cleaner' # Clear preview set cleaner '~/.config/lf/cleaner' # Clear preview
set previewer '~/.config/lf/previewer' # Make preview set previewer '~/.config/lf/previewer' # Make preview
@ -62,9 +63,14 @@ cmd delete ${{
}} }}
cmd set_bg ${{ cmd set_bg ${{
rm ~/.config/wallpaper rm -f ~/.config/wallpaper
cp "$fx" ~/.config/wallpaper cp "$fx" ~/.config/wallpaper
if [ -z "$(pidof Hyprland)" ]; then
feh --bg-fill --no-fehbg "$HOME/.config/wallpaper" feh --bg-fill --no-fehbg "$HOME/.config/wallpaper"
else
swww img "$HOME/.config/wallpaper"
fi
}} }}
cmd extract ${{ cmd extract ${{
@ -108,8 +114,8 @@ cmd open ${{
inode/x-empty|\ inode/x-empty|\
text/*) text/*)
[ -v new_window ] \ [ -v new_window ] \
&& ($TERMINAL -e $SHELL -c "$EDITOR \\\"$fx\\\"" >/dev/null 2>&1 &) \ && ($TERMINAL -e $SHELL -c "$EDITOR \"$fx\"" >/dev/null 2>&1 &) \
|| ($EDITOR \"$fx\") || ($EDITOR "$fx")
;; ;;
audio/*|video/x-ms-asf) audio/*|video/x-ms-asf)
mpv --audio-display=no $f ;; mpv --audio-display=no $f ;;
@ -135,6 +141,7 @@ cmd open ${{
lf -remote "send toggle" lf -remote "send toggle"
done & done &
;; ;;
application/msword|\
application/octet-stream|\ application/octet-stream|\
application/vnd.ms-powerpoint|\ application/vnd.ms-powerpoint|\
application/vnd.oasis.opendocument.database|\ application/vnd.oasis.opendocument.database|\

View file

@ -1,19 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
image() { image() {
FILE_PATH="$1" chafa -f sixel -s "$2x$3" --animate false "$1"
X=$4
Y=$5
MW=$(($2 - 1))
MH=$3
# Handling floating terms like nvim floatterm
if [ ! -z "$LF_OVERRIDE_X" ] && [ ! -z "$LF_OVERRIDE_Y" ]; then
X="$LF_OVERRIDE_X"
Y="$LF_OVERRIDE_Y"
fi
ueberzug cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$X" -y "$Y" --max-width "$MW" --max-height "$MH" -f "$FILE_PATH"
exit 1 exit 1
} }
@ -39,7 +27,7 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
;; ;;
*/pdf) */pdf)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" [ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" && convert "$CACHE.jpg" -negate "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;; ;;
application/*zip) application/*zip)