Skip to content

Remaining battery time stopped showing on Linux #124

@snejugal

Description

@snejugal

I recently noticed that the remaining battery time stopped showing on my laptop. I started digging into it and found these lines to be problematic:

https://github.com/tmux-plugins/tmux-battery/blob/master/scripts/battery_remain.sh#L118-L123

for whatever reason, my laptop natively running Linux snejugal 7.0.3 #1-NixOS SMP PREEMPT_DYNAMIC Thu Apr 30 09:13:05 UTC 2026 x86_64 GNU/Linux is detected as WSL by is_wsl (changed in #119). then the scripts starts looking for charge_full, charge_now, current_now in /sys/class/power-supply but can't find any. that's because these are actually (I guess) energy_full, energy_now and voltage_now on my machine:

$ ls /sys/class/power_supply/BAT0
alarm           charge_control_end_threshold  energy_full         extensions    model_name  present        subsystem   uevent
capacity        cycle_count                   energy_full_design  hwmon3        power       serial_number  technology  voltage_min_design
capacity_level  device                        energy_now          manufacturer  power_now   status         type        voltage_now

I guess this might have changed in recent Linux versions or depends on the driver.

print_battery_remain also supports upower and that works just fine, but my natively running Linux is detected as WSL, so that branch can never be reached. so I see a few problems here:

  1. the code gated behind is_wsl supposedly became outdated;
  2. this manual work with /sys interfaces is the primary way to calculate remaining time, not a fallback in case other tools are not available;
  3. one can't choose the backend to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions