diff --git a/bin/omarchy-cmd-screenrecord b/bin/omarchy-cmd-screenrecord index 3f828c0..8e8cd86 100755 --- a/bin/omarchy-cmd-screenrecord +++ b/bin/omarchy-cmd-screenrecord @@ -1,19 +1,36 @@ #!/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 - wl-screenrec \ - -f "$HOME/Videos/screenrecording-$(date +'%Y-%m-%d_%H-%M-%S').mp4" \ - --ffmpeg-encoder-options="-c:v libx264 -crf 23 -preset medium -movflags +faststart" \ - "$@" + eval "$RECORDER -f \"$filename\" $RECORDER_ARGS \"\$@\"" } -if pgrep -x wl-screenrec >/dev/null; then - pkill -x wl-screenrec - notify-send "Screen recording saved to ~/Videos" -t 2000 +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 +} + +if stop_recording; then + # Recording was stopped + : elif [[ "$1" == "output" ]]; then - screenrecording -o "" + screenrecording else region=$(slurp) || exit 1 screenrecording -g "$region" diff --git a/install/desktop.sh b/install/desktop.sh index e3f2780..cec524d 100644 --- a/install/desktop.sh +++ b/install/desktop.sh @@ -1,9 +1,18 @@ #!/bin/bash -yay -S --noconfirm --needed \ - brightnessctl playerctl pamixer wiremix wireplumber \ +# Base packages +PACKAGES="brightnessctl playerctl pamixer wiremix wireplumber \ fcitx5 fcitx5-gtk fcitx5-qt wl-clip-persist \ nautilus sushi ffmpegthumbnailer \ - slurp wl-screenrec satty \ + slurp satty \ mpv evince imv \ - chromium + chromium" + +# Add screen recorder based on GPU +if [ -n "$(lspci | grep -i 'nvidia')" ]; then + PACKAGES="$PACKAGES wf-recorder" +else + PACKAGES="$PACKAGES wl-screenrec" +fi + +yay -S --noconfirm --needed $PACKAGES diff --git a/migrations/1753176520.sh b/migrations/1753176520.sh new file mode 100644 index 0000000..46fc2da --- /dev/null +++ b/migrations/1753176520.sh @@ -0,0 +1,11 @@ +echo "Install wf-recorder for screen recording for nvidia" + +if [ -n "$(lspci | grep -i 'nvidia')" ]; then + if ! command -v wf-recorder &>/dev/null; then + yay -S --noconfirm --needed wf-recorder + fi + + if command -v wl-screenrec &>/dev/null; then + yay -R --noconfirm wl-screenrec + fi +fi