Skip to main content

Upower wrapper using dbus-next modern async aio

Project description

upower-pywrapper

A UPower DBus wrapper using Dbus-next inspired by wogscpar's upower-python.

Functions

Core

  • connect(): Connect to the System Bus. This is required before calling other methods.

Manager

  • get_devices(): Enumerate all power devices and fetch their object paths.
  • get_display_device(): Fetch the object path of the composite display device.
  • get_critical_action(): Get the configured critical action for the system.
  • get_manager_status(): Fetch global power manager status, including:
    • on_battery: Boolean indicating if running on battery.
    • lid_closed: Boolean indicating if lid is closed.
    • daemon_ver: The UPower daemon version.
    • lid_present: Boolean indicating if a lid is present.
  • is_lid_present(): Check if the system has a lid.
  • is_lid_closed(): Check if the lid is closed.
  • on_battery(): Check if the device is currently running on battery power.

Wakeups

  • has_wakeup_capabilities(): Check if the system supports wakeup capabilities.
  • get_wakeup_data(): Get data regarding system wakeups.
  • get_wakeup_total(): Get the total number of wakeups.

Device

These methods typically require a device object path (string) as an argument.

  • get_device_percentage(obj): Returns the remaining battery percentage for the specified device.
  • is_charging(obj): Check if the specified device is currently charging.
  • get_full_device_information(obj): Returns a comprehensive dictionary of device information (e.g., Capacity, Energy, Model, Vendor, Voltage, etc.).
  • get_device_state(obj): Returns the readable state string of the device (e.g., "Charging", "Discharging", "Full").

Example

Quick example on how to fetch remaining battery percentage:

import asyncio
from upower_api import UPowerWrapper


async def main():
    mybus = UPowerWrapper()
    await mybus.connect()

    disp_device = await mybus.get_display_device()
    percentage = await mybus.get_device_percentage(disp_device)
    print(percentage)

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upower_python_wrapper-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upower_python_wrapper-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file upower_python_wrapper-0.1.1.tar.gz.

File metadata

  • Download URL: upower_python_wrapper-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for upower_python_wrapper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a7064cb487c75caaac554879effaddf9e39b2f4f29e6b16ee215676909ebfef
MD5 09cbed67299402e3ebfdc90fc5062cc3
BLAKE2b-256 83f42a6fff62c5d20bcd862644440fe6be24287c3d61e54ab3e0ca2871f17fd9

See more details on using hashes here.

File details

Details for the file upower_python_wrapper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for upower_python_wrapper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27e98e719b7a6d198d90a4dda196b2364f7562ab66dac661704d1ed3f5780e56
MD5 74a5fa1aee8e9546f9b2bf2a2eb9a80a
BLAKE2b-256 96fbd1429bbf5444d224a88f920cee8c76442f69aa84a8422c22b5ead7a9a3a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page