From ea903c7d652365b58d86abfa464cbd99e30e101f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 22 Jul 2025 08:58:20 -0500 Subject: [PATCH] Cleanup the screenrecording script --- bin/omarchy-cmd-screenrecord | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/bin/omarchy-cmd-screenrecord b/bin/omarchy-cmd-screenrecord index 8e8cd86..20cedfe 100755 --- a/bin/omarchy-cmd-screenrecord +++ b/bin/omarchy-cmd-screenrecord @@ -1,34 +1,23 @@ #!/bin/bash # 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 screenrecording() { - local filename filename="$HOME/Videos/screenrecording-$(date +'%Y-%m-%d_%H-%M-%S').mp4" notify-send "Screen recording starting..." -t 1000 sleep 1 - 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 + if lspci | grep -qi 'nvidia'; then + wf-recorder -f "$filename" -c libx264 -p crf=23 -p preset=medium -p movflags=+faststart "$@" + else + wl-screenrec -f "$filename" --ffmpeg-encoder-options="-c:v libx264 -crf 23 -preset medium -movflags +faststart" "$@" fi - return 1 } -if stop_recording; then - # Recording was stopped - : +if pgrep -x wl-screenrec >/dev/null || pgrep -x wf-recorder >/dev/null; then + pkill -x wl-screenrec + pkill -x wf-recorder + notify-send "Screen recording saved to ~/Videos" -t 2000 elif [[ "$1" == "output" ]]; then screenrecording else