1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | #:META:X_RESOURCE:%.store: the command used to store the selection |
3 | #:META:X_RESOURCE:%.store:string:the command used to store the selection |
4 | #:META:X_RESOURCE:%.fetch: the command used to fetch the selection |
4 | #:META:X_RESOURCE:%.fetch:string:the command used to fetch the selection |
|
|
5 | |
|
|
6 | =head1 NAME |
|
|
7 | |
|
|
8 | remote-clipboard - manage a shared and possibly rmeote clipboard |
|
|
9 | |
|
|
10 | =head1 DESCRIPTION |
|
|
11 | |
|
|
12 | Somewhat of a misnomer, this extension adds two menu entries to the |
|
|
13 | selection popup that allows one to run external commands to store the |
|
|
14 | selection somewhere and fetch it again. |
|
|
15 | |
|
|
16 | We use it to implement a "distributed selection mechanism", which just |
|
|
17 | means that one command uploads the file to a remote server, and another |
|
|
18 | reads it. |
|
|
19 | |
|
|
20 | The commands can be set using the C<URxvt.remote-selection.store> and |
|
|
21 | C<URxvt.remote-selection.fetch> resources. The first should read the |
|
|
22 | selection to store from STDIN (always in UTF-8), the second should provide |
|
|
23 | the selection data on STDOUT (also in UTF-8). |
|
|
24 | |
|
|
25 | The defaults (which are likely useless to you) use rsh and cat: |
|
|
26 | |
|
|
27 | URxvt.remote-selection.store: rsh ruth 'cat >/tmp/distributed-selection' |
|
|
28 | URxvt.remote-selection.fetch: rsh ruth 'cat /tmp/distributed-selection' |
|
|
29 | |
|
|
30 | =cut |
5 | |
31 | |
6 | use Fcntl (); |
32 | use Fcntl (); |
7 | |
33 | |
8 | sub msg { |
34 | sub msg { |
9 | my ($self, $msg) = @_; |
35 | my ($self, $msg) = @_; |
… | |
… | |
85 | } |
111 | } |
86 | |
112 | |
87 | sub on_start { |
113 | sub on_start { |
88 | my ($self) = @_; |
114 | my ($self) = @_; |
89 | |
115 | |
90 | $self->{store_cmd} = $self->x_resource ("remote-selection.store") |
116 | $self->{store_cmd} = $self->x_resource ("%.store") |
91 | || "rsh ruth 'cat >/tmp/distributed-selection'"; |
117 | || "rsh ruth 'cat >/tmp/distributed-selection'"; |
92 | |
118 | |
93 | $self->{fetch_cmd} = $self->x_resource ("remote-selection.fetch") |
119 | $self->{fetch_cmd} = $self->x_resource ("%.fetch") |
94 | || "rsh ruth 'cat /tmp/distributed-selection'"; |
120 | || "rsh ruth 'cat /tmp/distributed-selection'"; |
95 | |
121 | |
96 | push @{ $self->{term}{selection_popup_hook} }, sub { |
122 | push @{ $self->{term}{selection_popup_hook} }, sub { |
97 | ("selection => remote" => sub { $self->store }) |
123 | ("selection => remote" => sub { $self->store }) |
98 | }; |
124 | }; |