The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tk::LockDisplay - Create modal dialog and wait for a password response.

SYNOPSIS

$lock = $parent->LockDisplay(-option => value, ... );

DESCRIPTION

This widget fills the display with a screensaver-like animation, makes a global grab and then waits for the user's authentication string, usually their password. Until the password is entered the display cannot be used: window manager commands are ignored, etcetera. Note, X server requests are not blocked.

Password verification is perforemd via a callback passed during widget creation.

While waiting for the user to respond, LockDisplay sets a global grab. This prevents the user from interacting with any application in any way except to type characters in the LockDisplay entry box. See the Lock() method.

The following option/value pairs are supported:

-authenticate

Password verification subroutine - it's passed two positional parameters, the username and password, and should return 1 if success, else 0.

-velocity

How fast the screensaver subroutine is called - smaller is faster! Default is 10 milliseconds.

-hide

How many seconds of display inactivity before hiding the password entry widget. Default is 10 seconds.

-mesmerize

Tk::LockDisplay has builtin screen displays: lines and annoying_blink. You can supply your own subroutine by passing a CODE reference. The subroutine is passed a single parameter, the canvas widget reference, which you can use to draw upon as you please. The default is lines, and I don't suggest even trying annoying_blink!

-debug

Set to 1 allows a <Double-1> event to unlock the display. Used while debugging your authentication callback.

METHODS

$lock->Lock;

This method locks the display and waits for the user's authentication data.

EXAMPLE

$lock = $mw->LockDisplay(-authenticate => \&check_pw);

sub check_pw {

    # Perform AFS validation.

    my($user, $pw) = @_;

    system "/usr/afsws/bin/klog $user $pw 2> /dev/null";
    return $? ? 0 : 1;          # 1 = success, 0 = failure

} # end check_pw

AUTHOR

Stephen.O.Lidie@Lehigh.EDU

COPYRIGHT

Copyright (C) 1998 - 1998, Stephen O. Lidie.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

KEYWORDS

screeensaver, dialog, modal