Lee Portnoff wrote: > Is there a way to have terminals automatically logoff after a certain > amount of inactivity time? Searching archives, I saw someone suggest > logmon (www.logmon.com) Is there any other way to achieve this? >
Here's a screen saver I wrote in perl to do this. It's probably badly done, but it works. Set the screen saver timeout to whatever you want, then this script will start and show a countdown for 10 seconds ($countdown - 1) before logout. It's written for xfce, so you'd need to modify the "logout_command" for other environments. -Steve -------- #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Font; use POSIX; # globals # will logout those in @affected_groups who are not also in # @immune_groups, everyone else gets a clock my @affected_groups = ( 'students' ); my @immune_groups = ( 'monitors', 'staff' ); my $countdown = 11; my $username = getpwuid( $> ); my @logout_command = ( 'xfce4-session-logout' ); my $affected; my $display_text; my ($x_position, $y_position); my $x_delta = 5; my $y_delta = 5; my $margin = 150; my ($screen_x, $screen_y); my $canvas; sub update { if ($affected) { --$countdown; if ($countdown < 1) { system( @logout_command ); exit; } $display_text = "Logout in\n$countdown\nseconds."; } else { $display_text = strftime( "%A, %B %e, %Y - %l:%M:%S %P", localtime() ); } my ($new_x, $new_y); $new_x = $x_position + $x_delta; if ( ($new_x > $screen_x - $margin) or ($new_x < $margin) ) { $x_delta = - $x_delta; $new_x = $x_position; } $new_y = $y_position + $y_delta; if ( ($new_y > $screen_y - $margin) or ($new_y < $margin) ) { $y_delta = - $y_delta; $new_y = $y_position; } $x_position = $new_x; $y_position = $new_y; $canvas->coords( 'label', $x_position, $y_position ); } sub user_in_group { my $group = shift; my $guid = getgrnam( $group ) or return; my @groups = split( ' ', `id -G` ); if (grep {$_ == $guid} @groups) { return 1; } else { return 0; } } sub user_affected { my $affected = 0; for my $group (@affected_groups) { if (user_in_group( $group )) { $affected = 1; } } for my $group (@immune_groups) { if (user_in_group( $group )) { $affected = 0; } } return $affected; } # ---- Start ---- $affected = user_affected(); # setup window my $main = MainWindow->new( -background => 'black' ); $main->overrideredirect( 1 ); $main->MoveToplevelWindow( 0, 0 ); $screen_x = $main->screenwidth; $screen_y = $main->screenheight; $x_position = $screen_x / 2; $y_position = $screen_y / 2; $main->geometry( $screen_x . 'x' . $screen_y ); $main->fontCreate( 'labelfont', -size => 20, -family => 'Times' ); $canvas = $main->Canvas( -height => $screen_y, -width => $screen_x, -borderwidth => 0 ); $canvas->pack( -expand => 1, -fill => 'both' ); $canvas->create( 'rectangle', 1, 1, $main->screenwidth - 1, $main->screenheight - 1, -fill => 'black', -outline => undef ); my $label = $main->Label( -textvariable => \$display_text, -foreground => 'black', -background => 'white', -font => 'labelfont' ); my $canvas_label = $canvas->create( 'window', $x_position, $y_position, -window => $label, -tags => ['label']); $main->repeat( 1000, \&update ); update(); MainLoop; # ---- End ---- ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _____________________________________________________________________ Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto: https://lists.sourceforge.net/lists/listinfo/ltsp-discuss For additional LTSP help, try #ltsp channel on irc.freenode.net