summary refs log tree commit diff stats
path: root/ranger/data
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2015-09-19 21:26:13 +0200
committerhut <hut@lepus.uberspace.de>2015-09-19 21:26:13 +0200
commit5ea0f609b93a3954e4e26b8387f7adab8fddc94b (patch)
tree79374d887d27809641e3c242415aaa2869ab440e /ranger/data
parent3fbb0f737b632bf2c116091eb73362d37583f746 (diff)
parent40bd7bc111775ae10ea547bc4d281830eb95757a (diff)
downloadranger-5ea0f609b93a3954e4e26b8387f7adab8fddc94b.tar.gz
Merge branch 'universal_scope_sh' of https://github.com/GermainZ/ranger
Diffstat (limited to 'ranger/data')
-rwxr-xr-xranger/data/scope.sh30
1 files changed, 23 insertions, 7 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index 3611c961..19404019 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -17,12 +17,14 @@
 # 4    | fix height | success. Don't reload when height changes
 # 5    | fix both   | success. Don't ever reload
 # 6    | image      | success. display the image $cached points to as an image preview
+# 7    | image      | success. display the file directly as an image
 
 # Meaningful aliases for arguments:
-path="$1"    # Full path of the selected file
-width="$2"   # Width of the preview pane (number of fitting characters)
-height="$3"  # Height of the preview pane (number of fitting characters)
-cached="$4"  # Path that should be used to cache image previews
+path="$1"            # Full path of the selected file
+width="$2"           # Width of the preview pane (number of fitting characters)
+height="$3"          # Height of the preview pane (number of fitting characters)
+cached="$4"          # Path that should be used to cache image previews
+preview_images="$5"  # "True" if image previews are enabled, "False" otherwise.
 
 maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln
 
@@ -44,6 +46,23 @@ trim() { head -n "$maxln"; }
 # wraps highlight to treat exit code 141 (killed by SIGPIPE) as success
 highlight() { command highlight "$@"; test $? = 0 -o $? = 141; }
 
+# Image previews, if enabled in ranger.
+if [ "$preview_images" = "True" ]; then
+    case "$mimetype" in
+        # Image previews for SVG files, disabled by default.
+        ###image/svg+xml)
+        ###   convert "$path" "$cached" && exit 6 || exit 1;;
+        # Image previews for image files. w3mimgdisplay will be called for all
+        # image files (unless overriden as above), but might fail for
+        # unsupported types.
+        image/*)
+            exit 7;;
+        # Image preview for video, disabled by default.:
+        ###video/*)
+        ###    ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
+    esac
+fi
+
 case "$extension" in
     # Archive extensions:
     7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
@@ -76,9 +95,6 @@ case "$mimetype" in
     # Ascii-previews of images:
     image/*)
         img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
-    # Image preview for videos, disabled by default:
-    # video/*)
-    #     ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
     # Display information about media files:
     video/* | audio/*)
         exiftool "$path" && exit 5