This commit is contained in:
Adolfo Gómez García 2018-11-26 13:44:48 +01:00
parent eb6065b203
commit 906824cafc
2 changed files with 14 additions and 8 deletions

View File

@ -57,7 +57,7 @@ doLogoff = False
def sigTerm(sigNo, stackFrame):
if trayIcon:
trayIcon.quit()
trayIcon.quit(extra=" (by sigterm)")
# About dialog

View File

@ -208,14 +208,20 @@ def initIdleDuration(atLeastSeconds):
def getIdleDuration():
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo)
if ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lastInputInfo)) == 0:
try:
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo)
if ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lastInputInfo)) == 0:
return 0
if lastInputInfo.dwTime > 1000000000: # Value toooo high, nonsense...
return 0
millis = ctypes.windll.kernel32.GetTickCount() - lastInputInfo.dwTime # @UndefinedVariable
if millis < 0:
return 0
return millis / 1000.0
except Exception as e:
logger.error('Getting idle duration: {}'.format(e))
return 0
if lastInputInfo.dwTime > 1000000000: # Value toooo high, nonsense...
return 0
millis = ctypes.windll.kernel32.GetTickCount() - lastInputInfo.dwTime # @UndefinedVariable
return millis / 1000.0
def getCurrentUser():