Module upower_dbus
Get information about your power devices using UPower and DBus.
Requiring this module will return the UPower Manager singleton.
Example:
local upower = require("upower_dbus") upower.Manager:init() -- What version of UPower is in use? upower.Manager.DaemonVersion -- Are we using a battery? upower.Manager.OnBattery -- Print all fields of the first device found for k, v in pairs(upower.Manager.devices[1]) do print(k, v) end -- Enumerate the Device Types known by UPower for _, v in ipairs(upower.enums.DeviceTypes) do print(v) end -- Say that the first device is a battery battery = upower.Manager.devices[1] print(battery.Percentage) -- may print 100.0 -- Update the devices in case something changed upower.Manager:update_devices() -- The battery discharged a bit battery.Percentage -- may print 99.0
Info:
- Copyright: 2016 Stefano Mazzucco
- License: Apache License, version 2.0
- Author: Stefano Mazzucco
Functions
upower.Device:update_mappings () | Update the device mappings. |
upower.Device:update_properties () | Update the Device properties by calling DBus |
upower.Device:refresh () | Refresh the Device status (and update its properties) Interrogate the Device calling the DBus method "Refresh" |
upower.Device:new (path) | Create a new Device |
upower.Manager:update_devices () | Update the UPower Devices
Call the DBus method EnumerateDevices and update
self.devices |
upower.Manager:update_properties () | Update the Manager's properties |
upower.Manager:init () | Initialize the Manager singleton |
Tables
upower.enums.DeviceTypes | |
upower.enums.BatteryStates | |
upower.enums.BatteryTechnologies | |
upower.enums.BatteryWarningLevels |
Functions
- upower.Device:update_mappings ()
-
Update the device mappings.
Unless you are sure that the properties of the Device
have changed, you may want to use update_properties
or refresh instead.
See also:
- upower.Device:update_properties ()
- Update the Device properties by calling DBus
- upower.Device:refresh ()
- Refresh the Device status (and update its properties) Interrogate the Device calling the DBus method "Refresh"
- upower.Device:new (path)
-
Create a new Device
Parameters:
- path
The DBus object path for the device.
If unspecified the string
"/invalid"
will be used.
- path
The DBus object path for the device.
If unspecified the string
- upower.Manager:update_devices ()
-
Update the UPower Devices
Call the DBus method
EnumerateDevices
and updateself.devices
- upower.Manager:update_properties ()
- Update the Manager's properties
- upower.Manager:init ()
- Initialize the Manager singleton
Tables
- upower.enums.DeviceTypes
-
Fields:
- Unknown
- Line Power
- Battery
- Ups
- Monitor
- Mouse
- Keyboard
- Pda
- Phone
- upower.enums.BatteryStates
-
Fields:
- Unknown
- Charging
- Discharging
- Empty
- Fully charged
- Pending charge
- Pending discharge
- upower.enums.BatteryTechnologies
-
Fields:
- Unknown
- Lithium ion
- Lithium polymer
- Lithium iron phosphate
- Lead acid
- Nickel cadmium
- Nickel metal hydride
- upower.enums.BatteryWarningLevels
-
Fields:
- Unknown
- None
- Discharging (only for UPSes)
- Low
- Critical
- Action