diff options
author | Jesse Luehrs <doy@tozt.net> | 2017-10-24 03:02:12 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2017-10-24 03:31:57 -0400 |
commit | dfae55c4d01f8f1cb0116ed3cb02b2db4995a937 (patch) | |
tree | f63c3d19e46a51a8b68855aea4c7986044c683d5 | |
parent | f6b458e4d2573fd802ac2acafbe5e13cfbcc5702 (diff) | |
download | conf-dfae55c4d01f8f1cb0116ed3cb02b2db4995a937.tar.gz conf-dfae55c4d01f8f1cb0116ed3cb02b2db4995a937.zip |
copy passwords to both primary and selection, and time-limit them
-rwxr-xr-x | bin/pass | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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; } |