I use a Lenovo Thinkpad and need a python program that can get me my laptop's charging percentage.
For Example: 74%, 98%, 16%
I've searched around but can't seem to find exactly what I need
Can anyone help?
I use a Lenovo Thinkpad and need a python program that can get me my laptop's charging percentage.
For Example: 74%, 98%, 16%
I've searched around but can't seem to find exactly what I need
Can anyone help?
You can get remaining time as follows:
import psutil as ps
batterystats = dict(ps.sensors_battery()._asdict())
print(batterystats)
timeleft = batterystats.get('secsleft')
percent = batterystats.get('percent')
print('battery percent : '+str(percent)+'%')
print('time left (secs) : '+str(timeleft)+' secs')
The answer is in seconds you can convert it though.
import psutil
print ("battery charge left: " + str(psutil.sensors_battery()[0]) + "%")
output
battery charge left: 95%