cswimr/home
Archived
Template
1
0
Fork 0

added recording support for spectacle-screenshot

This commit is contained in:
cswimr 2024-10-11 23:38:13 -04:00
parent e05e8a9a95
commit 2a84867059
Signed by: cswimr
GPG key ID: A9C162E867C851FA

View file

@ -88,25 +88,41 @@ function zipline {
}
function spectacle-screenshot {
# takes one argument, the path to save the screenshot to - if not provided, a temp file will be used
# takes two arguments:
# 1 - whether to save a recording or a screenshot (boolean) - defaults to screenshot (false) - RECORDING DOES NOT WORK ON X11
# 2 - the path to save the screenshot/recording to - if not provided, a temp file will be used
if (( ! $+commands[spectacle] )); then
echo "spectacle is not installed."
return 127
fi
if [[ -f "${1}" ]]; then
if [[ -z "${1}" ]]; then
readonly save_recording=false
else
readonly save_recording=$1
fi
if [[ -f "${2}" ]]; then
echo "File already exists. Please provide a different file path, or use the zipline function to upload the file."
echo "Example: zipline \"$file\""
return 1
fi
if [[ -z "${1}" ]]; then
readonly file=$(mktemp /tmp/spectacle-screenshot.XXXXXXXX.png)
if [[ -z "${2}" ]]; then
if $save_recording; then
readonly file=$(mktemp /tmp/spectacle-recording.XXXXXXXX.mp4)
else
readonly file=$(mktemp /tmp/spectacle-screenshot.XXXXXXXX.png)
fi
else
readonly file=$1
readonly file=$2
fi
command spectacle --nonotify --background --region --copy-image --output "$file"
if $save_recording; then
command spectacle --nonotify --background --record=region --copy-image --output "$file"
else
command spectacle --nonotify --background --region --copy-image --output "$file"
fi
[ ! -s "$file" ] && return 1
trap 'rm -f "$file"' EXIT