redisplay
changeset 1 0fde44ae8f1d
parent 0 5e0fc4f25c44
child 2 fb6344bb32dc
equal deleted inserted replaced
0:5e0fc4f25c44 1:0fde44ae8f1d
    22       or die "$0: Can't read method (time/hash) from $ARGV.\n";
    22       or die "$0: Can't read method (time/hash) from $ARGV.\n";
    23 
    23 
    24     my $user = $ENV{USER} // $ENV{LOGNAME} // getpwuid $>;
    24     my $user = $ENV{USER} // $ENV{LOGNAME} // getpwuid $>;
    25     my $host = hostname;
    25     my $host = hostname;
    26 
    26 
    27     open my $qr, '|qrencode -t ansi256'
    27     open(my $o, '>&STDOUT');
    28       or die "$0: Can't open qrencode: $!\n";
    28     if (-t STDIN) {
       
    29         open STDOUT, '|qrencode -t ansi256'
       
    30           or die "$0: Can't open qrencode: $!\n";
       
    31     }
    29 
    32 
    30     $qr->printf(
    33     printf "otpauth://%sotp/%s?secret=%s\n", $method,
    31         "otpauth://%sotp/%s?secret=%s\n", $method,
    34       url_encode("$user\@$host"), $secret;
    32         url_encode("$user\@$host"),       $secret
       
    33     );
       
    34 
    35 
    35     close $qr;
    36     close(STDOUT);
       
    37 
    36 }
    38 }
    37 
    39 
    38 exit main unless caller;
    40 exit main unless caller;