aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenrecord
blob: 770224391963ae2badcd8001e05fa4b8ee677c50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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"