#!/bin/sh

# amolinae's recording tool
screencast(){
  case $(printf "%s\n" "󰍬  Mic ON" "󰍭  Mic OFF" | fuzzel -d -l 3) in
  "󰍬  Mic ON")
    wf-recorder -D -a -f ~/Videos/Recordings/recording_$(date +"%Y-%m-%d_%H:%M:%S.mp4") ;;
  "󰍭  Mic OFF")
    wf-recorder -D --audio="$(pactl list short sources | grep output | awk '{print $2}')" -f ~/Videos/Recordings/recording_$(date +"%Y-%m-%d_%H:%M:%S.mp4") ;;
  esac 
}

video(){
  wf-recorder -D -f ~/Videos/Recordings/recording_$(date +"%Y-%m-%d_%H:%M:%S.mp4")
}

kill(){
  killall -s SIGINT wf-recorder && \
    notify-send "art" "Recording stopped" || \
    notify-send "art" "No recording process found" 
}

menu(){
  case $(printf "%s\n" "󰻒  Screencast" "󰕧  Video only" "󰕨  Stop recording" | fuzzel -d -l 4) in
    "󰻒  Screencast") screencast;;
    "󰕧  Video only") video;;
    "󰕨  Stop recording") kill;;
    *) kill;;
  esac
}

case "$1" in
	-h) echo "usage: aws [-h]" >&2; exit 1; ;;
  *) menu ;;
esac
