A collection of scripts
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

scr: allow for grabbing specific displays with `-o`

yemou 343e030e 85b0d7d7

+14 -7
+14 -7
scritps/scr
··· 39 39 " -a - record desktop audio" \ 40 40 " -c - copy image to clipboard" \ 41 41 " -h - display this message" \ 42 - " -m - record microphone audio" 42 + " -m - record microphone audio" \ 43 + " -o - output to use" 43 44 } 44 45 45 46 # Determine the action to run ··· 53 54 shift 54 55 55 56 # Determine options to run with based on arguments 57 + # (I need to stop) 56 58 for flag in "$@" 57 59 do 58 60 # Make sure arguments start with '-' and are atleast 2 characters long ··· 64 66 esac 65 67 66 68 # Split arguments to be 1 character long and determine options to use 67 - flag=${flag#-} 68 - while [ "$flag" ] 69 + args=${flag#-} 70 + while [ "$args" ] 69 71 do 70 - a=${flag%${flag#?}} 72 + a=${args%${args#?}} 71 73 case $a in 72 74 a ) desktop_audio=true ;; 73 75 c ) copy_clipboard=true ;; 74 76 h ) usage; exit 0 ;; 75 77 m ) microphone=true ;; 78 + o ) aargs=$* 79 + output=${aargs##*${flag}}; output=${output#\ }; output=${output%%\ *} 80 + [ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;; 76 81 * ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2 77 82 usage 1>&2; exit 1 ;; 78 83 esac 79 - flag=${flag#?} 84 + args=${args#?} 80 85 done 81 86 done 82 87 unset args arg ··· 140 145 filename="$scr_pic_dir/$pic_filename" 141 146 142 147 # 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 144 150 145 151 # Copy the image to the system clipboard 146 152 $copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; } ··· 178 184 # Intercept Ctrl+C and exit wf-recorder instead of the script 179 185 trap 'kill -2 $rec_pid' INT 180 186 187 + if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi 181 188 # Word splitting is favorable here 182 189 # 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 & 184 191 rec_pid=$! 185 192 printf '%s' "Press Ctrl+C to stop recording. " 1>&2 186 193 wait $rec_pid