--- rxvt-unicode/src/perl/remote-clipboard 2006/01/25 15:35:27 1.3 +++ rxvt-unicode/src/perl/remote-clipboard 2012/06/10 17:31:53 1.9 @@ -1,5 +1,34 @@ #! perl +#:META:X_RESOURCE:%.store:string:the command used to store the selection +#:META:X_RESOURCE:%.fetch:string:the command used to fetch the selection + +=head1 NAME + + remote-clipboard - manage a shared and possibly rmeote clipboard + +=head1 DESCRPTION + +Somewhat of a misnomer, this extension adds two menu entries to the +selection popup that allows one to run external commands to store the +selection somewhere and fetch it again. + +We use it to implement a "distributed selection mechanism", which just +means that one command uploads the file to a remote server, and another +reads it. + +The commands can be set using the C and +C resources. The first should read the +selection to store from STDIN (always in UTF-8), the second should provide +the selection data on STDOUT (also in UTF-8). + +The defaults (which are likely useless to you) use rsh and cat: + + URxvt.remote-selection.store: rsh ruth 'cat >/tmp/distributed-selection' + URxvt.remote-selection.fetch: rsh ruth 'cat /tmp/distributed-selection' + +=cut + use Fcntl (); sub msg { @@ -40,7 +69,7 @@ $self->{iow} = urxvt::iow ->new ->fd (fileno $fh) - ->events (urxvt::EVENT_WRITE) + ->events (urxvt::EV_WRITE) ->start ->cb (sub { if (my $len = syswrite $fh, $txt) { @@ -65,7 +94,7 @@ $self->{iow} = urxvt::iow ->new ->fd (fileno $fh) - ->events (urxvt::EVENT_READ) + ->events (urxvt::EV_READ) ->start ->cb (sub { if (my $len = sysread $fh, $txt, 8192, length $txt) { @@ -84,10 +113,10 @@ sub on_start { my ($self) = @_; - $self->{store_cmd} = $self->x_resource ("remote-selection.store") + $self->{store_cmd} = $self->x_resource ("%.store") || "rsh ruth 'cat >/tmp/distributed-selection'"; - $self->{fetch_cmd} = $self->x_resource ("remote-selection.fetch") + $self->{fetch_cmd} = $self->x_resource ("%.fetch") || "rsh ruth 'cat /tmp/distributed-selection'"; push @{ $self->{term}{selection_popup_hook} }, sub { @@ -100,13 +129,4 @@ () } -sub on_user_command { - my ($self, $cmd) = @_; - - if ($cmd eq "selection-pastebin:remote-pastebin") { - $self->upload_paste; - } - - () -}