From 3776cff6d5600c900af69a36f8383dd68711db8c Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 14 Jul 2011 16:15:15 +0200 Subject: [PATCH] fix acpi state for thinkpad --- tools/acpi.py | 27 ++++++++++++++++++++++++--- vendor/edcast-jack/libedcast/Makefile | 22 +++++++++++----------- webview.py | 4 ++-- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/tools/acpi.py b/tools/acpi.py index 9d1b6ca..b04d554 100644 --- a/tools/acpi.py +++ b/tools/acpi.py @@ -40,7 +40,7 @@ import os,stat,sys #enums -VERSION = "0.3.0" +VERSION = "0.3.1" OFFLINE = 0 ONLINE = 1 @@ -175,6 +175,8 @@ class AcpiLinux: #we read all acpi stuff from here self.proc_acpi_dir = "/proc/acpi" #self.proc_acpi_dir = "/home/riemer/main/ACPI/proc/acpi" + self.ac_sys_dir = '/sys/class/power_supply/AC' + self.bat_sys_dir = '/sys/class/power_supply/BAT0' self.init_batteries() self.init_fans() @@ -183,7 +185,6 @@ class AcpiLinux: self.update() - def update(self): """Read current states of supported acpi components""" @@ -209,7 +210,12 @@ class AcpiLinux: try: battery_dir_entries = os.listdir(self.proc_battery_dir) except OSError: - self.ac_line_state = ONLINE # no batteries: we assume that a cable is plugged in ;-) + ac_sys = open(self.ac_sys_dir+os.sep+'online') + state = ac_sys.readline() + if int(state): + self.ac_line_state = ONLINE + else: + self.ac_line_state = OFFLINE return #nothing more to do @@ -467,6 +473,21 @@ class AcpiLinux: def percent(self): """Returns percentage capacity of all batteries""" + if os.path.exists(self.bat_sys_dir): + list = ['charge_full', 'energy_full'] + for data in list: + path = self.bat_sys_dir+os.sep+data + if os.path.exists(path): + _charge_full = open(path) + charge_full = _charge_full.readline() + list = ['charge_now', 'energy_now'] + for data in list: + path = self.bat_sys_dir+os.sep+data + if os.path.exists(path): + _charge_now = open(path) + charge_now = _charge_now.readline() + return (int(charge_now) * 100) / int(charge_full) + life_capacity = 0 design_capacity = 0 for i,c in self.life_capacity.items(): diff --git a/vendor/edcast-jack/libedcast/Makefile b/vendor/edcast-jack/libedcast/Makefile index 5ceaa9c..4090b04 100644 --- a/vendor/edcast-jack/libedcast/Makefile +++ b/vendor/edcast-jack/libedcast/Makefile @@ -87,12 +87,12 @@ HEADERS = $(include_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run aclocal-1.10 -AMTAR = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run tar +ACLOCAL = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run aclocal-1.10 +AMTAR = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run tar AR = ar -AUTOCONF = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run autoconf -AUTOHEADER = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run autoheader -AUTOMAKE = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run automake-1.10 +AUTOCONF = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run autoconf +AUTOHEADER = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run autoheader +AUTOMAKE = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run automake-1.10 AWK = gawk CC = gcc CCDEPMODE = depmode=gcc3 @@ -136,7 +136,7 @@ LN_S = ln -s LTLIBOBJS = MAD_CFLAGS = MAD_LIBS = -lmad -MAKEINFO = ${SHELL} /home/dev/telecaster/telecaster/tools/edcast-jack/missing --run makeinfo +MAKEINFO = ${SHELL} /home/dev/telecaster/telecaster/vendor/edcast-jack/missing --run makeinfo MKDIR_P = /bin/mkdir -p OBJEXT = o OGG_CFLAGS = @@ -161,10 +161,10 @@ VORBIS_CFLAGS = VORBIS_LDFLAGS = VORBIS_LIBS = -lvorbis VORBIS_PREFIX = -abs_builddir = /home/dev/telecaster/telecaster/tools/edcast-jack/libedcast -abs_srcdir = /home/dev/telecaster/telecaster/tools/edcast-jack/libedcast -abs_top_builddir = /home/dev/telecaster/telecaster/tools/edcast-jack -abs_top_srcdir = /home/dev/telecaster/telecaster/tools/edcast-jack +abs_builddir = /home/dev/telecaster/telecaster/vendor/edcast-jack/libedcast +abs_srcdir = /home/dev/telecaster/telecaster/vendor/edcast-jack/libedcast +abs_top_builddir = /home/dev/telecaster/telecaster/vendor/edcast-jack +abs_top_srcdir = /home/dev/telecaster/telecaster/vendor/edcast-jack ac_ct_CC = gcc ac_ct_CXX = g++ ac_ct_F77 = @@ -193,7 +193,7 @@ host_vendor = unknown htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info -install_sh = $(SHELL) /home/dev/telecaster/telecaster/tools/edcast-jack/install-sh +install_sh = $(SHELL) /home/dev/telecaster/telecaster/vendor/edcast-jack/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale diff --git a/webview.py b/webview.py index 3467931..e2dff70 100644 --- a/webview.py +++ b/webview.py @@ -49,7 +49,7 @@ class WebView(FieldStorage): FieldStorage.__init__(self) self.conf = conf self.version = version - self.interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2','eth3'] + self.interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2', 'eth3', 'wlan0'] ip = '' for interface in self.interfaces: try: @@ -155,7 +155,7 @@ class WebView(FieldStorage): self.acpi.update() self.power_state = self.acpi.charging_state() if self.power_state == 0: - power_info = "batterie" + power_info = "batterie" elif self.power_state == 1 or self.power_state == 2: power_info = "secteur" else: -- 2.39.5