Changeset 174

Show
Ignore:
Timestamp:
07/09/2005 07:12:19 PM (3 years ago)
Author:
petli
Message:

Support Linux 2.6 cpu freq interface

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/petliwm.py

    r173 r174  
    3838     modewindow, modestatus, \ 
    3939     mw_clock, mw_acpi, \ 
     40     mw_watchfiles, \ 
    4041     inspect, misc, input 
    4142 
     
    185186           mw_clock.ModeWindowClock, 
    186187           mw_acpi.ModeWindowACPI, 
     188           mw_watchfiles.ModeWindowWatchFiles, 
    187189           inspect.InspectServer, 
    188190           ModeWindowTraceIM, 
     
    191193    mw_acpi_position = 0 
    192194    mw_acpi_justification = modewindow.LEFT 
     195 
     196    mw_watchfiles_position = 0.85 
     197    mw_watchfiles_justification = modewindow.RIGHT 
     198 
     199    mw_watchfiles = (mw_watchfiles.WatchedFile('/var/run/laptop-mode-enabled', 
     200                                               present_msg = '', 
     201                                               missing_msg = 'LTM OFF'), 
     202                     mw_watchfiles.WatchedFile('/var/run/network-error', 
     203                                               present_msg = 'NET: %s', 
     204                                               format_content = 1) 
     205                     ) 
     206 
     207    mw_watchfiles_interval = 5 
    193208     
    194209    client_class = MyClient 
     
    297312 
    298313    def F3(self, evt): 
    299         self.wm.current_screen.view_find_with_client(Or(name('Gecko'), 
     314        self.wm.current_screen.view_find_with_client(Or(name('Firefox-bin'), 
    300315                                                        name('Mozilla'), 
    301316                                                        name('Netscape'), 
  • trunk/plwm/__init__.py

    r170 r174  
    1 # $Id: __init__.py,v 1.9 2004-11-12 23:09:14 petli Exp $ 
     1# $Id: __init__.py,v 1.10 2005-07-10 00:12:19 petli Exp $ 
    22# 
    33# __init__.py for package plwm 
     
    4141            'mw_clock', 
    4242            'mw_load', 
     43            'mw_watchfiles', 
    4344            'outline', 
    4445            'panes', 
  • trunk/plwm/mw_acpi.py

    r170 r174  
    1 # $Id: mw_acpi.py,v 1.1 2004-11-12 23:09:14 petli Exp $ 
     1# $Id: mw_acpi.py,v 1.2 2005-07-10 00:12:19 petli Exp $ 
    22# -*- coding: iso-8859-1 -*- 
    33# 
     
    207207 
    208208            info = linux_proc_read_info(path) 
    209             self.has_performance = info[self.PERFORMANCE_MANAGEMENT] == 'yes' 
    210             self.has_throttling = info[self.THROTTLING_CONTROL] == 'yes' 
     209            self.has_performance = info.get(self.PERFORMANCE_MANAGEMENT) == 'yes' 
     210            self.has_throttling = info.get(self.THROTTLING_CONTROL) == 'yes' 
    211211 
    212212            if not self.has_performance and not self.has_throttling: 
     
    312312                return 0 
    313313 
     314 
     315    # Not really ACPI, this one.  But on Linux 2.6 kernels, the CPU frequency isn't  
     316    # displayed in the ACPI interface, but from the cpu-freq module. 
     317     
     318    class CpuFreqScaling: 
     319        EVENT = None 
     320        PROC_DIR = '/sys/devices/system/cpu' 
     321 
     322        SCALING_CPU_FREQ = '%s/cpufreq/scaling_cur_freq' 
     323         
     324        def __init__(self, id, path): 
     325            self.id = id 
     326            self.path = path 
     327 
     328            self.scaling_cpu_freq = self.SCALING_CPU_FREQ % (path, ) 
     329             
     330            self.messsage = '' 
     331 
     332            # frequency in kHz 
     333            self.freq = None 
     334 
     335            self.update() 
     336 
     337        def update(self): 
     338            try: 
     339                new_freq = int(open(self.scaling_cpu_freq).read(50)) 
     340            except (IOError, ValueError), e: 
     341                raise BadInfo('bad cpufreq: %s: %s' % (self.scaling_cpu_freq, e)) 
     342             
     343            if self.freq != new_freq: 
     344                self.freq = new_freq 
     345                self.message = '%d MHz' % (self.freq / 1000) 
     346                return 1 
     347            else: 
     348                return 0 
     349 
    314350     
    315351    def __init__(self): 
     
    381417            self.add_units(self.Battery) 
    382418            self.add_units(self.Processor) 
     419            self.add_units(self.CpuFreqScaling) 
    383420            self.add_units(self.ThermalZone) 
    384421 
     
    515552                self.mw_acpi_update(newstatus) 
    516553            else: 
    517                 wmanager.debug('acpi', 'event socket closed: %s', e) 
     554                wmanager.debug('acpi', 'event socket closed') 
    518555                self.mw_acpi_socket.close() 
    519556                self.mw_acpi_socket = None