aboutsummaryrefslogtreecommitdiff
path: root/urxvt/ext/clip
blob: 4f890c0ed6adcef0b575dfc27a8c0711072c8d52 (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
#!/usr/bin/env perl

# Copy PRIMARY selections to the clipboard too with xsel(1).

use strict;
use warnings;

sub on_start {
    my ($self) = @_;
    $self->enable( sel_grab => \&clip );
    return;
}

sub clip {
    my ($self) = @_;
    if ( open CLIPBOARD, '| xsel -ib' ) {
        my $sel = $self->selection();
        utf8::encode($sel);
        print CLIPBOARD $sel;
        close CLIPBOARD;
    }
    return;
}