Pinebook pro sway battery indicator broken

Hi!

I have a pinebook pro, and I’m running manjaro ARM with sway window manager.

The latest update broke the battery indicator. It now shows 100% all the time, occasionally flipping to 0% now and then.

Downgrading waybar fixed the issue for now, and it looks like someone already opened a bug report in that project:

I have a small kernel patch which should expose the battery information that waybar is expecting. I’ll post it here after compiling and testing it.

2 Likes

@tsys Something that can be upstreamed in the cw2015 driver?

Thanks for posting this. I noticed the same after upgrading in the weekend, but for whatever reason didn’t get around reporting it.

This seems to work, I’ll tidy it up and email the maintainer. I’ve compiled a modified kernel and packaged as arch package (took a while on the pbp) If anyone else wants to test it, I’ll upload it somewhere shortly.

From 7fe0f78aa5b67064e1e0d6da0f5bd87a27630ce9 Mon Sep 17 00:00:00 2001
From: Martin Ashby <martin@ashbysoft.com>
Date: Sun, 24 Jan 2021 20:21:39 +0000
Subject: [PATCH] Add CHARGE_NOW support to cw2015_battery.c. CHARGE_NOW is
 expected by some user software (such as waybar) instead of 'CAPACITY', in
 order to correctly calculate remaining battery life.

---
 drivers/power/supply/cw2015_battery.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 0146f1bfc..d11059774 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -511,6 +511,11 @@ static int cw_battery_get_property(struct power_supply *psy,
 			val->intval = 0;
 		break;
 
+	case POWER_SUPPLY_PROP_CHARGE_NOW:
+		val->intval = cw_bat->battery.charge_full_design_uah;
+		val->intval = val->intval * cw_bat->soc / 100;
+		break;
+
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		if (cw_battery_valid_time_to_empty(cw_bat) &&
 		    cw_bat->battery.charge_full_design_uah > 0) {
@@ -542,6 +547,7 @@ static enum power_supply_property cw_battery_properties[] = {
 	POWER_SUPPLY_PROP_CHARGE_COUNTER,
 	POWER_SUPPLY_PROP_CHARGE_FULL,
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 };
 
-- 
2.30.0
2 Likes

Nice. The maintainer of the cw2015 driver is our @tsys I believe.
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/MAINTAINERS?h=v5.10.10#n4070

1 Like

Kernel build from the manjaro arm base https ://gitlab.manjaro.org/manjaro-arm/packages/core/linux plus this patch in case anyone wants to try it.

https ://drive.google.com/file/d/19lzEcvEJC66SLMJqJkzasvSrGylaIkZi/view?usp=sharing

(it seems I’m not allowed to post links)

Took me longer to figure out how to get git send-email to work (still doesn’t work on the PBP) than to make and test this fix :eyes:

1 Like

Hey there,

Did this make it anywhere official?

I’m using the pinebook pro and still have this problem.

I’m on the manjaro arm testing branch.

It’s in upstream Waybar now:

But it’s not part of a waybar release yet.

Brill.

yay -S waybar-git has me up and running again.

The battery life on the pinebook pro is good enough it didn’t really matter, but it’s nice to have an idea how close to the edge I’m running.

Thank-you.

In newer versions of the sway image we introduced some shell scripts to use as battery indicator for waybar… [sway] improve waybar battery indicator with custom script for Pinebook / Pinebook Pro (2b493254) · Commits · manjaro-arm / applications / arm-profiles · GitLab

How should I best keep up to date? Is pacman -Syuu enough?