From 70759a2115ea2a3f4033884134e53f47572216c9 Mon Sep 17 00:00:00 2001 From: Gobinath Date: Tue, 17 Oct 2017 14:50:57 -0400 Subject: [PATCH] Add option to interpret system idle as break --- .gitignore | 2 +- README.md | 2 +- safeeyes/PluginManager.py | 8 +- safeeyes/SafeEyes.py | 4 +- safeeyes/SafeEyesCore.py | 8 +- .../config/locale/ca/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/cs/LC_MESSAGES/safeeyes.po | 11 +- .../config/locale/de/LC_MESSAGES/safeeyes.po | 8 +- .../locale/en_US/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/es/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/et/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/fa/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/fr/LC_MESSAGES/safeeyes.po | 11 +- .../config/locale/hi/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/hu/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/id/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/it/LC_MESSAGES/safeeyes.po | 11 +- .../config/locale/mk/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/nl/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/pl/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/pt/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/ru/LC_MESSAGES/safeeyes.po | 12 +- safeeyes/config/locale/safeeyes.pot | 381 ++++++++++++++++++ .../config/locale/sk/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/ta/LC_MESSAGES/safeeyes.po | 16 +- .../config/locale/tr/LC_MESSAGES/safeeyes.po | 8 +- .../config/locale/uk/LC_MESSAGES/safeeyes.po | 12 +- .../config/locale/vi/LC_MESSAGES/safeeyes.po | 8 +- .../locale/zh_CN/LC_MESSAGES/safeeyes.po | 12 +- safeeyes/plugins/smartpause/config.json | 10 +- safeeyes/plugins/smartpause/plugin.py | 16 +- safeeyes/plugins/trayicon/plugin.py | 4 +- 32 files changed, 576 insertions(+), 72 deletions(-) create mode 100644 safeeyes/config/locale/safeeyes.pot diff --git a/.gitignore b/.gitignore index 0afef64..9641228 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,7 @@ coverage.xml # Translations *.mo -*.pot +# *.pot # Django stuff: *.log diff --git a/README.md b/README.md index d7e525e..e44cffc 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ def disable(): """ pass -def update_next_break(date_time): +def update_next_break(break_obj, next_break_time): """ Update the next break time. """ diff --git a/safeeyes/PluginManager.py b/safeeyes/PluginManager.py index 89a8976..0942101 100644 --- a/safeeyes/PluginManager.py +++ b/safeeyes/PluginManager.py @@ -154,12 +154,12 @@ class PluginManager(object): if self.last_break.plugin_enabled(plugin['id'], plugin['enabled']): plugin['module'].on_countdown(countdown, seconds) - def update_next_break(self, break_time): + def update_next_break(self, break_obj, break_time): """ Execute the update_next_break(break_time) function of plugins. """ for plugin in self.__plugins_update_next_break: - plugin['module'].update_next_break(break_time) + plugin['module'].update_next_break(break_obj, break_time) return True def get_break_screen_widgets(self, break_obj): @@ -266,7 +266,7 @@ class PluginManager(object): self.__plugins_on_stop.append(plugin_obj) if self.__has_method(module, 'on_exit'): self.__plugins_on_exit.append(plugin_obj) - if self.__has_method(module, 'update_next_break', 1): + if self.__has_method(module, 'update_next_break', 2): self.__plugins_update_next_break.append(plugin_obj) else: # This is the first time to load the plugin @@ -288,7 +288,7 @@ class PluginManager(object): self.__plugins_on_stop.append(plugin_obj) if self.__has_method(module, 'on_exit'): self.__plugins_on_exit.append(plugin_obj) - if self.__has_method(module, 'update_next_break', 1): + if self.__has_method(module, 'update_next_break', 2): self.__plugins_update_next_break.append(plugin_obj) if self.__has_method(module, 'init', 3): self.__plugins_on_init.append(plugin_obj) diff --git a/safeeyes/SafeEyes.py b/safeeyes/SafeEyes.py index 712ad8f..85a0b36 100644 --- a/safeeyes/SafeEyes.py +++ b/safeeyes/SafeEyes.py @@ -237,11 +237,11 @@ class SafeEyes(object): self.plugins_manager.countdown(countdown, seconds) return True - def update_next_break(self, break_time): + def update_next_break(self, break_obj, break_time): """ Update the next break to plugins and save the session. """ - self.plugins_manager.update_next_break(break_time) + self.plugins_manager.update_next_break(break_obj, break_time) if self.config.get('persist_state'): Utility.write_json(Utility.SESSION_FILE_PATH, self.context['session']) diff --git a/safeeyes/SafeEyesCore.py b/safeeyes/SafeEyesCore.py index 084775f..3517681 100644 --- a/safeeyes/SafeEyesCore.py +++ b/safeeyes/SafeEyesCore.py @@ -199,7 +199,7 @@ class SafeEyesCore(object): self.scheduled_next_break_time = -1 next_break_time = current_time + datetime.timedelta(seconds=time_to_wait) - self.on_update_next_break.fire(next_break_time) + Utility.execute_main_thread(self.__fire_on_update_next_break, next_break_time) if self.__is_long_break(): self.context['break_type'] = 'long' @@ -218,6 +218,12 @@ class SafeEyesCore(object): self.context['new_cycle'] = self.next_break_index == 0 Utility.execute_main_thread(self.__fire_pre_break) + def __fire_on_update_next_break(self, next_break_time): + """ + Pass the next break information to the registered listeners. + """ + self.on_update_next_break.fire(self.breaks[self.next_break_index], next_break_time) + def __fire_pre_break(self): """ Show the notification and start the break after the notification. diff --git a/safeeyes/config/locale/ca/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/ca/LC_MESSAGES/safeeyes.po index f6807a2..15c2027 100644 --- a/safeeyes/config/locale/ca/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/ca/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-08 12:42+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Catalan \n" +"Language-Team: Catalan \n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/cs/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/cs/LC_MESSAGES/safeeyes.po index a344617..f0dab37 100644 --- a/safeeyes/config/locale/cs/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/cs/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-08 12:42+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Czech \n" +"Language-Team: Czech \n" "Language: cs\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -218,7 +218,8 @@ msgstr "Prosím nainstalujte si nástroj pro příkazový řádek'%s'" # Settings dialog msgid "Please add the resource %(resource)s to %(config_resource)s directory" -msgstr "Prosím přidejte prostředek %(resource)s do adresáře %(config_resource)s" +msgstr "" +"Prosím přidejte prostředek %(resource)s do adresáře %(config_resource)s" # Settings dialog msgid "New Break" @@ -316,6 +317,10 @@ msgstr "Pozastavit Safe Eyes když je systém v klidu" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Minimální čas v klidu na pozastavení Safe Eyes (v sekundách)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Systémová oblast" diff --git a/safeeyes/config/locale/de/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/de/LC_MESSAGES/safeeyes.po index 3715d69..f4c0bb1 100644 --- a/safeeyes/config/locale/de/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/de/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: German \n" +"Language-Team: German \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/en_US/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/en_US/LC_MESSAGES/safeeyes.po index 133363b..b61e968 100644 --- a/safeeyes/config/locale/en_US/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/en_US/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: 2017-09-17 07:59-0400\n" "PO-Revision-Date: 2017-10-08 12:42+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: English (United States) \n" +"Language-Team: English (United States) \n" "Language: en_US\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "Pause Safe Eyes if the system is idle" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Minimum idle time to pause Safe Eyes (in seconds)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Tray Icon" diff --git a/safeeyes/config/locale/es/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/es/LC_MESSAGES/safeeyes.po index 87c8a56..f2797e6 100644 --- a/safeeyes/config/locale/es/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/es/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-14 02:28+0000\n" "Last-Translator: Julio González \n" -"Language-Team: Spanish \n" +"Language-Team: Spanish \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/et/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/et/LC_MESSAGES/safeeyes.po index 1a04800..5a896e2 100644 --- a/safeeyes/config/locale/et/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/et/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Estonian \n" +"Language-Team: Estonian \n" "Language: et\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/fa/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/fa/LC_MESSAGES/safeeyes.po index f9c6ba5..c6eb29b 100644 --- a/safeeyes/config/locale/fa/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/fa/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Persian \n" +"Language-Team: Persian \n" "Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/fr/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/fr/LC_MESSAGES/safeeyes.po index de3e881..b89c239 100644 --- a/safeeyes/config/locale/fr/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/fr/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: French \n" +"Language-Team: French \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -320,7 +320,12 @@ msgstr "Mettre Safe Eyes en pause si le système est inactif" # plugin/smartpause msgid "Minimum idle time to pause Safe Eyes (in seconds)" -msgstr "Durée d'inactivité minimale pour mettre Safe Eyes en pause (en secondes)" +msgstr "" +"Durée d'inactivité minimale pour mettre Safe Eyes en pause (en secondes)" + +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" #: plugins/trayicon msgid "Tray Icon" diff --git a/safeeyes/config/locale/hi/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/hi/LC_MESSAGES/safeeyes.po index deb6dc0..ca76b2d 100644 --- a/safeeyes/config/locale/hi/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/hi/LC_MESSAGES/safeeyes.po @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: \n" +"Last-Translator: \n" "Language-Team: \n" +"Language: hi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.7.1\n" -"Last-Translator: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"Language: hi\n" # Short break msgid "Tightly close your eyes" @@ -313,6 +313,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/hu/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/hu/LC_MESSAGES/safeeyes.po index 56dca4f..925a6f1 100644 --- a/safeeyes/config/locale/hu/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/hu/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-16 11:08+0000\n" "Last-Translator: András Soltész \n" -"Language-Team: Hungarian \n" +"Language-Team: Hungarian \n" "Language: hu\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -315,6 +315,10 @@ msgstr "Safe Eyes felfüggesztése ha a rendszer üresjáratban van" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Minimális üresjárati idő a Safe Eyes felfüggesztéséhez (mp)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Tálca Ikon" diff --git a/safeeyes/config/locale/id/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/id/LC_MESSAGES/safeeyes.po index 750ce5c..9083f1e 100644 --- a/safeeyes/config/locale/id/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/id/LC_MESSAGES/safeeyes.po @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: \n" +"Last-Translator: \n" "Language-Team: \n" +"Language: id\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.7.1\n" -"Last-Translator: \n" "Plural-Forms: nplurals=1; plural=0;\n" -"Language: id\n" # Short break msgid "Tightly close your eyes" @@ -313,6 +313,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/it/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/it/LC_MESSAGES/safeeyes.po index cd28fc9..a02d63d 100644 --- a/safeeyes/config/locale/it/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/it/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-10 17:46+0000\n" "Last-Translator: Guglielmo Wilmup \n" -"Language-Team: Italian \n" +"Language-Team: Italian \n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -115,7 +115,8 @@ msgstr "Tempo prima di una pausa (in secondi)" # Settings dialog msgid "Keyboard shortcuts disabled period (in seconds)" -msgstr "Durata della disattivazione per le scorciatoie da tastiera (in secondi)" +msgstr "" +"Durata della disattivazione per le scorciatoie da tastiera (in secondi)" # Settings dialog msgid "Postpone duration (in minutes)" @@ -321,6 +322,10 @@ msgstr "Sospendi Safe Eyes quando il sistema è inattivo" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Tempo minimo di inattività per mettere in pausa Safe Eyes (in secondi)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Icona" diff --git a/safeeyes/config/locale/mk/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/mk/LC_MESSAGES/safeeyes.po index a842fbe..a438041 100644 --- a/safeeyes/config/locale/mk/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/mk/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Macedonian \n" +"Language-Team: Macedonian \n" "Language: mk\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/nl/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/nl/LC_MESSAGES/safeeyes.po index a7815bd..cb5d800 100644 --- a/safeeyes/config/locale/nl/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/nl/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Dutch \n" +"Language-Team: Dutch \n" "Language: nl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/pl/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/pl/LC_MESSAGES/safeeyes.po index cf7aa28..ac95fa6 100644 --- a/safeeyes/config/locale/pl/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/pl/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-16 11:08+0000\n" "Last-Translator: Daria Szatan \n" -"Language-Team: Polish \n" +"Language-Team: Polish \n" "Language: pl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "Zatrzymaj Safe Eyes podczas bezczynności" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Minimalny czas bezczynności (w sekundach)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Ikona w zasobniku" diff --git a/safeeyes/config/locale/pt/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/pt/LC_MESSAGES/safeeyes.po index dc8f544..60681fb 100644 --- a/safeeyes/config/locale/pt/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/pt/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Portuguese \n" +"Language-Team: Portuguese \n" "Language: pt\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/ru/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/ru/LC_MESSAGES/safeeyes.po index 1a1389a..1533a0e 100644 --- a/safeeyes/config/locale/ru/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/ru/LC_MESSAGES/safeeyes.po @@ -8,14 +8,14 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Duncan \n" -"Language-Team: Russian \n" +"Language-Team: Russian \n" "Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=" -"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Generator: Weblate 2.17\n" # Short break @@ -315,6 +315,10 @@ msgstr "Приостановить Safe Eyes, если система прост msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Минимальное время простоя для приостановки Safe Eyes (в секундах)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Иконка в трее" diff --git a/safeeyes/config/locale/safeeyes.pot b/safeeyes/config/locale/safeeyes.pot new file mode 100644 index 0000000..95eabf7 --- /dev/null +++ b/safeeyes/config/locale/safeeyes.pot @@ -0,0 +1,381 @@ +# SAFE EYES ENGLISH TRANSLATION. +# Copyright (C) 2017 Gobinath +# Gobinath slgobinath@gmail.com, 2017. +# +msgid "" +msgstr "" + +# Short break +msgid "Tightly close your eyes" +msgstr "" + +# Short break +msgid "Roll your eyes a few times to each side" +msgstr "" + +# Short break +msgid "Rotate your eyes in clockwise direction" +msgstr "" + +# Short break +msgid "Rotate your eyes in counterclockwise direction" +msgstr "" + +# Short break +msgid "Blink your eyes" +msgstr "" + +# Short break +msgid "Focus on a point in the far distance" +msgstr "" + +# Short break +msgid "Have some water" +msgstr "" + +# Long break +msgid "Walk for a while" +msgstr "" + +# Long break +msgid "Lean back at your seat and relax" +msgstr "" + +# Commandline arg description +msgid "show the about dialog" +msgstr "" + +# Commandline arg description +msgid "disable the currently running safeeyes instance" +msgstr "" + +# Commandline arg description +msgid "enable the currently running safeeyes instance" +msgstr "" + +# Commandline arg description +msgid "quit the running safeeyes instance and exit" +msgstr "" + +# Commandline arg description +msgid "show the settings dialog" +msgstr "" + +# Commandline arg description +msgid "start safeeyes in debug mode" +msgstr "" + +# About dialog +msgid "Close" +msgstr "" + +# Description in about dialog +# Safe Eyes protects your eyes from eye strain (asthenopia) by reminding you to take breaks while you're working long hours at the computer +msgid "description" +msgstr "" + +# About dialog +msgid "License" +msgstr "" + +# Break screen +msgid "Skip" +msgstr "" + +# Break screen +msgid "Postpone" +msgstr "" + +# Settings dialog +msgid "Break duration (in seconds)" +msgstr "" + +# Settings dialog +msgid "Interval between two breaks (in minutes)" +msgstr "" + +# Settings dialog +msgid "Time to prepare for a break (in seconds)" +msgstr "" + +# Settings dialog +msgid "Keyboard shortcuts disabled period (in seconds)" +msgstr "" + +# Settings dialog +msgid "Postpone duration (in minutes)" +msgstr "" + +# Settings dialog +msgid "Strict break (No way to skip breaks)" +msgstr "" + +# Settings dialog +msgid "Allow postponing breaks" +msgstr "" + +# Settings dialog +msgid "Persist the internal state" +msgstr "" + +# Settings dialog +msgid "Long break interval must be a multiple of short break interval" +msgstr "" + +# Settings dialog +msgid "Options" +msgstr "" + +# Settings dialog +msgid "Short Breaks" +msgstr "" + +# Settings dialog +msgid "Long Breaks" +msgstr "" + +# Settings dialog +msgid "Break" +msgstr "" + +# Settings dialog +msgid "Breaks" +msgstr "" + +# Settings dialog +msgid "Plugins" +msgstr "" + +# Settings dialog +msgid "Type" +msgstr "" + +# Settings dialog +msgid "Short" +msgstr "" + +# Settings dialog +msgid "Long" +msgstr "" + +# Settings dialog +msgid "Image" +msgstr "" + +# Settings dialog +msgid "Select" +msgstr "" + +# Settings dialog +msgid "Please select an image" +msgstr "" + +# Settings dialog +msgid "Duration" +msgstr "" + +# Settings dialog +msgid "Override" +msgstr "" + +# Settings dialog +msgid "Time (in seconds)" +msgstr "" + +# Settings dialog +msgid "Break Settings" +msgstr "" + +# Settings dialog +msgid "Plugin Settings" +msgstr "" + +# Settings dialog +msgid "Plugin does not support %s desktop environment" +msgstr "" + +# Settings dialog +msgid "Please install the Python module '%s'" +msgstr "" + +# Settings dialog +msgid "Please install the command-line tool '%s'" +msgstr "" + +# Settings dialog +msgid "Please add the resource %(resource)s to %(config_resource)s directory" +msgstr "" + +# Settings dialog +msgid "New Break" +msgstr "" + +# Settings dialog +msgid "Remove" +msgstr "" + +# Settings dialog +msgid "Discard" +msgstr "" + +# Settings dialog +msgid "Save" +msgstr "" + +# plugin/audiblealert +msgid "Audible Alert" +msgstr "" + +# plugin/audiblealert +msgid "Play an audible alert at the end of breaks" +msgstr "" + +# plugin/donotdisturb +msgid "Do Not Disturb" +msgstr "" + +# plugin/donotdisturb +msgid "Skip the break if the active window is in fullscreen mode" +msgstr "" + +# plugin/donotdisturb +msgid "Do not interrupt these windows anytime" +msgstr "" + +# plugin/donotdisturb +msgid "Interrupt these windows regardless of their state" +msgstr "" + +# plugin/donotdisturb +msgid "Switch the interruptible windows to normal mode" +msgstr "" + +# plugin/healthstats +msgid "Health Statistics" +msgstr "" + +# plugin/healthstats +msgid "Show statistics based on how you use Safe Eyes" +msgstr "" + +# plugin/notification +msgid "Notification" +msgstr "" + +# plugin/notification +msgid "Show a system notification before breaks" +msgstr "" + +# plugin/notification +msgid "Ready for a short break in %s seconds" +msgstr "" + +# plugin/notification +msgid "Ready for a long break in %s seconds" +msgstr "" + +# plugin/screensaver +msgid "Screensaver" +msgstr "" + +# plugin/screensaver +msgid "Lock the screen after long breaks by starting screensaver" +msgstr "" + +# plugin/screensaver +msgid "Custom screensaver command" +msgstr "" + +# plugin/screensaver +msgid "Minimum seconds to skip without screensaver" +msgstr "" + +# plugin/smartpause +msgid "Smart Pause" +msgstr "" + +# plugin/smartpause +msgid "Pause Safe Eyes if the system is idle" +msgstr "" + +# plugin/smartpause +msgid "Minimum idle time to pause Safe Eyes (in seconds)" +msgstr "" + +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + +#: plugins/trayicon +msgid "Tray Icon" +msgstr "" + +#: plugins/trayicon +msgid "Show a tray icon in the notification area" +msgstr "" + +#: plugins/trayicon +msgid "Show next break time in tray icon" +msgstr "" + +#: plugins/trayicon +msgid "About" +msgstr "" + +#: plugins/trayicon +msgid "Disable Safe Eyes" +msgstr "" + +#: plugins/trayicon +msgid "Disabled until %s" +msgstr "" + +#: plugins/trayicon +msgid "Disabled until restart" +msgstr "" + +#: plugins/trayicon +msgid "Enable Safe Eyes" +msgstr "" + +#: plugins/trayicon +msgid "For %d Hour" +msgid_plural "For %d Hours" +msgstr[0] "" +msgstr[1] "" + +#: plugins/trayicon +msgid "For %d Minute" +msgid_plural "For %d Minutes" +msgstr[0] "" +msgstr[1] "" + +#: plugins/trayicon +msgid "For %d Second" +msgid_plural "For %d Seconds" +msgstr[0] "" +msgstr[1] "" + +#: plugins/trayicon +msgid "Next break at %s" +msgstr "" + +#: plugins/trayicon +msgid "No Breaks Available" +msgstr "" + +#: plugins/trayicon +msgid "Settings" +msgstr "" + +#: plugins/trayicon +msgid "Take a break now" +msgstr "" + +#: plugins/trayicon +msgid "Until restart" +msgstr "" + +#: plugins/trayicon +msgid "Quit" +msgstr "" diff --git a/safeeyes/config/locale/sk/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/sk/LC_MESSAGES/safeeyes.po index df0094a..4d9e5d7 100644 --- a/safeeyes/config/locale/sk/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/sk/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Slovak \n" +"Language-Team: Slovak \n" "Language: sk\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/ta/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/ta/LC_MESSAGES/safeeyes.po index fe930bc..fbf9844 100644 --- a/safeeyes/config/locale/ta/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/ta/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: 2017-09-17 07:59-0400\n" "PO-Revision-Date: 2017-10-08 12:42+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Tamil \n" +"Language-Team: Tamil \n" "Language: ta\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -86,8 +86,8 @@ msgstr "மூடு" # Safe Eyes protects your eyes from eye strain (asthenopia) by reminding you to take breaks while you're working long hours at the computer msgid "description" msgstr "" -"அடிக்கடி ஓய்வெடுக்க அறிவுறுத்துவதன் மூலம் Safe Eyes கணனியில் நீண்ட நேரம் " -"பணியாற்றுவதால் ஏற்படும் கண் சோர்வை தடுக்கிறது" +"அடிக்கடி ஓய்வெடுக்க அறிவுறுத்துவதன் மூலம் Safe Eyes கணனியில் நீண்ட நேரம் பணியாற்றுவதால் " +"ஏற்படும் கண் சோர்வை தடுக்கிறது" # About dialog msgid "License" @@ -135,7 +135,9 @@ msgstr "உள்ளக நிலையை தக்கவைத்து கொ # Settings dialog msgid "Long break interval must be a multiple of short break interval" -msgstr "நீண்ட இடைவேளைகளுக்கிடையிலான நேரம் குறுகிய இடைவேளைகளுக்கிடையிலான நேரத்தின் மடங்காக இருக்க வேண்டும்" +msgstr "" +"நீண்ட இடைவேளைகளுக்கிடையிலான நேரம் குறுகிய இடைவேளைகளுக்கிடையிலான நேரத்தின் மடங்காக " +"இருக்க வேண்டும்" # Settings dialog msgid "Options" @@ -317,6 +319,10 @@ msgstr "கணினி செயலற்று இருந்தால் Saf msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "Safe Eyesஐ இடைநிறுத்துவதற்கான குறைந்தபட்ச செயலற்ற நேரம் (விநாடிகளில்)" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "Safe Eyes சின்னம்" diff --git a/safeeyes/config/locale/tr/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/tr/LC_MESSAGES/safeeyes.po index 065fb91..49f8259 100644 --- a/safeeyes/config/locale/tr/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/tr/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Turkish \n" +"Language-Team: Turkish \n" "Language: tr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,6 +317,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/uk/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/uk/LC_MESSAGES/safeeyes.po index 2f70307..ba3db70 100644 --- a/safeeyes/config/locale/uk/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/uk/LC_MESSAGES/safeeyes.po @@ -8,14 +8,14 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Ukrainian \n" +"Language-Team: Ukrainian \n" "Language: uk\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=" -"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Generator: Weblate 2.17\n" # Short break @@ -317,6 +317,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/vi/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/vi/LC_MESSAGES/safeeyes.po index 55ec614..98e1605 100644 --- a/safeeyes/config/locale/vi/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/vi/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-13 17:55+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Vietnamese \n" +"Language-Team: Vietnamese \n" "Language: vi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/config/locale/zh_CN/LC_MESSAGES/safeeyes.po b/safeeyes/config/locale/zh_CN/LC_MESSAGES/safeeyes.po index a5315cc..ee33b00 100644 --- a/safeeyes/config/locale/zh_CN/LC_MESSAGES/safeeyes.po +++ b/safeeyes/config/locale/zh_CN/LC_MESSAGES/safeeyes.po @@ -8,8 +8,8 @@ msgstr "" "POT-Creation-Date: \n" "PO-Revision-Date: 2017-10-08 12:42+0000\n" "Last-Translator: Gobinath L \n" -"Language-Team: Chinese (Simplified) \n" +"Language-Team: Chinese (Simplified) \n" "Language: zh_CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -84,7 +84,9 @@ msgstr "关闭" # Description in about dialog # Safe Eyes protects your eyes from eye strain (asthenopia) by reminding you to take breaks while you're working long hours at the computer msgid "description" -msgstr "当您持续使用电脑办公太长时间时,Safe Eyes 会提醒您休息一下,通过这种方式来保护您的眼睛,使您远离视疲劳" +msgstr "" +"当您持续使用电脑办公太长时间时,Safe Eyes 会提醒您休息一下,通过这种方式来保" +"护您的眼睛,使您远离视疲劳" # About dialog msgid "License" @@ -314,6 +316,10 @@ msgstr "" msgid "Minimum idle time to pause Safe Eyes (in seconds)" msgstr "" +# plugin/smartpause +msgid "Interpret idle time equivalent to upcoming break duration as a break" +msgstr "" + #: plugins/trayicon msgid "Tray Icon" msgstr "" diff --git a/safeeyes/plugins/smartpause/config.json b/safeeyes/plugins/smartpause/config.json index e771b0f..963eac5 100644 --- a/safeeyes/plugins/smartpause/config.json +++ b/safeeyes/plugins/smartpause/config.json @@ -2,7 +2,7 @@ "meta": { "name": "Smart Pause", "description": "Pause Safe Eyes if the system is idle", - "version": "0.0.1" + "version": "0.0.2" }, "dependencies": { "python_modules": [], @@ -16,9 +16,15 @@ "id": "idle_time", "label": "Minimum idle time to pause Safe Eyes (in seconds)", "type": "INT", - "default": 180, + "default": 60, "max": 3600, "min": 5 + }, + { + "id": "interpret_idle_as_break", + "label": "Interpret idle time equivalent to upcoming break duration as a break", + "type": "BOOL", + "default": false } ] } \ No newline at end of file diff --git a/safeeyes/plugins/smartpause/plugin.py b/safeeyes/plugins/smartpause/plugin.py index 369de1c..9ed2276 100644 --- a/safeeyes/plugins/smartpause/plugin.py +++ b/safeeyes/plugins/smartpause/plugin.py @@ -38,8 +38,10 @@ disable_safe_eyes = None smart_pause_activated = False idle_start_time = None next_break_time = None +next_break_duration = 0 break_interval = 0 waiting_time = 2 +interpret_idle_as_break = False def __system_idle_time(): """ @@ -81,11 +83,13 @@ def init(ctx, safeeyes_config, plugin_config): global idle_time global break_interval global waiting_time + global interpret_idle_as_break logging.debug('Initialize Smart Pause plugin') context = ctx enable_safe_eyes = context['api']['enable_safeeyes'] disable_safe_eyes = context['api']['disable_safeeyes'] idle_time = plugin_config['idle_time'] + interpret_idle_as_break = plugin_config['interpret_idle_as_break'] break_interval = safeeyes_config.get('break_interval') * 60 # Convert to seconds waiting_time = min(2, idle_time) # If idle time is 1 sec, wait only 1 sec @@ -114,10 +118,16 @@ def __start_idle_monitor(): logging.info('Resume Safe Eyes due to user activity') smart_pause_activated = False idle_period = (datetime.datetime.now() - idle_start_time) - if idle_period.total_seconds() < break_interval: + idle_seconds = idle_period.total_seconds() + if interpret_idle_as_break and idle_seconds >= next_break_duration: + # User is idle for break duration and wants to consider it as a break + enable_safe_eyes() + elif idle_seconds < break_interval: + # Credit back the idle time next_break = next_break_time + idle_period enable_safe_eyes(next_break.timestamp()) else: + # User is idle for more than the time between two breaks enable_safe_eyes() @@ -149,9 +159,11 @@ def on_stop(): idle_condition.notify_all() idle_condition.release() -def update_next_break(dateTime): +def update_next_break(break_obj, dateTime): """ Update the next break time. """ global next_break_time + global next_break_duration next_break_time = dateTime + next_break_duration = break_obj.time diff --git a/safeeyes/plugins/trayicon/plugin.py b/safeeyes/plugins/trayicon/plugin.py index 9708f1b..43f9721 100644 --- a/safeeyes/plugins/trayicon/plugin.py +++ b/safeeyes/plugins/trayicon/plugin.py @@ -371,11 +371,11 @@ def init(ctx, safeeyes_cfg, plugin_config): tray_icon.initialize(plugin_config) -def update_next_break(dateTime): +def update_next_break(break_obj, next_break_time): """ Update the next break time. """ - tray_icon.next_break_time(dateTime) + tray_icon.next_break_time(next_break_time) def on_pre_break(break_obj):