dotfiles/home/dot_local/bin/executable_screc

35 lines
848 B
Bash

#!/bin/sh
# Take a screen recording in webm format using wf-recorder
# The output file is echo'd to stdout and the path copied
# using the text/uri-list mimetype to the clipboard.
tmpd=$(mktemp -d -t screc.XXXXXX)
outfile="${tmpd}/out.webm"
intermediate="${tmpd}/int.mkv"
geometry=$(slurp)
wf-recorder -g "$geometry" -f "$intermediate" &
recpid=$!
read -sn1 -p 'Press any key to stop recording:'
echo
kill $recpid
ffmpeg -i $intermediate -r 10 -c:v libvpx-vp9 -row-mt 1 -b:v 0 -pass 1 -an -f null /dev/null
ffmpeg -i $intermediate -r 10 -c:v libvpx-vp9 -row-mt 1 -b:v 0 -pass 2 -crf 30 $outfile
echo "$outfile"
wl-copy -t text/uri-list "file://$outfile"
notify-send --expire-time 10000 \
--app-name=Screc \
"Recording Ready" \
"Screen recording saved to $outfile and copied to clipboard"
(sleep 60 && rm -r $tmpd) &
disown