Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Macchina support two batteries? #295

Open
mohabmetwalli opened this issue Oct 4, 2023 · 6 comments
Open

Does Macchina support two batteries? #295

mohabmetwalli opened this issue Oct 4, 2023 · 6 comments
Labels
category/fetching Something to do with the fetched information. status/help-wanted Your help is needed.

Comments

@mohabmetwalli
Copy link

I wasn't sure if I should open this issue as a bug or a feature request, so I thought I should ask this question first.

My laptop has two batteries, and I suspect this is the reason macchina cannot read battery percentage.

macchina --doctor output:

Let's check your system for errors... Here's a summary:

We've collected 9 readouts, including 1 failed read(s) and 0 read(s) which resulted in a warning.
Readout "Battery" failed with message: No such file or directory (os error 2)

ls /sys/class/power_supply --all output:

.  ..  AC  BAT0  BAT1  ucsi-source-psy-USBC000:001  ucsi-source-psy-USBC000:002
@grtcdr grtcdr added category/fetching Something to do with the fetched information. type/feature status/help-wanted Your help is needed. labels Oct 4, 2023
@grtcdr
Copy link
Member

grtcdr commented Oct 4, 2023

Hi.

It can't. I don't really know how to tackle this problem, either. I also don't have the hardware to try and write an implementation. It would be very appreciated if you or others alike could give us a hand with this problem.

@FantasyTeddy
Copy link
Contributor

Even if multiple batteries are present, shouldn't macchina just report the status of the first one?

@mohabmetwalli: Can you show the directory listing of /sys/class/power_supply/BAT0?

@grtcdr
Copy link
Member

grtcdr commented May 13, 2024

Even if multiple batteries are present, shouldn't macchina just report the status of the first one?

Yes, indeed. I'll see what I can do to fix this. Adding support for this could prove to be a lot of work in libmacchina — dual-battery friends, if you really want to see support for multi-battery reports, please contribute your patches to libmacchina seeing as I don't have the hardware to do any meaningful tests.

@grtcdr grtcdr changed the title [Question] Does Macchina support two batteries? Does Macchina support two batteries? May 13, 2024
@naguam
Copy link

naguam commented Sep 13, 2024

Hi,

Regarding batteries, this library might be helpful,

https://crates.io/crates/starship-battery

It has one API which lists batteries and their info and works with most major operating systems (including NetBSD thanks to my port) except OpenBSD for now.
(I wanted to do it but the Rust ecosystem was broken on OpenBSD when I tried and I did not want to fight with segfaults and resource over use / stalls with the LSP).

If I make this proposal despite macchina having already some battery reading features is because, this library basically provide an iterator with all available batteries + update methods, and this would ease the process of reading multiple batteries on any operating system with a single implementation on macchina's side.

The example directory in that library shows how to use the library, iterate over batteries and so on.

@grtcdr
Copy link
Member

grtcdr commented Sep 14, 2024

When we fetch things, we like to call libmacchina, that's the only backend we wish to use. So it would be best if we wrote our own implementation, we're already borrowing quite a few things from other libraries in libmacchina and I don't like that we do that.

@naguam
Copy link

naguam commented Sep 14, 2024

It was just a proposal to make things simpler and use the systems' APIs instead of running shell commands. (At least in the netbsd's case).

To be fair it would not make sense to make a rewrite at it would mostly be about making a clone.
The entire library's purpose is to provide battery info, and nothing else.
It's not a "do it all" library.

And of course it would be used in libmacchina, I though this repo and issue feed was for the project overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/fetching Something to do with the fetched information. status/help-wanted Your help is needed.
Development

No branches or pull requests

4 participants