Hi, the patch below will expose two more properties through upower. The porperties are "EnergyFullDesign" and "Capacity"
>From Upower Documentation: 'EnergyFullDesign' read 'd' Amount of energy (measured in Wh) the power source is designed to hold when it's considered full. This property is only valid if the property type has the value "battery". 'Capacity' read 'd' The capacity of the power source expressed as a percentage between 0 and 100. The capacity of the battery will reduce with age. A capacity value less than 75% is usually a sign that you should renew your battery. Typically this value is the same as (full-design / full) * 100. However, some primitive power sources are not capable reporting capacity and in this case the capacity property will be unset. This property is only valid if the property type has the value "battery". With capacity exposed through upower, it will silence a wrong notification about a broken battery KDE4. KDE4 sees a capacity of 0 which is probably a bug in KDE4 but i would prefer enhancing our UPower Backend instead of patching KDE4. Vadim added a note in this commit about the problem. http://marc.info/?l=openbsd-ports-cvs&m=139885033417756&w=2 Note: You must apply the acpibat patch from here before this one. http://marc.info/?l=openbsd-tech&m=140034438528555&w=2 Regards, Fabian $ upower -d Device: /org/freedesktop/UPower/devices/line_power_ac native-path: /ac power supply: yes updated: Sun May 18 12:41:38 2014 (1199 seconds ago) has history: no has statistics: no line-power warning-level: unknown online: yes icon-name: 'ac-adapter-symbolic' Device: /org/freedesktop/UPower/devices/battery_batt native-path: /batt power supply: yes updated: Sun May 18 12:41:38 2014 (1199 seconds ago) has history: yes has statistics: no battery present: yes rechargeable: yes state: fully-charged warning-level: none energy: 47.36 Wh energy-empty: 1.669 Wh energy-full: 47.78 Wh energy-full-design: 62.16 Wh <-- NEW energy-rate: 0 W voltage: 12.75 V percentage: 99% capacity: 76.8662% <-- NEW icon-name: 'battery-full-charged-symbolic' Device: /org/freedesktop/UPower/devices/DisplayDevice power supply: yes updated: Thu Jan 1 01:00:00 1970 (1400410897 seconds ago) has history: no has statistics: no battery present: yes state: fully-charged warning-level: none energy: 47.36 Wh energy-full: 47.78 Wh energy-rate: 0 W percentage: 99% icon-name: 'battery-full-charged-symbolic' Daemon: daemon-version: 0.99.0 on-battery: no lid-is-closed: no lid-is-present: yes is-docked: no critical-action: PowerOff Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/upower/Makefile,v retrieving revision 1.36 diff -u -p -r1.36 Makefile --- Makefile 20 Apr 2014 18:03:23 -0000 1.36 +++ Makefile 17 May 2014 16:00:12 -0000 @@ -5,7 +5,7 @@ ONLY_FOR_ARCHS =${APM_ARCHS} COMMENT = userland power management interface DISTNAME = upower-0.99.0 -REVISION = 0 +REVISION = 1 EXTRACT_SUFX = .tar.xz CATEGORIES = sysutils SHARED_LIBS += upower-glib 1.0 # 2.0 Index: patches/patch-src_openbsd_up-backend_c =================================================================== RCS file: /cvs/ports/sysutils/upower/patches/patch-src_openbsd_up-backend_c,v retrieving revision 1.16 diff -u -p -r1.16 patch-src_openbsd_up-backend_c --- patches/patch-src_openbsd_up-backend_c 23 Apr 2014 09:55:18 -0000 1.16 +++ patches/patch-src_openbsd_up-backend_c 17 May 2014 16:00:12 -0000 @@ -7,7 +7,7 @@ Subject: Update lid status when updating https://bugs.freedesktop.org/show_bug.cgi?id=77692 --- src/openbsd/up-backend.c.orig Tue Oct 29 11:37:08 2013 -+++ src/openbsd/up-backend.c Sun Apr 20 18:54:05 2014 ++++ src/openbsd/up-backend.c Sat May 17 17:55:23 2014 @@ -34,6 +34,7 @@ static void up_backend_finalize (GObject *object); static gboolean up_backend_apm_get_power_info(struct apm_power_info*); UpDeviceState up_backend_apm_get_battery_state_value(u_char battery_state); @@ -37,7 +37,60 @@ Subject: Update lid status when updating ret = up_backend_apm_get_power_info(&a); if (!ret) return ret; -@@ -405,6 +407,70 @@ up_apm_device_refresh(UpDevice* device) +@@ -319,8 +321,8 @@ up_backend_update_acpibat_state(UpDevice* device, stru + { + enum sensor_type type; + int numt; +- gdouble bst_volt, bst_rate, bif_lastfullcap, bst_cap, bif_lowcap; +- /* gdouble bif_dvolt, bif_dcap, capacity; */ ++ gdouble bst_volt, bst_rate, bif_cap, bif_lastfullcap, bst_cap, bif_lowcap, capacity; ++ /* gdouble bif_dvolt; */ + struct sensor sens; + size_t slen = sizeof(sens); + int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0}; +@@ -335,6 +337,9 @@ up_backend_update_acpibat_state(UpDevice* device, stru + else if (slen > 0 && (sens.flags & SENSOR_FINVALID) == 0) { + if (sens.type == SENSOR_VOLTS_DC && !strcmp(sens.desc, "current voltage")) + bst_volt = sens.value / 1000000.0f; ++ if ((sens.type == SENSOR_AMPHOUR || sens.type == SENSOR_WATTHOUR) && !strcmp(sens.desc, "capacity")) { ++ bif_cap = (sens.type == SENSOR_AMPHOUR ? bst_volt : 1) * sens.value / 1000000.0f; ++ } + if ((sens.type == SENSOR_AMPHOUR || sens.type == SENSOR_WATTHOUR) && !strcmp(sens.desc, "last full capacity")) { + bif_lastfullcap = (sens.type == SENSOR_AMPHOUR ? bst_volt : 1) * sens.value / 1000000.0f; + } +@@ -349,19 +354,30 @@ up_backend_update_acpibat_state(UpDevice* device, stru + } + /* + bif_dvolt = "voltage" = unused ? +- capacity = lastfull/dcap * 100 ? + amphour1 = warning capacity ? + raw0 = battery state + */ + } + } + } ++ ++ capacity = 0.0f; ++ if(bif_lastfullcap > 0 && bif_cap > 0) { ++ capacity = (bif_lastfullcap / bif_cap) * 100.0f; ++ if (capacity < 0) ++ capacity = 0.0f; ++ if (capacity > 100.0) ++ capacity = 100.0f; ++ } ++ + g_object_set (device, + "energy", bst_cap, + "energy-full", bif_lastfullcap, ++ "energy-full-design", bif_cap, + "energy-rate", bst_rate, + "energy-empty", bif_lowcap, + "voltage", bst_volt, ++ "capacity", capacity, + (void*) NULL); + } + +@@ -405,6 +421,70 @@ up_apm_device_refresh(UpDevice* device) } return ret;