tl;dr: I’m looking for something like AccuBattery, but for Linux

What do you use to measure laptop battery life in Linux?

I can easily get a momentary estimate of battery life. But this fluctuates based on load, screen backlight etc.

I’m looking for something that will collect my usage patterns over time - load, #processes, screen backlight, … - and allow me to predict remaining runtime more accurately.

I’d love for the data to be parsable, so that I can analyze it myself and e.g. find the “worst offenders” - processes affecting battery runtime the most.

Thank you for any tips!

  • czak@lemmy.mlOP
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    Thanks, I do like powertop. I think it’s pretty good for short measurements, e.g. over 30 seconds:

    % sudo powertop --time=30
    
    The battery reports a discharge rate of 4.17 W
    The energy consumed was 125 J
    The estimated remaining time is 11 hours, 4 minutes
    

    But in the real world I will not be getting 11 hours of runtime. The moment I start a browser or play a video, power consumption goes way up.

    • Atemu@lemmy.ml
      link
      fedilink
      arrow-up
      10
      arrow-down
      1
      ·
      1 year ago

      Well, no program can accurately predict how you are going to use your laptop in the next hours. The best you can do is sample a given reference period and assume it’ll be the same but you have already noted the problem with that.

      I’d recommend you monitor total power draw while using your laptop. It’s inversely proportiaonal to battery life: If you could reach 10h at 5W, you’d only reach 5h at 10W, 2.5h at 20W and so on; you can think of it as a metric for battery drain.

      • czak@lemmy.mlOP
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Agreed, that sounds like the way to go. I was hoping there was already something to do the monitoring for me :)

    • l3mming@lemmy.fmhy.ml
      link
      fedilink
      arrow-up
      5
      ·
      edit-2
      1 year ago

      If you’re technically inclined, a simple bash script with a for loop could dump the time and discharge rate to a text file every minute. Then you could copy/paste that into LibreOffice calc and do yourself some pretty graphs, or whatever.

      edit: just found a tool called powerstat which looks like it does sampling over longer intervals.

      sudo apt install powerstat

      • czak@lemmy.mlOP
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Interesting, hadn’t heard of powerstat. I’ll be checking that, thanks!