我们是否有Windows电池报告的Linux / Ubuntu替代品,该报告powercfg /batteryreport
在Windows的命令提示符下运行会生成实际的html文件,从而显示计算机的完整电池运行时间?
已经有一个应用程序可以向您显示电池状态的图形报告。它被调用Gnome Power Statistics
,可以通过终端gnome-power-statistics
或通过搜索Unity Dash来启动。看起来是这样的:
如果您坚持使用HTML报告并在浏览器中查看它,这是我在20分钟左右的时间内编写的脚本,该脚本在默认浏览器中显示电池信息。
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[0]])
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
另存为simple_battery_report.py
并运行为
LC_ALL=C python simple_battery_report.py`
这是它的外观:
请注意,这不是最有效的解决方案,它不会刷新其信息。我强烈建议您使用其他GUI应用程序。
对于命令行爱好者,这里是这样:
$ 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'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句