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.
  • **is_present(obj): Check if device has batteries

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.2.2.tar.gz (4.6 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.2.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: upower_python_wrapper-0.1.2.2.tar.gz
  • Upload date:
  • Size: 4.6 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.2.2.tar.gz
Algorithm Hash digest
SHA256 704b6f1eee9c7564f69d9f04d8631ce1c3280ff2ee4d1de8c9e8420010578b94
MD5 7ac174e05461b193b66330984841b8e6
BLAKE2b-256 9d041b71aabb1aa7b473cd65b274f61879b9067b571f58997096d12eb5e8fc53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for upower_python_wrapper-0.1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3a8772c2d372d5e06d182c558de77bfef0042034f23b3a2eb3c23033e478f07
MD5 637184d7ceb877e343483d65023729ae
BLAKE2b-256 7e1e520bc4eb6e7e413c2305fe7cfa8d407afb69574cc9c93740c4d38ae24462

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