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.

-animation

A string indicating what screensaver plugin to use, or 'none' to disable the screensaver. Supplied plugins are 'lines' (default) and 'counter', which reside in the directory .../Tk/LockDisplay. You can drop a plugin of your own in that directory - see the section Plugin Format below for details. You can also supply your own animation 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.

-animationinterval

The number of milliseconds between calls to the screen saver animation code. Default is 10 milliseconds.

-hide

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

-text

Title text centered in canvas.

-foreground

Title text color.

-background

Canvas color.

-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 " . quotemeta($pw) . " 2> /dev/null";
    if ($? == 0) {
        exit;         # success
    } else {
        return 0;     # failure
    }

} # end check_pw

PLUGIN FORMAT

Refer to the "counter" plugin file .../Tk/LockDisplay/counter.pm for details on the structure of a LockDisplay animation plugin.

HISTORY

Version 1.0
    Beta Release.
Version 1.1
    . Implement plugins and other fixes suggested by Achim Bohnet.  Thanks!
    . Allow plugin name 'none' to disable screensaver.  Thanks Roderick Anderson!

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