device activity checking for powersaver on a linux laptop

jerf at compy.attbi.com jerf at compy.attbi.com
Sat Feb 1 19:22:54 EST 2003


On Sat, 01 Feb 2003 23:22:13 +0100, Fabian Lienert wrote:

> Dear pythonists,
> 
> I am new to python and want to write a program, that saves battery power on
> a linux laptop. For example it should power off the display, when there is no
> keyboard or mouse activity for a minute.

Commands exist for these things already, and as a result of the commands
existing, nobody has bothered to interface the system calls that are
necessary to do that work to Python. Trying to do this with stock Python
is hopeless. If you *absolutely insist* on doing this, you *must* write C
extensions.

If you want to fiddle with some of the settings, look at 

man xset

to set some of the display parameters.

man hdparm 

will let you set the disk spin timeouts. Other then the disk and screen, I
am not aware of any other major power draws on a correctly-configured
laptop. (Some early ACPI implementations would jam the cooling fan on its
highest settings, from what I gather, but you should be able to update the
kernel in that case.)

Note that it may be flatly impossible to truly *power off* the display, as
opposed to just blanking it. AFAIK, for instance, it is not possible to
shut my display off without closing the lid. YMMV, but I wouldn't spend
too much time worrying about it; if "xset dpms force off" doesn't
completely shut power off to the screen, probably nothing will. (On my
system, the screen goes black when I type that, but the power is still
on.) And if it DOES power off the screen, then xset can set the timeout.

Now, you can write a Python program that wraps around system calls and
uses os.system or equivalent calls to pass commands through to the system,
but since the desired functionality already exists in these programs I
doubt you'll find that terribly interesting.




More information about the Python-list mailing list