#!/usr/bin/perl
# Takes input in STDIN, and runs it as the argument of @ARGV.  Basically, this
# lets us pipe an image through 'viewany eog' to load it with eye-of-gnome; or
# anything similar.  You generally want to invoke by hand, not automatically.

###############################################################################
### Configuration #############################################################
###############################################################################

## If set, print a copy of the command we want to run as well.
our $DEBUG = 1;

###############################################################################
### Declarations ##############################################################
###############################################################################

use File::Temp qw(tempfile);
use strict;
use warnings;

###############################################################################
### main () ###################################################################
###############################################################################

my ($fh, $file) = tempfile () or die "Couldn't open temp file: $!\n";
while (<STDIN>) { print $fh $_ }

print "@ARGV $file\n" if $DEBUG;
exec (@ARGV, $file);
