Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i3status doesn't distinguish between Idle and discharging battery. #488

Open
adippl opened this issue May 1, 2022 · 3 comments
Open

i3status doesn't distinguish between Idle and discharging battery. #488

adippl opened this issue May 1, 2022 · 3 comments

Comments

@adippl
Copy link

adippl commented May 1, 2022

At some point i3status on my computer stopped correctly displaying battery status while battery is idle. It is a really annoying bug.
I'm using gentoo linux.

I've looked into the code and discovered that i3status treats Discharging and Not charging states the same way.
Could you please considering merging this small patch to fix it?
This is small change causes i3status to display status_unk string when battery state is detected as Not charging

diff --git a/src/print_battery_info.c b/src/print_battery_info.c
index 7465d17..f9fd037 100644
--- a/src/print_battery_info.c
+++ b/src/print_battery_info.c
@@ -187,8 +187,10 @@ static bool slurp_battery_info(battery_info_ctx_t *ctx, struct battery_info *bat
             batt_info->status = CS_CHARGING;
         else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))
             batt_info->status = CS_FULL;
-        else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Discharging") || BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Not charging"))
+        else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Discharging"))
             batt_info->status = CS_DISCHARGING;
+        else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Not charging"))
+            batt_info->status = CS_UNKNOWN;
         else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS="))
             batt_info->status = CS_UNKNOWN;
         else if (BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN=") ||

@simontunnat
Copy link

simontunnat commented May 2, 2022

I get the same issue on a ThinkPad X1 Nano:

$ cat /sys/class/power_supply/BAT0/status    
    
Not charging 

My other devices seem to only use the unknown status.

Would appreciate a bugfix for this.

@adippl
Copy link
Author

adippl commented May 2, 2022

I currently have i3status installed on 3 lenovo laptops: x270, T550, T480
All 3 laptops use Not charging state.

Example with dual batteries:

$ grep -n "" /sys/class/power_supply/BAT*/status
/sys/class/power_supply/BAT0/status:1:Not charging
/sys/class/power_supply/BAT1/status:1:Charging

@erbth
Copy link
Contributor

erbth commented Oct 9, 2022

Some time ago I run into this, too, and created #486. It adds another status and prints 'IDLE' when a battery is reported as "Not charging" by the driver. I've just rebased it to current main. If you like you could give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants