capacity is supposed to be the running battery percentage, not a
representation of its current state of the factory capacity (which
isn't something that's ever shown in Linux or macOS).
Use the new "ignore-system-percentage" property to work-around that
problem.
Closes: #141, #103
On some hardware, the "capacity" sysfs contains the capacity of the
battery when full compared to when it was new, instead of the percentage
of battery available.
Make it possible to ignore the "capacity" with this new property.
This adds a variety of missing device kinds specific to the Bluetooth
classes supported in gnome-bluetooth [1].
In up_device_to_text these types have only been added to the
`percentage` class, which is currently the only property exposed by
org.bluez.Battery1, where these devices are coming from.
[1]: cf4a0ba59d/lib/bluetooth-utils.c (L165)
Almost every device kind except line power and invalid (>= last) carry a
valid percentage property. By inverting this conditional not every new
device needs to be added explicitly to this already long and lacking
chain (PDA and MONITOR were already missing).
Those devices date back from the mid-2000s. If they still work, and
somebody is still interested in having them export their battery status,
we would recommend moving this information to the appropriate kernel
drivers.
It's really confusing seeing "not a switch [...]" when we actually
managed to find a switch, so throw 2 errors in the debug when both
checks fail, rather than as things are being tested.
src/up-input.c:294:3: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
294 | close (input->eventfp);
| ^~~~~
| pclose
Despite what the comments say, the device is indeed a valid input
device, it's just not one we want to add to the power devices,
as done in up-daemon.c's up_daemon_device_added_cb().
Rather than using the type of the first sibling device we find, which is
usually the pointing device portion, make sure that keyboard/pointing
device combo devices are identified as keyboards.
If an external keyboard with a backlight gets unplugged then
up_kbd_backlight_event_io would constantly get called, burning 100% CPU.
To make things worse, up_kbd_backlight_event_io would also constantly post
DBUS events, causing gnome-shell to also become very unresponsive.
This commit fixes this by returning FALSE from up_kbd_backlight_event_io
on unplug.
While at it also fix calling up_kbd_backlight_emit_change with a negative
brightness value in other error scenarios. Specifically this fixes
calling up_kbd_backlight_emit_change with -1 on the initial
up_kbd_backlight_event_io call in which case up_kbd_backlight_brightness_read
will typically fail with ENODATA.