PersonalityOwn4076 · 2022-03-16 15:14
Anyone know where I can edit this to get it to show the proper battery level or have any advice for other options to show the battery level? I tried [fancy battery](https://github.com/kjvic/fancy-battery.el) but it seems like they get their battery levels from the built in battery package, so it's still wrong.
​
Edit:
I can get the battery level with the code below but the output looks kinda bad.
`(setq battery-level "more /sys/class/power_supply/battery/capacity")`
`(shell-command-to-string battery-level)`
​
Output is
`/sys/class/power_supply/battery/capacity`
`::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::`
`69`
`"`
7890yuiop · 2022-03-16 21:52
What is your `battery-status-function` set to?
If you're using `/sys/class/power_supply/...` then it looks like `battery-linux-sysfs` should be used, but you could maybe experiment with other options.
On the whole though, Emacs will simply be reporting what the system tells it, so it sounds super weird that you're getting different numbers from different things assuming they're both talking to the same API.
PersonalityOwn4076 · 2022-03-16 22:01
How can I check what `battery-status-function` is set to? I'm not seeing it in `M-x`. I am not seeing a `battery-linux-sysfs` in `/sys/class/power_supply/...` but `/battery/capacity` has always been correct for me, so I am not too worried about that. But yeah, it is really odd how it gives exactly a third of the battery every time.
7890yuiop · 2022-03-16 23:47
It's a variable.
PersonalityOwn4076 · 2022-03-17 14:16
I tried `C-h v` to check and it shows the code for the function and it has several different paths in it and my elisp isn't good enough to tell which it is using.
7890yuiop · 2022-03-18 09:47
So you're not seeing this?
battery-status-function is a variable defined in ‘battery.el’.
Its value is ‘battery-linux-sysfs’
If not I would try customizing it and setting it to `battery-linux-sysfs`.
I'd also run `emacs -Q` and `M-x load-battery` and check that variable and see if it's the same. If it's not, and changing it is the solution, you'd need to hunt down what it is in your config which is giving it a bad value.
PersonalityOwn4076 · 2022-03-18 15:08
When running `emacs -Q` I get that load-battery doesn't exist (I am using 29.05, built from source about a month ago) and my original value was `battery-upower` but I changed it to `battery-linux-sysfs` and now it doesn't show any battery, I get Power N/A when checking the battery.
7890yuiop · 2022-03-18 23:06
Gah, sorry: typing when I'm tired. I meant `emacs -Q` and `M-x load-library RET battery` and managed to mangle the latter bit.
At a *guess* `battery-upower` should be consistent with information from running `upower -d` on the command line.
I find it surprising that `battery-linux-sysfs` doesn't work, as on my system that is described as:
Get ACPI status information from Linux kernel.
This function works only with the new ‘/sys/class/power_supply/’
format introduced in Linux version 2.4.25.
which seems to describe your case.
That's all I've got, in any case. Good luck.