summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2017-10-24 03:02:12 -0400
committerJesse Luehrs <doy@tozt.net>2017-10-24 03:31:57 -0400
commitdfae55c4d01f8f1cb0116ed3cb02b2db4995a937 (patch)
treef63c3d19e46a51a8b68855aea4c7986044c683d5
parentf6b458e4d2573fd802ac2acafbe5e13cfbcc5702 (diff)
downloadconf-dfae55c4d01f8f1cb0116ed3cb02b2db4995a937.tar.gz
conf-dfae55c4d01f8f1cb0116ed3cb02b2db4995a937.zip
copy passwords to both primary and selection, and time-limit them
-rwxr-xr-xbin/pass17
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/pass b/bin/pass
index 741b020..fd4a9aa 100755
--- a/bin/pass
+++ b/bin/pass
@@ -72,8 +72,17 @@ else {
sub clip {
my ($text) = @_;
- open my $fh, '|-', 'xclip -loops 1 -quiet 2> /dev/null'
- or die "couldn't run xclip";
- $fh->write("$text\n");
- $fh->close;
+ my @pids;
+ for my $selection (qw(primary clipboard)) {
+ my $pid = fork;
+ if (!$pid) {
+ open my $fh, '|-', "timeout 1m xclip -loops 1 -quiet -selection $selection 2> /dev/null"
+ or die "couldn't run xclip";
+ $fh->write("$text\n");
+ $fh->close;
+ exit;
+ }
+ push @pids, $pid;
+ }
+ waitpid($_, 0) for @pids;
}