Problem with xbmc.getGlobalIdleTime()
#1
I'm running a logoff script with a goal of logging off the current user after x minutes of inactivity. It seems that xbmc.getGlobalIdleTime() increments when there is media playing. For example, if I start playing a movie, exactly 10 minutes into it the user is logged-off. Below is the script I'm using, followed by a debug log. I would appreciate any assistance. Thanks!

autoexec.py:

# idle time in minutes
IDLE_TIME_MIN = 10
s = 1
while s > 0:
# get idle time
it = xbmc.getGlobalIdleTime()
#calculate sleep time in msec
s = ((IDLE_TIME_MIN * 60) - it ) * 1000
# sleep
if (s > 0): xbmc.sleep(s)
# log off
xbmc.executebuiltin('System.LogOff')

Debug log:
http://pastebin.ubuntu.com/257757/
Reply
#2
Maybe check for xbmcPlayer.isPlaying() as well, and don't run logoff if so? I would guess if the user uses the keyboard / mouse it will trigger an event and reset the idle timer...
Reply
#3
Thanks for the great idea! It works!

The only problem I have now is the script executes only once since it starts when XBMC is started as opposed to when a user logs on.

Is there a way to automatically execute a script every time a user logs on? I think that is what I need here.

Thank you.
Reply
#4
I remember something about a autoexec.py, check the page below or maybe the forum threads, if that only runs when XBMC starts or when you logon as well.

http://www.xbmc.org/wiki/?title=HOW-TO_i...ts_in_XBMC
Reply

Logout Mark Read Team Forum Stats Members Help
Problem with xbmc.getGlobalIdleTime()0