diff options
Diffstat (limited to '.local/bin/screenrecord')
-rwxr-xr-x | .local/bin/screenrecord | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.local/bin/screenrecord b/.local/bin/screenrecord new file mode 100755 index 0000000..7702243 --- /dev/null +++ b/.local/bin/screenrecord @@ -0,0 +1,17 @@ +#!/bin/sh -eu + +process=x11grab +directory=$HOME/Desktop/screen-recordings +default=$(xrandr | awk '/*/ { print $1 }' | head -n1) +file="$(date +%I:%M:%S-%p-%A-%d-%B-%Y).mp4" +resolution=${1:-$default} + +[ "${1:-}" = "stop" ] && kill -15 "$(ps -aux | awk "/$process/"' { print $2 }' | head -n 1)" +[ "${1:-}" = "stop" ] && exit + +[ "$(ps -aux | awk "/$process/"' { print $2 }' | wc -l)" != 1 ] && printf 'Screen Already Recording!\n' && exit + +mkdir --parents "$directory" +notify-send --expire-time=2000 "Screen Recording Started ($resolution)" "$directory/$file" && sleep 2 +ffmpeg -f alsa -i default -f alsa -i default -f x11grab -s "$resolution" -i "$DISPLAY" -r 24 -c:v libx264rgb -crf 0 -preset ultrafast "$directory/$file" || true +notify-send "Screen Recording Ended ($resolution)" "$directory/$file" |