GUdev.Client

g GObject.Object GObject.Object GUdev.Client GUdev.Client GObject.Object->GUdev.Client

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (subsystems)

query_by_device_file (device_file)

query_by_device_number (type, number)

query_by_subsystem (subsystem)

query_by_subsystem_and_name (subsystem, name)

query_by_sysfs_path (sysfs_path)

Virtual Methods

Inherited:

GObject.Object (7)

do_uevent (action, device)

Properties

Name

Type

Flags

Short Description

subsystems

[str]

r/w/co

The subsystems to listen for changes on

Signals

Inherited:

GObject.Object (1)

Name

Short Description

uevent

Emitted when client receives an uevent.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class GUdev.Client(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GUdev.ClientClass

GUdev.Client is used to query information about devices on a Linux system from the Linux kernel and the udev device manager.

Device information is retrieved from the kernel (through the sysfs filesystem) and the udev daemon (through a tmpfs filesystem) and presented through GUdev.Device objects. This means that no blocking IO ever happens (in both cases, we are essentially just reading data from kernel memory) and as such there are no asynchronous versions of the provided methods.

To get GUdev.Device objects, use GUdev.Client.query_by_subsystem(), GUdev.Client.query_by_device_number(), GUdev.Client.query_by_device_file(), GUdev.Client.query_by_sysfs_path(), GUdev.Client.query_by_subsystem_and_name() or the GUdev.Enumerator type.

To listen to uevents, connect to the GUdev.Client ::uevent signal.

classmethod new(subsystems)
Parameters:

subsystems ([str] or None) – A None terminated string array of subsystems to listen for uevents on, None to not listen on uevents at all, or an empty array to listen to uevents on all subsystems. See the documentation for the GUdev.Client :subsystems property for details on this parameter.

Returns:

A new GUdev.Client object. Free with GObject.Object.unref().

Return type:

GUdev.Client

Constructs a GUdev.Client object that can be used to query information about devices. Connect to the GUdev.Client ::uevent signal to listen for uevents. Note that signals are emitted in the

thread-default main loop of the thread that you call this constructor from.

query_by_device_file(device_file)
Parameters:

device_file (str) – A device file.

Returns:

A GUdev.Device object or None if the device was not found. Free with GObject.Object.unref().

Return type:

GUdev.Device or None

Looks up a device for a device file.

query_by_device_number(type, number)
Parameters:
Returns:

A GUdev.Device object or None if the device was not found. Free with GObject.Object.unref().

Return type:

GUdev.Device or None

Looks up a device for a type and device number.

query_by_subsystem(subsystem)
Parameters:

subsystem (str or None) – The subsystem to get devices for or None to get all devices.

Returns:

A list of GUdev.Device objects. The caller should free the result by using GObject.Object.unref() on each element in the list and then g_list_free() on the list.

Return type:

[GUdev.Device] or None

Gets all devices belonging to subsystem.

query_by_subsystem_and_name(subsystem, name)
Parameters:
  • subsystem (str) – A subsystem name.

  • name (str) – The name of the device.

Returns:

A GUdev.Device object or None if the device was not found. Free with GObject.Object.unref().

Return type:

GUdev.Device or None

Looks up a device for a subsystem and name.

query_by_sysfs_path(sysfs_path)
Parameters:

sysfs_path (str) – A sysfs path.

Returns:

A GUdev.Device object or None if the device was not found. Free with GObject.Object.unref().

Return type:

GUdev.Device or None

Looks up a device for a sysfs path.

do_uevent(action, device) virtual
Parameters:

Signal Details

GUdev.Client.signals.uevent(client, action, device)
Signal Name:

uevent

Flags:

RUN_LAST

Parameters:
  • client (GUdev.Client) – The object which received the signal

  • action (str) – The action for the uevent e.g. “add”, “remove”, “change”, “move”, “online” or “offline”

  • device (GUdev.Device) – Details about the GUdev.Device the event is for.

Emitted when client receives an uevent.

Note that while you’ll have access to all the device’s properties and attributes for the majority of actions, only the sysfs path will be available when the device is removed.

Also note that the action is an arbitrary string, controlled by device drivers. Other values than those listed is possible, but unlikely.

This signal is emitted in the

thread-default main loop of the thread that client was created in.

Property Details

GUdev.Client.props.subsystems
Name:

subsystems

Type:

[str]

Default Value:

[]

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The subsystems to listen for uevents on.

To listen for only a specific DEVTYPE for a given SUBSYSTEM, use “subsystem/devtype”. For example, to only listen for uevents where SUBSYSTEM is usb and DEVTYPE is usb_interface, use “usb/usb_interface”.

If this property is None, then no events will be reported. If it’s the empty array, events from all subsystems will be reported.