summaryrefslogtreecommitdiff
path: root/lib/App/Raps2
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-10 10:57:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-10 10:57:32 +0200
commita22ee15c603e3fb7066fdd2eca8adf192719ca97 (patch)
treecc50546af47cbb156309c9c0caca831e702bf493 /lib/App/Raps2
parent622a4ad3f3e7da1837f253f816788069631891ad (diff)
Raps2/UI.pm: to_clipboard: Return undef if xclip fails
Diffstat (limited to 'lib/App/Raps2')
-rw-r--r--lib/App/Raps2/UI.pm17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/App/Raps2/UI.pm b/lib/App/Raps2/UI.pm
index d993316..2392ec6 100644
--- a/lib/App/Raps2/UI.pm
+++ b/lib/App/Raps2/UI.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use 5.010;
-use Carp qw(confess);
+use Carp qw(cluck confess);
use POSIX;
use Term::ReadLine;
@@ -31,7 +31,7 @@ sub list {
}
printf( $format, map { $_->[1] // q{} } @list );
- return;
+ return 1;
}
sub read_line {
@@ -92,14 +92,14 @@ sub to_clipboard {
my ( $self, $str ) = @_;
open( my $clipboard, q{|-}, 'xclip -l 1' )
- or confess("Failed to execute xclip -l 1: $!");
+ or return;
print $clipboard $str;
close($clipboard)
- or confess("Failed to close pipe to xclip: $!");
+ or cluck("Failed to close pipe to xclip: $!");
- return;
+ return 1;
}
sub output {
@@ -109,7 +109,7 @@ sub output {
printf( "%-8s : %s\n", $pair->[0], $pair->[1] // q{}, );
}
- return;
+ return 1;
}
1;
@@ -174,7 +174,10 @@ otherwise B<read_pw> dies. Returns the input.
=item $ui->to_clipboard(I<$string>)
-Place I<string> in the primary X Clipboard.
+Place I<string> in the primary X Clipboard (by calling the B<xclip> program)
+
+Returns true upon success, undef if the operation failed. Use $! to get the
+error message.
=item $ui->output(I<\@pair>, I<...>)