sugar3.power module

The power module provides an interface to powerd, a daemon that manages the aggressive suspend and wakeup policies for early OLPC laptops.

The module does nothing if powerd is not present. powerd is not required on laptops other than OLPC XO-1, XO-1.5, XO-1.75 and XO-4. Distributions of Sugar on other hardware need not include the powerd package.

class sugar3.power.PowerManager

Bases: object

Control of automatic idle suspend, with reference counting.

sugar3.activity.activity.Activity calls inhibit_suspend() before speaking text, or when an activity collaboration begins.

Activities may call inhibit_suspend() before playing music, video, speaking large amounts of text, collaborating, or waiting for response to network operations.

As an example, the Clock activity inhibits automatic idle suspend while it is active, so that the displayed clock-face continues to change. Otherwise it would freeze.

sugar3.activity.activity.Activity calls shutdown() as an activity terminates, in case the activity has failed to call restore_suspend().

While automatic idle suspend is inhibited, powerd will continue to dim and blank the display.

Both the inhibit_suspend() and restore_suspend() methods are reference counted; automatic idle suspend is not restored until the same number of calls to restore are made.

powerd is resilient against failure to restore automatic idle suspend; it verifies an inhibit request and deletes it if the requesting process has terminated.

inhibit_suspend()

Inhibit automatic idle suspend until restored.

is_suspend_inhibited()

Check if automatic idle suspend is inhibited.

Returns

whether automatic idle suspend is inhibited.

Return type

inhibited (bool)

restore_suspend()

Possibly restore automatic idle suspend.

shutdown()

Shutdown the power manager.

Restores automatic idle suspend regardless of reference counting.

suspend_breaks_collaboration()

Does automatic idle suspend break collaboration with this toolkit? Yes. For future use by a toolkit with more resilient collaboration.

Returns

True

sugar3.power.get_power_manager()

Get the power manager instance. Only one instance exists, and will always be returned.

Returns

an instance of sugar3.power.PowerManager.