wf-recorder instead of wl-screenrec (NVIDIA support for screen recording) (#278)

* use wf-recorder instead of wl-screenrec

wl-screenrec does not support NVIDIA drivers as of now

* install wf-recorder and migration for it

* use wl-screenrec for non-nvidia and wf-recorder otherwise

* useless comment

* only use one of the screen recording features
This commit is contained in:
Andreas Nigg
2025-07-22 15:47:25 +02:00
committed by GitHub
parent a94ee3dee8
commit 6d8a1e3bcf
3 changed files with 49 additions and 12 deletions

View File

@ -1,19 +1,36 @@
#!/bin/bash #!/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() { screenrecording() {
local filename
filename="$HOME/Videos/screenrecording-$(date +'%Y-%m-%d_%H-%M-%S').mp4"
notify-send "Screen recording starting..." -t 1000 notify-send "Screen recording starting..." -t 1000
sleep 1 sleep 1
wl-screenrec \ eval "$RECORDER -f \"$filename\" $RECORDER_ARGS \"\$@\""
-f "$HOME/Videos/screenrecording-$(date +'%Y-%m-%d_%H-%M-%S').mp4" \
--ffmpeg-encoder-options="-c:v libx264 -crf 23 -preset medium -movflags +faststart" \
"$@"
} }
if pgrep -x wl-screenrec >/dev/null; then stop_recording() {
pkill -x wl-screenrec if pgrep -x "$RECORDER" >/dev/null; then
notify-send "Screen recording saved to ~/Videos" -t 2000 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 elif [[ "$1" == "output" ]]; then
screenrecording -o "" screenrecording
else else
region=$(slurp) || exit 1 region=$(slurp) || exit 1
screenrecording -g "$region" screenrecording -g "$region"

View File

@ -1,9 +1,18 @@
#!/bin/bash #!/bin/bash
yay -S --noconfirm --needed \ # Base packages
brightnessctl playerctl pamixer wiremix wireplumber \ PACKAGES="brightnessctl playerctl pamixer wiremix wireplumber \
fcitx5 fcitx5-gtk fcitx5-qt wl-clip-persist \ fcitx5 fcitx5-gtk fcitx5-qt wl-clip-persist \
nautilus sushi ffmpegthumbnailer \ nautilus sushi ffmpegthumbnailer \
slurp wl-screenrec satty \ slurp satty \
mpv evince imv \ 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

11
migrations/1753176520.sh Normal file
View File

@ -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