From 1c7abb93eb39417fcf81c67875bfd804f3458a1a Mon Sep 17 00:00:00 2001 From: Daniel Lublin Date: Mon, 4 Feb 2019 11:09:14 +0100 Subject: Add launchsingle option --- README | 5 +++++ url-picker | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README b/README index 4579604..06cf28a 100644 --- a/README +++ b/README @@ -72,6 +72,10 @@ position is restored to where it was in the terminal window before url-picker was invoked. The url launched is displayed on the bottom row of the terminal window for five seconds. +To avoid surprises, the resource `url-picker.launchsingle` can be set to +`false` to stop url-picker from automatically launching a single (sole) found +URL, until its number has been typed. + RESOURCES The following resources are recognized by url-picker: @@ -82,6 +86,7 @@ URxvt.url-picker.input.foregroundColor Fg color for numbers typed URxvt.url-picker.label.backgroundColor Bg color for numbered labels URxvt.url-picker.label.foregroundColor Fg color for numbered labels URxvt.url-picker.launcher Browser override +URxvt.url-picker.launchsingle "false" to not auto-launch single url URXVT.url-picker.order "descending" numbers in reverse URxvt.url-picker.prompt.backgroundColor Bg color for "Follow:" prompt URxvt.url-picker.prompt.foregroundColor Fg color for "Follow:" prompt diff --git a/url-picker b/url-picker index 0ce4838..fab9359 100644 --- a/url-picker +++ b/url-picker @@ -151,7 +151,9 @@ sub update { $overlay->hide; } } - if (scalar(@matches) == 1) { + # Auto-launch a single url only if the launchsingle resource is true + # (default), or if some digits were input + if (scalar(@matches) == 1 && ($self->{launchsingle} || $len > 0)) { $self->launch(@matches[0]); } else { $self->screen_cur($self->nrow,8+$len); @@ -206,6 +208,7 @@ sub on_start { $self->{launcher} = $self->my_resource("launcher") || $self->x_resource("url-launcher") || "sensible-browser"; + $self->{launchsingle} = ($self->my_resource("launchsingle") ne "false"); $self->{descending} = ($self->my_resource("order") eq "descending"); $self->{url_picker} = (); } -- cgit v1.2.3