jadoba on 19 Oct 2006 17:59:03 -0000


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

[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