scripts reorganize
This commit is contained in:
75
scripts/WMScripts/record.sh
Executable file
75
scripts/WMScripts/record.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script allows one to record a slected area of the screen.
|
||||
# Calling the script again will end recording, and save the file to
|
||||
# ~/Videos/screen captures/$(date +%F_%T).mp4
|
||||
|
||||
# create directory if necessary
|
||||
mkdir -p ~/Videos/screen\ captures
|
||||
|
||||
# variables
|
||||
record_file="/tmp/record_file"
|
||||
now="$(date +%F_%T)"
|
||||
file="$HOME/Videos/screen captures/$now.mp4"
|
||||
|
||||
|
||||
stop_recording () {
|
||||
kill -2 "$(head -1 $record_file)"
|
||||
kill -KILL "$(head -2 $record_file | tail -n1 )"
|
||||
old_date="$(cat $record_file | tail -n1)"
|
||||
rm "$record_file"
|
||||
|
||||
# notif
|
||||
dunstify -u low \
|
||||
-a Record \
|
||||
-r 8827 \
|
||||
-i ~/.icons/candy-icons/apps/scalable/simplescreenrecorder.svg \
|
||||
"Saved recording to $old_date.mp4"
|
||||
echo "Saved recording to $old_date.mp4"
|
||||
}
|
||||
|
||||
|
||||
start_recording () {
|
||||
case "$XDG_SESSION_TYPE" in
|
||||
x11)
|
||||
# get coordinates
|
||||
slop=$(slop -f "%x %y %w %h %g %i") || exit 1
|
||||
read -r X Y W H G ID <<< "$slop"
|
||||
|
||||
# record screen
|
||||
ffmpeg -v 1 -r 30 -f x11grab -s "$W"x"$H" -i :0.0+"$X","$Y" -show_region 1 -vf "scale=2*trunc(iw/2):2*trunc(ih/2)" -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -crf 18 -threads 0 "$file" -y &
|
||||
;;
|
||||
wayland)
|
||||
# get coordinates
|
||||
if ! slurp="$(slurp)"; then
|
||||
exit
|
||||
fi
|
||||
wf-recorder -g "$slurp" -f "$file" --framerate 30 &
|
||||
;;
|
||||
*)
|
||||
dunstify -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/camorama.svg "This session type is not supported by record.sh"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# print metadata to tmp file
|
||||
echo $! > "$record_file"
|
||||
echo $$ >> "$record_file"
|
||||
echo "$now" >> "$record_file"
|
||||
|
||||
|
||||
# loop notif
|
||||
i=0
|
||||
while :; do
|
||||
i=$(($i + 1))
|
||||
dunstify -u low \
|
||||
-a Record \
|
||||
-r 8827 \
|
||||
-i ~/.icons/candy-icons/apps/scalable/simplescreenrecorder.svg \
|
||||
"Recording for $(date -d@$i -u +%H:%M:%S)"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
[[ -e "$record_file" ]] && stop_recording || start_recording
|
||||
Reference in New Issue
Block a user