···
" -a - record desktop audio" \
" -c - copy image to clipboard" \
" -h - display this message" \
42
-
" -m - record microphone audio"
42
+
" -m - record microphone audio" \
43
+
" -o - output to use"
# Determine the action to run
···
# Determine options to run with based on arguments
# Make sure arguments start with '-' and are atleast 2 characters long
···
# Split arguments to be 1 character long and determine options to use
a ) desktop_audio=true ;;
c ) copy_clipboard=true ;;
79
+
output=${aargs##*${flag}}; output=${output#\ }; output=${output%%\ *}
80
+
[ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;;
* ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2
···
filename="$scr_pic_dir/$pic_filename"
# Get the geometry of the screenshot from the user and take the screenshot
143
-
grim -g "$(slurp)" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
148
+
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
149
+
grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
# Copy the image to the system clipboard
$copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }
···
# Intercept Ctrl+C and exit wf-recorder instead of the script
trap 'kill -2 $rec_pid' INT
187
+
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
# Word splitting is favorable here
# shellcheck disable=SC2086
183
-
wf-recorder $args -g "$(slurp)" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
190
+
wf-recorder $args "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
printf '%s' "Press Ctrl+C to stop recording. " 1>&2