0

https://askubuntu.com/a/309146/ says:

Now we are encouraged to use -> /sys/class/power_supply/BAT0.

UPDATE: Linux 3.19 and onwards, we should look at the following directory -> /sys/class/power_supply/BAT1/

But on my NixOS:

$ uname -a
Linux o 5.19.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Jul 31 21:03:01 UTC 2022 x86_64 GNU/Linux
$ cat /sys/class/power_supply/BAT1/status 
cat: /sys/class/power_supply/BAT1/status: No such file or directory
$ cat /sys/class/power_supply/BAT0/status 
Discharging

So I was wondering what have happened?

Tim
  • 101,790

1 Answers1

1

What has happened is that the edit is incorrect, or at least no longer correct (or perhaps, based on comments, specific to Arch Linux). Batteries are counted from 0, and identifiers can be skipped, so you’ll find BAT0, BAT1 etc. depending on the system.

Thus you need to look at all battery directories, you can’t assume in general that any given system will have BAT0 or BAT1 etc. Some laptops even have multiple batteries and multiple BAT? directories.

Stephen Kitt
  • 434,908