#!/bin/sh
SCREEN="ffmpeg -s 3440x1440 -f x11grab -r 60 -i :0.0+0,0"
SYSTEM_AUDIO="-f pulse -i alsa_output.pci-0000_00_1f.3.iec958-stereo.monitor"
MICROPHONE="-f pulse -i default:monitor"
COMPRESSION="-c:a flac -c:v hevc_nvenc -b:v 10M"
FILENAME="$HOME/wdraidz/media/game-videos/$(date +%m-%d-%Y_%R:%S).mkv"
SIGSEND="kill -RTMIN+2 $(pidof dwmblocks)"

if [ $1 = 1 ]; then
  $SCREEN $SYSTEM_AUDIO $MICROPHONE -filter_complex "[1:0][2:0]amerge=inputs=2[a]" -map 0:v -map "[a]" $COMPRESSION $FILENAME&
else
  $SCREEN $SYSTEM_AUDIO $COMPRESSION $FILENAME&
fi

$SIGSEND
