added recording support for spectacle-screenshot
This commit is contained in:
parent
e05e8a9a95
commit
2a84867059
1 changed files with 22 additions and 6 deletions
|
@ -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=$1
|
||||
readonly file=$(mktemp /tmp/spectacle-screenshot.XXXXXXXX.png)
|
||||
fi
|
||||
else
|
||||
readonly file=$2
|
||||
fi
|
||||
|
||||
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
|
||||
|
|
Reference in a new issue