Michael C. Toren on 20 Oct 2006 17:29:24 -0000


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

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


On Fri, Oct 20, 2006 at 07:20:57AM -0700, jadoba@jadoba.net wrote:
> >What about using screen blanking/saver as a trigger?  Re-activation
> >could be manual.
> 
> This I can imagine is plausible, perhaps using if statements and the
> 'ps' command with grep to trigger the ifconfig command whenever it
> notices xscreensaver has been called. I haven't tested wether or not
> xscreensaver shows up in output of ps after it starts, however. same
> thing with seti, which I don't run, and if I did, it might seem a bit
> like a conflict of interests to run seti and also take down my internet
> connection every time i idle.

xscreensaver is designed such that it runs an external program the user
specifies when it detects inactivity.  If you don't use virtual consoles,
and are willing to accept the limitation that your network will only be up
when your X session is active, perhaps the easiest way to go about this
would be to write a wrapper for xscreensaver to use when executing the
external program.  For example, if xscreensaver is configured to normally
run the command:

	/usr/bin/foo -bar

You would change the configuration to instead run the command:

	/usr/local/bin/xscreensaver-ifupdown-wrapper /usr/bin/foo -bar

The wrapper would need to execute "ifdown eth0" at startup, install an
exit handler which would run "ifup eth0" at shutdown, and then execute the
command specified as command line arguments.  In order for this to work,
you'll need to confirm that xscreensaver terminates it's children in such
a way that it allows their exit handlers to run -- i.e., it doesn't just
send the child a SIGKILL.

Such a wrapper *might* look something like the following, untested code:

	#!/bin/bash

	/sbin/ifdown eth0
	$* &
	trap "/sbin/ifup eth0; kill $!; exit" EXIT HUP TERM INT QUIT
	wait

HTH,
-mct
___________________________________________________________________________
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