Do we have a Linux/Ubuntu alternative for Windows' battery report where running
powercfg /batteryreport on Windows' command prompt generates an actual html file showing the complete battery run time of the machine?
There is already an app that can show you graphical report of battery status. It is called
Gnome Power Statistics and can be started via terminal as
gnome-power-statistics or via searching Unity Dash. Here's how it looks like:
In case you insist on using HTML report and viewing it in your browser, here is a script that I made within 20 minutes or so, that displays battery info in your default browser.
import subprocess import os devs = [ line for line in subprocess.check_output(['upower','--enumerate']).decode().split('\n') ] battery = [ item.strip() for item in devs if 'BAT' in item ] report = subprocess.check_output(['upower','-i',battery]) top = """ <html> <header><title>This is title</title></header> <body> """ bottom = """ </body> </html> """ with open('report.html','w') as f: f.write(top) for line in report.decode().split('\n'): f.write('<p>' + line + '</p>\n' ) f.write(bottom) pid = subprocess.Popen(['xdg-open','report.html']).pid
Save this as
simple_battery_report.py and run as
LC_ALL=C python simple_battery_report.py`
And here's how it looks:
Note, this is not the most efficient solution, it doesn't refresh its information. I would strongly recommend using that other GUI app.
For command line enthusiasts here's this:
$ LC_ALL=C upower --enumerate | awk '/BAT/'| xargs upower -i native-path: BAT1 vendor: TOSHIBA model: PABAS0241231 serial: 0000000000000E6A power supply: yes updated: 2016年08月26日 星期五 21时58分27秒 (117 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: fully-charged warning-level: none energy: 35.2388 Wh energy-empty: 0 Wh energy-full: 35.2536 Wh energy-full-design: 44.104 Wh energy-rate: 0.0148 W voltage: 16.887 V percentage: 100% capacity: 79.9329% technology: lithium-ion icon-name: 'battery-full-charged-symbolic'