Discharging battery state not being the default might be a breaking change #123

Closed
opened 7 months ago by Nulo · 10 comments
Nulo commented 7 months ago

8709e8da38

This made my battery icon disappear when my Thinkpad is not charging because of the battery charging lock. Wouldn't that be considered a breaking change?

https://codeberg.org/dnkl/yambar/commit/8709e8da3835f5954f5d8d577035f76e68f82353 This made my battery icon disappear when my Thinkpad is not charging because of the battery charging lock. Wouldn't that be considered a breaking change?
Owner

Can you check which state it's in? Chances are it's a state yambar doesn't recognize at all, thus falling back to "unknown".

/sys/class/power_supply/<battery name>/status

Can you check which state it's in? Chances are it's a state yambar doesn't recognize at all, thus falling back to "unknown". `/sys/class/power_supply/<battery name>/status`
Poster

I'll check later, but my problem is that before, it defaulted to "discharging" while now it defaults to "unknown" which makes it hide the battery from my bar.

I'll check later, but my problem is that before, it defaulted to "discharging" while now it defaults to "unknown" which makes it hide the battery from my bar.
Owner

which makes it hide the battery from my bar.

Does it remain gone forever, or does it come back later?

While I think it's a good idea to refrain from breaking changes in general, in this case the "breaking" change was a bug fix. It also sounds as if your battery behaves weirdly. Thus, I don't think reverting 8709e8da38 is justified.

You should be able to revert to the old behavior with a simple config change. Something like this (untested):

diff --git a/examples/configurations/laptop.conf b/examples/configurations/laptop.conf
index 19d0bb4..7a51786 100644
--- a/examples/configurations/laptop.conf
+++ b/examples/configurations/laptop.conf
@@ -248,11 +248,10 @@ bar:
     - battery:
         name: BAT0
         poll-interval: 30
-        content:
-          map:
-            tag: state
-            values:
-              discharging:
+        anchors:
+          discharging: &discharging
+            list:
+              items:
                 - ramp:
                     tag: capacity
                     items:
@@ -267,6 +266,14 @@ bar:
                       - string: {text: , font: *awesome}
                       - string: {text: , foreground: 00ff00ff, font: *awesome}
                 - string: {text: "{capacity}% {estimate}"}
+        content:
+          map:
+            tag: state
+            values:
+              unknown:
+                <<: *discharging
+              discharging:
+                <<: *discharging
               charging:
                 - string: {text: , foreground: 00ff00ff, font: *awesome}
                 - string: {text: "{capacity}% {estimate}"}
> which makes it hide the battery from my bar. Does it remain gone forever, or does it come back later? While I think it's a good idea to refrain from breaking changes in general, in this case the "breaking" change was a bug fix. It also sounds as if your battery behaves weirdly. Thus, I don't think reverting https://codeberg.org/dnkl/yambar/commit/8709e8da3835f5954f5d8d577035f76e68f82353 is justified. You should be able to revert to the old behavior with a simple config change. Something like this (untested): ```diff diff --git a/examples/configurations/laptop.conf b/examples/configurations/laptop.conf index 19d0bb4..7a51786 100644 --- a/examples/configurations/laptop.conf +++ b/examples/configurations/laptop.conf @@ -248,11 +248,10 @@ bar: - battery: name: BAT0 poll-interval: 30 - content: - map: - tag: state - values: - discharging: + anchors: + discharging: &discharging + list: + items: - ramp: tag: capacity items: @@ -267,6 +266,14 @@ bar: - string: {text: , font: *awesome} - string: {text: , foreground: 00ff00ff, font: *awesome} - string: {text: "{capacity}% {estimate}"} + content: + map: + tag: state + values: + unknown: + <<: *discharging + discharging: + <<: *discharging charging: - string: {text: , foreground: 00ff00ff, font: *awesome} - string: {text: "{capacity}% {estimate}"} ```
Poster

I think I exaggerated with having it reverted. Yes, I know, a very trivial config change fixes it. I will try to get the proper status though next time it goes "unknown"

I think I exaggerated with having it reverted. Yes, I know, a very trivial config change fixes it. I will try to get the proper status though next time it goes "unknown"
Poster

It also sounds as if your battery behaves weirdly

It's just how Thinkpad's battery charging limit behaviour works.

$ cat /sys/class/power_supply/BAT0/status
Unknown
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0

  native-path:          BAT0
  vendor:               LGC
  model:                45N1025
  serial:               27629
  power supply:         yes
  updated:              Sat Oct 30 22:46:10 2021 (89 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              18.3261 Wh
    energy-empty:        0 Wh
    energy-full:         30.8025 Wh
    energy-full-design:  68.9976 Wh
    energy-rate:         33.8804 W
    voltage:             12.017 V
    time to full:        22.1 minutes
    percentage:          59%
    capacity:            44.6429%
    technology:          lithium-ion
    icon-name:          'battery-good-charging-symbolic'
    
> It also sounds as if your battery behaves weirdly It's just how Thinkpad's battery charging limit behaviour works. ``` $ cat /sys/class/power_supply/BAT0/status Unknown $ upower -i /org/freedesktop/UPower/devices/battery_BAT0 native-path: BAT0 vendor: LGC model: 45N1025 serial: 27629 power supply: yes updated: Sat Oct 30 22:46:10 2021 (89 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: charging warning-level: none energy: 18.3261 Wh energy-empty: 0 Wh energy-full: 30.8025 Wh energy-full-design: 68.9976 Wh energy-rate: 33.8804 W voltage: 12.017 V time to full: 22.1 minutes percentage: 59% capacity: 44.6429% technology: lithium-ion icon-name: 'battery-good-charging-symbolic' ```
Owner

Not sure if there's anything more yambar can do here? Is there some thinkpad specific sysfs file we could look at?

If not, I think the best solution is to update the config. I've already pushed an update to the example conf.

Not sure if there's anything more yambar can do here? Is there some thinkpad specific sysfs file we could look at? If not, I think the best solution is to update the config. I've already pushed an update to the example conf.
Poster

Yes, I agree.

Yes, I agree.
Nulo closed this issue 7 months ago
dnkl added the
wontfix
label 7 months ago
Owner

I just noticed I have a similar (or same even?) issue; my battery switches to "unknown" while charging after reaching 90% or so. In my case, mapping this to discharging is wrong, since it is charging - it eventually reaches the "full" state.

What I'll do is simply treat "unknown" as "almost full - consider unplugging" in my config, and maybe use a different color.

I've been looking around at other projects, and this appears to be an issue that pops up every now and then. Some solutions I saw were quite elaborate, looking at the AC status plus capacity stats and trying to guess the battery state. I'd rather not go there...

However, I do think we should document this in the man page.

I just noticed I have a similar (or same even?) issue; my battery switches to "unknown" while charging after reaching 90% or so. In my case, mapping this to discharging is wrong, since it _is_ charging - it eventually reaches the "full" state. What I'll do is simply treat "unknown" as "almost full - consider unplugging" in my config, and maybe use a different color. I've been looking around at other projects, and this appears to be an issue that pops up every now and then. Some solutions I saw were quite elaborate, looking at the AC status plus capacity stats and trying to guess the battery state. I'd rather not go there... However, I do think we should document this in the man page.
Owner

Man page updated in 58038a4236

Man page updated in https://codeberg.org/dnkl/yambar/commit/58038a42361b60ee9c9d72612c1ab96c5a9baf4e
Poster

Yes, I set mine as charging as it is still plugged in but it is "locked".

Yes, I set mine as charging as it is still plugged in but it is "locked".
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.