From 6e6dc45da0f9263f300372f22607d8422cd755d0 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Sep 2022 13:42:05 +0200 Subject: [PATCH] upstream changes --- ranger/.config/ranger/rifle.conf | 7 ++++ ranger/.config/ranger/scope.sh | 71 +++++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/ranger/.config/ranger/rifle.conf b/ranger/.config/ranger/rifle.conf index 2178b91..9178c89 100644 --- a/ranger/.config/ranger/rifle.conf +++ b/ranger/.config/ranger/rifle.conf @@ -178,12 +178,15 @@ ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@" ext cb[rz], has qcomicbook, X, flag f = qcomicbook "$@" ext cb[rz], has mcomix, X, flag f = mcomix -- "$@" ext cb[rz], has zathura, X, flag f = zathura -- "$@" +ext cb[rz], has atril, X, flag f = atril -- "$@" ext sla, has scribus, X, flag f = scribus -- "$@" #------------------------------------------- # Images #------------------------------------------- +mime ^image, has viewnior, X, flag f = viewnior -- "$@" + mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" mime ^image/svg, has display, X, flag f = display -- "$@" @@ -199,6 +202,7 @@ mime ^image, has nomacs, X, flag f = nomacs -- "$@" mime ^image, has geeqie, X, flag f = geeqie -- "$@" mime ^image, has gpicview, X, flag f = gpicview -- "$@" mime ^image, has gwenview, X, flag f = gwenview -- "$@" +mime ^image, has xviewer, X, flag f = xviewer -- "$@" mime ^image, has mcomix, X, flag f = mcomix -- "$@" mime ^image, has gimp, X, flag f = gimp -- "$@" mime ^image, has krita, X, flag f = krita -- "$@" @@ -227,6 +231,9 @@ ext ace, has unace = unace l "$1" | less ext ace, has unace = for file in "$@"; do unace e "$file"; done ext rar, has unrar = unrar l "$1" | less ext rar, has unrar = for file in "$@"; do unrar x "$file"; done +ext rar|zip, has qcomicbook, X, flag f = qcomicbook "$@" +ext rar|zip, has mcomix, X, flag f = mcomix -- "$@" +ext rar|zip, has zathura, X, flag f = zathura -- "$@" #------------------------------------------- # Fonts diff --git a/ranger/.config/ranger/scope.sh b/ranger/.config/ranger/scope.sh index 9a47bd3..feb6022 100755 --- a/ranger/.config/ranger/scope.sh +++ b/ranger/.config/ranger/scope.sh @@ -80,12 +80,16 @@ handle_extension() { exit 1;; ## OpenDocument - odt|ods|odp|sxw) + odt|sxw) ## Preview as text conversion odt2txt "${FILE_PATH}" && exit 5 ## Preview as markdown conversion pandoc -s -t markdown -- "${FILE_PATH}" && exit 5 exit 1;; + ods|odp) + ## Preview as text conversion (unsupported by pandoc for markdown) + odt2txt "${FILE_PATH}" && exit 5 + exit 1;; ## XLSX xlsx) @@ -104,7 +108,15 @@ handle_extension() { ;; ## JSON - json|ipynb) + json) + jq --color-output . "${FILE_PATH}" && exit 5 + python -m json.tool -- "${FILE_PATH}" && exit 5 + ;; + + ## Jupyter Notebooks + ipynb) + jupyter nbconvert --to markdown "${FILE_PATH}" --stdout | env COLORTERM=8bit bat --color=always --style=plain --language=markdown && exit 5 + jupyter nbconvert --to markdown "${FILE_PATH}" --stdout && exit 5 jq --color-output . "${FILE_PATH}" && exit 5 python -m json.tool -- "${FILE_PATH}" && exit 5 ;; @@ -128,9 +140,11 @@ handle_image() { local mimetype="${1}" case "${mimetype}" in ## SVG - # image/svg+xml|image/svg) - # convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 - # exit 1;; + image/svg+xml|image/svg) + rsvg-convert --keep-aspect-ratio --width "${DEFAULT_SIZE%x*}" "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}.png" \ + && mv "${IMAGE_CACHE_PATH}.png" "${IMAGE_CACHE_PATH}" \ + && exit 6 + exit 1;; ## DjVu # image/vnd.djvu) @@ -149,16 +163,24 @@ handle_image() { convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 fi - ## `w3mimgdisplay` will be called for all images (unless overriden + ## `w3mimgdisplay` will be called for all images (unless overridden ## as above), but might fail for unsupported types. exit 7;; ## Video # video/*) - # # Thumbnail + # # Get embedded thumbnail + # ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy "${IMAGE_CACHE_PATH}" && exit 6 + # # Get frame 10% into video # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 # exit 1;; + ## Audio + # audio/*) + # # Get embedded thumbnail + # ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy \ + # "${IMAGE_CACHE_PATH}" && exit 6;; + ## PDF # application/pdf) # pdftoppm -f 1 -l 1 \ @@ -248,19 +270,23 @@ handle_image() { # mv "${TMPPNG}" "${IMAGE_CACHE_PATH}" # } - # case "${FILE_EXTENSION_LOWER}" in - # ## 3D models - # ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH} - # ## is hardcoded as jpeg. So we make a tempfile.png and just - # ## move/rename it to jpg. This works because image libraries are - # ## smart enough to handle it. - # csg|scad) - # openscad_image "${FILE_PATH}" && exit 6 - # ;; - # 3mf|amf|dxf|off|stl) - # openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6 - # ;; - # esac + case "${FILE_EXTENSION_LOWER}" in + ## 3D models + ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH} + ## is hardcoded as jpeg. So we make a tempfile.png and just + ## move/rename it to jpg. This works because image libraries are + ## smart enough to handle it. + # csg|scad) + # openscad_image "${FILE_PATH}" && exit 6 + # ;; + # 3mf|amf|dxf|off|stl) + # openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6 + # ;; + drawio) + draw.io -x "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" \ + --width "${DEFAULT_SIZE%x*}" && exit 6 + exit 1;; + esac } handle_mime() { @@ -337,6 +363,11 @@ handle_mime() { mediainfo "${FILE_PATH}" && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; + + ## ELF files (executables and shared objects) + application/x-executable | application/x-pie-executable | application/x-sharedlib) + readelf -WCa "${FILE_PATH}" && exit 5 + exit 1;; esac }