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.
Those devices have been supported in the Linux kernel since at least
3.19, so there's no need to try and support those with our user-space
handling.
Closes: #3
Check that external devices which show up as "battery" types have their
capacity_level correctly read, and that the device's type will be
correctly read after an input node is attached.
This check is supposed to start a poll for 1) batteries embedded in
external devices 2) batteries when battery polling is not disabled.
Make sure to start the poll for all batteries embedded in devices even
the ones that are just detected as "battery".
On some devices the power_supply node will show up before a related node
such as "input", making it impossible to know which type of device we're
attached to without waiting. Try to detect the device type again if the
device type is still "battery".
This fixes some Logitech devices appearing as "Battery" instead of their
respective device type, such as "mouse".
Use the correct refresh function for device batteries which aren't of a
known type. This fixes battery information not getting updated on many
Logitech wireless devices.
Reproducer:
- Unplug Logitech receiver
- Replug Logitech receiver
- Press button on Logitech keyboard
- Move mouse/touchpad
The touchpad battery would be stuck in "unknown" and with a "type" of
battery. This commit forces the correct refresh function to be used, one
that reads the capacity_level on those devices, and will update the
overall battery level.
Closes: #72
This directory may not exist when cleaning out /var (e. g. on stateless
systems). As upowerd cannot mkdir it by itself due to `ProtectSystem`,
let systemd create it via `StateDirectory`.
Keep `ReadWritePaths` and the `mkdir` in the Makefile to continue to
support a non-default `--historydir`.