os/pkgs/record-screen.nix

29 lines
1.1 KiB
Nix

self:
with self; ''
set -e
RECORDER_PID=$(${procps}/bin/ps aux | ${gnugrep}/bin/grep "\--class screen-recorder" | ${gnugrep}/bin/grep -v grep | ${gawk}/bin/awk '{print $2}')
NUM_PID=$(echo -n $RECORDER_PID | ${coreutils}/bin/wc -w)
if (( NUM_PID > 0 )); then
FILE_LOCATION=$(${procps}/bin/ps aux | ${gnugrep}/bin/grep "\--class screen-recorder" | ${gnugrep}/bin/grep -v grep | ${gawk}/bin/awk '{print $NF}')
kill $RECORDER_PID
${libnotify}/bin/notify-send "Recorded to $FILE_LOCATION"
exit 0
fi
if [ "$1" = "fullscreen" ]; then
GEOMETRY="$(${slurp}/bin/slurp -d -b \#ffffff11 -o)"
else
GEOMETRY="$(${slurp}/bin/slurp -d -b \#ffffff11)"
fi
mkdir -p "$HOME/Videos/Screenrecordings"
RESOLUTION="$(echo $GEOMETRY | ${gawk}/bin/awk '{print $2}')"
FILE_LOCATION="$HOME/Videos/Screenrecordings/$(${coreutils}/bin/date +%Y%m%d_%Hh%Mm%Ss)_$RESOLUTION.mp4"
echo "Recording $GEOMETRY into $FILE_LOCATION"
${alacritty}/bin/alacritty \
--class screen-recorder \
-e ${wf-recorder}/bin/wf-recorder -g "$GEOMETRY" -f "$FILE_LOCATION"
${libnotify}/bin/notify-send "Recording to $FILE_LOCATION"
''