···24242525# Source the configuration file
2626# A sample configuration can be found in my dotfiles at:
2727-# https://github.com/yemouu/setup/blob/master/root/home/cfg/scr/config.sh
2828-. "$SCR_CFG_DIR/config.sh" || \
2929- { printf '%s\n' "${0##*/}: failed to source $SCR_CONFIG_DIR/config.sh" 1>&2; exit 1; }
2727+# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
2828+. "$SCR_CFG_DIR/config.sh" || {
2929+ printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
3030+}
30313132# Usage statement for the script
3233usage() {
3334 printf '%s\n' "usage: ${0##*/} action [options]" \
3435 "actions:" \
3535- " aud - audio" \
3636- " pic - picture" \
3737- " rec - record" \
3636+ "\taud - audio" \
3737+ "\tpic - picture" \
3838+ "\trec - record" \
3839 "options:" \
3939- " -a - record desktop audio" \
4040- " -c - copy image to clipboard" \
4141- " -h - display this message" \
4242- " -m - record microphone audio" \
4343- " -o - output to use"
4040+ "\t-a - record desktop audio (aud,rec)" \
4141+ "\t-c - copy image to clipboard (pic)" \
4242+ "\t-h - display this message" \
4343+ "\t-m - record microphone audio (aud,rec)" \
4444+ "\t-o - output to use (pic,rec)" \
4545+ "\t-d - all displays (pic)"
4446}
45474648# Determine the action to run
···7375 case $a in
7476 a ) desktop_audio=true ;;
7577 c ) copy_clipboard=true ;;
7878+ d ) output=all ;; # Kinda redundent lol
7679 h ) usage; exit 0 ;;
7780 m ) microphone=true ;;
7881 o ) aargs=$*
···144147145148 filename="$scr_pic_dir/$pic_filename"
146149147147- # Get the geometry of the screenshot from the user and take the screenshot
148148- if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
149149- grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
150150+ if [ "$output" = "all" ]
151151+ then
152152+ # Grim will screenshot all monitors by default
153153+ grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
154154+ else
155155+ # Get the geometry of the screenshot from the user and take the screenshot
156156+ if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
157157+ grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
158158+ fi
159159+150160151161 # Copy the image to the system clipboard
152162 $copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }
···187197 if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
188198 # Word splitting is favorable here
189199 # shellcheck disable=SC2086
190190- wf-recorder $args "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
200200+ wf-recorder $args $rec_extraflags "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
191201 rec_pid=$!
192202 printf '%s' "Press Ctrl+C to stop recording. " 1>&2
193203 wait $rec_pid
···206216}
207217208218$action
219219+220220+# Run post scripts
221221+# Scripts in the directory `$SCR_CFG_DIR/scripts` will
222222+# take in `$action` as `$1` and `$filename` as `$2`.
223223+# Sample scripts can be found in my dotfiles at:
224224+# https://github.com/yemouu/setup/blob/master/home/cfg/scr/scripts
225225+for i in "$SCR_CFG_DIR/scripts/"*
226226+do
227227+ [ -x "$i" ] && {
228228+ printf '%s\n' "# $i --- START" >> "$SCR_CACHE_DIR/scripts.log"
229229+ $i "$action" "$filename" > "$SCR_CACHE_DIR/scripts.log" 2>&1
230230+ printf '%s\n' "# $i --- END" >> "$SCR_CACHE_DIR/scripts.log"
231231+ }
232232+done