feat(hypr): add capturing gif support to screen-cap.bash
This commit is contained in:
parent
0722a6c6db
commit
939a45ff6b
@ -4,12 +4,14 @@
|
|||||||
# - wf-recorder: https://github.com/ammen99/wf-recorder
|
# - wf-recorder: https://github.com/ammen99/wf-recorder
|
||||||
# - notification daemon: https://archlinux.org/packages/?name=notification-daemon
|
# - notification daemon: https://archlinux.org/packages/?name=notification-daemon
|
||||||
# - wl-clipboard: https://github.com/bugaevc/wl-clipboard
|
# - wl-clipboard: https://github.com/bugaevc/wl-clipboard
|
||||||
|
# - gifski: https://github.com/sindresorhus/Gifski
|
||||||
#
|
#
|
||||||
# Some of this is hacky because I can't get wf-recorder to nicely output GIFs by itself :(
|
# Some of this is hacky because I can't get wf-recorder to nicely output GIFs by itself :(
|
||||||
|
|
||||||
mk-mp4() {
|
mk-mp4() {
|
||||||
local program_name="Screen Capture"
|
local program_name="Screen Capture"
|
||||||
local pid_file="/tmp/mk-gif-pid"
|
local pid_file="/tmp/mk-gif-pid"
|
||||||
|
local output_type="${1:-MP4}"
|
||||||
|
|
||||||
if [[ -f "${pid_file}" ]]; then
|
if [[ -f "${pid_file}" ]]; then
|
||||||
notify-send "Saving ${program_name}" "This May Take a Minute" -a "${program_name}"
|
notify-send "Saving ${program_name}" "This May Take a Minute" -a "${program_name}"
|
||||||
@ -22,19 +24,27 @@ mk-mp4() {
|
|||||||
notify-send "Saved ${program_name}" "Successfully Saved Screen Capture to Clipboard" -a "${program_name}"
|
notify-send "Saved ${program_name}" "Successfully Saved Screen Capture to Clipboard" -a "${program_name}"
|
||||||
else
|
else
|
||||||
local input_tmpfile
|
local input_tmpfile
|
||||||
notify-send "Starting ${program_name}" "Recording GIF of Selected Region" -a "${program_name}"
|
notify-send "Starting ${program_name}" "Recording ${output_type^^} of Selected Region" -a "${program_name}"
|
||||||
(
|
(
|
||||||
local tmp_dir
|
local tmp_dir
|
||||||
tmp_dir="$(mktemp -d)"
|
tmp_dir="$(mktemp -d)"
|
||||||
cd "${tmp_dir}"
|
cd "${tmp_dir}"
|
||||||
input_tmpfile="${tmp_dir}/$(mktemp wf-recorder.XXXXXXXXXXX)"
|
input_tmpfile="${tmp_dir}/$(mktemp wf-recorder.XXXXXXXXXXX).mp4"
|
||||||
wf-recorder -g "$(slurp)" -f "${input_tmpfile}.mp4" -c h264_vaapi -d /dev/dri/renderD128 --framerate 24 -- &
|
wf-recorder -g "$(slurp)" -f "${input_tmpfile}" -c h264_vaapi -d /dev/dri/renderD128 -- &
|
||||||
printf "%s" $! >"${pid_file}"
|
printf "%s" $! >"${pid_file}"
|
||||||
wait
|
wait
|
||||||
wl-copy --type video/mp4 <"${input_tmpfile}.mp4"
|
if [[ "${output_type}" == "gif" ]]; then
|
||||||
|
local gifski_tmpoutput
|
||||||
|
pwd
|
||||||
|
gifski_tmpoutput="${tmp_dir}/$(mktemp gifski.XXXXXXXXXXX).gif"
|
||||||
|
gifski "${input_tmpfile}" --output "${gifski_tmpoutput}"
|
||||||
|
wl-copy --type image/gif <"${gifski_tmpoutput}"
|
||||||
|
else
|
||||||
|
wl-copy --type video/mp4 <"${input_tmpfile}"
|
||||||
|
fi
|
||||||
rm -f "${pid_file}"
|
rm -f "${pid_file}"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mk-mp4
|
mk-mp4 "${@}"
|
||||||
|
@ -65,6 +65,7 @@ bind=SUPER,A,togglefloating,
|
|||||||
bind=SUPERSHIFT,Q,exec,swaylock
|
bind=SUPERSHIFT,Q,exec,swaylock
|
||||||
bind=SUPER,S,exec,grim -g "$(slurp)" - | wl-copy --type image/png
|
bind=SUPER,S,exec,grim -g "$(slurp)" - | wl-copy --type image/png
|
||||||
bind=SUPERSHIFT,S,exec,~/.config/hypr/scripts/screen-cap.bash
|
bind=SUPERSHIFT,S,exec,~/.config/hypr/scripts/screen-cap.bash
|
||||||
|
bind=SUPERSHIFT,A,exec,~/.config/hypr/scripts/screen-cap.bash gif
|
||||||
bind=SUPERSHIFT,M,exit
|
bind=SUPERSHIFT,M,exit
|
||||||
|
|
||||||
# Mediakey bindings as taken from `wev`
|
# Mediakey bindings as taken from `wev`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user