mirror of
https://github.com/librephoenix/nixos-config
synced 2025-01-18 22:55:52 +05:30
Added a lot more ranger file previews!
This commit is contained in:
parent
74c362e9ca
commit
4c25bedde2
|
@ -256,7 +256,7 @@ set cd_tab_fuzzy false
|
||||||
|
|
||||||
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
|
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
|
||||||
# disable this feature.
|
# disable this feature.
|
||||||
set preview_max_size 200000000
|
set preview_max_size 0
|
||||||
|
|
||||||
# The key hint lists up to this size have their sublists expanded.
|
# The key hint lists up to this size have their sublists expanded.
|
||||||
# Otherwise the submaps are replaced with "...".
|
# Otherwise the submaps are replaced with "...".
|
||||||
|
|
|
@ -170,29 +170,29 @@ handle_image() {
|
||||||
## as above), but might fail for unsupported types.
|
## as above), but might fail for unsupported types.
|
||||||
exit 7;;
|
exit 7;;
|
||||||
|
|
||||||
## Video
|
# Video
|
||||||
# video/*)
|
video/*)
|
||||||
# # Get embedded thumbnail
|
# Get frame 10% into video
|
||||||
# ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy "${IMAGE_CACHE_PATH}" && exit 6
|
ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
|
||||||
# # Get frame 10% into video
|
# Get embedded thumbnail
|
||||||
# ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
|
ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
# exit 1;;
|
exit 1;;
|
||||||
|
|
||||||
## Audio
|
# Audio
|
||||||
# audio/*)
|
audio/*)
|
||||||
# # Get embedded thumbnail
|
# Get embedded thumbnail
|
||||||
# ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy \
|
ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy \
|
||||||
# "${IMAGE_CACHE_PATH}" && exit 6;;
|
"${IMAGE_CACHE_PATH}" && exit 6;;
|
||||||
|
|
||||||
## PDF
|
# PDF
|
||||||
# application/pdf)
|
application/pdf)
|
||||||
# pdftoppm -f 1 -l 1 \
|
pdftoppm -f 1 -l 1 \
|
||||||
# -scale-to-x "${DEFAULT_SIZE%x*}" \
|
-scale-to-x "${DEFAULT_SIZE%x*}" \
|
||||||
# -scale-to-y -1 \
|
-scale-to-y -1 \
|
||||||
# -singlefile \
|
-singlefile \
|
||||||
# -jpeg -tiffcompression jpeg \
|
-jpeg -tiffcompression jpeg \
|
||||||
# -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
|
-- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
|
||||||
# && exit 6 || exit 1;;
|
&& exit 6 || exit 1;;
|
||||||
|
|
||||||
|
|
||||||
## ePub, MOBI, FB2 (using Calibre)
|
## ePub, MOBI, FB2 (using Calibre)
|
||||||
|
@ -205,7 +205,7 @@ handle_image() {
|
||||||
# >/dev/null && exit 6
|
# >/dev/null && exit 6
|
||||||
# exit 1;;
|
# exit 1;;
|
||||||
|
|
||||||
## Font
|
# Font
|
||||||
application/font*|application/*opentype)
|
application/font*|application/*opentype)
|
||||||
preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png"
|
preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png"
|
||||||
if fontimage -o "${preview_png}" \
|
if fontimage -o "${preview_png}" \
|
||||||
|
@ -265,29 +265,42 @@ handle_image() {
|
||||||
# ;;
|
# ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# openscad_image() {
|
openscad_image() {
|
||||||
# TMPPNG="$(mktemp -t xxxxxx.png)"
|
TMPPNG="$(mktemp -t XXXXXXXXXX --suffix '.png')"
|
||||||
# openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
|
openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
|
||||||
# --imgsize="${OPENSCAD_IMGSIZE/x/,}" \
|
--imgsize="${OPENSCAD_IMGSIZE/x/,}" \
|
||||||
# -o "${TMPPNG}" "${1}"
|
-o "${TMPPNG}" "${1}"
|
||||||
# mv "${TMPPNG}" "${IMAGE_CACHE_PATH}"
|
mv "${TMPPNG}" "${IMAGE_CACHE_PATH}"
|
||||||
# }
|
}
|
||||||
|
|
||||||
|
FULL_FILE_PATH=$(readlink -f $FILE_PATH);
|
||||||
case "${FILE_EXTENSION_LOWER}" in
|
case "${FILE_EXTENSION_LOWER}" in
|
||||||
## 3D models
|
# 3D models
|
||||||
## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH}
|
# OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH}
|
||||||
## is hardcoded as jpeg. So we make a tempfile.png and just
|
# is hardcoded as jpeg. So we make a tempfile.png and just
|
||||||
## move/rename it to jpg. This works because image libraries are
|
# move/rename it to jpg. This works because image libraries are
|
||||||
## smart enough to handle it.
|
# smart enough to handle it.
|
||||||
# csg|scad)
|
csg|scad)
|
||||||
# openscad_image "${FILE_PATH}" && exit 6
|
openscad_image "${FILE_PATH}" && exit 6
|
||||||
# ;;
|
;;
|
||||||
# 3mf|amf|dxf|off|stl)
|
stl)
|
||||||
# openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6
|
openscad_image <(echo "import(\"${FULL_FILE_PATH}\");") && exit 6
|
||||||
# ;;
|
;;
|
||||||
|
3mf|amf|dxf|off|stl)
|
||||||
|
openscad_image <(echo "import(\"${FULL_FILE_PATH}\");") && exit 6
|
||||||
|
;;
|
||||||
drawio)
|
drawio)
|
||||||
draw.io -x "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" \
|
draw.io -x "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" \
|
||||||
--width "${DEFAULT_SIZE%x*}" && exit 6
|
--width "${DEFAULT_SIZE%x*}" && exit 6
|
||||||
|
;;
|
||||||
|
blend|blend~)
|
||||||
|
blender-thumbnailer "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
;;
|
||||||
|
kra|kra~)
|
||||||
|
unzip -pP "" -- "${FILE_PATH}" "mergedimage.png" > "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
;;
|
||||||
|
xopp|xopp~)
|
||||||
|
xournalpp "${FILE_PATH}" --create-img "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
ranger = super.ranger.overrideAttrs (oldAttrs: rec {
|
ranger = super.ranger.overrideAttrs (oldAttrs: rec {
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
substituteInPlace ranger/__init__.py \
|
substituteInPlace ranger/__init__.py \
|
||||||
--replace "DEFAULT_PAGER = 'less'" "DEFAULT_PAGER = '${lib.getBin pkgs.less}/bin/less'"
|
--replace "DEFAULT_PAGER = 'less'" "DEFAULT_PAGER = '${lib.getBin pkgs.bat}/bin/bat'"
|
||||||
|
|
||||||
# give image previews out of the box when building with w3m
|
# give image previews out of the box when building with w3m
|
||||||
substituteInPlace ranger/config/rc.conf \
|
substituteInPlace ranger/config/rc.conf \
|
||||||
|
@ -28,5 +28,10 @@
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
poppler_utils
|
||||||
|
librsvg
|
||||||
|
ffmpegthumbnailer
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue