Hi, I'm trying to make a simple battery warning program for my laptop, or script would be a better name. I'we done some python before but does not remember that much right now. My script looks like this:
CODE
import os
battery_os = os.popen("acpi -b")
for line in battery_os.readlines():
battery = line
limit = " Battery 0: Discharging, 5%"
print limit
print battery[1-31]
if limit == battery[1-31]:
print 'Hello'
The idéa is simply to compare the output of "acpi -b" with gives something like "Battery 0: Charging, 7%, 02:08:13 until charged" and then compare this first part "Battery 0: Charging, 7%" for a special value before "%" and when those are the same do some kind of sound or why not eject the cd...

Maybe I should add some kind of delay somewhere as well since it does not have to check the battery multiplie times per second.
So back to my question, how do I compare char 1-20 for example in a string with an other string?
CODE
if limit == battery[1-31]
ps. I know there are programs for this but right now I'm using fluxbox (quite simple Linux Window Manager) and I would like to do my own simple battery checker. ds.