1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-10-09 19:11:15 +02:00

ueberzug&vifm: ready for new version

This commit is contained in:
2023-07-09 15:52:48 +02:00
parent fd29c9e82a
commit ea1882895c
3 changed files with 93 additions and 198 deletions

View File

@@ -1,23 +1,21 @@
#!/usr/bin/env bash
#!/bin/sh
# by cirala, checkout github.com/cirala/vifmimg
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
if [ ! -f "/usr/bin/ueberzug" ]; then
vifm
exit
if [ -z "$(command -v vifm)" ]; then
printf "vifm isn't installed on your system!\n"
exit 1
elif [ -z "$(command -v ueberzug)" ]; then
exec vifm "$@"
else
cleanup() {
exec 3>&-
rm "$FIFO_UEBERZUG"
}
[ ! -d "$HOME/.cache/vifm" ] && mkdir -p "$HOME/.cache/vifm"
export FIFO_UEBERZUG="$HOME/.cache/vifm/ueberzug-${$}"
mkfifo "$FIFO_UEBERZUG"
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
exec 3>"$FIFO_UEBERZUG"
trap cleanup EXIT
vifm "$@" 3>&-
vifmimg clear
fi
function cleanup {
rm "$FIFO_UEBERZUG" 2>/dev/null
pkill -P $$ 2>/dev/null
}
pkill -P $$ 2>/dev/null
rm "$FIFO_UEBERZUG" 2>/dev/null
mkfifo "$FIFO_UEBERZUG" >/dev/null
trap cleanup EXIT 2>/dev/null
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash 2>&1 >/dev/null &
vifm "$@"
cleanup