cmd-johnson / node-power-info

Cross-platform node library for accessing battery power information
https://www.npmjs.com/package/node-power-info
MIT License
3 stars 2 forks source link

Added battery remaining time (macOS) #5

Closed elaberge closed 7 years ago

elaberge commented 7 years ago

Extracts the remaining time (charge or discharge) from pmset, in an hh:mm format string (ex.: "1:54"). Undefined if no estimation is available.

cmd-johnson commented 7 years ago

Thank you for adding this. This change looks easy enough and I just tested it on my work MacBook and it seems to work just fine. The only thing that might need changing eventually would probably be the time format - I don't think the library should make any assumptions on that and maybe provide an object containing hours and minutes.

Okay, maybe return both a 'hh:mm' string and a { hours: 1, minutes: 54 } object, so users can decide themselves if they want the pre-formatted string or want to format the time themselves. I'll merge this, give the time formatting a bit more thought, implement the change and then update the package.

And sorry for getting around to check this out only today, it was quite a busy week.