Setidle Program
James Akiyama
jamesa at dadla.UUCP
Sat Jul 20 04:00:47 AEST 1985
This is a program which allows a user to set and maintain a specified idle
time on his tty. The default (giving no parameters) sets the idle time to
zero every 10 minutes. It is useful for those who need to maintain control
on their idle time without being present at their terminals.
To use the program one types:
setidle [idle time] [update time]
I hope this finds use with some of you out there.
--------CUT HERE-----------------------------------------------------------
#include <stdio.h>
#include <sys/types.h>
main(argc,argv)
int argc;
char **argv;
{
long now;
long idle[2];
long i;
int k;
nice(20);
if (argc == 1) {
i = 0;
k = 600;
} else if (argc == 3) {
sscanf(argv[1],"%d",&i);
sscanf(argv[2],"%d",&k);
} else {
fprintf(stderr,"Useage: setidle [idle time] [update time]\n");
exit(1);
}
while (getppid() != 1) {
time(&now);
idle[0] = now - i;
idle[1] = now - i;
utime(ttyname(1),idle);
sleep(k);
}
exit(0);
}
More information about the Comp.sources.unix
mailing list