blob: b09eadfeb5dcd488bde40736a9d66278f5a8f39f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env perl
# Copy PRIMARY selections to the clipboard too with xsel(1).
use strict;
use warnings;
use Carp;
our $VERSION = 1.0;
sub on_start {
my ($self) = @_;
$self->enable( sel_grab => \&clip );
return;
}
sub clip {
my ($self) = @_;
my $selection = $self->selection();
utf8::encode($selection);
open my $clipboard, q{|-}, 'xsel -ib'
or croak('xsel(1) not available');
print {$clipboard} $selection
or croak('Failed to write to xsel(1) pipe');
close $clipboard
or croak('Failed to close xsel(1) pipe');
return;
}
|