Merge branch 'user/okmans/improvement/recording-mode' into 'master'
Improve the recorder script See merge request tile-os/tileos-settings-sway!17
This commit is contained in:
commit
8f24ae2946
2 changed files with 47 additions and 24 deletions
|
@ -16,4 +16,4 @@ mode --pango_markup $mode_recording {
|
||||||
$bindsym $mod+Shift+r mode $mode_recording
|
$bindsym $mod+Shift+r mode $mode_recording
|
||||||
|
|
||||||
## Launch // Stop Recording Mode ##
|
## Launch // Stop Recording Mode ##
|
||||||
$bindsym $mod+Escape exec killall -s SIGINT wf-recorder
|
$bindsym $mod+Escape exec $recorder
|
||||||
|
|
|
@ -1,44 +1,67 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
|
||||||
|
|
||||||
pgrep wf-recorder
|
|
||||||
status=$?
|
|
||||||
|
|
||||||
countdown() {
|
countdown() {
|
||||||
notify "Recording in 3 seconds" -t 1000
|
for count in {3..1}; do
|
||||||
sleep 1
|
notify "Recording in $count seconds" -t 1000
|
||||||
notify "Recording in 2 seconds" -t 1000
|
sleep 1
|
||||||
sleep 1
|
done
|
||||||
notify "Recording in 1 seconds" -t 1000
|
|
||||||
sleep 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notify() {
|
notify() {
|
||||||
line=$1
|
notify-send \
|
||||||
shift
|
"$1" \
|
||||||
notify-send "Recording" "${line}" -i /usr/share/icons/Yaru/scalable/devices/camera-video-symbolic.svg "$*"
|
-i "/usr/share/icons/Yaru/scalable/devices/camera-video-symbolic.svg" \
|
||||||
|
"${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $status != 0 ]; then
|
kill_waybar() {
|
||||||
|
pkill -RTMIN+8 waybar
|
||||||
|
}
|
||||||
|
|
||||||
|
kill_recursive() {
|
||||||
|
ps -o sid= -p "$1" | xargs pkill --signal SIGINT -g
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
pid=$(cat "$1")
|
||||||
|
rm "$1"
|
||||||
|
kill_waybar
|
||||||
|
kill_recursive "$pid"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
pid_file="/tmp/screenrecorder-$UID.pid"
|
||||||
|
|
||||||
|
test -e "$pid_file" && cleanup "$pid_file"
|
||||||
|
echo "$$" > "$pid_file"
|
||||||
|
|
||||||
target_path=$(xdg-user-dir VIDEOS)
|
target_path=$(xdg-user-dir VIDEOS)
|
||||||
timestamp=$(date +'recording_%Y%m%d-%H%M%S')
|
timestamp=$(date +'recording_%Y%m%d-%H%M%S')
|
||||||
|
|
||||||
notify "Select a region to record" -t 1000
|
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
|
countdown
|
||||||
(sleep 0.5 && pkill -RTMIN+8 waybar) &
|
(sleep 0.5 && kill_waybar) &
|
||||||
|
|
||||||
if [ "$1" == "-a" ]; then
|
if [[ "$1" == "-a" ]]; then
|
||||||
file="$target_path/$timestamp.mp4"
|
file="$target_path/$timestamp.mp4"
|
||||||
wf-recorder --audio -g "$area" --file="$file"
|
wf-recorder --audio -g "$area" --file="$file"
|
||||||
else
|
else
|
||||||
file="$target_path/$timestamp.webm"
|
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
|
fi
|
||||||
|
|
||||||
pkill -RTMIN+8 waybar && notify "Finished recording ${file}"
|
kill_waybar && notify "Finished recording ${file}"
|
||||||
else
|
rm $pid_file
|
||||||
pkill --signal SIGINT wf-recorder
|
}
|
||||||
pkill -RTMIN+8 waybar
|
main "$@"
|
||||||
fi
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue