diff --git a/bin/scrcap b/bin/scrcap index 74776461..d48de44f 100755 --- a/bin/scrcap +++ b/bin/scrcap @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p maim slop xclip libnotify +#! nix-shell -i bash -p maim slop # A script that takes a screenshot (prompts you for what region/window to # capture) and stores it in the clipboard. diff --git a/bin/scrrec b/bin/scrrec index 7d9c3c7b..02368562 100755 --- a/bin/scrrec +++ b/bin/scrrec @@ -7,13 +7,21 @@ # mov2gif script included in this repo (which is powered by gifsicle and # ffmpeg). # -# Usage: rec somefile.mp4 -# rec another.gif +# Usage: scrrec somefile.mp4 +# scrrec another.gif + +is_script= +geom= +delay=1 +while getopts sg:d: opt; do + case $opt in + s) is_script=1 ;; + g) geom="$OPTARG" ;; + d) delay="$OPTARG" ;; + esac +done +shift $((OPTIND-1)) -if [[ $1 == -s ]]; then - is_script=1 - shift -fi if [[ -f /tmp/_stop ]]; then echo q > /tmp/_stop @@ -25,7 +33,11 @@ if [[ -f /tmp/_stop ]]; then exit 0 fi -read -r X Y W H < <(slop -f "%x %y %w %h") +if [[ $geom ]]; then + read -r W H X Y <<<"${geom//[x+]/ }" +else + read -r X Y W H < <(slop -n -f "%x %y %w %h") +fi dest=${1:-./rec.mp4} if [[ $dest == *.gif ]]; then echo "Detected gif" @@ -35,14 +47,16 @@ fi if [[ $is_script ]]; then echo "Starting" touch /tmp/_stop - ffmpeg -y -f x11grab -s "$W"x"$H" -i :0.0+$X,$Y -framerate 30 "${mp4dest:-$dest}"