Functions

device_tree_get_compatibles (sysfs_root)

error_quark ()

init ()

list_devices ()

mcc_to_iso (mcc)

svg_path_get_bounding_box (path, x1, x2, y1, y2)

timeout_add_seconds_once (priority, seconds, function, *data)

wakeup_timeout_add_seconds_once (priority, seconds, function, *data)

Details

Gm.device_tree_get_compatibles(sysfs_root)
Parameters:

sysfs_root (str) – Path where /sys is mounted. Defaults to /sys if None is passed.

Raises:

GLib.Error

Returns:

compatible machine types or None

Return type:

[str]

Read compatible machine types from sysfs_root/firmware/devicetree/base/compatible on Linux. If the path doesn’t exist or host is not Linux return None.

For debugging purposes GMOBILE_DT_COMPATIBLES can be set to a : separated list of compatibles which will be returned instead.

New in version 0.0.1.

Gm.error_quark()
Returns:

a #GQuark.

Return type:

int

Gets the GM Error Quark.

New in version 0.0.1.

Gm.init()

Call this function to initialize the library explicitly. This makes the embedded device information available.

New in version 0.0.1.

Gm.list_devices()
Returns:

The devices

Return type:

[str] or None

List device tree names of known devices.

New in version 0.2.2.

Gm.mcc_to_iso(mcc)
Parameters:

mcc (str) – The mcc

Raises:

GLib.Error

Returns:

The country code or None.

Return type:

str

Get the ISO 3316-1 country code based on a given mobile country code (MCC). It’s sufficient for the given string to have the MCC as prefix. In other words it is o.k. to pass an IMSI.

On error NULL is returned and error is set.

New in version 0.4.0.

Gm.svg_path_get_bounding_box(path, x1, x2, y1, y2)
Parameters:
  • path (str) – An SVG path

  • x1 (int) – The lower x coordinate

  • x2 (int) – The upper x coordinate

  • y1 (int) – The lower y coordinate

  • y2 (int) – The upper y coordinate

Raises:

GLib.Error

Returns:

TRUE when parsing was successful, FALSE otherwise.

See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths for path syntax introduction.

Return type:

bool

Returns the bounding box of an SVG path. As this is meant for display cutouts we operate on integer (whole pixel) values. When parsing fails, FALSE is returned and error contains the error information.

New in version 0.0.1.

Gm.timeout_add_seconds_once(priority, seconds, function, *data)
Parameters:
Returns:

the ID (greater than 0) of the event source or 0 in case of error.

Return type:

int

Sets a function to be called after a timeout with priority priority. Correctly calculates the timeout even when the system is suspended in between.

The timeout given is in terms of CLOCK_BOOTTIME time, it hence is also correct across suspend and resume. If that doesn’t matter use g_timeout_add_seconds_full instead.

Note that glib’s g_timeout_add_seconds() doesn’t take system suspend/resume into account: https://gitlab.gnome.org/GNOME/glib/-/issues/2739

Changed in 0.3.0: Returns 0 when timer setup failed

New in version 0.0.1.

Gm.wakeup_timeout_add_seconds_once(priority, seconds, function, *data)
Parameters:
Raises:

GLib.Error

Returns:

the ID (greater than 0) of the event source or 0 in case of error.

Return type:

int

Sets a function to be called after a timeout with the default priority, GLib.PRIORITY_DEFAULT. Correctly calculates the timeout even when the system is suspended in between. It will wake up the system when needed.

If the process doesn’t have enough permissions to wake the system creating the timer will fail. On Linux at least CAP_WAKE_ALARM capabilities are needed.

The timeout given is in terms of CLOCK_BOOTTIME_ALARM time, it hence is also correct across suspend and resume. If that doesn’t matter use g_timeout_add_seconds instead.

Note that glib’s g_timeout_add_seconds() doesn’t take system suspend/resume into account: https://gitlab.gnome.org/GNOME/glib/-/issues/2739

New in version 0.3.0.