Starts work on gif and mp4 generator for sxiv
This commit is contained in:
parent
1290817923
commit
14b5dd71de
2 changed files with 92 additions and 17 deletions
49
bin/createGif
Executable file
49
bin/createGif
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Creates a gif using a list of files from stdin
|
||||||
|
tmpdir="/tmp/sxiv-gif/"
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
mkdir -p "$tmpdir"
|
||||||
|
|
||||||
|
framerate="prompt"
|
||||||
|
format="gif"
|
||||||
|
extension=""
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
"-r"|"--framerate")
|
||||||
|
framerate="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"--mp4")
|
||||||
|
format="mp4"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$framerate" == "prompt" ]]; then
|
||||||
|
framerate=$(echo -e "0.25\n0.5\n0.75\n1\n2\n5\n10" | rofi -dmenu -p Timeout)
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=1
|
||||||
|
while read file; do
|
||||||
|
extension="${file##*.}"
|
||||||
|
number=$(printf "%03d" $i)
|
||||||
|
echo "$number"
|
||||||
|
cp "$file" "${tmpdir}file${number}.${extension}"
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$format" in
|
||||||
|
"mp4")
|
||||||
|
ffmpeg -f image2 -framerate "$framerate" -i "${tmpdir}file%03d.${extension}" -crf 0 "${tmpdir}out.${format}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ffmpeg -f image2 -framerate "$framerate" -i "${tmpdir}file%03d.${extension}" "${tmpdir}out.${format}"
|
||||||
|
esac
|
||||||
|
|
||||||
|
mv "${tmpdir}out.${format}" "$HOME/Desktop/"
|
||||||
|
|
||||||
|
notify-send "Done"
|
|
@ -1,6 +1,30 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
while read file
|
|
||||||
do
|
# This file is run from the sxiv when ctrl+x is pushed and then another key combination
|
||||||
|
#
|
||||||
|
# The file names are passed to stdin (1 per line)
|
||||||
|
#
|
||||||
|
# The key combination pushed after ctrl+x is sent as the first argument
|
||||||
|
#
|
||||||
|
# I have organised this script so when ctrl is pushed, a single command is run using all of the selected images
|
||||||
|
# e.g. creating a gif out of all selected images
|
||||||
|
#
|
||||||
|
# If ctrl is not pushed, the command is run on each image individually
|
||||||
|
# e.g. rotating images or opening them in gimp
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"C-g")
|
||||||
|
cat | createGif ;;
|
||||||
|
"C-v")
|
||||||
|
cat | createGif --mp4 ;;
|
||||||
|
"C-"*)
|
||||||
|
# If none of the above were used and ctrl was pushed, send a notificaton with the key combination
|
||||||
|
notify-send "$1" ;;
|
||||||
|
*)
|
||||||
|
# If the above key combinations were not pushed, loop through each of the images and check the combinations below
|
||||||
|
while read file
|
||||||
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"greater" )
|
"greater" )
|
||||||
convert -rotate 90 "$file" "$file" ;;
|
convert -rotate 90 "$file" "$file" ;;
|
||||||
|
@ -12,7 +36,9 @@ do
|
||||||
gimp "$file" & disown ;;
|
gimp "$file" & disown ;;
|
||||||
"G")
|
"G")
|
||||||
optirun gimp "$file" & disown ;;
|
optirun gimp "$file" & disown ;;
|
||||||
* )
|
*)
|
||||||
|
# If none of the above were used, send a notificaton with the key combination
|
||||||
notify-send "$1"
|
notify-send "$1"
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue