Here's a perl script I wrote to autologout users. The script gets
started automatically from $HOME/.gnome2/session-manual when the user
logs in, and watches for changes to the state of xscreensaver. You will
want to make sure that xscreensaver gets started when the user logs in
and the timeout value in .xscreensaver is what you want. I set this up
when I create user accounts.
Works about 95% of the time. I think I may have a race condition between
when xscreensaver starts and the script tries to attach to the
screensaver. If the script starts up before xscreensaver it will not be
able to attach and it will terminate.
#!/usr/bin/perl
#
# This script will perform an autologout of a user from a gnome-session
# when the screensaver blanks the screen.
#
# The 'xscreensaver-command -watch' command will watch for changes in the
# xscreensaver state. It automatically attaches to the screensaver that
# is running on the display it is started from. If no screensaver is
running, it
# will terminate.
#
# When a BLANK or LOCK event is seen, the 'gnome-session' is killed,
# effectively logging the user out.
# This works, although it is a bit of a brute force method. Brute force
# is required in order to make sure all processes get killed. For example,
# we would not want the session to stay up if the user did not save a
# doc and a dialogue box appeared. Some negative side effects are that
# work will be lost and Staroffice tends to core dump.
#
$proc = "gnome-session";
$user = (getpwuid($<))[0];
# Get the process id of the users 'gnome-session'
$pid_line = `ps -u $user -f -o pid,comm | grep $proc`;
$pid_line=~ /(\d+)/;
$pid = $1;
# Start watching xscreensaver for events.
open (IN, "xscreensaver-command -watch |");
while (<IN>)
{
if (m/^(BLANK|LOCK)/)
{
`kill $pid`;
exit 0;
}
}
_______________________________________________
SunRay-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/sunray-users