smaller cleanup, optimization and clarified in the source why the reenter-standby...
[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 my_global_session = None
12
13 def timeout():
14         print "[StartupToStandby] Timeout, Open Standby Screen"
15         my_global_session.open(Standby)
16
17 timer = eTimer()
18 timer.callback.append(timeout)
19
20 def main(session, **kwargs):
21         print "[StartupToStandby] Open Config Screen"
22         session.open(StartupToStandbyConfiguration)
23
24 # sessionstart
25 def sessionstart(reason, session = None):
26         print "[StartupToStandby] autostart"
27         if config.plugins.startuptostandby.enabled.value and reason == 0:
28                 global my_global_session
29                 my_global_session = session
30                 my_global_session.open(Standby)
31                 # wait 10 seconds before setting standby again -
32                 # bad hack so we do not only have a blank screen but are actually in standby...
33                 print "[StartupToStandby] start timer..."
34                 timer.startLongTimer(10)
35
36 def Plugins(path, **kwargs):
37         return [PluginDescriptor(name="StartupToStandby", description="Startup To Standby", where = PluginDescriptor.WHERE_PLUGINMENU,fnc = main),
38                         PluginDescriptor(name="StartupToStandby", description = "Startup To Standby", where = PluginDescriptor.WHERE_SESSIONSTART,fnc = sessionstart)]
39