#!/bin/sh
set -eux

usage() {
  red "Missing argument $1.\n"
  cat <<EOF
Usage:
    record-my-screen.sh <OUTPUT_PATH>

      Arguments:
        OUTPUT_PATH        Path of the final WebM file

Examples:
    Capture the screen and save it in 'output.webm'
        record-my-screen.sh output.webm
EOF
}

OUTPUT_PATH="${1:-}"
[ -z "${OUTPUT_PATH}" ] && {
  usage 'OUTPUT_PATH'
  exit 2
}

SCREEN_RESOLUTION="$(xrandr -q --current | grep '[*]' | awk '{print$1}')"

ffmpeg                    \
  -f pulse                \
  -i default              \
  -f x11grab              \
  -s "$SCREEN_RESOLUTION" \
  -i :0                   \
  "$OUTPUT_PATH"

# https://github.com/georgmartius/vid.stab
