2025-07-18 20:55:28 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2025-07-22 15:47:25 +02:00
|
|
|
# Set recorder based on GPU
|
|
|
|
if lspci | grep -qi 'nvidia'; then
|
|
|
|
RECORDER="wf-recorder"
|
|
|
|
RECORDER_ARGS="-c libx264 -p crf=23 -p preset=medium -p movflags=+faststart"
|
|
|
|
else
|
|
|
|
RECORDER="wl-screenrec"
|
|
|
|
RECORDER_ARGS="--ffmpeg-encoder-options=\"-c:v libx264 -crf 23 -preset medium -movflags +faststart\""
|
|
|
|
fi
|
|
|
|
|
2025-07-19 17:02:52 -05:00
|
|
|
screenrecording() {
|
2025-07-22 15:47:25 +02:00
|
|
|
local filename
|
|
|
|
filename="$HOME/Videos/screenrecording-$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
2025-07-19 22:43:28 -05:00
|
|
|
notify-send "Screen recording starting..." -t 1000
|
|
|
|
sleep 1
|
2025-07-22 15:47:25 +02:00
|
|
|
eval "$RECORDER -f \"$filename\" $RECORDER_ARGS \"\$@\""
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_recording() {
|
|
|
|
if pgrep -x "$RECORDER" >/dev/null; then
|
|
|
|
pkill -x "$RECORDER"
|
|
|
|
notify-send "Screen recording saved to ~/Videos" -t 2000
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
return 1
|
2025-07-19 17:02:52 -05:00
|
|
|
}
|
|
|
|
|
2025-07-22 15:47:25 +02:00
|
|
|
if stop_recording; then
|
|
|
|
# Recording was stopped
|
|
|
|
:
|
2025-07-19 22:43:28 -05:00
|
|
|
elif [[ "$1" == "output" ]]; then
|
2025-07-22 15:47:25 +02:00
|
|
|
screenrecording
|
2025-07-18 20:55:28 -07:00
|
|
|
else
|
|
|
|
region=$(slurp) || exit 1
|
2025-07-19 17:02:52 -05:00
|
|
|
screenrecording -g "$region"
|
2025-07-18 20:55:28 -07:00
|
|
|
fi
|