Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
5.91k stars 667 forks source link

Wireless mouse battery not detected by the battery module and can't be added manually #972

Closed p4block closed 1 year ago

p4block commented 3 years ago

I got a wireless mouse with a battery and you can manually look the voltage and stuff with cat just fine in its sysfs folder.

hal@arch /sys/class/power_supply % ls -lh
lrwxrwxrwx root root 0 B Mon Jan 11 04:38:38 2021   hidpp_battery_0@ ⇒ ../../devices/pci0000:00/0000:00:07.1/0000:0c:00.3/usb5/5-3/5-3:1.2/0003:046D:C539.000B/0003:046D:407F.0010/power_supply/hidpp_battery_0

However an unconfigured battery module will detect no batteries and any attempt at telling it to use "hidpp_battery_0" will fail.

This can be worked around with scripting, but would be cool if wireless mice and other peripherals worked out of the box.

p4block commented 3 years ago

Note that this mouse only reports battery voltage and not a fixed percentage so it could definitely be crashy if it was detected (or maybe it is getting detected and failing gracefully)

BrknRobot commented 3 years ago

My HID++ 2.0 mouse (Logitech MX Master 2S) has these sysfs interfaces.

status = Charging, Discharging, Unknown capacity_level = Critical, Low, Normal, Full, Unknown

capacity_level is only available when status is Discharging. status and capacity_level are unknown when the device goes into low power mode after a short period of inactivity.

jinnko commented 3 years ago

Similar issue with my Logitech M590 mouse and K780 keyboard connected using the UnifyingReceiver.

Using upower -e | xargs -n1 upower -i I'm able to enumerate existing batteries and see the values reported by the mouse and keyboard, but unable to get them reported by waybar-battery.

p4block commented 2 years ago

On Linux 5.15 rc1 there's support for (at least) my mouse and it now shows proper capacity in sysfs

/sys/class/power_supply/hidpp_battery_0/ cat capacity 
68

The module even shows up in waybar but as 0% image

Something is being weird here

appetrosyan commented 2 years ago

I own a Logitech g903. It should be detected properly, but instead I get a

image

image

p4block commented 2 years ago

Today, waybar showed the correct % of the mouse, but after a while it started going to 0%, 100%, disappear... But it's the first time it has actually shown the percentage.

The kernel sysfs interface is probably weird, some fix got there to 5.16 or waybar 0.9.9 but it's not fixed completely

hajosattila commented 2 years ago

Similar issue with my Keychron K8

5n00p4eg commented 2 years ago

Same on Fedora. I'm using Keychron K6

cat /sys/class/power_supply/hid-dc:2c:26:ef:0f:4a-battery/capacity
91

the module shows 0 or 100, randomly.

p4block commented 1 year ago

Fixed at some point by what I presume is the kernel and/or the fixes in waybar. Working perfectly on my system for a while.