Search
j0ke.net Open Build Service
>
Projects
>
multimedia
>
freevo
> freevo-1.8.0-shutdown_sleep.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File freevo-1.8.0-shutdown_sleep.patch of Package freevo
--- src/plugins/shutdown.py +++ src/plugins/shutdown.py @@ -36,15 +36,17 @@ import config from gui import ConfirmBox +from gui.AlertBox import AlertBox from item import Item from plugin import MainMenuPlugin -def shutdown(menuw=None, argshutdown=None, argrestart=None, exit=False): +def shutdown(menuw=None, argshutdown=None, argrestart=None, argsleep=None, exit=False): """ Function to shut down freevo or the whole system. This system will be shut down when argshutdown is True, restarted when argrestart is true, - else only Freevo will be stopped. + shutdown in 45 minues when argsleep is true, else only Freevo will + be stopped. """ _debug_('shutdown(menuw=%r, argshutdown=%r, argrestart=%r, exit=%r)' % (menuw, argshutdown, argrestart, exit), 2) import osd @@ -55,6 +57,12 @@ osd = osd.get_singleton() util.mediainfo.sync() + + if argsleep: + os.system( 'echo %s | at now + 45 minutes' % config.SHUTDOWN_SLEEP_CMD ) + AlertBox(text=_('The System will power down in 45 minutes!')).show() + return + if not osd.active: # this function is called from the signal handler, but # we are dead already. @@ -143,10 +151,12 @@ if config.SYS_SHUTDOWN_CONFIRM: items = [ (self.confirm_freevo, _('Shutdown Freevo') ), (self.confirm_system, _('Shutdown system') ), + (self.confirm_sleep, _('Start Sleep in 45m') ), (self.confirm_system_restart, _('Restart system') ) ] else: items = [ (self.shutdown_freevo, _('Shutdown Freevo') ), (self.shutdown_system, _('Shutdown system') ), + (self.shutdown_sleep, _('Sleep in 45 minutes') ), (self.shutdown_system_restart, _('Restart system') ) ] if config.SYS_SHUTDOWN_ENABLE: items = [ items[1], items[0], items[2] ] @@ -175,6 +185,15 @@ ConfirmBox(text=what, handler=self.shutdown_system, default_choice=config.SYS_SHUTDOWN_CONFIRM-1).show() + def confirm_sleep(self, arg=None, menuw=None): + """ + Pops up a ConfirmBox. + """ + _debug_('confirm_sleep(arg=%r, menuw=%r)' % (arg, menuw), 2) + self.menuw = menuw + what = _('Do you really want to start the sleep timer?') + ConfirmBox(text=what, handler=self.shutdown_sleep, + default_choice=config.SYS_SHUTDOWN_CONFIRM-1).show() def confirm_system_restart(self, arg=None, menuw=None): """ @@ -192,7 +211,7 @@ shutdown freevo, don't shutdown the system """ _debug_('shutdown_freevo(arg=%r, menuw=%r)' % (arg, menuw), 2) - shutdown(menuw=menuw, argshutdown=False, argrestart=False) + shutdown(menuw=menuw, argshutdown=False, argrestart=False, argsleep=False) def shutdown_system(self, arg=None, menuw=None): @@ -200,15 +219,21 @@ shutdown the complete system """ _debug_('shutdown_system(arg=%r, menuw=%r)' % (arg, menuw), 2) - shutdown(menuw=menuw, argshutdown=True, argrestart=False) + shutdown(menuw=menuw, argshutdown=True, argrestart=False, argsleep=False) + def shutdown_sleep(self, arg=None, menuw=None): + """ + start the sleep timer + """ + _debug_('shutdown_sleep(arg=%r, menuw=%r)' % (arg, menuw), 2) + shutdown(menuw=menuw, argshutdown=False, argrestart=False, argsleep=True) def shutdown_system_restart(self, arg=None, menuw=None): """ restart the complete system """ _debug_('shutdown_system_restart(arg=%r, menuw=%r)' % (arg, menuw), 2) - shutdown(menuw=menuw, argshutdown=False, argrestart=True) + shutdown(menuw=menuw, argshutdown=False, argrestart=True, argsleep=False) --- freevo_config.py +++ freevo_config.py @@ -437,6 +437,8 @@ SYS_RESTART_CMD = 'shutdown -r now' # like SYS_SHUTDOWN_CMD, only for reboot +SYS_SLEEP_CMD = 'shutdown -h now' # like SYS_SHUTDOWN_CMD, only for sleep + SYS_SHUTDOWN_ENABLE = 0 # Performs a whole system shutdown at SHUTDOWN! # For standalone boxes.