Compare commits
8 Commits
01999c9cd1
...
a85754ea38
Author | SHA1 | Date |
---|---|---|
Skylar "The Cobra" Widulski | a85754ea38 | |
Skylar "The Cobra" Widulski | 0583dfc3f7 | |
Skylar "The Cobra" Widulski | d122fa42b8 | |
Skylar "The Cobra" Widulski | 1d1ff0a885 | |
Skylar "The Cobra" Widulski | 3f41844283 | |
Skylar "The Cobra" Widulski | b2b9d6a1ac | |
Skylar "The Cobra" Widulski | 958710ba7c | |
Skylar "The Cobra" Widulski | 1442043c5b |
|
@ -11,9 +11,9 @@ WARNING: Do NOT use Ctrl+C on a `wf-shadow -s` session.
|
|||
USAGE: wf-shadow OPTION [OPTIONS...]
|
||||
|
||||
OPTIONS:
|
||||
-s, --start [MONITOR] Start a wf-shadow instance with display number MONITOR.
|
||||
-r, --record [MONITOR] Record the last few moments of video using a wofi menu.
|
||||
-e, --end [MONITOR] End wf-shadow instance with display number MONITOR.
|
||||
-s, --start [OUTPUT] Start a wf-shadow instance with output number OUTPUT.
|
||||
-r, --record [OUTPUT] Record the last few moments of video using a wofi menu.
|
||||
-e, --end [OUTPUT] End wf-shadow instance with output number OUTPUT.
|
||||
-a, --audio DEVICE Use DEVICE for audio recording. Passed to wf-recorder -a.
|
||||
-V, --video DEVICE Use DEVICE for video encoding. Passed to wf-recorder -d.
|
||||
-A, --acodec CODEC Use CODEC as the audio codec in ffmpeg encoding.
|
||||
|
@ -22,8 +22,10 @@ OPTIONS:
|
|||
-N, --no-video Disable video recording. Overrides video options.
|
||||
-y, --yes-audio Enable audio recording. Overrides -n.
|
||||
-Y, --yes-video Enable video recording. Overrides -N.
|
||||
-R, --raw-record OUTPUT FILE SECONDS Low level record. Passed directly to the \`record\` function.
|
||||
-v, --verbose Verbose output.
|
||||
-h, --help Show this menu.
|
||||
--version Display version information.
|
||||
|
||||
For a more in-depth guide, see wf-shadow(1)
|
||||
```
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
.\" Generated by scdoc 1.11.2
|
||||
.\" Complete documentation for this program is not available as a GNU info page
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.nh
|
||||
.ad l
|
||||
.\" Begin generated content:
|
||||
.TH "wf-shadow-tui" "1" "2023-05-17" "wf-shadow" "General Commands Manual"
|
||||
.P
|
||||
.SH NAME
|
||||
.P
|
||||
\fBwf-shadow-tui\fR — A TUI menu system for wf-shadow(1)
|
||||
.P
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
\fBwf-shadow-tui\fR [\fIOPTION\fR]
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
\fBwf-shadow-tui\fR is a script intended to simplify the use of wf-shadow(1) by
|
||||
displaying a dialog(1)-based curses menu to the user.\&
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.P
|
||||
\fB-h, --help\fR
|
||||
.RS 4
|
||||
Show a help menu.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-v, --version\fR
|
||||
.RS 4
|
||||
Get version number of \fBwf-shadow-tui\fR.\&
|
||||
.P
|
||||
.RE
|
||||
.SH SEE ALSO
|
||||
.P
|
||||
wf-shadow(1) dialog(1) wlr-randr(1)
|
||||
.P
|
||||
.SH AUTHOR
|
||||
Skylar "The Cobra" Widulski <cobra@vern.\&cc>
|
|
@ -0,0 +1,29 @@
|
|||
wf-shadow-tui(1) "wf-shadow" "General Commands Manual"
|
||||
|
||||
# NAME
|
||||
|
||||
*wf-shadow-tui* — A TUI menu system for wf-shadow(1)
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
*wf-shadow-tui* [_OPTION_]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
*wf-shadow-tui* is a script intended to simplify the use of wf-shadow(1) by
|
||||
displaying a dialog(1)-based curses menu to the user.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-h, --help*
|
||||
Show a help menu.
|
||||
|
||||
*-v, --version*
|
||||
Get version number of *wf-shadow-tui*.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
wf-shadow(1) dialog(1) wlr-randr(1)
|
||||
|
||||
# AUTHOR
|
||||
Skylar "The Cobra" Widulski <cobra@vern.cc>
|
|
@ -5,7 +5,7 @@
|
|||
.nh
|
||||
.ad l
|
||||
.\" Begin generated content:
|
||||
.TH "wf-shadow" "1" "2023-05-16" "wf-shadow" "General Commands Manual"
|
||||
.TH "wf-shadow" "1" "2023-05-17" "wf-shadow" "General Commands Manual"
|
||||
.P
|
||||
.SH NAME
|
||||
.P
|
||||
|
@ -26,8 +26,7 @@ and wofi(1) in order to accomplish the task.\&
|
|||
.P
|
||||
\fB-A, --acodec\fR \fICODEC\fR
|
||||
.RS 4
|
||||
This option is passed directly to ffmpeg(1)'\&s \fI-acodec\fR.\& Saved between
|
||||
clips over the course of a session'\&s lifetime.\&
|
||||
This option is passed directly to ffmpeg(1)'\&s \fI-acodec\fR.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-a, --audio\fR \fIDEVICE\fR
|
||||
|
@ -38,8 +37,7 @@ that is recorded by \fBwf-shadow\fR.\&
|
|||
.RE
|
||||
\fB-c, --vcodec\fR \fICODEC\fR
|
||||
.RS 4
|
||||
This option is passed directly to ffmpeg(1)'\&s \fI-vcodec\fR.\& Saved between
|
||||
clips over the course of a session'\&s lifetime.\&
|
||||
This option is passed directly to ffmpeg(1)'\&s \fI-vcodec\fR.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-d, --debug\fR
|
||||
|
@ -59,20 +57,24 @@ Shows a simple help menu.\&
|
|||
.RE
|
||||
\fB-N, --no-video\fR
|
||||
.RS 4
|
||||
By default, \fBwf-shadow\fR enables video recording.\& Saved between clips
|
||||
over the course of a session'\&s lifetime.\&
|
||||
By default, \fBwf-shadow\fR enables video recording.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-n, --no-audio\fR
|
||||
.RS 4
|
||||
By default, \fBwf-shadow\fR enables the -a option of wf-recorder(1).\& This
|
||||
option disables it.\& Saved between clips over the course of a session'\&s
|
||||
lifetime.\&
|
||||
option disables it.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-R, --raw-record\fR
|
||||
.RS 4
|
||||
Pass arguments directly to the record function.\& Somewhat like an API.\&
|
||||
.P
|
||||
.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.\&
|
||||
|
@ -96,14 +98,17 @@ Show the output of wf-recorder(1), ffmpeg(1), and wofi(1).\&
|
|||
.RE
|
||||
\fB-Y, --yes-video\fR
|
||||
.RS 4
|
||||
Enable video recording.\& Overrides \fI-N\fR.\& Saved between clips over the
|
||||
course of a session'\&s lifetime.\&
|
||||
Enable video recording.\& Overrides \fI-N\fR.\&
|
||||
.P
|
||||
.RE
|
||||
\fB-y, --yes-audio\fR
|
||||
.RS 4
|
||||
Enable audio recording.\& Overrides \fI-n\fR.\& Saved between clips over the
|
||||
course of a session'\&s lifetime.\&
|
||||
Enable audio recording.\& Overrides \fI-n\fR.\&
|
||||
.P
|
||||
.RE
|
||||
\fB--version\fR
|
||||
.RS 4
|
||||
Display version information of \fBwf-shadow\fR and its dependencies.\&
|
||||
.P
|
||||
.RE
|
||||
.SH ENVIRONMENT
|
||||
|
@ -214,15 +219,9 @@ 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)
|
||||
wf-shadow-tui(1) wf-recorder(1) wofi(1) ffmpeg(1) pactl(1) date(1) bash(1)
|
||||
.P
|
||||
.SH AUTHOR
|
||||
Skylar "The Cobra" Widulski <thecobra@riseup.\&net>
|
||||
Skylar "The Cobra" Widulski <cobra@vern.\&cc>
|
||||
|
|
|
@ -18,16 +18,14 @@ and wofi(1) in order to accomplish the task.
|
|||
# OPTIONS
|
||||
|
||||
*-A, --acodec* _CODEC_
|
||||
This option is passed directly to ffmpeg(1)'s _-acodec_. Saved between
|
||||
clips over the course of a session's lifetime.
|
||||
This option is passed directly to ffmpeg(1)'s _-acodec_.
|
||||
|
||||
*-a, --audio* _DEVICE_
|
||||
This option is used in order to set the pulseaudio/pipewire-pulse device
|
||||
that is recorded by *wf-shadow*.
|
||||
|
||||
*-c, --vcodec* _CODEC_
|
||||
This option is passed directly to ffmpeg(1)'s _-vcodec_. Saved between
|
||||
clips over the course of a session's lifetime.
|
||||
This option is passed directly to ffmpeg(1)'s _-vcodec_.
|
||||
|
||||
*-d, --debug*
|
||||
Sets the bash(1) _-x_ option.
|
||||
|
@ -39,16 +37,18 @@ and wofi(1) in order to accomplish the task.
|
|||
Shows a simple help menu.
|
||||
|
||||
*-N, --no-video*
|
||||
By default, *wf-shadow* enables video recording. Saved between clips
|
||||
over the course of a session's lifetime.
|
||||
By default, *wf-shadow* enables video recording.
|
||||
|
||||
*-n, --no-audio*
|
||||
By default, *wf-shadow* enables the -a option of wf-recorder(1). This
|
||||
option disables it. Saved between clips over the course of a session's
|
||||
lifetime.
|
||||
option disables it.
|
||||
|
||||
*-R, --raw-record*
|
||||
Pass arguments directly to the record function. Somewhat like an API.
|
||||
|
||||
*-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*.
|
||||
|
@ -64,12 +64,13 @@ and wofi(1) in order to accomplish the task.
|
|||
Show the output of wf-recorder(1), ffmpeg(1), and wofi(1).
|
||||
|
||||
*-Y, --yes-video*
|
||||
Enable video recording. Overrides _-N_. Saved between clips over the
|
||||
course of a session's lifetime.
|
||||
Enable video recording. Overrides _-N_.
|
||||
|
||||
*-y, --yes-audio*
|
||||
Enable audio recording. Overrides _-n_. Saved between clips over the
|
||||
course of a session's lifetime.
|
||||
Enable audio recording. Overrides _-n_.
|
||||
|
||||
*--version*
|
||||
Display version information of *wf-shadow* and its dependencies.
|
||||
|
||||
# ENVIRONMENT
|
||||
|
||||
|
@ -145,15 +146,9 @@ 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)
|
||||
wf-shadow-tui(1) wf-recorder(1) wofi(1) ffmpeg(1) pactl(1) date(1) bash(1)
|
||||
|
||||
# AUTHOR
|
||||
Skylar "The Cobra" Widulski <thecobra@riseup.net>
|
||||
Skylar "The Cobra" Widulski <cobra@vern.cc>
|
||||
|
|
76
wf-shadow
76
wf-shadow
|
@ -15,6 +15,8 @@
|
|||
# this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
VER='v1.5.5'
|
||||
|
||||
RUNTIME="${XDG_RUNTIME_DIR:-/run}/wf-shadow"
|
||||
CONFIG="${WF_SHADOW_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/wf-shadow/config.sh}"
|
||||
|
||||
|
@ -55,6 +57,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
|
||||
|
@ -73,11 +76,6 @@ if ! command -v wf-recorder &>/dev/null; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v wofi &>/dev/null; then
|
||||
printf "Need wofi\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_help() {
|
||||
cat << EOF
|
||||
wf-shadow: A Wayland shadow recorder using wf-recorder and wofi
|
||||
|
@ -96,8 +94,10 @@ OPTIONS:
|
|||
-N, --no-video Disable video recording. Overrides video options.
|
||||
-y, --yes-audio Enable audio recording. Overrides -n.
|
||||
-Y, --yes-video Enable video recording. Overrides -N.
|
||||
-R, --raw-record OUTPUT FILE SECONDS Low level record. Passed directly to the \`record\` function.
|
||||
-v, --verbose Verbose output.
|
||||
-h, --help Show this menu.
|
||||
--version Display version information.
|
||||
|
||||
For a more in-depth guide, see wf-shadow(1)
|
||||
EOF
|
||||
|
@ -119,36 +119,23 @@ 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 &
|
||||
wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} -a $AUDIO_DEV -f "$i" <<< y$'\n'$OUTPUT &
|
||||
else
|
||||
wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} ${NO_AUDIO:--a} ${AUDIO_DEV:+"${NO_AUDIO:-$AUDIO_DEV}"} -f "$i" <<< y$'\n'$OUTPUT &>/dev/null &
|
||||
wf-recorder ${VIDEO_DEV:+-d "$VIDEO_DEV"} -a $AUDIO_DEV -f "$i" <<< y$'\n'$OUTPUT &>/dev/null &
|
||||
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
|
||||
}
|
||||
|
||||
until [ -z "$1" ]; do
|
||||
re="[0-9]+"
|
||||
re="^[0-9]+$"
|
||||
case "$1" in
|
||||
'-h' | '--help') print_help ;;
|
||||
'-e' | '--end')
|
||||
|
@ -207,20 +194,33 @@ until [ -z "$1" ]; do
|
|||
'-Y' | '--yes-video')
|
||||
NO_VIDEO=""
|
||||
shift 1 ;;
|
||||
'-R' | '--raw-record')
|
||||
if [ -n "$4" ]; then
|
||||
OUTPUT="$2"
|
||||
FILE="$3"
|
||||
TIME="$4"
|
||||
RAW_RECORD=1
|
||||
shift 4
|
||||
else
|
||||
print_help
|
||||
fi ;;
|
||||
'-d' | '--debug')
|
||||
set -x
|
||||
shift 1 ;;
|
||||
'-v' | '--verbose')
|
||||
VERBOSE=" "
|
||||
shift 1 ;;
|
||||
'--version')
|
||||
printf "wf-shadow %s\n" "$VER"
|
||||
wf-recorder -v
|
||||
if command -v wofi &>/dev/null; then
|
||||
printf "wofi %s\n" "$(wofi -v)"
|
||||
fi
|
||||
exit ;;
|
||||
*) print_help ;;
|
||||
esac
|
||||
done
|
||||
|
||||
declare -p AUDIO_CODEC > "$RUNTIME"/"$OUTPUT".env
|
||||
declare -p NO_AUDIO >> "$RUNTIME"/"$OUTPUT".env
|
||||
declare -p VIDEO_CODEC >> "$RUNTIME"/"$OUTPUT".env
|
||||
declare -p NO_VIDEO >> "$RUNTIME"/"$OUTPUT".env
|
||||
|
||||
if [ -n "$NO_VIDEO" ] && [ -n "$NO_AUDIO" ]; then
|
||||
printf "Must have either audio or video recording enabled.\n"
|
||||
|
@ -236,9 +236,32 @@ if [ "$START" == 1 ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$RAW_RECORD" == 1 ]; then
|
||||
kill -2 "$(<"$RUNTIME"/"$OUTPUT".pid)"
|
||||
record "$FILE" "$TIME"
|
||||
|
||||
fi
|
||||
|
||||
if [ "$RECORD" == 1 ]; then
|
||||
if ! command -v wofi &>/dev/null; then
|
||||
printf "Need wofi\n"
|
||||
exit 1
|
||||
fi
|
||||
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)"
|
||||
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
|
||||
|
@ -248,7 +271,6 @@ if [ "$END" == 1 ]; then
|
|||
if [ -e "$RUNTIME"/"$OUTPUT"_host.pid ]; then
|
||||
kill "$(<"$RUNTIME"/"$OUTPUT"_host.pid)"
|
||||
rm -f "$RUNTIME"/"$OUTPUT"_host.pid
|
||||
rm -f "$RUNTIME"/"$OUTPUT".env
|
||||
else
|
||||
printf "No such session on output %d\n" "$OUTPUT"
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2023 Skylar Widulski
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
VER="v1.3.1"
|
||||
|
||||
RUNTIME="${XDG_RUNTIME_DIR:-/run}/wf-shadow"
|
||||
CONFIG="${WF_SHADOW_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/wf-shadow/config.sh}"
|
||||
|
||||
AUDIO_DEV=""
|
||||
AUDIO_CODEC=""
|
||||
NO_AUDIO=""
|
||||
VIDEO_DEV=""
|
||||
VIDEO_CODEC=""
|
||||
NO_VIDEO=""
|
||||
: "${WF_SHADOW_DIR:="$HOME"/Videos/wf-shadow}"
|
||||
: "${WF_SHADOW_FMT:=%Y%m%d_%H:%M:%S}"
|
||||
: "${WF_SHADOW_EXT:=mp4}"
|
||||
|
||||
. "$CONFIG"
|
||||
|
||||
TITLE='--title wf-shadow-tui'
|
||||
|
||||
if ! command -v wf-shadow &>/dev/null; then
|
||||
printf 'Need wf-shadow\n'
|
||||
fi
|
||||
|
||||
if ! command -v wlr-randr &>/dev/null; then
|
||||
printf 'Need wlr-randr\n'
|
||||
fi
|
||||
|
||||
if ! command -v dialog &>/dev/null; then
|
||||
printf 'Need dialog\n'
|
||||
fi
|
||||
|
||||
if command -v tput &>/dev/null; then
|
||||
tput smcup
|
||||
fi
|
||||
|
||||
trap 'if command -v tput &>/dev/null; then tput rmcup; fi' EXIT
|
||||
|
||||
get_output() {
|
||||
RANDR="$(wlr-randr)"
|
||||
i=0
|
||||
while read -r line; do
|
||||
if [[ "$line" =~ - ]]; then
|
||||
((i++))
|
||||
fi
|
||||
done <<< "$RANDR"
|
||||
OUTPUT="$(eval "dialog $TITLE --menu 'Output:' 24 64 24 $(while read -r line; do
|
||||
if [[ "$line" =~ - ]]; then
|
||||
tmp="${line#*(}"
|
||||
tmp="${tmp%)*}"
|
||||
printf "$i '(%s) \t" "$tmp"
|
||||
|
||||
tmp=${line#*\"}
|
||||
tmp="${tmp% (*}"
|
||||
printf "%s' " "$tmp"
|
||||
|
||||
((i--))
|
||||
fi
|
||||
done <<< "$RANDR") 3>&1 1>&2 2>&3")"
|
||||
}
|
||||
|
||||
get_action() {
|
||||
ACTION="$(eval "dialog $TITLE --menu 'Action for output $OUTPUT:' 24 64 24 $([ ! -f "$RUNTIME/${OUTPUT}_host.pid" ] && printf "'Start' 'Start a session of wf-shadow on this output'") $([ -f "$RUNTIME/${OUTPUT}_host.pid" ] && printf "'Record' 'Clip the last few seconds of video' 'End' 'End the wf-shadow session'") 3>&1 1>&2 2>&3")"
|
||||
}
|
||||
|
||||
get_seconds() {
|
||||
TIME="$(eval "dialog $TITLE --inputbox 'Seconds to clip:' 0 0 30 3>&1 1>&2 2>&3")"
|
||||
}
|
||||
|
||||
get_seconds_wrap() {
|
||||
unset TIME
|
||||
get_seconds
|
||||
if [ -z "$TIME" ]; then
|
||||
get_action_wrap
|
||||
else
|
||||
wf-shadow -R "$OUTPUT" "$(<"$RUNTIME/${OUTPUT}_current")" "$TIME"
|
||||
fi
|
||||
}
|
||||
|
||||
get_output_wrap() {
|
||||
unset OUTPUT
|
||||
get_output
|
||||
if [ -z "$OUTPUT" ]; then
|
||||
get_main_wrap
|
||||
else
|
||||
get_action_wrap
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
get_action_wrap() {
|
||||
unset ACTION
|
||||
get_action
|
||||
if [ -z "$ACTION" ]; then
|
||||
get_output_wrap
|
||||
else
|
||||
case "$ACTION" in
|
||||
Start)
|
||||
wf-shadow --start "$OUTPUT" &>/dev/null & disown
|
||||
sleep 0.1
|
||||
get_action_wrap ;;
|
||||
End)
|
||||
wf-shadow --end "$OUTPUT"
|
||||
sleep 0.1
|
||||
get_action_wrap ;;
|
||||
Record) get_seconds_wrap ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
get_option() {
|
||||
OPTION="$(eval "dialog $TITLE --menu "Configuration" 24 125 24 'AUDIO_DEV' 'PulseAudio device to record' 'AUDIO_CODEC' 'FFmepg audio codec' 'NO_AUDIO' 'Whether or not no audio should be recorded' 'VIDEO_DEV' 'DRI render device (/dev/dri/renderDxxx) to use to encode video' 'VIDEO_CODEC' 'FFmpeg video codec' 'NO_VIDEO' 'Whether or not no video should be encoded into the final clips' 'WF_SHADOW_DIR' 'Directory to store clips in' 'WF_SHADOW_FMT' '\`date\` format to use in file names of clips' 'WF_SHADOW_EXT' 'Container and file extension to use in clip file names' 'WF_SHADOW_SAVE' 'Command used to get the path to the file in which clips should be saved. Overrides the last 3 options.' 3>&1 1>&2 2>&3")"
|
||||
}
|
||||
|
||||
option_inputbox() {
|
||||
eval "dialog $TITLE --inputbox '$1' 0 '$2' $3 3>&1 1>&2 2>&3"
|
||||
}
|
||||
|
||||
option_yesno() {
|
||||
eval "dialog $TITLE --yesno 'NO_$1' 5 24 3>&1 1>&2 2>&3"
|
||||
case $? in
|
||||
0) printf 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
option_dir() {
|
||||
eval "dialog $TITLE --dselect $HOME 60 80 3>&1 1>&2 2>&3"
|
||||
}
|
||||
|
||||
config_to_file() {
|
||||
declare -p AUDIO_DEV > "$CONFIG"
|
||||
declare -p AUDIO_CODEC >> "$CONFIG"
|
||||
declare -p NO_AUDIO >> "$CONFIG"
|
||||
declare -p VIDEO_DEV >> "$CONFIG"
|
||||
declare -p VIDEO_CODEC >> "$CONFIG"
|
||||
declare -p NO_VIDEO >> "$CONFIG"
|
||||
declare -p WF_SHADOW_DIR >> "$CONFIG"
|
||||
declare -p WF_SHADOW_FMT >> "$CONFIG"
|
||||
declare -p WF_SHADOW_EXT >> "$CONFIG"
|
||||
declare -p WF_SHADOW_SAVE >> "$CONFIG"
|
||||
}
|
||||
|
||||
get_option_wrap() {
|
||||
unset OPTION
|
||||
get_option
|
||||
case "$OPTION" in
|
||||
AUDIO_DEV) AUDIO_DEV="$(option_inputbox AUDIO_DEV 120 ${AUDIO_DEV:-$(pactl list sources | sed -n 's/\s*Name:\s*\(.*\)/\1/p' | tail -1 2>/dev/null)})" ;;
|
||||
AUDIO_CODEC) AUDIO_CODEC="$(option_inputbox AUDIO_CODEC 24 ${AUDIO_CODEC:-aac})" ;;
|
||||
NO_AUDIO) NO_AUDIO="$(option_yesno AUDIO)" ;;
|
||||
VIDEO_DEV) VIDEO_DEV="$(option_inputbox VIDEO_DEV 64 ${VIDEO_DEV:-/dev/dri/renderD128})" ;;
|
||||
VIDEO_CODEC) VIDEO_CODEC="$(option_inputbox VIDEO_CODEC 24 ${VIDEO_CODEC:-libx264})" ;;
|
||||
NO_VIDEO) NO_VIDEO="$(option_yesno VIDEO)" ;;
|
||||
WF_SHADOW_DIR) WF_SHADOW_DIR="$(option_dir)" ;;
|
||||
WF_SHADOW_FMT) WF_SHADOW_FMT="$(option_inputbox WF_SHADOW_FMT 24 ${WF_SHADOW_FMT:-%Y%m%d_%H:%M:%S})" ;;
|
||||
WF_SHADOW_EXT) WF_SHADOW_EXT="$(option_inputbox WF_SHADOW_EXT 24 ${WF_SHADOW_EXT:-mp4})" ;;
|
||||
WF_SHADOW_SAVE) WF_SHADOW_SAVE="$(option_inputbox WF_SHADOW_SAVE 120)" ;;
|
||||
*) config_to_file; get_main_wrap; exit ;;
|
||||
esac
|
||||
get_option_wrap
|
||||
}
|
||||
|
||||
get_main() {
|
||||
MAIN="$(eval "dialog $TITLE --menu 'Main Menu' 9 64 9 'Outputs' 'Start, record, or end a wf-shadow session' 'Config' 'Configure wf-shadow' 3>&1 1>&2 2>&3")"
|
||||
}
|
||||
|
||||
get_main_wrap() {
|
||||
unset MAIN
|
||||
get_main
|
||||
case "$MAIN" in
|
||||
Outputs) get_output_wrap ;;
|
||||
Config) get_option_wrap ;;
|
||||
esac
|
||||
}
|
||||
|
||||
until [ -z "$1" ]; do
|
||||
case "$1" in
|
||||
'-v' | '--version')
|
||||
printf "wf-shadow-tui %s\n" "$VER"
|
||||
wf-shadow --version
|
||||
printf "dialog %s\n" "$(dialog --version)"
|
||||
exit ;;
|
||||
'-h' | '--help')
|
||||
cat << EOF
|
||||
USAGE: wf-shadow-tui [OPTION]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Show this help menu
|
||||
-v, --version Show version information
|
||||
|
||||
EOF
|
||||
exit ;;
|
||||
esac
|
||||
done
|
||||
|
||||
get_main_wrap
|
Loading…
Reference in New Issue