All pastes #955286 Raw Edit

GS42K0

public text v1 · immutable
#955286 ·published 2008-03-24 15:01 UTC
rendered paste body
#!/usr/bin/perl -w
#
use IO::Handle;

# fork a player control process to write
my $info_pipe_pid = open IPR, '-|';

IPR->autoflush();

die "can't open stdout" unless defined $info_pipe_pid;
if(!$info_pipe_pid) { 
	system("killall gmplayer");
	system("gmplayer  -skin Terminator3 -vo xv -prefer-ipv4 -quiet -playlist $ARGV[0]");
	exit;
}


open IPW, '>test-pipe' or die "can't open test-pipe $!...";
IPW->autoflush();
print IPW "New session:\n";
my $cut_id;
my $sshalt_pid;
while(<IPR>){
	print;
	if( /^Playing/ ){
		# kill the screensaver-halt
		if ($sshalt_pid) {
			kill 15, $sshalt_pid;
			wait;
			undef $sshalt_pid;
		}
		# append to the player_log ;)
		print IPW;
		# open firefox/osd for gangsterfreak info
		if( /(http:\/\/[^\/]+)\/cut\/(\d+)/ && $2 != $cut_id && `pidof firefox-bin`) {
			$cut_id = $2;
			system "firefox $1/uf/$cut_id";
		}
	} 
	elsif (/^VIDEO/) {
		$sshalt_pid = fork;
		if (!$sshalt_pid) {
			warn "going to inhibit the screen-saver";
			exec 'gnome-screensaver-command -i';
			exit;
		}
	}
}
close IPW;
wait;
close IPR;
kill 15, $sshalt_pid if $sshalt_pid;
wait;
print "done";