From 637f6fe675bc54b35586f97bc334a54f2317f0a0 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 4 Nov 2022 23:27:59 -0500 Subject: [PATCH] feat(hypr): improve screen cap quality --- dots/.config/hypr/scripts/screen-cap.bash | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dots/.config/hypr/scripts/screen-cap.bash b/dots/.config/hypr/scripts/screen-cap.bash index 00850c21..a32bc4cf 100755 --- a/dots/.config/hypr/scripts/screen-cap.bash +++ b/dots/.config/hypr/scripts/screen-cap.bash @@ -25,12 +25,15 @@ mk-gif() { local input_tmpfile notify-send "Starting ${program_name}" "Recording GIF of Selected Region" -a "${program_name}" ( - cd "/tmp" - input_tmpfile="/tmp/$(mktemp wf-recorder.XXXXXXXXXXX)" + local tmp_dir + tmp_dir="$(mktemp -d)" + cd "${tmp_dir}" + input_tmpfile="${tmp_dir}/$(mktemp wf-recorder.XXXXXXXXXXX)" wf-recorder -g "$(slurp)" -f "${input_tmpfile}.mp4" -- & printf "%s" $! >"${pid_file}" wait - ffmpeg -i "${input_tmpfile}.mp4" -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "${input_tmpfile}.gif" + ffmpeg -i "${input_tmpfile}.mp4" -filter_complex "[0:v] palettegen" palette.png + ffmpeg -i "${input_tmpfile}.mp4" -i palette.png -filter_complex "[0:v][1:v] paletteuse" -framerate 10 "${input_tmpfile}.gif" wl-copy --type image/gif <"${input_tmpfile}.gif" rm -f "${pid_file}" )