From 1380bad3d264dda7d06881d86f62025c0fecb3b2 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Fri, 13 Jan 2012 02:05:30 +0100 Subject: [PATCH] url-select: selected URLs are automatically copied When an URL is selected, it is copied to the clipboard using the selected tool. --- url-select | 13 +++++++++++++ 1 file changed, 13 insertions(+) mode change 100644 => 100755 url-select diff --git a/url-select b/url-select old mode 100644 new mode 100755 index 7b07b20..120d83d --- a/url-select +++ b/url-select @@ -24,6 +24,11 @@ # URxvt.urlLauncher: Browser/command to open selected URL with # URxvt.underlineURLs: If set to true, all URLs get underlined # URvxt.urlButton: Mouse button to click-open URLs (default: 2) +# URxvt.urlCopier: Command to copy the URL to the clipboard (optional) +# Recommended (and tested) - the following script: +# #!/bin/sh +# echo -n "$*" | xclip -in + use strict; @@ -37,6 +42,12 @@ sub on_start { my ($self) = @_; # read resource settings + if ($self->x_resource('urlCopier')) { + @{$self->{copier}} = split /\s+/, $self->x_resource('urlCopier'); + } else { + @{$self->{copier}} = (); + } + if ($self->x_resource('urlLauncher')) { @{$self->{browser}} = split /\s+/, $self->x_resource('urlLauncher'); } else { @@ -176,6 +187,7 @@ sub select_next { # another url on current line $self->{n} += $dir; hilight($self); + $self->exec_async(@{$self->{copier}}, $self->{found}->[$self->{n}]->[4]) if $self->{copier}; return; } @@ -199,6 +211,7 @@ sub select_next { $self->{row} = $row; $self->{n} = $dir < 0 ? $#{$self->{found}} : 0; hilight($self); + $self->exec_async(@{$self->{copier}}, $self->{found}->[$self->{n}]->[4]) if $self->{copier}; return; } }