Exemplo n.º 1
0
 def init(self):
     self.iconStopped = KIcon(ICON_STOPPED)
     self.iconRunning = KIcon(ICON_RUNNING)
     self.setHasConfigurationInterface(True)
     self.process = KProcess()
     self.dontStart = False
     self.restart = False
     # Set size of Plasmoid
     self.resize(100, 100)
     self.setMinimumSize(10, 10)
     self.setAspectRatioMode(Plasma.KeepAspectRatio)
     self.setBackgroundHints(Plasma.Applet.DefaultBackground)
     self.theme = Plasma.Svg(self)
     self.theme.setImagePath(THEME)
     self.button = Plasma.IconWidget(self.parent)
     self.button.setIcon(self.iconStopped)
     self.layout = QGraphicsGridLayout(self.applet)
     self.layout.setContentsMargins(0, 0, 0, 0)
     self.layout.addItem(self.button, 0, 0)
     # Set the tooltip
     self.tooltip = Plasma.ToolTipContent()
     self.tooltip.setMainText(i18n("Redshift"))
     self.tooltip.setSubText(i18n("Click to toggle it on"))
     self.tooltip.setImage(self.iconStopped)
     Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
     # Connect signals and slots
     self.button.clicked.connect(self.toggle)
     self.appletDestroyed.connect(self.destroy)
     self.process.finished.connect(self.toggle)
     # Load configuration
     self.configChanged()
     # Set the default latitude and longitude values in the
     # configuration file, so that the config dialog can read them
     if not (self.latitude or self.longitude):
         self.latitude = KSystemTimeZones.local().latitude()
         self.longitude = KSystemTimeZones.local().longitude()
         cfgGeneral = self.config().group("General")
         cfgGeneral.writeEntry("latitude", self.latitude)
         cfgGeneral.writeEntry("longitude", self.longitude)
     # Autolaunch
     if self.autolaunch:
         print ("Autostarting Redshift")
         self.toggle()
Exemplo n.º 2
0
'''f.lux executable'''
FLUX = 'xflux'
'''Redshift executable'''
REDSHIFT = 'redshift'
'''Refresh (check if running) rate, in ms'''
REFRESH = 1000
'''Default night temp'''
DEFAULT_NIGHT = 3700
'''Default day temp'''
DEFAULT_DAY = 5500
'''Default Redshift mode'''
DEFAULT_MODE = 'randr'
'''Default program'''
DEFAULT_PROGRAM = 'Redshift'
'''Get latitude and longitude from KDE and set them as default'''
DEFAULT_LATITUDE = KSystemTimeZones.local().latitude()
DEFAULT_LONGITUDE = KSystemTimeZones.local().longitude()

#Plasmoid gained by inheritance
class FluxApplet(plasmascript.Applet):

	#constructor
	def __init__(self, parent, args=None):
		plasmascript.Applet.__init__(self, parent)
		self.parent = parent

	#done once when initiating
	def init(self):
		self.button = Plasma.IconWidget(self.parent)
		self.iconStopped = KIcon(ICON_STOPPED)
		self.iconRunning = KIcon(ICON_RUNNING)