#!/usr/bin/env python3 charge_now_path = "/sys/class/power_supply/BAT0/charge_now" current_now_path = "/sys/class/power_supply/BAT0/current_now" f = open(charge_now_path, "r") charge_now = int(f.readlines()[0]) f = open(current_now_path, "r") current_now = int(f.readlines()[0]) ratio = charge_now / current_now * 100 hours = ratio / 60 minutes = ratio % 60 print(str(hours) + ":" + str(minutes))