Battery status API in macOS?

前端 未结 4 593
北荒
北荒 2020-11-28 07:49

How can I read the status of the battery on my MacBookPro from my own application?

Googling has so far only revealed APIs for device drivers to handle power events -

4条回答
  •  醉话见心
    2020-11-28 08:46

    Maybe help extracted text into script app

    pmset -g batt | head -n 1 | cut -c19- | rev | cut -c 2- | rev
    

    output

    Battery Power
    AC Power
    

提交回复
热议问题