#!/bin/bash # Dependencies: libav-tools # Usage: ./script to start and ./script again to stop set -x rate="25" area="1920x1080" res="1280x720" screen="0" display="0" output="$HOME/Videos/Screencasts/$(date +'%Y-%m-%d_%H-%M-%S').flv" pidfile="/tmp/screencast.pid" if [ -e "$pidfile" ] then kill "$(cat "$pidfile")" rm "$pidfile" notify-send -i gnome-screenshot "SCREENCAST STOPPED" \ "The screencast was saved to $output" else notify-send -i gnome-screenshot "SCREENCAST STARTED" \ "The screencast will be save to $output" avconv -v quiet -f x11grab -r "$rate" -s "$area" -i :"$screen"."$display" \ -s "$res" -vcodec libx264 "$output" & echo $! > /tmp/screencast.pid fi