#!/usr/bin/perl

use warnings;
use strict;

sub osd {
	my @lines = @_;

	my $osd = "aosd_cat --font 'Verdana 48' --y-offset -1600 --fade-in 0 --fade-out 0 -t 0 --shadow-offset=3 --padding=3 --lines=" . ( $#lines + 1 );
	warn "# $osd\n";
	open(my $pipe, '|-', $osd) || die $!;
	print $pipe join("\n", @lines),$/;
	close($pipe);
}

#warn "recordmydesktop --height 1200 --no-cursor --no-sound --fps 25 --v_quality 63 --v_bitrate 90000 --on-the-fly-encoding\n";

warn "ffmpeg -f x11grab -s 1920x1200 -r 25 -sameq -i :0.0+0,0 -y screencast.mjpeg\n";


my @lines = ();

while(<>) {
	chomp;
	if ( $_ eq '' ) {
		print "\n", join("\n", @lines), "\n\n[ENTER] to show\n";
		<STDIN>;
		osd @lines;
		@lines = ();
	} else {
		push @lines, $_;
	}
}
