0
저는 최근에 우분투 12.10으로 업그레이드되었습니다. (이전에 11.04 사용자였습니다.) 제가 알아챈 점 중 하나는 배터리 전원으로 작동 할 때, 배터리가 오래 있어야하는 시간에 대한 예상 시간.우분투 12.10 배터리 견적가
나는 백분율을 줄 수있는 것을 발견했지만, 특정 시간을 제공 할 설치 프로그램이 있는지 궁금해하고있었습니다.
감사합니다.
저는 최근에 우분투 12.10으로 업그레이드되었습니다. (이전에 11.04 사용자였습니다.) 제가 알아챈 점 중 하나는 배터리 전원으로 작동 할 때, 배터리가 오래 있어야하는 시간에 대한 예상 시간.우분투 12.10 배터리 견적가
나는 백분율을 줄 수있는 것을 발견했지만, 특정 시간을 제공 할 설치 프로그램이 있는지 궁금해하고있었습니다.
감사합니다.
내 노트북 배터리를 모니터링하기 위해 이전에 작성한 Python-2 스크립트입니다. 현재 배터리 충전 비율, 예상 실행 시간을 인쇄합니다 (기록을 유지하고 그에 대한 확률적인 추를 적용하는 것이 좋을지라도). 배터리가 가득 찰 때까지 예상 시간을 충전하는 것이 좋습니다. 또한 방전하면 현재의 전력 소비 및 배터리 상태에 따라 총 배터리 런타임이 출력됩니다. 모든 수치는 보수적 인 것으로, 즉 배터리 실행 시간에 대한 더 낮은 견적 및 충전까지의 시간에 대한 예상치가 꽉 참입니다.
#!/usr/bin/python2
import os
import sys
import math
for psup in os.listdir('/sys/class/power_supply'):
if not psup.startswith('BAT'):
continue
charge_now = int(open('/sys/class/power_supply/%s/charge_now' % psup).read())
charge_full = int(open('/sys/class/power_supply/%s/charge_full' % psup).read())
charge_full_design = int(open('/sys/class/power_supply/%s/charge_full_design' % psup).read())
current_now = int(open('/sys/class/power_supply/%s/current_now' % psup).read())
status = open('/sys/class/power_supply/%s/status' % psup).read().strip()
t_full_seconds_total = None
t_remain_seconds_total = None
if status == 'Charging':
t_remain_seconds_total = max((float(charge_full - charge_now)/float(current_now)) ,
(float(charge_full_design - charge_now)/float(current_now))) * 3600.
elif status == 'Discharging':
t_remain_seconds_total = float(charge_now)/float(current_now) * 3600.
t_full_seconds_total = (float(max(charge_full_design, charge_full))/float(current_now)) * 3600.
t_charge_percentage = float(charge_now)/float(max(charge_full, charge_full_design))
if t_remain_seconds_total:
t_remain_hours = math.floor(t_remain_seconds_total/3600)
t_remain_minutes = math.floor((t_remain_seconds_total - t_remain_hours * 3600)/60.)
t_remain_seconds = (t_remain_seconds_total - t_remain_hours * 3600 - t_remain_minutes * 60)
t_remain = ' %0.2dh%0.2dm%0.2ds left' % (t_remain_hours, t_remain_minutes, t_remain_seconds)
else:
t_remain = ''
t_full = None
if t_full_seconds_total:
t_full_hours = math.floor(t_full_seconds_total/3600)
t_full_minutes = math.floor((t_full_seconds_total - t_full_hours * 3600)/60.)
t_full_seconds = (t_full_seconds_total - t_full_hours * 3600 - t_full_minutes * 60)
t_full = ' %0.2dh%0.2dm%0.2ds runtime from fully charged battery' % (t_full_hours, t_full_minutes, t_full_seconds)
print psup + ' ['+ ('='*int(60*t_charge_percentage)).ljust(60) +'] ' + '%d%% %s' % (100*t_charge_percentage, status) + t_remain
if t_full:
print psup + t_full
이 질문은 Ask Ubuntu에 속하기 때문에 주제가 아닌 것 같습니다. –