url-select: selected URLs are automatically copied
When an URL is selected, it is copied to the clipboard using the selected tool.
This commit is contained in:
parent
d48894fc14
commit
1380bad3d2
13
url-select
Normal file → Executable file
13
url-select
Normal file → Executable file
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user