Skip to content

Instantly share code, notes, and snippets.

@saevarb
Created February 22, 2019 22:07
Show Gist options
  • Save saevarb/2c6cf55285d3ffda552449d3556d8983 to your computer and use it in GitHub Desktop.
Save saevarb/2c6cf55285d3ffda552449d3556d8983 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This will not work with set -e because killing ffmpeg means whole script
# ends.
set -xuo pipefail
dorecord() {
local filename="$(date "+%F_%V_%H-%M-%S").webm"
local start="$(date "+%s")"
notify-send "Recording started.."
ffmpeg -f x11grab -s 1920x1080 -an -i :0.0 -c:v libvpx -b:v 5M -crf 10 -quality realtime -y -loglevel quiet "$filename"
local end="$(date "+%s")"
scp "$filename" "vps:sbrg/screenshots/$filename"
echo "http://sbrg.me/screenshots/$filename" | xclip -i -sel clipboard
notify-send "Done recording after $((end-start)) seconds"
rm $filename
}
pidof ffmpeg && kill -SIGINT $(pidof ffmpeg) || dorecord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment