Mark Baker on 19 Oct 2006 18:19:19 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

RE: [PLUG] 'ifconfig eth0 down' on mouse/kbd being idle


You may want to take a look at some of the group computing scripts such as
SETI that run when your computer is idle or an open source screen saver
script that you could use the code from.  I did a quick search and found a
few such as "idleize" which you may be able to use for your own script.


Mark

-----Original Message-----
From: plug-bounces@lists.phillylinux.org
[mailto:plug-bounces@lists.phillylinux.org] On Behalf Of jadoba@jadoba.net
Sent: Thursday, October 19, 2006 1:59 PM
To: plug@lists.phillylinux.org
Subject: [PLUG] 'ifconfig eth0 down' on mouse/kbd being idle

I'd like to create a shell script that will execute 'ifconfig eth0 down'
when both the mouse and keyboard have been idle (iow, no input) for a set
amount of time. I would also like for the same script to bring eth0 back up
when a key is pressed or the mouse is moved.

I can only guess it can be done by monitoring /dev/input/mouse0 and
/dev/input/event1 (which seems to be my mouse and keyboard device files,
respectively) but don't know whether it is possible in a simple shell
script, or if I'd have to use perl (which I never learned). Aside from cat,
I don't know how to monitor a device file for activity.

My most obvious question is, has anyone done this before, or has anyone
heard of this being done and can they link me to the code? Otherwise, can
anyone give me a quick outline of what commands a script like that should
contain (namely, how to monitor the device files from within a script, how
to set a timer for the activity, how to hav it run ifconfig at the correct
time, and how to trigger ifconfig again when activity is reported back to
the script)

thanks

-jim

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug