Commit graph

1849 commits

Author SHA1 Message Date
Kate Hsuan
c5df437cc1 linux: up-device-supply: fix the resource leak
1. free the udev parent node automatically.
2. free new_model_name variable in the same scope.
2025-11-28 15:00:22 +08:00
Kate Hsuan
d79841fe40 meson: Release 1.91.0
The major change includes:
1. Support multiple keyboard backlight LED control.
2025-11-25 16:39:56 +08:00
Kate Hsuan
a4d0d469f3 meson: so relase bump up due to recent property changes 2025-11-25 15:25:06 +08:00
Kate Hsuan
09ada726f7 dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property
This property is duplicated from BatteryLevel and confuses the user.
2025-11-25 14:33:55 +08:00
Kate Hsuan
391e3323f0 etc: UPower.conf.d: add UPower.conf.d
The configuration files in the UPower.conf.d will override the primary
configuration.
2025-11-12 15:46:00 +08:00
Manuel A. Fernandez Montecelo
46bbc8a602 Add support for conf.d style dirs (UPower.conf.d)
This change adds the feature to read config from conf.d style
directories (UPower.conf.d), commonly supported by other tools, as an
extension of the main config file.

This is useful and convenient in several situations, for example:

- distributions can set different values from the defaults shipped
  upstream without having to modify the main UPower.conf

- different packages or config-management tools can change config just
  by adding, removing or modifying files in that directory

The main config file, e.g. '/etc/UPower/UPower.conf', will be
processed first, and then files in the UPower.conf.d dir, if existing.

The directory to use is derived automatically, e.g.
'/etc/UPower/UPower.conf.d/' if the main config file is
'/etc/UPower/UPower.conf'.  Only files within that directory are
considered, and only those with valid config-group 'UPower' and with
the filename format: starting with '00-' to '99-', ending in '.conf'
and with alphanumeric characters, dash or underscore in between.

The candidate files within the given directory are sorted (with
g_strcmp0(), so the ordering will be as with strcmp()).  The
configuration in the files being processed later will override
previous config, in particular the main config, but also the one from
previous files processed, if the Group and Key coincide.

Add also relevant integration test: 'test_conf_d_support'
2025-11-12 15:45:56 +08:00
Luca Boccassi
5f572ffd9a polkit: fix config syntax
These fields do not start with an underscore. polkitd complains
about them:

 polkitd[2017783]: skipping unknown tag <_description> at line 18
 polkitd[2017783]: skipping unknown tag <_message> at line 19
2025-10-21 16:59:38 +08:00
Kate Hsuan
9c8769d7df ci: fix pre-commit test
Resolve the libatomic dependency issue.
2025-10-21 16:51:40 +08:00
Kate Hsuan
8ce78b7f9e meson_options: replace deprecated boolean variable 2025-09-17 12:27:42 +08:00
Kate Hsuan
f26409e925 rules: 95-upower-hid: update hwdb from upstream NUT
Update to the latest hwdb from NUT.

