Fix screenshot/cast scripts

This commit is contained in:
Henrik Lissner 2020-02-08 23:26:11 -05:00
parent 8616ae118a
commit 90dec2e245
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 12 additions and 9 deletions

View file

@ -4,13 +4,14 @@
# Uses ffmpeg to convert a video file to a gif file. Optimizes the final result # Uses ffmpeg to convert a video file to a gif file. Optimizes the final result
# with gifsicle. # with gifsicle.
# #
# Requires: ffmpeg # Requires: ffmpeg gifsicle
# Optional: gifsicle
# #
# Example: # Example:
# vid2gif some-vid.mp4 output.gif # vid2gif some-vid.mp4 output.gif
# vid2gif -f 10 -s 00:00:10 -t 00:00:05 some-vid.mp4 output.gif # vid2gif -f 10 -s 00:00:10 -t 00:00:05 some-vid.mp4 output.gif
shift # Get rid of extraneous nix-shell argument
set -e set -e
PALETTE="/tmp/palette.png" PALETTE="/tmp/palette.png"

View file

@ -11,7 +11,7 @@ trap cleanup EXIT
# Delay for long enough that we can refocus the targeted window # Delay for long enough that we can refocus the targeted window
if maim --delay=${2:-1} -us >"$tmp"; then if maim --delay=${2:-1} -us >"$tmp"; then
xclip -selection clipboard -t image/png "$tmp" && xclip -selection clipboard -t image/png "$tmp" &&
notify-send "Screenshot saved" notify-send "Screenshot saved" "Copied image to clipboard"
else else
notify-send -u low "Aborted screenshot" notify-send -u low "Aborted screenshot"
fi fi

View file

@ -10,6 +10,8 @@
# Usage: scrrec somefile.mp4 # Usage: scrrec somefile.mp4
# scrrec another.gif # scrrec another.gif
shift # Get rid of extraneous nix-shell argument
is_script= is_script=
geom= geom=
delay=1 delay=1
@ -41,16 +43,16 @@ countdown() {
if (( count > 0 )); then if (( count > 0 )); then
for ((i=count;i>0;i--)); do for ((i=count;i>0;i--)); do
if [[ $is_script ]]; then if [[ $is_script ]]; then
echo "Recording in $i"
else
notify-send -u critical -t 1000 "Recording in $i" notify-send -u critical -t 1000 "Recording in $i"
else
echo "Recording in $i"
fi fi
sleep 1 sleep 1
done done
elif [[ $is_script ]]; then elif [[ $is_script ]]; then
echo "Started recording..."
else
notify-send -u critical "Starting recording..." notify-send -u critical "Starting recording..."
else
echo "Started recording..."
fi fi
} }
@ -67,7 +69,7 @@ recording-start() {
mov2gif "$mp4dest" "$dest" && rm -fv "$mp4dest" mov2gif "$mp4dest" "$dest" && rm -fv "$mp4dest"
fi fi
echo "$dest" | xclip -selection clipboard -in echo "$dest" | xclip -selection clipboard -in
notify-send "Screencast saved to $dest" "Copied to clipboard!" notify-send "Screencast successful" "Saved to $dest\nAnd copied to your clipboard!"
} }
@ -91,6 +93,6 @@ cleanup() { [[ $compton ]] && systemctl --user start compton; }
trap cleanup EXIT trap cleanup EXIT
# Let 'er rip # Let 'er rip
recording-start "$dest" "$X" "$Y" "$W" "$H" recording-start "$1" "$X" "$Y" "$W" "$H"
# vim:set ft=sh shiftwidth=2: # vim:set ft=sh shiftwidth=2: