]> gitweb.fluxo.info Git - rhatto/dotfiles/ranger.git/commitdiff
Customized scope.sh with video preview, firejail workaround and debug recipe
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 2 Mar 2018 23:51:24 +0000 (20:51 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 2 Mar 2018 23:51:24 +0000 (20:51 -0300)
config.dot/ranger/scope.sh.link

index 57aaa1d427601abe07b8b6e51c01f013f1e6cf6f..989de8ed18bb0cec70887bfbdcda2b37cb8576c2 100755 (executable)
@@ -27,9 +27,16 @@ cached="$4"  # Path that should be used to cache image previews
 maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln
 
 # Find out something about the file:
-mimetype=$(file --mime-type -Lb "$path")
+#mimetype=$(file --mime-type -Lb "$path")
 extension=$(/bin/echo -E "${path##*.}" | tr "[:upper:]" "[:lower:]")
 
+# Workaround for firejail
+#mimetype=$(/usr/bin/file --mime-type -Lb "$path")
+#mimetype=$(file --mime-type -Lb "$path" | grep -v "^Redirecting symlink to")
+#mimetype=$(file --mime-type -Lb "$path" | sed -e 's/^.* //')
+#mimetype=$(file --mime-type -Lb "$path" | xargs)
+mimetype=$(firejail --quiet /usr/bin/file --mime-type -Lb "$path")
+
 # Functions:
 # runs a command and saves its output into $output.  Useful if you need
 # the return value AND want to use the output in a pipe
@@ -38,6 +45,12 @@ try() { output=$(eval '"$@"'); }
 # writes the output of the previously used "try" command
 dump() { /bin/echo -E "$output"; }
 
+# Use xmessage if you need to debug something
+#xmessage $*
+#xmessage $extension
+#xmessage $mimetype
+#exit
+
 # a common post-processing function used after most commands
 trim() { head -n "$maxln"; }
 
@@ -77,8 +90,8 @@ case "$mimetype" in
     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;;
+    video/*)
+        ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
     # Display information about media files:
     video/* | audio/*)
         exiftool "$path" && exit 5