Created
April 20, 2023 06:12
-
-
Save muety/c35c80bb9b4ec665589c6ec5170f9b34 to your computer and use it in GitHub Desktop.
Simple script to print current power draw in Watts on Linux notebooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
if __name__ == '__main__': | |
while True: | |
with open('/sys/class/power_supply/BAT0/current_now', 'r') as f: | |
current = float(f.readline().strip()) | |
with open('/sys/class/power_supply/BAT0/voltage_now', 'r') as f: | |
voltage = float(f.readline().strip()) | |
print(f'{current * voltage / 1000000000000} W', end='\r') | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment