chore(nix/hm/price): remove loose file
Some checks failed
Check Formatting of Files / Check-Formatting (push) Has been cancelled
Some checks failed
Check Formatting of Files / Check-Formatting (push) Has been cancelled
This commit is contained in:
parent
6632b6add3
commit
9165e8f279
@ -1,74 +0,0 @@
|
|||||||
#!/usr/bin/env -S nix shell github:nix-community/nixgl#nixGLIntel nixpkgs#bash nixpkgs#wl-screenrec nixpkgs#gifski nixpkgs#inotify-tools nixpkgs#libnotify nixpkgs#mktemp nixpkgs#slurp nixpkgs#slurp --command bash
|
|
||||||
|
|
||||||
# Dependencies:
|
|
||||||
# - wl-screenrec: https://github.com/russelltg/wl-screenrec
|
|
||||||
# - notification daemon: https://archlinux.org/packages/?name=notification-daemon
|
|
||||||
# - wl-clipboard: https://github.com/bugaevc/wl-clipboard
|
|
||||||
# - gifski: https://github.com/sindresorhus/Gifski
|
|
||||||
#
|
|
||||||
# Gifski is necessary because `wl-screenrec` doesn't support gifs
|
|
||||||
|
|
||||||
# set -euoE pipefail
|
|
||||||
|
|
||||||
mk-screen-cap() {
|
|
||||||
local program_name="Screen Capture"
|
|
||||||
local pid_file="/tmp/mk-gif-pid"
|
|
||||||
local output_type="${1:-webm}"
|
|
||||||
|
|
||||||
if [[ -f "$pid_file" ]]; then
|
|
||||||
printf "Ending screen capture\n"
|
|
||||||
notify-send "Saving ${program_name}" "This May Take a Minute" -a "$program_name"
|
|
||||||
if ! kill -SIGINT "$(cat "$pid_file")"; then
|
|
||||||
notify-send "Failed ${program_name}" "Failed to Save Screen Capture" -u "critical" -a "$program_name"
|
|
||||||
printf "Failed to save screen capture!\n"
|
|
||||||
rm -rf "$pid_file"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
printf -- "Beginning recording\n"
|
|
||||||
local tmp_file
|
|
||||||
notify-send "Starting ${program_name}" "Recording ${output_type^^} of Selected Region" -a "$program_name"
|
|
||||||
local tmp_diruullllllllllllllllllllllllllllllllllllllllllhhhhhjkklh
|
|
||||||
tmp_dir="$(mktemp -d)"
|
|
||||||
local file_extension="$output_type"
|
|
||||||
if [[ "$output_type" == "gif" ]]; then
|
|
||||||
file_extension="webm"
|
|
||||||
fi
|
|
||||||
local tmp_file
|
|
||||||
tmp_file="$(mktemp --tmpdir="$tmp_dir" recording.XXXXXXXXXXX).${file_extension}"
|
|
||||||
printf "Working temp file: '%s'\n" "$tmp_file"
|
|
||||||
|
|
||||||
local geometry
|
|
||||||
geometry="$(slurp)"
|
|
||||||
nixGLIntel wl-screenrec --filename "$tmp_file" --geometry "$geometry" &
|
|
||||||
local pid="${!}"
|
|
||||||
printf "%s" "$pid" >"$pid_file"
|
|
||||||
printf "Putting pid: '%d' into pid file: '%s'\n" "$pid" "$pid_file"
|
|
||||||
wait -n "$pid"
|
|
||||||
|
|
||||||
if [[ "$output_type" == "gif" ]]; then
|
|
||||||
printf "Converting recording to gif...\n"
|
|
||||||
local gifski_tmpout
|
|
||||||
gifski_tmpout="${tmp_dir}/$(mktemp --"$tmp_dir" gifski.XXXXXXXXXXX).gif"
|
|
||||||
gifski --output "$gifski_tmpout" "$tmp_file"
|
|
||||||
mv "$gifski_tmpout" "$tmp_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local save_path
|
|
||||||
save_path="${HOME}/Videos/Screen-Recordings"
|
|
||||||
mkdir -p "$save_path"
|
|
||||||
save_path="${save_path}/$(date --iso-8601="seconds").${output_type}"
|
|
||||||
printf "Recording ended, saving to: '%s'\n" "$save_path"
|
|
||||||
mv "$tmp_file" "$save_path"
|
|
||||||
|
|
||||||
printf "Copying recording to clipboard\n"
|
|
||||||
local mimetype
|
|
||||||
mimetype="$(file -b --mime-type "$save_path")"
|
|
||||||
wl-copy --type="$mimetype" <"$save_path"
|
|
||||||
rm -f "$pid_file"
|
|
||||||
notify-send "Saved ${program_name}" "Successfully Saved Screen Capture to Clipboard" -a "$program_name"
|
|
||||||
printf "Finished Recording, exiting...\n"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
mk-screen-cap "${@}"
|
|
Loading…
Reference in New Issue
Block a user