From e9b88a0942a2ad6787d4bfbf6346fe2691a404ef Mon Sep 17 00:00:00 2001 From: "Denis(Difrex) Zheleztsov" Date: Mon, 15 Sep 2014 16:07:10 +0400 Subject: [PATCH] Show password to terminal if X is not runnig --- pm.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pm.pl b/pm.pl index e02b1a0..de62e33 100755 --- a/pm.pl +++ b/pm.pl @@ -46,11 +46,21 @@ if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) { my $get_h = $pass->show( $opt_n, $opt_u ); my $get_pass = $get_h->{password}; - $copy->copy($get_pass); + if ( defined( $ENV{'DISPLAY'} ) ) { + $copy->copy($get_pass); - print colored("Password copied to xclipboard.", 'green'); - print "\nURI is "; - print colored($get_h->{resource} . "\n", 'bold blue'); + print colored("Password copied to xclipboard.", 'green'); + print "\nURI is "; + print colored($get_h->{resource} . "\n", 'bold blue'); + } + else { + print colored("Warning! Password will show to terminal!", 'red'); + print " Yes/No: "; + my $ans = ; + chomp($ans); + print "$get_pass\n" if $ans eq "Yes"; + print "Cancel\n" if $ans ne "Yes"; + } } elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {