From 4f2abdf86ca8b111cd7db5b5fe259d03ce914d89 Mon Sep 17 00:00:00 2001 From: Q Date: Mon, 14 Nov 2022 17:50:42 +0200 Subject: [PATCH] run shell command --- av/ffmpeg-screencapture | 65 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/av/ffmpeg-screencapture b/av/ffmpeg-screencapture index e4dfa0d..1a658ea 100755 --- a/av/ffmpeg-screencapture +++ b/av/ffmpeg-screencapture @@ -9,9 +9,9 @@ _help() { default framerate: '$framerate' default delay: '$delay' -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(){ @@ -26,6 +26,7 @@ framerate=15 delay=0 interact=0 new_shell=0 +shell_command=bash for (( i=1; i<=$#; i++ )); do [[ ${!i} = "-h"* ]] && _helpexit [[ ${!i} = "--h"* ]] && _helpexit @@ -58,10 +59,11 @@ for (( i=1; i<=$#; i++ )); do fi if [[ ${!i} = "--shell" ]]; then new_shell=1 + shell_command="${!j}" + shift fi - done - +shell_command="${shell_command:-bash}" if [[ $delay -gt 0 ]]; then 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 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 \ - -video_size $size \ - -framerate $framerate \ - -f x11grab \ - -i $DISPLAY+${pos} \ - -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ - -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ - -an \ - -movflags faststart \ - -loglevel panic \ - -hide_banner \ - "$filename" & + -video_size $size \ + -framerate $framerate \ + -f x11grab \ + -i $DISPLAY+${pos} \ + -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ + -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ + -an \ + -movflags faststart \ + -loglevel panic \ + -hide_banner \ + "$filename" & ffpid=$! clear - bash + eval "$shell_command" kill -INT $ffpid trap - EXIT SIGINT SIGTERM - kill $animpid > /dev/null 2>&1 - #animate_clear - printf "%s %s" "$pre" "$post" >&2 - + tput init + echo "" else ffmpeg \ - -video_size $size \ - -framerate $framerate \ - -f x11grab \ - -i $DISPLAY+${pos} \ - -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ - -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ - -an \ - -movflags faststart \ - -loglevel panic \ - -hide_banner \ - "$filename" + -video_size $size \ + -framerate $framerate \ + -f x11grab \ + -i $DISPLAY+${pos} \ + -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \ + -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ + -an \ + -movflags faststart \ + -loglevel panic \ + -hide_banner \ + "$filename" fi echo "Saved to: $filename"