Logo Search packages:      
Sourcecode: guidance-power-manager version File versions

def guidance-power-manager::PowerManager::checkBatteryCritical (   self  ) 

Check for warning and critical battery label and notify-warn or
    initiate the configured action. 

Definition at line 945 of file guidance-power-manager.py.

00945                                   :
        """ Check for warning and critical battery label and notify-warn or
            initiate the configured action. """

        if not self.powermanager.hasBattery:
            return

        if self.batt_state == "discharging":
            currentLevel = int(self.batt_remain/60)

            warningLevel = self.criticalLevel + 5 # warn five minutes before critical
            criticalLevel = self.criticalLevel

            debug("CurrentBat: %i, WarningBat: %i, CriticalBat: %i" % (currentLevel, warningLevel, criticalLevel))
            # We only want to suspend if the chargelevel is above a certain threshold,
            # it sometimes takes some time for HAL to report remaining time correctly
            if currentLevel <= criticalLevel and self.batt_level < CHARGE_LEVEL_THRESHOLD:
                if not self.powermanager.criticalBatteryState and self.powermanager.onBattery():
                    self.powermanager.criticalBatteryState = True

                    action = str(self.config.readEntry("batteryCriticalAction"))
                    if not self.act_name.has_key(action):
                        action = self.act_name[self.cb_act_def_critical]

                    if action == "nothing":
                        note = i18n("You are about to run out of battery power, doing nothing now.")
                    elif action == "blank":
                        note = i18n("You are about to run out of battery power, blanking screen now.")
                    elif action == "suspend":
                        note = i18n("You are about to run out of battery power, suspending now.")
                    elif action == "hibernate":
                        note = i18n("You are about to run out of battery power, hibernating now.")
                    elif action == "shutdown":
                        note = i18n("You are about to run out of battery power, shutting down now.")
                    self.notify(note, self.act_icon[action])
                    if self.act_call[action] != None:
                        QTimer.singleShot(2000, self.act_call[action])
            else:
                self.powermanager.criticalBatteryState = False
                if currentLevel <= warningLevel and self.batt_level < CHARGE_LEVEL_THRESHOLD:
                    if not self.powermanager.warningBatteryState:
                        self.powermanager.warningBatteryState = True
                        self.notify(i18n("You are low on battery power."), self.getIcon())
                else:
                    self.powermanager.warningBatteryState = False

    def checkIdletime(self):


Generated by  Doxygen 1.6.0   Back to index