#!/bin/bash

OUT=x11grab.mkv
rm $OUT

sleep 5

WID=$(xdotool selectwindow)
LOCATION=$(xdotool getwindowgeometry $WID | awk '/Position:/ {print $2}')
SIZE=$(xdotool getwindowgeometry $WID | awk '/Geometry:/ {print $2}')

ffmpeg	-video_size ${SIZE}						\
		-framerate 30 -f x11grab				\
		-i ${DISPLAY}+${LOCATION}				\
		-c:v libx264 -crf 0 					\
		-preset ultrafast						\
		${OUT}
