#!/bin/sh set -eu usage() { cat <<-'EOF' record-my-screen [FILE] record-my-screen -h EOF } help() { cat <<-'EOF' Options: -h, --help show this message FILE the name of the output file (default: out.webm) Do a screen capture. Exit with "q". Examples: Just run it: $ record-my-screen EOF } for flag in "$@"; do case "$flag" in (--) break ;; (--help) usage help exit ;; (*) ;; esac done while getopts 'h' flag; do case "$flag" in (h) usage help exit ;; (*) usage >&2 exit 2 ;; esac done shift $((OPTIND - 1)) FILE="${1:-out.webm}" RESOLUTION="$(xrandr -q --current | awk '/[*]/ && $0=$1')" ffmpeg \ -f pulse \ -i default \ -f x11grab \ -s "$RESOLUTION" \ -i "$DISPLAY" \ "$FILE"