UPowerGlib.Client

g GObject.GInterface GObject.GInterface Gio.AsyncInitable Gio.AsyncInitable GObject.GInterface->Gio.AsyncInitable Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object UPowerGlib.Client UPowerGlib.Client GObject.Object->UPowerGlib.Client Gio.AsyncInitable->UPowerGlib.Client Gio.Initable->UPowerGlib.Client

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.AsyncInitable (4), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_async (cancellable, callback, *user_data)

class

new_finish (res)

class

new_full (cancellable)

get_critical_action ()

get_daemon_version ()

get_devices ()

get_devices2 ()

get_devices_async (cancellable, callback, *user_data)

get_devices_finish (res)

get_display_device ()

get_lid_is_closed ()

get_lid_is_present ()

get_on_battery ()

Virtual Methods

Inherited:

GObject.Object (7), Gio.AsyncInitable (2), Gio.Initable (1)

do_device_added (device)

do_device_removed (object_path)

Properties

Name

Type

Flags

Short Description

daemon-version

str

r

lid-is-closed

bool

d/r

deprecated

lid-is-present

bool

d/r

deprecated

on-battery

bool

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

device-added

The ::device-added signal is emitted when a power device is added.

device-removed

The ::device-removed signal is emitted when a power device is removed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

priv

UPowerGlib.ClientPrivate

r

Class Details

class UPowerGlib.Client(**kwargs)
Bases:

GObject.Object, Gio.AsyncInitable, Gio.Initable

Abstract:

No

Structure:

UPowerGlib.ClientClass

classmethod new()
Returns:

a new UPowerGlib.Client object, or None on failure.

Return type:

UPowerGlib.Client

Creates a new UPowerGlib.Client object. If connecting to upowerd on D-Bus fails, this returns None and prints out a warning with the error message. Consider using UPowerGlib.Client.new_full() instead which allows you to handle errors and cancelling long operations yourself.

New in version 0.9.0.

classmethod new_async(cancellable, callback, *user_data)
Parameters:

Asynchronously creates a new UPowerGlib.Client object.

This is an asynchronous failable function.

New in version 0.99.14.

classmethod new_finish(res)
Parameters:

res (Gio.AsyncResult) – a Gio.AsyncResult obtained from the Gio.AsyncReadyCallback passed to UPowerGlib.Client.new_async()

Raises:

GLib.Error

Returns:

a UPowerGlib.Client or None if error is set. Free with GObject.Object.unref().

Return type:

UPowerGlib.Client

Finishes an operation started with UPowerGlib.Client.new_async().

New in version 0.99.14.

classmethod new_full(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – A Gio.Cancellable or None.

Raises:

GLib.Error

Returns:

a new UPowerGlib.Client object, or None on failure.

Return type:

UPowerGlib.Client

Creates a new UPowerGlib.Client object. If connecting to upowerd on D-Bus fails, this returns None and sets error.

New in version 0.99.5.

get_critical_action()
Returns:

the action name, or None on error.

Return type:

str

Gets a string representing the configured critical action, depending on availability.

New in version 1.0.

get_daemon_version()
Returns:

string containing the daemon version, e.g. 008

Return type:

str

Get UPower daemon version.

New in version 0.9.0.

get_devices()
Returns:

an array of UPowerGlib.Device objects or None on error, free with g_ptr_array_unref()

Return type:

[UPowerGlib.Device]

Get a copy of the device objects. This function does not set the free function for the GLib.PtrArray so you need use GObject.Object.unref on all elements when you are finished with the array.

New in version 0.9.0.

Deprecated since version 0.99.8.

get_devices2()
Returns:

an array of UPowerGlib.Device objects or None on error, free with g_ptr_array_unref()

Return type:

[UPowerGlib.Device]

Get a copy of the device objects.

New in version 0.99.8.

get_devices_async(cancellable, callback, *user_data)
Parameters:

Asynchronously fetches the list of UPowerGlib.Device objects.

New in version 0.99.14.

get_devices_finish(res)
Parameters:

res (Gio.AsyncResult) – a Gio.AsyncResult obtained from the Gio.AsyncReadyCallback passed to UPowerGlib.Client.get_devices_async()

Raises:

GLib.Error

Returns:

an array of UPowerGlib.Device objects or None on error.

Return type:

[UPowerGlib.Device]

Finishes an operation started with UPowerGlib.Client.get_devices_async().

get_display_device()
Returns:

a UPowerGlib.Device object, or None on error.

Return type:

UPowerGlib.Device

Get the composite display device.

New in version 1.0.

get_lid_is_closed()
Returns:

True if lid is closed or False otherwise.

Return type:

bool

Get whether the laptop lid is closed.

New in version 0.9.0.

get_lid_is_present()
Returns:

True if the machine has a laptop lid

Return type:

bool

Get whether a laptop lid is present on this machine.

New in version 0.9.2.

get_on_battery()
Returns:

True if the system is currently running on battery, False otherwise.

Return type:

bool

Get whether the system is running on battery power.

New in version 0.9.0.

do_device_added(device) virtual
Parameters:

device (UPowerGlib.Device) –

do_device_removed(object_path) virtual
Parameters:

object_path (str) –

Signal Details

UPowerGlib.Client.signals.device_added(client, device)
Signal Name:

device-added

Flags:

RUN_LAST

Parameters:

The ::device-added signal is emitted when a power device is added.

New in version 0.9.0.

UPowerGlib.Client.signals.device_removed(client, object_path)
Signal Name:

device-removed

Flags:

RUN_LAST

Parameters:

The ::device-removed signal is emitted when a power device is removed.

New in version 1.0.

Property Details

UPowerGlib.Client.props.daemon_version
Name:

daemon-version

Type:

str

Default Value:

None

Flags:

READABLE

The daemon version.

New in version 0.9.0.

UPowerGlib.Client.props.lid_is_closed
Name:

lid-is-closed

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE

If the laptop lid is closed.

New in version 0.9.0.

Deprecated since version ???.

UPowerGlib.Client.props.lid_is_present
Name:

lid-is-present

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE

If a laptop lid is present.

New in version 0.9.0.

Deprecated since version ???.

UPowerGlib.Client.props.on_battery
Name:

on-battery

Type:

bool

Default Value:

False

Flags:

READABLE

If the computer is on battery power.

New in version 0.9.0.