#!/bin/sh
GSRPID=$(pidof gpu-screen-recorder)
DWMBLOCKSPID=$(pidof dwmblocks)

if [[ -n $GSRPID ]]; then
  kill -n 2 $GSRPID
  kill -n 36 $DWMBLOCKSPID
  notify-send "recording saved" -i :
  exit
fi

if [[ $1 == 1 ]]; then 
  gpu-screen-recorder -w DP-0 -k hevc -c mkv -f 60 -bm cbr -q 12000 -ac opus -a "default_output" \
    -o "$HOME/wdraidz/media/game-videos/$(date +%m-%d-%Y_%R:%S).mkv"&
  kill -n 36 $DWMBLOCKSPID
  notify-send "recording started with no mic" -i :
else
  gpu-screen-recorder -w DP-0 -k hevc -c mkv -f 60 -bm cbr -q 12000 -ac opus -a "default_output|default_input" \
    -o "$HOME/wdraidz/media/game-videos/$(date +%m-%d-%Y_%R:%S).mkv"&
  kill -n 36 $DWMBLOCKSPID
  notify-send "recording started" -i :
fi
