Files
illogical-impulse/.config/ags/scripts/record-script.sh
T
Sneethe 108e0a8c78 record-script.sh fixes
Even if ~/Videos exists, `xdg-user-dir VIDEOS` requires xdg-user-dirs-update to be run first.
Some people just mkdir their desired xdg-user-dir directories. And so they won't have $HOME/.config/user-dirs.dirs for `xdg-user-dir VIDEOS` to work.
Now instead if there is no user-dirs.dirs match for VIDEOS then $HOME/Videos/ is used instead.

You can now cancel the recording region, which exits the script. Previously if you pressed escape when choosing the recording region, record-script would record the fullscreen.
This resulted in me accidentally recording my entire screen for hours.
2025-06-04 07:30:10 +10:00

40 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
getdate() {
date '+%Y-%m-%d_%H.%M.%S'
}
getaudiooutput() {
pactl list sources | grep 'Name' | grep 'monitor' | cut -d ' ' -f2
}
getactivemonitor() {
hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name'
}
xdgvideo="$(xdg-user-dir VIDEOS)"
if [[ $xdgvideo = "$HOME" ]]; then
unset xdgvideo
fi
mkdir -p "${xdgvideo:-$HOME/Videos}"
cd "${xdgvideo:-$HOME/Videos}" || exit
if pgrep wf-recorder > /dev/null; then
notify-send "Recording Stopped" "Stopped" -a 'record-script.sh' &
pkill wf-recorder &
else
if ! region="$(slurp 2>&1)"; then
notify-send "Recording Cancelled" "Selection was Cancelled" -a 'record-script.sh'
exit 1
fi
notify-send "Starting recording" 'recording_'"$(getdate)"'.mp4' -a 'record-script.sh'
if [[ "$1" == "--sound" ]]; then
wf-recorder --pixel-format yuv420p -f './recording_'"$(getdate)"'.mp4' -t --geometry "$region" --audio="$(getaudiooutput)" & disown
elif [[ "$1" == "--fullscreen-sound" ]]; then
wf-recorder -o $(getactivemonitor) --pixel-format yuv420p -f './recording_'"$(getdate)"'.mp4' -t --audio="$(getaudiooutput)" & disown
elif [[ "$1" == "--fullscreen" ]]; then
wf-recorder -o $(getactivemonitor) --pixel-format yuv420p -f './recording_'"$(getdate)"'.mp4' -t & disown
else
wf-recorder --pixel-format yuv420p -f './recording_'"$(getdate)"'.mp4' -t --geometry "$region" & disown
fi
fi