5
socket=${XDG_RUNTIME_DIR}/mir_socket
6
if [ -v MIR_SERVER ]; then socket=${MIR_SERVER}; fi
10
if [ "$1" == "--help" -o "$1" == "-h" ]
12
echo "$(basename $0) - screencast capture script for use with Mir servers"
13
echo "Usage: $0 [options]"
15
echo " --width set the capture width [${width}]"
16
echo " --height set the capture height [${height}]"
17
echo " --output set the output filename [${output}]"
18
echo " --socket set the mir socket [${socket}]"
20
elif [ "$1" == "--socket" ]; then shift; socket=$1
21
elif [ "$1" == "--output" ]; then shift; output=$1
22
elif [ "$1" == "--width" ]; then shift; width=$1
23
elif [ "$1" == "--height" ]; then shift; height=$1
29
echo height = ${height}
30
echo output = ${output}
31
echo socket = ${socket}
33
if ! which mirscreencast >> /dev/null ; then echo "Need mirscreencast - run \"sudo apt install mir-utils\""; exit 1 ;fi
34
if ! which mencoder >> /dev/null ; then echo "Need mencoder - run \"sudo apt install mencoder\""; exit 1 ;fi
36
if [ -e ${output} ]; then echo "Output exists, moving to ${output}~"; mv ${output} ${output}~ ;fi
37
while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done
40
mirscreencast --size ${width} ${height} -m ${socket} -f ${tempfile}& mirscreencast_pid=$!
41
trap 'kill ${mirscreencast_pid}; rm -f -- "${tempfile}"; exit 0' INT TERM HUP EXIT
43
sleep 1; # don't lose the next message in the spew from mirscreencast
44
read -rsp $'\n\nPress enter when recording complete...'
46
mencoder -demuxer rawvideo -rawvideo fps=60:w=${width}:h=${height}:format=bgra -ovc x264 -o ${output} ${tempfile}