From 9763dd58e32f5f4726dc0188ee9a0c17147be466 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Tue, 4 Aug 2026 01:21:17 +0300 Subject: New way of doing some things I guess. Changes to be committed: modified: Vencord/settings/settings.json modified: X11/xinit modified: appimageupdate deleted: backlight modified: btop/btop.conf modified: clockpower modified: htop/htoprc modified: keybinds modified: lock modified: nvim/init.vim deleted: qBittorrent/ICEBERG.qbtheme deleted: qBittorrent/ayuDark.qbtheme deleted: vpn modified: xrec modified: zsh/aliases modified: zsh/env modified: zsh/zshrc --- xrec | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'xrec') diff --git a/xrec b/xrec index 867963a..2008c6f 100755 --- a/xrec +++ b/xrec @@ -2,18 +2,59 @@ set -e -recordingPATH=~/media/screenrecords/ +recordingPATH="$HOME/media/screenrecords" +PID_FILE="/tmp/ffmpeg_screenrecord.pid" + +mkdir -p "$recordingPATH" + +# Detect NVENC support; fallback to fast CPU encoding if no NVIDIA GPU is detected +if command -v nvidia-smi &> /dev/null && nvidia-smi &> /dev/null; then + ENCODER_FLAGS="-c:v h264_nvenc -preset p6 -tune hq -rc constqp -qp 17" +else + ENCODER_FLAGS="-c:v libx264 -preset ultrafast -crf 17" # or medium/slow to be on par with p6 but ehh +fi case $1 in start) - dunstify -t 3000 -i /dev/null " Recording Starts In 3 Seconds" + if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then + dunstify -t 3000 -i /dev/null "⚠️ Recording is already running!" + exit 1 + fi + + dunstify -t 3000 -i /dev/null " Recording Starts In 3 Seconds" sleep 3 - ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 -crf 16 ${recordingPATH}screenrecording_$(($(ls $recordingPATH | wc -l)+1)).mp4 ;; + + TIMESTAMP=$(date +'%Y-%m-%d_%H-%M-%S') + OUTPUT_FILE="${recordingPATH}/screenrecording_${TIMESTAMP}.mp4" + + # Standard yuv420p conversion allows players to auto-expand blacks properly + ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 \ + $ENCODER_FLAGS -profile:v high -pix_fmt yuv420p -movflags +faststart \ + "$OUTPUT_FILE" >/dev/null 2>&1 & + + echo $! > "$PID_FILE" + ;; stop) - pkill ffmpeg - dunstify -t 3000 -i /dev/null " Recording Finished" + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if kill -0 "$PID" 2>/dev/null; then + kill -SIGINT "$PID" + rm -f "$PID_FILE" + dunstify -t 3000 -i /dev/null " Recording Finished" + else + dunstify -t 3000 -i /dev/null "⚠️ Process not running." + rm -f "$PID_FILE" + fi + else + dunstify -t 3000 -i /dev/null "⚠️ No active recording." + fi + ;; + + *) + echo "Usage: $0 {start|stop}" + exit 1 ;; esac -- cgit v1.2.3