Compare commits

...

6 Commits

3 changed files with 54 additions and 1 deletions

View File

@ -91,6 +91,52 @@ cmd delete ${{
[ $ans = "y" ] && rm -rf -- $fx
}}
cmd compressvideo ${{
clear;
set -f;
converted_filenames=""; #notify-send variable
converted_files_count=0; #notify-send variable
echo "Compression Rate? (default: 31, maximum: 50)";
read -N 2 compressionRate;
#If not a number (e.g. empty), give default 31 value
if ! [[ $compressionRate =~ ^[0-5][0-9]$ ]]; then
compressionRate="31";
fi
for pickedFilepath in $fx; do
#could instead use ffprobe but would get more complicated as the filetype suffix becomes unknown
case $pickedFilepath in
*.mp4)
tempFilepath=$(echo "$pickedFilepath" | sed 's|.mp4|(CONVERTING).mp4|');
mv -f "$pickedFilepath" "$tempFilepath";
ffmpeg -i "$tempFilepath" -vcodec libx265 -crf "$compressionRate" "$pickedFilepath";
rm -f -- "$tempFilepath";
;;
*.webm | *.mkv)
newFilepath=$(echo "$pickedFilepath" | sed 's/\(.webm\|.mkv\)/.mp4/');
ffmpeg -i "$pickedFilepath" -vcodec libx265 -crf "$compressionRate" "$newFilepath";
rm -f -- "$pickedFilepath";
;;
*)
continue 1;;
esac
((converted_files_count=converted_files_count+1));
converted_filenames="$converted_filenames"$'\n'"$pickedFilepath";
done
#Notify the user of the results
if [[ $converted_files_count -gt 0 ]]; then
converted_filenames=$(echo "$converted_filenames" | sed 's|.*\/||');
notify-send "Compressed Videos($converted_files_count):" "$converted_filenames";
fi;
}}
cmd moveto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
@ -177,5 +223,7 @@ map <c-l> unselect
map <a-x> compressvideo
# Source Bookmarks
source "~/.config/lf/shortcutrc"

View File

@ -30,6 +30,11 @@ image/svg+xml)
[ ! -f "$CACHE" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1"
image "$CACHE.png" "$2" "$3" "$4" "$5" "$1"
;;
image/x-xcf)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
[ ! -f "$CACHE.jpg" ] && convert "$1[0]" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
text/troff) man ./ "$1" | col -b ;;

View File

@ -9,7 +9,7 @@ output="$(date '+%y%m%d-%H%M-%S').png"
xclip_cmd="xclip -sel clip -t image/png"
ocr_cmd="xclip -sel clip"
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\nOCR a selected area (copy)" | dmenu -l 7 -i -p "Screenshot which area?")" in
"a selected area") maim -u -s pic-selected-"${output}" ;;
"current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;