dotfiles.git

commit 33b791be0ce8c0f1e69407e4b151a19b5fb23e6e

Author: Adam Evyčędo <git@apiote.xyz>

fixes to previewers

 .config/sh/functions | 18 +++++++++---------


diff --git a/.config/sh/functions b/.config/sh/functions
index 124085d692e6bb15f513cf1e49789d33537576ce..7c8984666b12b9eaf92cb9b99cab37f2c2b3a6c8 100644
--- a/.config/sh/functions
+++ b/.config/sh/functions
@@ -739,13 +739,13 @@ 		luakit "$1"
 		exit
 	fi
 
-	mime=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f1 | tr -d ' ')
-	charset=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f2 | tr -d ' ')
+	mime=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f1 | tr -d ' ')
+	charset=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f2 | tr -d ' ')
 	case $mime in
 		text/*) bat -f "$1" ;;
 		image/*) setsid swayimg "$1" >/dev/null 2>&1 & ;;
-		video/*) mpv "$1" >/dev/null 2>&1 & ;;
-		audio/*) mpa "$1" >/dev/null 2>&1 & ;;
+		video/*) setsid fun mpv "$1" >/dev/null 2>&1 & ;;
+		audio/*) setsid fun mpa "$1" >/dev/null 2>&1 & ;;
 		application/json) bat -f "$1" ;;
 		application/javascript) bat -f "$1" ;;
 		application/pdf) setsid zathura "$1" >/dev/null 2>&1 & ;;
@@ -765,9 +765,9 @@ 	esac
 }
 
 preview() {
-	mime=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f1 | tr -d ' ')
-	charset=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f2 | tr -d ' ')
-	# TODO images, maybe stills from videos, pdfs, zstd in tar
+	mime=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f1 | tr -d ' ')
+	charset=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f2 | tr -d ' ')
+	# TODO images, maybe stills from videos, pdfs
 	case $mime in
 		text/*) view "$1" ;;
 		image/*|video/*|audio/*) ffprobe "$1" 2>&1;;
@@ -788,8 +788,8 @@ 	esac
 }
 
 edit() {
-	mime=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f1 | tr -d ' ')
-	charset=$(file -i "$1" | cut -d ':' -f2 | cut -d ';' -f2 | tr -d ' ')
+	mime=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f1 | tr -d ' ')
+	charset=$(file -i "$1" | rev | cut -d ':' -f1 | rev | cut -d ';' -f2 | tr -d ' ')
 	case $mime in
 		text/*) hx "$1" ;;
 		image/*) setsid gimp "$1" >/dev/null 2>&1 & ;;