auto away status update
This commit is contained in:
parent
5002dbe33f
commit
7708ce1d24
4 changed files with 31 additions and 17 deletions
|
@ -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("AutoAwayStatusWindows", "Auto away time in minutes\n(0 - to disable)", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("AutoAwayStatusLinux", "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("AutoAwayStatusWindows")
|
||||
self.setWindowTitle("AutoAwayStatusLinux")
|
||||
self.ok = QtGui.QPushButton(self)
|
||||
self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25))
|
||||
self.ok.setText(
|
||||
QtGui.QApplication.translate("AutoAwayStatusWindows", "Save", None, QtGui.QApplication.UnicodeUTF8))
|
||||
QtGui.QApplication.translate("AutoAwayStatusLinux", "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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Required: xprintidle (sudo apt-get install )
|
||||
Required package: xprintidle (sudo apt-get install xprintidle)
|
||||
|
|
|
@ -49,6 +49,7 @@ class AutoAwayStatusWindows(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()
|
||||
|
@ -66,8 +67,10 @@ class AutoAwayStatusWindows(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
|
||||
|
@ -103,7 +106,10 @@ class AutoAwayStatusWindows(plugin_super_class.PluginSuperClass):
|
|||
def loop(self):
|
||||
self._active = True
|
||||
while self._exec:
|
||||
time.sleep(30)
|
||||
time.sleep(5)
|
||||
d = get_idle_duration()
|
||||
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)
|
||||
|
|
|
@ -8,8 +8,10 @@ For more info visit [plugins.md](https://github.com/xveduk/toxygen/blob/master/d
|
|||
|
||||
- ToxId - share your Tox ID and copy friend's Tox ID easily.
|
||||
- MarqueeStatus - create ticker from your status message.
|
||||
- BirthDay - get notifications on your friends' birthdays
|
||||
- Bot - bot which can communicate with your friends when you are away
|
||||
- SearchPlugin - select text in message and find it in search engine
|
||||
- BirthDay - get notifications on your friends' birthdays.
|
||||
- Bot - bot which can communicate with your friends when you are away.
|
||||
- SearchPlugin - select text in message and find it in search engine.
|
||||
- AutoAwayStatusLinux - sets "Away" status when user is inactive (Linux only).
|
||||
- AutoAwayStatusWindows - sets "Away" status when user is inactive (Windows only).
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue