Sleep timer
#1
i have an xbox in my bedroom running xbmc, and sometimes i fell asleep watching something, or wanted music while i was falling asleep. not wanting to leave my xbox on all night i created a sleep timer script.

it's the first thing i've ever written in python, and it turned out to be really simple.

Quote:import xbmc, xbmcgui
import time;

action_previous_menu = 10

dialog = xbmcgui.dialog()

list = ['cancel','15','30','45','60','90']
selected = dialog.select('sleep timer (minutes)', list)

if selected != 0:
time.sleep(60.0 * float(list[selected]))
xbmc.shutdown()

i know xbmc has a "shutdown after idle" setting, but if you're playing a long playlist i don't think it will work.
Reply
#2
hey.. nice.. iv been looking for this. gonna try it today.

ah.. worked perfectly.. great job dude Smile
I donated $40 to the XBMC project, and so should you.
Reply
#3
it's always nice to see such programs
but there was already one

this one is really much smaller   :bowdown:

i have one question
could there be an option that you could input the time
so and the 15,30,45 and an option you can input a time of youre own
Reply
#4
i wouldn't know how to do it in the gui, but you can edit the script really easily.

Quote:list = ['cancel','15','30','45','60','90']

add your options anywhere after 'cancel', since that needs to be the first option.
Reply
#5
you can use the keyboard to set your own time : (not tested)
Quote:import xbmc, xbmcgui
import time;

action_previous_menu = 10

dialog = xbmcgui.dialog()

list = ['cancel','time set','15','30','45','60','90']
selected = dialog.select('sleep timer (minutes)', list)

if selected ==1:
keyb.domodal()
if (keyb.isconfirmed()):
t=keyb.gettext()
time.sleep(60.0 * float(t))
xbmc.shutdown()

if selected >= 2:
time.sleep(60.0 * float(list[selected]))
xbmc.shutdown()

i'm not sur for "float(t)".. try it and tell us !
Reply

Logout Mark Read Team Forum Stats Members Help
Sleep timer0