]> git.parisson.com Git - telecaster-cgi.git/commitdiff
fix acpi state for thinkpad
authoryomguy <yomguy@parisson.com>
Thu, 14 Jul 2011 14:15:15 +0000 (16:15 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 14 Jul 2011 14:15:15 +0000 (16:15 +0200)
tools/acpi.py
vendor/edcast-jack/libedcast/Makefile
webview.py

index 9d1b6ca94405e6257c648752d87eb2a9bb999c33..b04d554b14991972c0d32e8e6db50eba849a8426 100644 (file)
@@ -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():
index 5ceaa9c4140b882f9a44eae7b07d7386d9ff2cc8..4090b04a27de1ffa73325215668d026847c225ee 100644 (file)
@@ -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
index 34679319a37231406bd6afae957357c14ddbece1..e2dff702091498013c17b167c30b9b186f7b73fc 100644 (file)
@@ -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 = "<span style=\"color: red\">batterie</span>"
+            power_info = "<span style=\"color: red\"><b>batterie</b></span>"
         elif self.power_state == 1 or self.power_state == 2:
             power_info = "<span style=\"color: green\">secteur</span>"
         else: