run shell command

This commit is contained in:
Q
2022-11-14 17:50:42 +02:00
parent dd7e6f4d1d
commit 4f2abdf86c

View File

@@ -9,9 +9,9 @@ _help() {
default framerate: '$framerate' default framerate: '$framerate'
default delay: '$delay' default delay: '$delay'
-i for interactive selection using "slop" -i for interactive selection using "slop"
--shell to record current terminal --shell "[cmd]" to record current terminal, default cmd: bash
Hit "q" when finished! Hit "q" when finished (or exit shell in --shell)!
' '
} }
_helpexit(){ _helpexit(){
@@ -26,6 +26,7 @@ framerate=15
delay=0 delay=0
interact=0 interact=0
new_shell=0 new_shell=0
shell_command=bash
for (( i=1; i<=$#; i++ )); do for (( i=1; i<=$#; i++ )); do
[[ ${!i} = "-h"* ]] && _helpexit [[ ${!i} = "-h"* ]] && _helpexit
[[ ${!i} = "--h"* ]] && _helpexit [[ ${!i} = "--h"* ]] && _helpexit
@@ -58,10 +59,11 @@ for (( i=1; i<=$#; i++ )); do
fi fi
if [[ ${!i} = "--shell" ]]; then if [[ ${!i} = "--shell" ]]; then
new_shell=1 new_shell=1
shell_command="${!j}"
shift
fi fi
done done
shell_command="${shell_command:-bash}"
if [[ $delay -gt 0 ]]; then if [[ $delay -gt 0 ]]; then
echo Waiting.. for $delay seconds echo Waiting.. for $delay seconds
@@ -95,43 +97,38 @@ if [[ $new_shell -eq 1 ]]; then
echo Starting to record in 5 seconds, or press enter echo Starting to record in 5 seconds, or press enter
read -t 5 foo || true read -t 5 foo || true
x0=$( tput cols )
pre=$( qolop eval "_qPos save; _qPos abs 1 $x0; _qCol R;" )
post=$( qolop eval "_qCol Z; _qPos restore;" )
ffmpeg \ ffmpeg \
-video_size $size \ -video_size $size \
-framerate $framerate \ -framerate $framerate \
-f x11grab \ -f x11grab \
-i $DISPLAY+${pos} \ -i $DISPLAY+${pos} \
-vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \
-c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \
-an \ -an \
-movflags faststart \ -movflags faststart \
-loglevel panic \ -loglevel panic \
-hide_banner \ -hide_banner \
"$filename" & "$filename" &
ffpid=$! ffpid=$!
clear clear
bash eval "$shell_command"
kill -INT $ffpid kill -INT $ffpid
trap - EXIT SIGINT SIGTERM trap - EXIT SIGINT SIGTERM
kill $animpid > /dev/null 2>&1 tput init
#animate_clear echo ""
printf "%s %s" "$pre" "$post" >&2
else else
ffmpeg \ ffmpeg \
-video_size $size \ -video_size $size \
-framerate $framerate \ -framerate $framerate \
-f x11grab \ -f x11grab \
-i $DISPLAY+${pos} \ -i $DISPLAY+${pos} \
-vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \
-c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \
-an \ -an \
-movflags faststart \ -movflags faststart \
-loglevel panic \ -loglevel panic \
-hide_banner \ -hide_banner \
"$filename" "$filename"
fi fi
echo "Saved to: $filename" echo "Saved to: $filename"