lf with sixels support
parent
7d0ff36a37
commit
c905a33643
|
@ -6,7 +6,6 @@ let
|
||||||
rm = "${pkgs.coreutils-full}/bin/rm";
|
rm = "${pkgs.coreutils-full}/bin/rm";
|
||||||
mkdir = "${pkgs.coreutils-full}/bin/mkdir";
|
mkdir = "${pkgs.coreutils-full}/bin/mkdir";
|
||||||
mkfifo = "${pkgs.coreutils-full}/bin/mkfifo";
|
mkfifo = "${pkgs.coreutils-full}/bin/mkfifo";
|
||||||
ueberzug = "${pkgs.ueberzug}/bin/ueberzug";
|
|
||||||
lfcache = "${config.home.homeDirectory}/.cache/lf";
|
lfcache = "${config.home.homeDirectory}/.cache/lf";
|
||||||
in pkgs.writeScriptBin "lf-wrapper" ''
|
in pkgs.writeScriptBin "lf-wrapper" ''
|
||||||
#!${shell}
|
#!${shell}
|
||||||
|
@ -176,20 +175,10 @@ in pkgs.writeScriptBin "lf-wrapper" ''
|
||||||
*.nix=:\
|
*.nix=:\
|
||||||
"
|
"
|
||||||
|
|
||||||
cleanup () {
|
|
||||||
exec 3>&-
|
|
||||||
rm "$FIFO_UEBERZUG"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
${lf} "$@"
|
${lf} "$@"
|
||||||
else
|
else
|
||||||
[ ! -d "${lfcache}" ] && ${mkdir} -p "${lfcache}"
|
[ ! -d "${lfcache}" ] && ${mkdir} -p "${lfcache}"
|
||||||
export FIFO_UEBERZUG="${lfcache}/ueberzug-''$''$"
|
${lf} "$@" 3>&-
|
||||||
${mkfifo} "$FIFO_UEBERZUG"
|
|
||||||
${ueberzug} layer -s <"$FIFO_UEBERZUG" -p json &
|
|
||||||
exec 3>"$FIFO_UEBERZUG"
|
|
||||||
trap cleanup HUP INT QUIT TERM PWR EXIT
|
|
||||||
${lf} "$@"
|
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
|
|
|
@ -1,31 +1,28 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
atool = "${pkgs.atool}/bin/atool";
|
||||||
|
awk = "${pkgs.gawk}/bin/awk";
|
||||||
|
bat = "${pkgs.bat}/bin/bat";
|
||||||
|
chafa = "${pkgs.chafa}/bin/chafa";
|
||||||
|
col = "${pkgs.util-linux}/bin/col";
|
||||||
|
ffmpegthumbnailer = "${pkgs.ffmpegthumbnailer}/bin/ffmpegthumbnailer";
|
||||||
file = "${pkgs.file}/bin/file";
|
file = "${pkgs.file}/bin/file";
|
||||||
|
gpg = "${pkgs.gnupg}/bin/gpg";
|
||||||
|
lfcache = "${config.home.homeDirectory}/.cache/lf";
|
||||||
lynx = "${pkgs.lynx}/bin/lynx";
|
lynx = "${pkgs.lynx}/bin/lynx";
|
||||||
man = "${pkgs.man}/bin/man";
|
man = "${pkgs.man}/bin/man";
|
||||||
col = "${pkgs.util-linux}/bin/col";
|
|
||||||
bat = "${pkgs.bat}/bin/bat";
|
|
||||||
atool = "${pkgs.atool}/bin/atool";
|
|
||||||
odt2txt = "${pkgs.odt2txt}/bin/odt2txt";
|
|
||||||
gpg = "${pkgs.gnupg}/bin/gpg";
|
|
||||||
mediainfo = "${pkgs.mediainfo}/bin/mediainfo";
|
mediainfo = "${pkgs.mediainfo}/bin/mediainfo";
|
||||||
|
odt2txt = "${pkgs.odt2txt}/bin/odt2txt";
|
||||||
|
pdftoppm = "${pkgs.poppler_utils}/bin/pdftoppm";
|
||||||
printf = "${pkgs.coreutils-full}/bin/printf";
|
printf = "${pkgs.coreutils-full}/bin/printf";
|
||||||
lfcache = "${config.home.homeDirectory}/.cache/lf";
|
|
||||||
stat = "${pkgs.coreutils-full}/bin/stat";
|
|
||||||
readlink = "${pkgs.coreutils-full}/bin/readlink";
|
readlink = "${pkgs.coreutils-full}/bin/readlink";
|
||||||
sha256sum = "${pkgs.coreutils-full}/bin/sha256sum";
|
sha256sum = "${pkgs.coreutils-full}/bin/sha256sum";
|
||||||
awk = "${pkgs.gawk}/bin/awk";
|
stat = "${pkgs.coreutils-full}/bin/stat";
|
||||||
ffmpegthumbnailer = "${pkgs.ffmpegthumbnailer}/bin/ffmpegthumbnailer";
|
|
||||||
pdftoppm = "${pkgs.poppler_utils}/bin/pdftoppm";
|
|
||||||
in pkgs.writeShellScript "pv.sh" ''
|
in pkgs.writeShellScript "pv.sh" ''
|
||||||
|
|
||||||
image() {
|
image() {
|
||||||
if [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ -n "$FIFO_UEBERZUG" ]; then
|
${chafa} "$1" -f sixel -s "$(($2-2))x$3" | sed 's/#/\n#/g'
|
||||||
${printf} '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
|
|
||||||
else
|
|
||||||
${mediainfo} "$1"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cache_file () {
|
get_cache_file () {
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
{ config, inputs, pkgs, stablePkgs, ... }:
|
{ config, inputs, pkgs, stablePkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: {
|
||||||
|
# use lf fork with support for sixel graphics
|
||||||
|
lf = super.lf.overrideAttrs (old: {
|
||||||
|
src = super.fetchFromGitHub {
|
||||||
|
owner = "horriblename";
|
||||||
|
repo = "lf";
|
||||||
|
rev = "8997e5b03772d5628ed6a490777048581d978674";
|
||||||
|
sha256 = "rJq2Tv3py6HvRI1O2odTdGb1ksdijhO3FcJsPj5dm34=";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
# Let Home Manager install and manage itself.
|
# Let Home Manager install and manage itself.
|
||||||
# programs.home-manager.enable = true;
|
# programs.home-manager.enable = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue