Suspend and Wake
#1
Hi,
i noticed that everytime i wake up my Pc (windows) from sleep mode XBMC re-scan my library. This means that exist an event that catch this situation: i need to write a very simple addon that everytime my PC wake up launches an external application (.exe).
Can someone helps me?
Reply
#2
Isn't that a function of your operating system rather than of an application such as XBMC? It may be more fruitful to Google for a generic Windows solution. This is not an uncommon requirement (do something upon resume from sleep), so you should find plenty of hits.
Reply
#3
For an example check the code of my addon. Below are the interesting bits:


PHP Code:
RESUME_TIMEOUT // in seconds if I recall correctly
SLEEP_TIME 1000 // milliseconds


        
resume_watchdog_time time.time()
        
# run until XBMC quits
        
while(not xbmc.abortRequested):

            if 
use_resume_watchdog:
                if (
time.time() - resume_watchdog_time) > RESUME_TIMEOUT:
                        
self.log("System resuming after suspend; logging out.")
                        
// do whatever you want to after resuming here

                
resume_watchdog_time time.time()

            if 
not xbmc.abortRequested:
                
xbmc.sleep(SLEEP_TIME)

        
self.log('Preparing to exit'

Basically what I do is keep track of time in a loop. If this loop takes longer than RESUME_TIMEOUT then I assume that the computer has been suspended for a while and just resumed. Not 100% safe (if the computer suspends again between the "if (time.time() - resume_watchdog_time) > RESUME_TIMEOUT:" and "resume_watchdog_time = time.time()" lines then you won't notice the suspended state), but good enough for me.
Reply

Logout Mark Read Team Forum Stats Members Help
Suspend and Wake0