Make the recorder script more readable
This commit is contained in:
parent
d59a58120b
commit
bca213279f
1 changed files with 19 additions and 12 deletions
|
@ -1,18 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
countdown() {
|
||||
notify "Recording in 3 seconds" -t 1000
|
||||
sleep 1
|
||||
notify "Recording in 2 seconds" -t 1000
|
||||
sleep 1
|
||||
notify "Recording in 1 seconds" -t 1000
|
||||
for count in {3..1}; do
|
||||
notify "Recording in $count seconds" -t 1000
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
notify() {
|
||||
line=$1
|
||||
shift
|
||||
notify-send "${line}" -i /usr/share/icons/Yaru/scalable/devices/camera-video-symbolic.svg "$@"
|
||||
notify-send \
|
||||
"$1" \
|
||||
-i "/usr/share/icons/Yaru/scalable/devices/camera-video-symbolic.svg" \
|
||||
"${@:2}"
|
||||
}
|
||||
|
||||
kill_waybar() {
|
||||
|
@ -41,17 +40,25 @@ main() {
|
|||
timestamp=$(date +'recording_%Y%m%d-%H%M%S')
|
||||
|
||||
notify "Select a region to record" -t 1000
|
||||
area=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
|
||||
area=$(swaymsg -t get_tree | \
|
||||
jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | \
|
||||
slurp)
|
||||
|
||||
countdown
|
||||
(sleep 0.5 && kill_waybar) &
|
||||
|
||||
if [ "$1" == "-a" ]; then
|
||||
if [[ "$1" == "-a" ]]; then
|
||||
file="$target_path/$timestamp.mp4"
|
||||
wf-recorder --audio -g "$area" --file="$file"
|
||||
else
|
||||
file="$target_path/$timestamp.webm"
|
||||
wf-recorder -g "$area" -c libvpx --codec-param="qmin=0" --codec-param="qmax=25" --codec-param="crf=4" --codec-param="b:v=1M" --file="$file"
|
||||
wf-recorder \
|
||||
-g "$area" -c libvpx \
|
||||
--codec-param="qmin=0" \
|
||||
--codec-param="qmax=25" \
|
||||
--codec-param="crf=4" \
|
||||
--codec-param="b:v=1M" \
|
||||
--file="$file"
|
||||
fi
|
||||
|
||||
kill_waybar && notify "Finished recording ${file}"
|
||||
|
|
Loading…
Add table
Reference in a new issue