Link: https://networkupstools.org
Link: https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb
2025-09-16 15:51:36 +08:00
Luciano Santos
5bf9cac60d build: Make installation of tests optional
Default to installing them, while letting people/distributors decide
what they want.
2025-09-16 15:25:49 +08:00
Sicelo A. Mhlongo
84aab7aefa linux: up-enumerator-udev: also permit lp5523:kb name
While common keyboard backlight devices use 'kbd_backlight' in the name, per
linux kernel include/dt-bindings/leds/common.h, there are a few legacy names,
including 'lp5523:kbN'. They cannot be easily changed now because it would
break userspace, hence the names are still provided in the kernel.  Support
them in upower as well. The lp5523 as used on the Nokia N900 exposes six
independent keyboard backlight LEDs, and UPower is able to manage them with
this patch in place.
2025-09-05 17:22:08 +08:00
Kate Hsuan
afb346cf77 linux: integration-test: Multiple keyboard backlight LED support
The integration test for multiple keyboard backlight support.
2025-09-05 17:22:08 +08:00
Kate Hsuan
e0baa3fdcb up-daemon: The implementation of EnumerateKbdBacklight
The implementation for enumerating all keyboard backlight LED objects
on the system.
2025-09-05 17:22:08 +08:00
Kate Hsuan
d316a111f7 dbus: org.freedesktop.UPower: Enumerate kbd backlight LEDs
Enumerate all keyboard backlight LED objects on the system.
2025-09-05 17:22:08 +08:00
Kate Hsuan
4ba78c54a9 linux: up-enumerator-udev: enumerate the LED subsystem
The LED udev subsystem was added to the list to watch the
keyboard backlight LED device events.
2025-09-05 17:22:08 +08:00
Kate Hsuan
6bfc3d6100 up-daemon: device-added and device-removed keyboard backlight device
The keyboard backlight device will be added to or removed from DeviceList
when receiving the "device-added" and "device-removed" signal.
2025-09-05 17:22:08 +08:00
Kate Hsuan
796ce9e579 up-daemon: DeviceList for keyboard backlight LED devices
The DeviceList was created to store the keyboard backlight LED devices.
2025-09-05 17:22:08 +08:00
Kate Hsuan
fd6eebb397 linux: up-enumerator-udev: Process add, change, and remove udev events for keyboard backlight device
Add, update, and remove the keyboard backlight LED device when receiving
add, change, and remove udev events.
2025-09-05 17:18:17 +08:00
Kate Hsuan
e01aa7c903 linux: up-kbd-backlight-led: the keyboard backlight control implementation for Linux
The implementation for Linux included:
1. Set and get brightness.
2. Get max brightness.
3. Signal if the brightness was changed by the device.
2025-09-05 16:47:11 +08:00
Kate Hsuan
1d40bc2027 linux: up-backend: Add and remove keyboard backlight LED device
These are the callback functions for the signals "device-added" and
"device-removed" to add and remove keyboard backlight devices.
2025-09-05 11:49:38 +08:00
Kate Hsuan
9f9b8478bd up-device-list: Introduce the UpDeviceKbdBacklight object
This commit makes UpDeviceList store the UpDeviceKbdBacklight objects and
sets the udev native path property of UpDevice and UpDeviceKbdBacklight.
2025-09-05 11:49:38 +08:00
Kate Hsuan
aaf52de8dc up-device-kbd-backlight: The parent class for keyboard backlight control
This parent class can be used for multiple implementations, such as freebsd
and Linux. The child class inherits it to register the device to upower
and access the dbus services.
2025-09-05 11:49:38 +08:00
Kate Hsuan
0dcb46475f dbus: org.freedesktop.UPower.KbdBacklight: Description for deprecating the KbdBacklight object path
The object path /org/freedesktop/UPower/KbdBacklight is going to be deprecated in the future.
The upper-layer app should migrate to the new API instead.
2025-09-05 11:49:38 +08:00
Kate Hsuan
40a4498454 dbus: KbdBacklight: Add a native path attribute
The DBus property shows the udev native path.
2025-09-05 11:49:38 +08:00
Kate Hsuan
c56ff5f207 Release 1.90.10
- Fix wrong model name of the devices (!267, #309)
- Switch charge_types to "Custom" when charging threshold is enabled (!268, #275)
- Fix invalid command line arguments (!269)
- Fix leak when reporting daemon usage error (!270)
- OpenBSD: support battery status from qcpas (!272)
- Fix history progression (!274, #316)
- Add a battery filter to the upower command line (!275)
- Change the charging behaviors using charge_types (!276, !46, #275)
- Fix integration tests issues, including floating point value and race between umockdev and upower (!277, !278)
- Rework upower command (!280)
- Propagate charge-threshold-enabled to display device (!281)
2025-08-26 16:04:24 +08:00
Josh Triplett
3369d31472 upower: Add a -b/--battery option to dump only battery information
This is useful when asking people to give information about battery
health. It avoids having to give two-step instructions of first
enumerating devices with `upower -e`, then looking for a device whose
name starts with `/org/freedesktop/UPower/devices/battery_`, then
running `upower -i` on that device.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
2025-08-26 13:29:52 +08:00
Florian Müllner
ff605e51c1
up-daemon: Propagate charge-threshold-enabled to display device
The property indicates that a device is plugged-in but not charging
because of the charging threshold. Desktops may want to indicate
that state, but the property is currently only exposed on actual
devices, not the virtual display device that is usually exposed
in the interface.

To address this, propagate the property to the display device
if at least one device has charge thresholds enabled.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5228
2025-08-21 14:30:45 +02:00
Kate Hsuan
4d6da1bb0f tools: up-tool: rework upower dump and enumerate
1. Move dump and enumerate to the separated functions.
2. Introduce an output filter.

Co-work-with: Cursor
Reviewed-by: Kate Hsuan <hpa@redhat.com>
2025-08-20 14:25:37 +08:00
Kate Hsuan
e1d25fa549 linux: integration-test: The type of percentage property is double
The data type of the "Percentage" property is double, so the value is a
floating point number, ex, 100.0
2025-08-12 16:10:52 +08:00
Michael Biebl
12a165e153 linux: integration-test: fix comparison of floating point values
Use assertAlmostEqual for all values that are floating point numbers:

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual

This avoids issues with excessive precision on i386.
More information https://wiki.debian.org/ArchitectureSpecificsMemo#i386

See also the corresponding downstream bug report
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050436

The patch was generated using:

for i in Capacity Energy EnergyEmpty EnergyFull EnergyFullDesign EnergyRate Luminosity Percentage Temperature Voltage ; do
    sed -i -r "s/(assertEqual)(.*$i)/assertAlmostEqual\2/g" src/linux/integration-test.py
done

Fixes: #251
2025-08-12 15:46:23 +08:00
Kate Hsuan
903a8278f8 linux: integration-test: the settings discovery for charge threshold
The test case for settings discovery for charge threshold.
The test cases include:
1. only charge_types (4)
2. charge_control_start_threshold + charge_control_end_threshold +
   charge_types (7)
3. charge_control_end_threshold + charge_types (6)
2025-08-11 15:05:10 +08:00
Kate Hsuan
3a2fe524d0 linux: up-device-supply-battery: Discover the settings of charge threshold
This commit discovers the settings, including charge_control_start_threshold,
charge_control_end_threshold, and charge_types and update the results to
the battery information.
2025-08-11 15:05:10 +08:00
Kate Hsuan
1bf86b5483 up-device-battery: set up charge-threshold-settings-supported property
Setup and update the charge-threshold-settings-supported property.
2025-08-11 15:05:10 +08:00
Kate Hsuan
1c7b9d8bae dbus: org.freedesktop.UPower.Device: the ChargeThresholdSettingsSupported property
The types of settings for charge thresholds that are supported. The value
is a bitmask value and it is the sum of the supported types.

1: The system supports charge start threshold. The battery discharges to a
   percentage, then starts charging.
2: The system supports charge end threshold. The battery charges to a
   percentage, then stops charging.
4: The system supports optimized charging behaviors controlled by the
   system firmware.

Examples:

If the system supports charge start threshold and charge end threshold,
the value is 3.

If the system supports charge end threshold and the battery charging
behavior is controlled by the system firmware, the value is 6.
2025-08-11 15:05:10 +08:00
Kate Hsuan
2afc3c62ca linux: integration-test: Switch between Long_Life, Fast, Standard, and Adaptive
Charge_types has to be "Long_Life" if charging threshold is enabled.
Charge_types has to be "Fast", "Standard", or "Adaptive" if charging
threshold is disabled.
2025-08-11 15:05:04 +08:00
Kate Hsuan
33efe441f6 linux: up-device-supply-battery: Set charge_types to enable/disable the charge threshold
If the charge threshold is enabled, the charge_types set "Long_Life". If
the charge threshold is disabled, the charge_types set to any of
charge_types for charging, such as "Fast", "Standard", and "Adaptive".
This commit is only for the system that only has the charge_types attribute
to control the battery behaviour.
2025-08-07 14:06:06 +08:00
Kate Hsuan
a97c3ceaf5 linux: up-device-supply-battery: Using charge_types Long_Life and Standard to manage charging threshold
We found some systems, such as Lenovo ideapad that don't support
charge_control_start_threshold  and charge_control_end_threshold but it
provide the charge_types Long_Life and Standard. The chatre_types
Long_Life operate the battery in the conservation mode. That means
if Long_Life and Standard are found, the system supports the
charge threshold feature.

Co-work-with: Cursor
Reviewed-by: Kate Hsuan <hpa@redhat.com>
2025-08-07 14:06:06 +08:00
Kate Hsuan
0e6493ce22 linux: up-device-supply-battery: Set charge_types through an enum
The charge enum is used to set the charge_types and namespacing the
emum to prevent varaible name conflicts.
2025-08-07 14:06:06 +08:00
Kate Hsuan
e8fa017be4 linux: integration-test: reduce the test failure for the slow system
On a slow system like riscv64, the test_daemon_version and
test_daemon_restart tests sometimes failed. A delay was added after the
daemon starts to give it enough time to fully initialize, which has
reduced the chance of these tests failing.
2025-08-07 12:38:18 +08:00
Kate Hsuan
fe36d9ee4a linux: integration-test: fix random test failure for test_bluetooth_hidpp_mouse
Sometime we found the errors shows below when pipeline test was running.

379s ERROR: test_bluetooth_hidpp_mouse (__main__.Tests.test_bluetooth_hidpp_mouse)
379s Logitech Bluetooth LE mouse with HID++ kernel support
379s ----------------------------------------------------------------------
379s Traceback (most recent call last):
379s   File "/usr/libexec/upower/integration-test.py", line 4380, in test_bluetooth_hidpp_mouse
379s     self.assertEventually(
379s     ~~~~~~~~~~~~~~~~~~~~~^
379s         lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
379s     )
379s     ^
379s   File "/usr/libexec/upower/integration-test.py", line 399, in assertEventually
379s     if condition() == value:
379s        ~~~~~~~~~^^
379s   File "/usr/libexec/upower/integration-test.py", line 4381, in <lambda>
379s     lambda: self.get_dbus_dev_property(bat0_up, "Model"), value=alias
379s             ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
379s   File "/usr/libexec/upower/integration-test.py", line 316, in get_dbus_dev_property
379s     return self.dbus.call_sync(
379s            ~~~~~~~~~~~~~~~~~~~^
379s         UP,
379s         ^^^
379s     ...<7 lines>...
379s         None,
379s         ^^^^^
379s     ).unpack()[0]
379s     ^
379s gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/UPower/devices/mouse_dev_11_22_33_44_AA_BB” (19)
379s

The upower and bluez daemons were started after the udev was
initialized to avoid the random errors.
2025-08-07 12:34:35 +08:00
Kate Hsuan
bdb05da4a1 linux: integration-test: Switch the charge_types between Custom and Fast with charging threshold status
The charge_types is set to "Custom" when the charging threshold is
enabled. If the charging threshold is disabled, it will be reset
to "Fast".
2025-07-23 11:06:45 +08:00
Kate Hsuan
559b4ac208 linux: up-device-supply-battery: Set charge_types to "Custom" when enabling charging threshold
If the charge_types isn't set to "Custom" on a Dell laptop, the charging
threshold doesn't work. This commit sets the charge_types to "Custom" if
the charging threshold is enabled. Also, the charge_types will be set to
"Fast", "Standard", or "Adaptive" when the charging threshold is disabled.

This commit reads and writes the battery udev attribute "charge_types".
However, this attribute can't be found on some of the systems, so the error
on reading and writing charge_types attribute is ignored.
2025-07-23 11:06:38 +08:00
Fabrice Bellet
e7893f4624 up-history: reverse preset progression 2025-06-25 17:04:48 +08:00
Landry Breuil
fd4aaf3c65 openbsd: add support to fetch battery status from qcpas 2025-06-05 17:03:02 +08:00
Ula Shipman
2724566a2a tools: Reorder upower(1) command-line options to match manual page 2025-06-04 10:45:49 -07:00
Ula Shipman
9efac77ae7 docs: Document all upower(1) command-line options 2025-06-04 10:45:41 -07:00
Ula Shipman
ec6631a11e tools: Handle invalid command-line arguments 2025-05-29 13:53:09 +08:00
Ula Shipman
8f870fc3d2 daemon: Fix memory leak when reporting usage error 2025-05-27 19:20:53 -07:00
Kate Hsuan
a2bf0200f2 linux: integration-test: Two mice were paired with a unifying receiver
The model name of the two mice should be displayed when paired with one
unifying receiver.
2025-05-13 11:08:48 +08:00