@ -37,6 +37,7 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
self . _exec = None
self . _active = False
self . _time = json . loads ( self . load_settings ( ) ) [ ' time ' ]
self . _prev_status = 0
def close ( self ) :
self . stop ( )
@ -54,8 +55,10 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
def save ( self ) :
self . save_settings ( ' { " time " : ' + str ( self . _time ) + ' } ' )
def change_status ( self ) :
invoke_in_main_thread ( self . _profile . set_status , 1 )
def change_status ( self , status = 1 ) :
if self . _profile . status != 1 :
self . _prev_status = self . _profile . status
invoke_in_main_thread ( self . _profile . set_status , status )
def get_window ( self ) :
inst = self
@ -66,15 +69,15 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
self . setGeometry ( QtCore . QRect ( 450 , 300 , 350 , 100 ) )
self . label = QtGui . QLabel ( self )
self . label . setGeometry ( QtCore . QRect ( 20 , 0 , 310 , 35 ) )
self . label . setText ( QtGui . QApplication . translate ( " AutoAwayStatus Windows " , " Auto away time in minutes \n (0 - to disable) " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . label . setText ( QtGui . QApplication . translate ( " AutoAwayStatus Linux " , " Auto away time in minutes \n (0 - to disable) " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . time = QtGui . QLineEdit ( self )
self . time . setGeometry ( QtCore . QRect ( 20 , 40 , 310 , 25 ) )
self . time . setText ( str ( inst . _time ) )
self . setWindowTitle ( " AutoAwayStatus Windows " )
self . setWindowTitle ( " AutoAwayStatus Linux " )
self . ok = QtGui . QPushButton ( self )
self . ok . setGeometry ( QtCore . QRect ( 20 , 70 , 310 , 25 ) )
self . ok . setText (
QtGui . QApplication . translate ( " AutoAwayStatus Windows " , " Save " , None , QtGui . QApplication . UnicodeUTF8 ) )
QtGui . QApplication . translate ( " AutoAwayStatus Linux " , " Save " , None , QtGui . QApplication . UnicodeUTF8 ) )
self . ok . clicked . connect ( self . update )
def update ( self ) :
@ -91,8 +94,11 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
def loop ( self ) :
self . _active = True
while self . _exec :
time . sleep ( 30 )
time . sleep ( 5 )
d = check_output ( [ ' xprintidle ' ] )
d = int ( d ) / / 1000
if self . _time and d > 60 * self . _time :
self . change_status ( )
if self . _time :
if d > 60 * self . _time :
self . change_status ( )
elif self . _profile . status == 1 :
self . change_status ( self . _prev_status )