Move wofi to -r so other programs can use wf-shadow

Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-05-16 16:43:09 -04:00
parent 01999c9cd1
commit 1442043c5b
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
3 changed files with 21 additions and 28 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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