Starting from Kernel 3.4 a patch I wrote to probe HID devices that have a capability to report battery status is available, however the powermanagement infrastructure does not take in account the power-supply field exposed by upower that tells that my mouse/keyboard does not power my computer, thus preventing it from hibernation if I remove theirs batteries or if they are at low level. Also when this is the case the the plasmoid should make use the batteries name instead of battery 0, battery 1... Here how upower -d command outputs this info: daniel@Hommer:~/code/hid$ upower -d Device: /org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery native-path: /sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:1/0005:05AC:022C.0007/power_supply/hid-00:22:41:D9:18:E7-battery model: MacAdmins keyboard power supply: no updated: Mon May 28 21:00:24 2012 (1 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: discharging energy: 0 Wh energy-empty: 0 Wh energy-full: 0 Wh energy-full-design: 0 Wh energy-rate: 0 W percentage: 67% capacity: 100% History (charge): 1338249623 67.000 discharging 1338249622 0.000 unknown History (rate): 1338249622 0.000 unknown Device: /org/freedesktop/UPower/devices/battery_hid_70oCDo60oF5oFFo3F_battery native-path: /sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:2/0005:05AC:030E.0008/power_supply/hid-70:CD:60:F5:FF:3F-battery model: nexxs Trackpad power supply: no updated: Mon May 28 21:00:24 2012 (1 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: discharging energy: 0 Wh energy-empty: 0 Wh energy-full: 0 Wh energy-full-design: 0 Wh energy-rate: 0 W percentage: 15% capacity: 100% History (charge): 1338249624 15.000 discharging Daemon: daemon-version: 0.9.16 can-suspend: yes can-hibernate no on-battery: yes on-low-battery: no lid-is-closed: no lid-is-present: no is-docked: no Reproducible: Always
daniel@Hommer:~$ solid-hardware details /org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery udi = '/org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery' parent = '/org/freedesktop/UPower' (string) vendor = '' (string) product = 'MacAdmins keyboard' (string) description = 'Unknown Battery' (string) Battery.plugged = true (bool) Battery.type = 'PrimaryBattery' (0x3) (enum) Battery.chargePercent = 62 (0x3e) (int) Battery.rechargeable = true (bool) Battery.chargeState = 'Discharging' (0x2) (enum)
Git commit d1661d1638851fd950c5926fb2040ea2abe2a8f0 by Lukas Tinkl. Committed on 29/05/2012 at 17:03. Pushed by lukas into branch 'KDE/4.8'. don't consider external batteries (mice, keyboard, BT) as primary dantti will test later today M +5 -2 solid/solid/backends/upower/upowerbattery.cpp http://commits.kde.org/kdelibs/d1661d1638851fd950c5926fb2040ea2abe2a8f0
Git commit 7f8c750541790de5a380409466cf07cfe19c3651 by Lukas Tinkl. Committed on 06/06/2012 at 15:47. Pushed by lukas into branch 'KDE/4.8'. Revert "don't consider external batteries (mice, keyboard, BT) as primary" This reverts commit d1661d1638851fd950c5926fb2040ea2abe2a8f0. This causes more trouble than expected, newer kernels/upower contain a bug that (in my case and many others) marks ALL batteries as non-powersupply. Related: bug 301033 M +2 -5 solid/solid/backends/upower/upowerbattery.cpp http://commits.kde.org/kdelibs/7f8c750541790de5a380409466cf07cfe19c3651
Git commit 240411008dce4557d9dd536cc517471394219a80 by Dirk Mueller, on behalf of Lukas Tinkl. Committed on 06/06/2012 at 15:47. Pushed by mueller into branch 'KDE/4.8.x'. Revert "don't consider external batteries (mice, keyboard, BT) as primary" This reverts commit d1661d1638851fd950c5926fb2040ea2abe2a8f0. This causes more trouble than expected, newer kernels/upower contain a bug that (in my case and many others) marks ALL batteries as non-powersupply. Related: bug 301033 M +2 -5 solid/solid/backends/upower/upowerbattery.cpp http://commits.kde.org/kdelibs/240411008dce4557d9dd536cc517471394219a80
Thinking more about this bug... the patch you added to kernel/upower should never mark auxiliary batteries as Primary (see comment #1). Fixing that should also cure the recent bug with remaining time missing in the battery applet and prevent bugs such as #301033
That is the main problem, the assumption if they are primary or not should be exclusive to "power-supply" field, any other assumption is a hack, if upower reports a keyboard as power-supply it's a bug in upower, which isn't the current case since any /sys...power named hid-{MAC}-battery is marked as not power-supply.
No, the problem is that NO batteries at all are marked as power-supply ;)
Then please paste your's upower -d output, since here it works well, also note that upower can tell if you are on battery, which is buggy on my output but I have just fixed the issue so instead of iterating over all baterries to know if you are on battery power you can just ask upower for that.
We are using the on-battery property, no prob with that... upower --dump: [root@goblin ~]# upower --dump Device: /org/freedesktop/UPower/devices/line_power_AC native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/ACPI0003:00/power_supply/AC power supply: no updated: Mon Jun 18 09:14:34 2012 (0 seconds ago) has history: no has statistics: no line-power online: no Device: /org/freedesktop/UPower/devices/battery_BAT0 native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 vendor: Panasonic model: 42T4620 serial: 509 power supply: no updated: Mon Jun 18 09:14:34 2012 (0 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: discharging energy: 66.48 Wh energy-empty: 0 Wh energy-full: 69.79 Wh energy-full-design: 84.24 Wh energy-rate: 0 W voltage: 12.383 V percentage: 95.2572% capacity: 82.8466% technology: lithium-ion Daemon: daemon-version: 0.9.16 can-suspend: yes can-hibernate yes on-battery: yes on-low-battery: no lid-is-closed: no lid-is-present: yes is-docked: no
Git commit b86adffd69a972f612e0fb00f8c4e8154142c730 by Kai Uwe Broulik. Committed on 13/05/2013 at 17:34. Pushed by broulik into branch 'master'. Add support for the Power Supply property of UPower which indicates if a battery is actually powering the machine (ie. laptop battery) or just reported by one of your peripherals (eg. mouse, keyboard). This will eventually allow other parties such as the battery notifier to disregard them when calculating overall battery percentage or PowerDevil to notify about REVIEW: 110384 M +5 -0 solid/solid/backends/fakehw/fakebattery.cpp M +1 -0 solid/solid/backends/fakehw/fakebattery.h M +14 -1 solid/solid/backends/fakehw/fakecomputer.xml M +11 -0 solid/solid/backends/hal/halbattery.cpp M +2 -0 solid/solid/backends/hal/halbattery.h M +12 -0 solid/solid/backends/upower/upowerbattery.cpp M +3 -0 solid/solid/backends/upower/upowerbattery.h M +1 -1 solid/solid/backends/upower/upowerdevice.cpp M +6 -0 solid/solid/battery.cpp M +8 -0 solid/solid/battery.h M +7 -0 solid/solid/ifaces/battery.h http://commits.kde.org/kdelibs/b86adffd69a972f612e0fb00f8c4e8154142c730