#!/usr/bin/perl -w # PIN code requester # Satisfies BlueZ requirements # Written by Fulop Balazs , 2004 use strict; use Tk; my $mainwin = new MainWindow ( -title => "Enter PIN", -borderwidth => 20 ); my $frame = $mainwin -> Frame ( -borderwidth => 5 ); $frame -> Label ( -text => "PIN:" ) -> pack ( -side => "left" ); my $pin = $frame -> Entry ( -justify => "center", -validate => "key", -validatecommand => \&check ) -> pack ( -side => "right" ); $pin -> bind ( "" => \&ok ); $pin -> bind ( "" => \&cancel ); $pin -> focus; $frame -> pack ( -side => "top" ); $mainwin -> Button ( -text => "Ok", -command => \&ok ) -> pack ( -side => "left" ); $mainwin -> Button ( -text => "Cancel", -command => \&cancel ) -> pack ( -side => "right" ); MainLoop; sub check { return 1 if ($_[1] =~ /[0-9]/); return 0; } sub ok { my $code = $pin -> get; cancel () if ("" eq $code); print "PIN:" . $code . "\n"; exit; } sub cancel { print "ERR\n"; exit; }