From 1442043c5bd440d905f54b1791aa3de14361a399 Mon Sep 17 00:00:00 2001 From: "Skylar \"The Cobra\" Widulski" Date: Tue, 16 May 2023 16:43:09 -0400 Subject: [PATCH] Move wofi to -r so other programs can use wf-shadow Signed-off-by: Skylar "The Cobra" Widulski --- doc/wf-shadow.1 | 9 ++------- doc/wf-shadow.1.scd | 9 ++------- wf-shadow | 31 +++++++++++++++++-------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/doc/wf-shadow.1 b/doc/wf-shadow.1 index 7deb3da..f80d47f 100644 --- a/doc/wf-shadow.1 +++ b/doc/wf-shadow.1 @@ -72,7 +72,8 @@ lifetime.\& .RE \fB-r, --record\fR [\fIOUTPUT\fR] .RS 4 -Record the last few moments of video using a wofi(1) menu.\& +Record the last few moments of video using a wofi(1) menu.\& Any arbitrary +number of seconds can be input.\& .P This will use the same \fIOUTPUT\fR number as any running session of \fBwf-shadow\fR.\& @@ -214,12 +215,6 @@ Start a \fBwf-shadow\fR session on output #2, using /dev/dri/renderD128 as the video encoder.\& Print verbose output.\& .P .RE -.SH EXIT STATUS -.P -143 A session has ended.\& -.P -Other See output.\& -.P .SH SEE ALSO .P wf-recorder(1) wofi(1) ffmpeg(1) pactl(1) date(1) bash(1) diff --git a/doc/wf-shadow.1.scd b/doc/wf-shadow.1.scd index ca6efae..c771b23 100644 --- a/doc/wf-shadow.1.scd +++ b/doc/wf-shadow.1.scd @@ -48,7 +48,8 @@ and wofi(1) in order to accomplish the task. lifetime. *-r, --record* [_OUTPUT_] - Record the last few moments of video using a wofi(1) menu. + Record the last few moments of video using a wofi(1) menu. Any arbitrary + number of seconds can be input. This will use the same _OUTPUT_ number as any running session of *wf-shadow*. @@ -145,12 +146,6 @@ variables. Start a *wf-shadow* session on output #2, using /dev/dri/renderD128 as the video encoder. Print verbose output. -# EXIT STATUS - -143 A session has ended. - -Other See output. - # SEE ALSO wf-recorder(1) wofi(1) ffmpeg(1) pactl(1) date(1) bash(1) diff --git a/wf-shadow b/wf-shadow index a569dfe..b07a522 100755 --- a/wf-shadow +++ b/wf-shadow @@ -55,6 +55,7 @@ fi trap 'kill $(jobs -p) 2>/dev/null' EXIT trap 'exit' INT set -m +shopt -s extglob if [ ! -d "$RUNTIME" ]; then mkdir -p "$RUNTIME" 2>/dev/null @@ -119,10 +120,10 @@ record() { } start() { - local WOFI_STRING="5 seconds\n10 seconds\n15 seconds\n30 seconds\n1 minute\n5 minutes\n10 minutes\nCancel\n" while true; do for i in /tmp/wf-shadow/"$OUTPUT"-{00..10}.mp4; do printf '' >> "$i" + printf '%s' "$i" > "$RUNTIME"/"$OUTPUT"_current if [ -n "$VERBOSE" ]; then wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} ${NO_AUDIO:--a} ${AUDIO_DEV:+"${NO_AUDIO:-$AUDIO_DEV}"} -f "$i" <<< y$'\n'$OUTPUT & else @@ -130,19 +131,6 @@ start() { fi printf "%s" "$!" > "$RUNTIME"/"$OUTPUT".pid fg || exit - . "$RUNTIME"/"$OUTPUT".env - - case "$(eval "printf '$WOFI_STRING' | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 ${VERBOSE:-2>/dev/null}")" in - - '5 seconds') record "$i" 5 ;; - '10 seconds') record "$i" 10 ;; - '15 seconds') record "$i" 15 ;; - '30 seconds') record "$i" 30 ;; - '1 minute') record "$i" 60 ;; - '5 minutes') record "$i" 300 ;; - '10 minutes') record "$I" 600 ;; - *) ;; - esac & done done } @@ -238,7 +226,22 @@ fi if [ "$RECORD" == 1 ]; then if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then + WOFI_STRING="5 seconds\n10 seconds\n15 seconds\n30 seconds\n1 minute\n5 minutes\n10 minutes\nCancel\n" + TIME="$(eval "printf '$WOFI_STRING' | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 ${VERBOSE:-2>/dev/null}")" + FILE="$(<"$RUNTIME"/"$OUTPUT"_current)" kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)" + . "$RUNTIME"/"$OUTPUT".env + case "$TIME" in + '5 seconds') record "$FILE" 5 ;; + '10 seconds') record "$FILE" 10 ;; + '15 seconds') record "$FILE" 15 ;; + '30 seconds') record "$FILE" 30 ;; + '1 minute') record "$FILE" 60 ;; + '5 minutes') record "$FILE" 300 ;; + '10 minutes') record "$FILE" 600 ;; + +([0-9])) record "$FILE" "$TIME" ;; + *) ;; + esac else printf "No such session on output %d\n" "$OUTPUT" fi