Mark Baker on 19 Oct 2006 21:19:49 -0000


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

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


There are some simple utilities that can be called for some of the linux
distros that give kb mouse idle times.   What distro are we working with?

Mark

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

On Thu, Oct 19, 2006 at 10:58:31AM -0700, jadoba@jadoba.net wrote:
> 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.

The "run a cron job once a minute" techniques seem like a huge waste of
resources to me.

You want to be hooking into something that's already polling for human I/O
events (if this were NetBSD, I'd say "wscons") and registering (and then
renewing later) a timer on them which, if expired takes action.

Maybe the Linux distribution involved makes use of something like
SCIM:

  http://www.scim-im.org/

which looks like it probably provides some hooks for monitoring
keydown/keyup mousedown/mouseup.

Another decent place to look is the XScreenSaver source; checking the same
places it does for I/O information should work, and you could run the
process that checks and downs/ups the interface in the same way
(automatically forking and sitting in the background till an exit request is
passed to it later).

--
gabriel rosenkoetter
gr@eclipsed.net

___________________________________________________________________________
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