Skip to content

Instantly share code, notes, and snippets.

@xaicron
Created February 15, 2010 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xaicron/304564 to your computer and use it in GitHub Desktop.
Save xaicron/304564 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Encode qw/decode/;
use Gtk2 -init;
use Pod::Usage qw/pod2usage/;
use opts;
opts
my $encoding => { isa => 'Str', default => 'utf8' },
my $help => { isa => 'Bool' },
;
pod2usage 1 if $help;
my $data = decode $encoding, do { local $/; <STDIN> } || '';
&main();exit;
sub main() {
my $clip = Gtk2::Clipboard->get(Gtk2::Gdk->SELECTION_CLIPBOARD);
$clip->set_text($data);
$clip->store;
Gtk2->main_iteration_do(1) if $^O eq 'MSWin32';
}
__END__
=head1 NAME
pclip - save clipboard for Gtk2
=head1 SYNOPSIS
cat file | pclip [--encoding encoding --help]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment