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

Add powerMonitor IsOnBatteryPower method #26457

Closed
3 tasks done
Ricket opened this issue Nov 12, 2020 · 2 comments · Fixed by #26494
Closed
3 tasks done

Add powerMonitor IsOnBatteryPower method #26457

Ricket opened this issue Nov 12, 2020 · 2 comments · Fixed by #26494

Comments

@Ricket
Copy link

Ricket commented Nov 12, 2020

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

powerMonitor triggers events when the computer goes on AC or on battery. But there's no way to know on app startup whether the system is already on battery or AC. An event isn't triggered until the state change happens.

I learned from this comment that Electron inherits powerMonitor from Chromium. Well, Chromium's PowerMonitor class has a IsOnBatteryPower method.

Proposed Solution

Add an isOnBatteryPower method to the powerMonitor module.

Alternatives Considered

Alternatively, Electron could fire the on-ac or on-battery event on app startup. In fact, perhaps this should also be the case. (I verified it does not currently do this)

Additional Information

n/a

@Ricket
Copy link
Author

Ricket commented Nov 17, 2020

Thank you @nornagon !

@nornagon
Copy link
Member

Thanks @Ricket for the suggestion and the helpful research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants