···
# Source the configuration file
# A sample configuration can be found in my dotfiles at:
+
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
+
. "$SCR_CFG_DIR/config.sh" || {
+
printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
# Usage statement for the script
printf '%s\n' "usage: ${0##*/} action [options]" \
+
"\t-a - record desktop audio (aud,rec)" \
+
"\t-c - copy image to clipboard (pic)" \
+
"\t-h - display this message" \
+
"\t-m - record microphone audio (aud,rec)" \
+
"\t-o - output to use (pic,rec)" \
+
"\t-d - all displays (pic)"
# Determine the action to run
···
a ) desktop_audio=true ;;
c ) copy_clipboard=true ;;
+
d ) output=all ;; # Kinda redundent lol
···
filename="$scr_pic_dir/$pic_filename"
+
if [ "$output" = "all" ]
+
# Grim will screenshot all monitors by default
+
grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
+
# Get the geometry of the screenshot from the user and take the screenshot
+
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
+
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; }
···
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
# Word splitting is favorable here
# shellcheck disable=SC2086
+
wf-recorder $args $rec_extraflags "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
printf '%s' "Press Ctrl+C to stop recording. " 1>&2
···
+
# Scripts in the directory `$SCR_CFG_DIR/scripts` will
+
# take in `$action` as `$1` and `$filename` as `$2`.
+
# Sample scripts can be found in my dotfiles at:
+
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/scripts
+
for i in "$SCR_CFG_DIR/scripts/"*
+
printf '%s\n' "# $i --- START" >> "$SCR_CACHE_DIR/scripts.log"
+
$i "$action" "$filename" > "$SCR_CACHE_DIR/scripts.log" 2>&1
+
printf '%s\n' "# $i --- END" >> "$SCR_CACHE_DIR/scripts.log"