+39
-15
scritps/scr
+39
-15
scritps/scr
···
24
24
25
25
# Source the configuration file
26
26
# A sample configuration can be found in my dotfiles at:
27
-
# https://github.com/yemouu/setup/blob/master/root/home/cfg/scr/config.sh
28
-
. "$SCR_CFG_DIR/config.sh" || \
29
-
{ printf '%s\n' "${0##*/}: failed to source $SCR_CONFIG_DIR/config.sh" 1>&2; exit 1; }
27
+
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
28
+
. "$SCR_CFG_DIR/config.sh" || {
29
+
printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
30
+
}
30
31
31
32
# Usage statement for the script
32
33
usage() {
33
34
printf '%s\n' "usage: ${0##*/} action [options]" \
34
35
"actions:" \
35
-
" aud - audio" \
36
-
" pic - picture" \
37
-
" rec - record" \
36
+
"\taud - audio" \
37
+
"\tpic - picture" \
38
+
"\trec - record" \
38
39
"options:" \
39
-
" -a - record desktop audio" \
40
-
" -c - copy image to clipboard" \
41
-
" -h - display this message" \
42
-
" -m - record microphone audio" \
43
-
" -o - output to use"
40
+
"\t-a - record desktop audio (aud,rec)" \
41
+
"\t-c - copy image to clipboard (pic)" \
42
+
"\t-h - display this message" \
43
+
"\t-m - record microphone audio (aud,rec)" \
44
+
"\t-o - output to use (pic,rec)" \
45
+
"\t-d - all displays (pic)"
44
46
}
45
47
46
48
# Determine the action to run
···
73
75
case $a in
74
76
a ) desktop_audio=true ;;
75
77
c ) copy_clipboard=true ;;
78
+
d ) output=all ;; # Kinda redundent lol
76
79
h ) usage; exit 0 ;;
77
80
m ) microphone=true ;;
78
81
o ) aargs=$*
···
144
147
145
148
filename="$scr_pic_dir/$pic_filename"
146
149
147
-
# Get the geometry of the screenshot from the user and take the screenshot
148
-
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
149
-
grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
150
+
if [ "$output" = "all" ]
151
+
then
152
+
# Grim will screenshot all monitors by default
153
+
grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
154
+
else
155
+
# Get the geometry of the screenshot from the user and take the screenshot
156
+
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
157
+
grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
158
+
fi
159
+
150
160
151
161
# Copy the image to the system clipboard
152
162
$copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }
···
187
197
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
188
198
# Word splitting is favorable here
189
199
# shellcheck disable=SC2086
190
-
wf-recorder $args "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
200
+
wf-recorder $args $rec_extraflags "$@" -f "$filename" > "$SCR_CACHE_DIR/rec.log" 2>&1 &
191
201
rec_pid=$!
192
202
printf '%s' "Press Ctrl+C to stop recording. " 1>&2
193
203
wait $rec_pid
···
206
216
}
207
217
208
218
$action
219
+
220
+
# Run post scripts
221
+
# Scripts in the directory `$SCR_CFG_DIR/scripts` will
222
+
# take in `$action` as `$1` and `$filename` as `$2`.
223
+
# Sample scripts can be found in my dotfiles at:
224
+
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/scripts
225
+
for i in "$SCR_CFG_DIR/scripts/"*
226
+
do
227
+
[ -x "$i" ] && {
228
+
printf '%s\n' "# $i --- START" >> "$SCR_CACHE_DIR/scripts.log"
229
+
$i "$action" "$filename" > "$SCR_CACHE_DIR/scripts.log" 2>&1
230
+
printf '%s\n' "# $i --- END" >> "$SCR_CACHE_DIR/scripts.log"
231
+
}
232
+
done