From c22143897b300085d7c8ef37e8fe4850a0c2aca2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 21 Jul 2011 16:53:18 +0200 Subject: Make xclip command configurable (->chrome support) --- lib/App/Raps2.pm | 3 +++ lib/App/Raps2/UI.pm | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/App') diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index d13aaed..f6a675b 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -134,11 +134,13 @@ sub create_defaults { my $cost = $self->{default}{cost} // 12; my $pwgen_cmd = $self->{default}{pwgen_cmd} // 'pwgen -s 23 1'; + my $xclip_cmd = $self->{default}{xclip_cmd} // 'xclip -l 1'; write_file( $self->{xdg_conf} . '/defaults', "cost = ${cost}\n", "pwgen_cmd = ${pwgen_cmd}\n", + "xclip_cmd = ${xclip_cmd}\n", ); return; @@ -151,6 +153,7 @@ sub load_defaults { $self->{default}{cost} //= $cfg->{_}->{cost}; $self->{default}{pwgen_cmd} //= $cfg->{_}->{pwgen_cmd}; + $self->{default}{xclip_cmd} //= $cfg->{_}->{xclip_cmd}; return; } diff --git a/lib/App/Raps2/UI.pm b/lib/App/Raps2/UI.pm index 4914b71..ca86a59 100644 --- a/lib/App/Raps2/UI.pm +++ b/lib/App/Raps2/UI.pm @@ -89,15 +89,17 @@ sub read_pw { } sub to_clipboard { - my ( $self, $str ) = @_; + my ( $self, $str, $cmd ) = @_; + + $cmd //= 'xclip -l 1'; - open( my $clipboard, q{|-}, 'xclip -l 1' ) + open( my $clipboard, q{|-}, $cmd ) or return; print $clipboard $str; close($clipboard) - or cluck("Failed to close pipe to xclip: $!"); + or cluck("Failed to close pipe to ${cmd}: ${!}"); return 1; } @@ -172,9 +174,10 @@ Prompt the user for a password. I is displayed, the user's input is noch echoed. If I is set, the user has to enter the same input twice, otherwise B dies. Returns the input. -=item $ui->to_clipboard(I<$string>) +=item $ui->to_clipboard(I<$string>, [I]) -Place I in the primary X Clipboard (by calling the B program) +Call I to place I in the primary X Clipboard. I +defaults to C<< xclip -l 1 >>. Returns true upon success, undef if the operation failed. Use $! to get the error message. -- cgit v1.2.3