You are not logged in.

#1 2009-07-14 16:30:10

connexion2000
Member
Registered: 2006-10-15
Posts: 116

eeepc plasmoid plasmoid slow as hell

Hi,
I am currently developing (modifying) plasmoid for eeepc, fully based on acpi-eeepc-generic scripts. It is based on eee-plasmoid downloadable from kde-look.org but that version operates directly on /sys and sometimes hangs my machine (wlan on/off). So I modified it to use acpi-eeepc-generic. But I have one problem. Viewing this plasmoid in plasmoidviewer works perfectly and it is ultra fast. But when I add it to desktop, one turning off/on operation takes around 1 minute. Why is that?

You can download plasmoid here: http://code.google.com/p/acpi-eeepc-gen … tail?id=33

Here is the code:

from PyQt4.QtCore import *
from PyQt4.QtGui import * 
from PyKDE4.kdecore import i18n
from PyKDE4.kdeui import *     
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript 
import os                       
import subprocess               

sysfolder = '/sys/devices/platform/eeepc'
rffolder = '/sys/class/rfkill'           
scriptfolder = '/etc/acpi/eeepc'         

class eeeScript:
  def __init__(self, parent, script, control, icon, title):
    self.script = script                                   
    self.control = control                                 
    self.icon = icon                                       
    self.title = title                                     
    self.enabled = True                                    
    self.parent = parent                                   
    self.widget = Plasma.IconWidget(parent)                

  def checkEnabled(self):
    f = open(self.fullfile).read().strip()
    self.enabled = True if f is '1' else False
                                              
  def toggle(self):                           
    command = ['sudo', self.script]           
    subprocess.Popen(command).wait()          
    self.updateDisplay()                      
    Plasma.ToolTipManager.self().show(self.widget)
                                                  
  #Check if the device is enabled, and update its icon and tooltip accordingly
  def updateDisplay(self):                                                    
    #Show a grayed-out version of the icon when not enabled                   
    if self.enabled:                                                          
      px = KIcon(self.icon)                                                   
    else:                                                                     
      y = self.parent.size().height()                                         
      px = QIcon(KIcon(self.icon).pixmap(QSize(y, y), KIcon.Disabled))        
    self.widget.setIcon(px)                                                   
    #And update tooltip's description                                         
    status = "Enabled" if self.enabled else "Disabled"                        
    tt = Plasma.ToolTipContent(i18n(self.title), i18n(status), KIcon(self.icon))
    Plasma.ToolTipManager.self().setContent(self.widget, tt)                    

class eeeSysScript (eeeScript):
  def __init__(self, parent, script, control, icon, title):
    eeeScript.__init__(self, parent, script, control, icon, title)
    self.fullfile = '%s/%s' % (sysfolder, self.control)           

#Applies for bt and wlan
class eeeRfScript (eeeScript):
  def __init__(self, parent, script, control, icon, title):
    eeeScript.__init__(self, parent, script, control, icon, title)
    self.fullfile = '%s/%s/state' % (rffolder, self.control)      

class EeePlasmoid(plasmascript.Applet):
  def __init__(self, parent, args=None):
    plasmascript.Applet.__init__(self, parent)
                                              
  def init(self):                             
    self.setHasConfigurationInterface(False)  
    self.theme = Plasma.Svg(self)             
    self.theme.setImagePath('widgets/background')
    self.setBackgroundHints(Plasma.Applet.DefaultBackground)
    self.setAspectRatioMode(Plasma.KeepAspectRatio)         
                                                            
    ff = self.formFactor()                                  
    layout = Qt.Vertical if ff is Plasma.Vertical else Qt.Horizontal
    self.layout = QGraphicsLinearLayout(layout, self.applet)        
    self.layout.setContentsMargins(0,0,0,0)                         
    self.setMinimumSize(10,10)                                      

    #Check if our /sys/... folder exists. This is a pretty good indicator of support                                                                            
    if not os.path.exists(sysfolder):                                           
      msg = i18n('%s doesn\'t seem to exist\n, is the eeepc_laptop module loaded?' % sysfolder)                                                                 
      label = Plasma.Label(self.applet)                                         
      label.setText(msg)                                                        
      self.layout.addItem(label)                                                
    else:                                                                       
      self.setLayout(self.layout)                                               
                                                                                
      self.cardr = eeeSysScript(self.applet, '%s/acpi-eeepc-generic-toggle-cardreader.sh' % (scriptfolder),                                                     
'cardr','media-flash-sd-mmc', 'Card Reader')                                    
      self.camera = eeeSysScript(self.applet, '%s/acpi-eeepc-generic-toggle-webcam.sh' % (scriptfolder), 'camera', 'camera-web', 'Webcam')                      
      self.wlan = eeeRfScript(self.applet, '%s/acpi-eeepc-generic-toggle-wifi.sh' % (scriptfolder), 'rfkill0', 'network-wireless', 'Wireless')                  
      self.bt = eeeRfScript(self.applet, '%s/acpi-eeepc-generic-toggle-bluetooth.sh' % (scriptfolder), 'rfkill1', 'preferences-system-bluetooth', 'Bluetooth')  
      self.scripts = [self.cardr, self.camera, self.wlan, self.bt]              

      for script in self.scripts:
        self.layout.addItem(script.widget)
        QObject.connect(script.widget, SIGNAL('clicked()'), script.toggle)
        #Refresh icons every 5s
        timer = QTimer(self)
        QObject.connect(timer, SIGNAL('timeout()'), self.refreshAll)
        timer.start(5000)
      self.refreshAll()

  def refreshAll(self):
    for script in self.scripts:
      script.checkEnabled()
      script.updateDisplay()

def CreateApplet(parent):
    return EeePlasmoid(parent)

Offline

Board footer

Powered by FluxBB