os/pkgs/record-screen.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
1 KiB
Nix
Raw Normal View History

self:
with self; ''
set -e
2024-09-06 15:38:43 +00:00
RECORDER_PID=$(${procps}/bin/ps aux | ${gnugrep}/bin/grep "wf-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
2024-09-06 15:38:43 +00:00
FILE_LOCATION=$(${procps}/bin/ps aux | ${gnugrep}/bin/grep "wf-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"
2024-09-06 15:38:43 +00:00
${wf-recorder}/bin/wf-recorder -g "$GEOMETRY" -f "$FILE_LOCATION"
${libnotify}/bin/notify-send "Recording to $FILE_LOCATION"
''