Initial
[enigma2-plugins.git] / startuptostandby / src / plugin.py
1 # -*- coding: iso-8859-1 -*-
2 from Plugins.Plugin import PluginDescriptor
3 from Components.config import config, ConfigSubsection, ConfigEnableDisable
4 from Screens.Standby import Standby
5 from StartupToStandbyConfiguration import StartupToStandbyConfiguration
6 from enigma import eTimer
7
8 config.plugins.startuptostandby = ConfigSubsection()
9 config.plugins.startuptostandby.enabled = ConfigEnableDisable(default = False)
10
11
12 def __init__(self):
13         self.timer = eTimer()
14         self.session = {}       
15
16 def main(session, **kwargs):
17         print "[StartupToStandby] Open Config Screen"
18         session.open(StartupToStandbyConfiguration)
19         
20 # Autostart
21 def autostart(reason, **kwargs):
22         print "[StartupToStandby] autostart"
23         if config.plugins.startuptostandby.enabled.value and reason == 0 and kwargs.has_key("session"):
24                 session = kwargs["session"]
25                 session.open(Standby)
26                 timer = eTimer()
27                 #wait 10 seconds before setting standby again - bad hack...
28                 print "[StartupToStandby] start timer..."
29                 timer.timeout.get().append(timeout)
30                 timer.start(10000)
31                 print "[StartupToStandby] ...ready"
32
33 def timeout():
34         print "[StartupToStandby] Timeout!"
35         #standby-screen is open - close it
36         print "[StartupToStandby] Close Standby Screen"
37         session.open(Standby)
38         #and open it again...
39         print "[StartupToStandby] Open Standby Screen"
40         session.open(Standby)
41         #end timer, since we only need to do this once.
42         print "[StartupToStandby] Stop Timer"
43         timer.stop()
44                 
45 def Plugins(path, **kwargs):
46         return [PluginDescriptor(name="StartupToStandby", description="Startup To Standby", where = PluginDescriptor.WHERE_PLUGINMENU,fnc = main),
47                         PluginDescriptor(name="StartupToStandby", description = "Startup To Standby", where = PluginDescriptor.WHERE_SESSIONSTART,fnc = autostart)]
48
49