keep it simple. don't store unneeded parameters.
[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 timer = eTimer()
11 session = None
12
13 def main(session, **kwargs):
14         print "[StartupToStandby] Open Config Screen"
15         session.open(StartupToStandbyConfiguration)
16         
17 # Autostart
18 def autostart(reason, **kwargs):
19         global timer
20         global session
21
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                 #wait 10 seconds before setting standby again - bad hack...
27                 print "[StartupToStandby] start timer..."
28                 timer.timeout.get().append(timeout)
29                 timer.startLongTimer(10)
30                 print "[StartupToStandby] ...ready"
31
32 def timeout():
33         global session
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         
42         
43 def Plugins(path, **kwargs):
44         return [PluginDescriptor(name="StartupToStandby", description="Startup To Standby", where = PluginDescriptor.WHERE_PLUGINMENU,fnc = main),
45                         PluginDescriptor(name="StartupToStandby", description = "Startup To Standby", where = PluginDescriptor.WHERE_SESSIONSTART,fnc = autostart)]
46
47