#!/bin/sh set -e getTargetDirectory() { test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \ . ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs echo "${XDG_VIDEOS_DIR:-~/pictures}/screencasts" } FILE=${3:-$(getTargetDirectory)/$(date -Ins).mp4} while getopts 'r:so:w' c; do case $c in r) GEOM="$OPTARG" ;; s) GEOM=$(slurp -o) ;; o) FILE="$OPTARG" ;; w) GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) ;; esac done shift $((OPTIND-1)) if [ -z "$GEOM" ]; then GEOM=$(slurp) fi if [ -z "$GEOM" ]; then exit fi wf-recorder -c libx264 -x yuv420p -g "$GEOM" -f "$FILE" "$@"