Add postpone break until system becomes idle
This commit is contained in:
parent
2e52d9d664
commit
7a22adf91d
|
@ -79,13 +79,15 @@ class SafeEyes(object):
|
|||
self.plugins_manager = PluginManager(self.context, self.config)
|
||||
self.safe_eyes_core = SafeEyesCore(self.context)
|
||||
self.safe_eyes_core.on_pre_break += self.plugins_manager.pre_break
|
||||
self.safe_eyes_core.on_start_break += self.start_break
|
||||
self.safe_eyes_core.on_start_break += self.on_start_break
|
||||
self.safe_eyes_core.start_break += self.start_break
|
||||
self.safe_eyes_core.on_count_down += self.countdown
|
||||
self.safe_eyes_core.on_stop_break += self.stop_break
|
||||
self.safe_eyes_core.on_update_next_break += self.update_next_break
|
||||
self.safe_eyes_core.initialize(self.config)
|
||||
self.context['api']['take_break'] = lambda: Utility.execute_main_thread(self.safe_eyes_core.take_break)
|
||||
self.context['api']['has_breaks'] = self.safe_eyes_core.has_breaks
|
||||
self.context['api']['postpone'] = self.safe_eyes_core.postpone
|
||||
self.plugins_manager.init(self.context, self.config)
|
||||
atexit.register(self.persist_session)
|
||||
self.rpc_server = RPCServer(self.config.get('rpc_port'), self.context)
|
||||
|
@ -223,16 +225,21 @@ class SafeEyes(object):
|
|||
status = _('Disabled until restart')
|
||||
self._status = status
|
||||
|
||||
def start_break(self, break_obj):
|
||||
def on_start_break(self, break_obj):
|
||||
"""
|
||||
Pass the break information to plugins and break screen.
|
||||
Pass the break information to plugins.
|
||||
"""
|
||||
if not self.plugins_manager.start_break(break_obj):
|
||||
return False
|
||||
return True
|
||||
|
||||
def start_break(self, break_obj):
|
||||
"""
|
||||
Pass the break information to break screen.
|
||||
"""
|
||||
# Get the HTML widgets content from plugins
|
||||
widget = self.plugins_manager.get_break_screen_widgets(break_obj)
|
||||
self.break_screen.show_message(break_obj, widget)
|
||||
return True
|
||||
|
||||
def countdown(self, countdown, seconds):
|
||||
"""
|
||||
|
@ -270,7 +277,7 @@ class SafeEyes(object):
|
|||
Return the status of Safe Eyes.
|
||||
"""
|
||||
return self._status
|
||||
|
||||
|
||||
def persist_session(self):
|
||||
"""
|
||||
Save the session object to the session file.
|
||||
|
|
|
@ -47,15 +47,19 @@ class SafeEyesCore(object):
|
|||
self.long_break_duration = 0
|
||||
self.next_break_index = context['session'].get('next_break_index', 0)
|
||||
self.postpone_duration = 0
|
||||
self.default_postpone_duration = 0
|
||||
self.pre_break_warning_time = 0
|
||||
self.running = False
|
||||
self.short_break_duration = 0
|
||||
self.scheduled_next_break_time = -1
|
||||
self.scheduled_next_break_timestamp = -1
|
||||
self.scheduled_next_break_time = None
|
||||
self.paused_time = -1
|
||||
# This event is fired before <time-to-prepare> for a break
|
||||
self.on_pre_break = EventHook()
|
||||
# This event is fired at the start of a break
|
||||
# This event is fired just before the start of a break
|
||||
self.on_start_break = EventHook()
|
||||
# This event is fired at the start of a break
|
||||
self.start_break = EventHook()
|
||||
# This event is fired during every count down
|
||||
self.on_count_down = EventHook()
|
||||
# This event is fired at the end of a break
|
||||
|
@ -79,8 +83,9 @@ class SafeEyesCore(object):
|
|||
self.pre_break_warning_time = config.get('pre_break_warning_time')
|
||||
self.long_break_duration = config.get('long_break_duration')
|
||||
self.short_break_duration = config.get('short_break_duration')
|
||||
self.break_interval = config.get('break_interval') * 60 # Convert to seconds
|
||||
self.postpone_duration = config.get('postpone_duration') * 60 # Convert to seconds
|
||||
self.break_interval = config.get('break_interval') * 60 # Convert to seconds
|
||||
self.default_postpone_duration = config.get('postpone_duration') * 60 # Convert to seconds
|
||||
self.postpone_duration = self.default_postpone_duration
|
||||
|
||||
self.__init_breaks(BreakType.SHORT_BREAK, config.get('short_breaks'), config.get('no_of_short_breaks_per_long_break'))
|
||||
self.__init_breaks(BreakType.LONG_BREAK, config.get('long_breaks'), config.get('no_of_short_breaks_per_long_break'))
|
||||
|
@ -101,7 +106,7 @@ class SafeEyesCore(object):
|
|||
if not self.running:
|
||||
logging.info("Start Safe Eyes core")
|
||||
self.running = True
|
||||
self.scheduled_next_break_time = int(next_break_time)
|
||||
self.scheduled_next_break_timestamp = int(next_break_time)
|
||||
Utility.start_thread(self.__scheduler_job)
|
||||
|
||||
def stop(self):
|
||||
|
@ -128,10 +133,15 @@ class SafeEyesCore(object):
|
|||
"""
|
||||
self.context['skipped'] = True
|
||||
|
||||
def postpone(self):
|
||||
def postpone(self, duration=-1):
|
||||
"""
|
||||
User postponed the break using Postpone button
|
||||
"""
|
||||
if duration > 0:
|
||||
self.postpone_duration = duration
|
||||
else:
|
||||
self.postpone_duration = self.default_postpone_duration
|
||||
logging.debug("Postpone the break for %d seconds", self.postpone_duration)
|
||||
self.context['postponed'] = True
|
||||
|
||||
def take_break(self):
|
||||
|
@ -199,13 +209,13 @@ class SafeEyesCore(object):
|
|||
logging.info('Skip next long break due to the pause longer than break duration')
|
||||
# Skip the next long break
|
||||
self.__select_next_break()
|
||||
|
||||
if current_timestamp < self.scheduled_next_break_time:
|
||||
time_to_wait = round(self.scheduled_next_break_time - current_timestamp)
|
||||
self.scheduled_next_break_time = -1
|
||||
|
||||
next_break_time = current_time + datetime.timedelta(seconds=time_to_wait)
|
||||
Utility.execute_main_thread(self.__fire_on_update_next_break, next_break_time)
|
||||
if current_timestamp < self.scheduled_next_break_timestamp:
|
||||
time_to_wait = round(self.scheduled_next_break_timestamp - current_timestamp)
|
||||
self.scheduled_next_break_timestamp = -1
|
||||
|
||||
self.scheduled_next_break_time = current_time + datetime.timedelta(seconds=time_to_wait)
|
||||
Utility.execute_main_thread(self.__fire_on_update_next_break, self.scheduled_next_break_time)
|
||||
|
||||
if self.__is_long_break():
|
||||
self.context['break_type'] = 'long'
|
||||
|
@ -249,13 +259,27 @@ class SafeEyesCore(object):
|
|||
return
|
||||
Utility.execute_main_thread(self.__fire_start_break)
|
||||
|
||||
def __postpone_break(self):
|
||||
self.__wait_for(self.postpone_duration)
|
||||
Utility.execute_main_thread(self.__fire_start_break)
|
||||
|
||||
def __fire_start_break(self):
|
||||
# Show the break screen
|
||||
if not self.on_start_break.fire(self.breaks[self.next_break_index]):
|
||||
# Plugins wanted to ignore this break
|
||||
# Plugins want to ignore this break
|
||||
self.__start_next_break()
|
||||
return
|
||||
Utility.start_thread(self.__start_break)
|
||||
if self.context['postponed']:
|
||||
# Plugins want to postpone this break
|
||||
self.context['postponed'] = False
|
||||
# Update the next break time
|
||||
self.scheduled_next_break_time = self.scheduled_next_break_time + datetime.timedelta(seconds=self.postpone_duration)
|
||||
self.__fire_on_update_next_break(self.scheduled_next_break_time)
|
||||
# Wait in user thread
|
||||
Utility.start_thread(self.__postpone_break)
|
||||
else:
|
||||
self.start_break.fire(self.breaks[self.next_break_index])
|
||||
Utility.start_thread(self.__start_break)
|
||||
|
||||
def __start_break(self):
|
||||
"""
|
||||
|
|
|
@ -335,6 +335,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -333,6 +333,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -337,6 +337,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -339,6 +339,10 @@ msgstr ""
|
|||
"Považovat čas nečinnosti trvající stejně, jako nadcházející přestávka, za "
|
||||
"přestávku"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Oznamovací oblast"
|
||||
|
|
|
@ -349,6 +349,10 @@ msgstr "Mindste tomgangstid for at pause Safe Eyes (i sekunder)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Fortolk inaktiv tid svarende til kommende pause varighed som en pause"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
#, fuzzy
|
||||
msgid "Tray Icon"
|
||||
|
|
|
@ -337,6 +337,10 @@ msgstr "Maximaldauer Leerlauf zum Pausieren (in Sekunden)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Mit Pausendauer gleiche Leerlaufdauer als Pause interpretieren"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Symbol im Tray"
|
||||
|
|
|
@ -337,6 +337,10 @@ msgstr "Minimum idle time to pause Safe Eyes (in seconds)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Tray Icon"
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr "Tiempo minimo inactivo para pausar Safe Eyes (en segundos)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Icono de bandeja"
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr "Minimaalne süsteemi jõudeoleku aeg programmi peatamiseks (sekundites)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Arvesta järgmise pausi aja sisse sellele eelnenud puhkeaeg"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Paneeliikoon"
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -345,6 +345,10 @@ msgstr ""
|
|||
"Interpréter le temps d’inactivité équivalent à la pause à venir comme une "
|
||||
"pause"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Icône de notification"
|
||||
|
|
|
@ -334,6 +334,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -335,6 +335,10 @@ msgstr "Minimális üresjárati idő a Safe Eyes felfüggesztéséhez (mp)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Tálca Ikon"
|
||||
|
|
|
@ -333,6 +333,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -342,6 +342,10 @@ msgstr ""
|
|||
"Considera il tempo di inattività del computer equivalente alla durata della "
|
||||
"prossima pausa"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Icona"
|
||||
|
|
|
@ -342,6 +342,10 @@ msgstr ""
|
|||
"Laikyti neveiklumo laiką, kuris lygus būsimos pertraukos trukmei, kaip "
|
||||
"pertrauką"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Dėklo piktograma"
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -8,8 +8,8 @@ msgstr ""
|
|||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2018-06-22 23:16+0000\n"
|
||||
"Last-Translator: Allan Nordhøy <epost@anotheragency.no>\n"
|
||||
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/"
|
||||
"safe-eyes/translations/nb/>\n"
|
||||
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/safe-"
|
||||
"eyes/translations/nb/>\n"
|
||||
"Language: nb\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
@ -334,6 +334,10 @@ msgstr "Minimal lediggang å pause Øyetrygg etter (i sekunder)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Tolk lediggang som leder opp mot en pause som pause"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Systemkurvisikon"
|
||||
|
|
|
@ -340,6 +340,10 @@ msgstr "Minimale tijd dat systeem inactief moet zijn (in seconden)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Inactief opvatten als aankomende pauzeduur"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Systeemvakpictogram"
|
||||
|
|
|
@ -339,6 +339,10 @@ msgstr ""
|
|||
"Interpretuj czas bezczynności odpowiadający zbliżonemu czasowi trwania "
|
||||
"przerwy jako przerwę"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Ikona w zasobniku"
|
||||
|
|
|
@ -341,6 +341,10 @@ msgstr ""
|
|||
"Interprete o tempo ocioso equivalente à duração da próxima parada como uma "
|
||||
"parada"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Ícone de bandeja"
|
||||
|
|
|
@ -14,8 +14,8 @@ msgstr ""
|
|||
"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 3.1-dev\n"
|
||||
|
||||
# Short break
|
||||
|
@ -337,6 +337,10 @@ msgstr ""
|
|||
"Интерпретировать время простоя равное продолжительности предстоящего "
|
||||
"перерыва как перерыв"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Иконка в трее"
|
||||
|
|
|
@ -322,6 +322,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr "Pozastaviť Safe Eyes pri nečinnost dlhšej ako (v sekundách)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "Započítaj čas, kedy počítač nie je používaný, do prestávky"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Ikona na paneli"
|
||||
|
|
|
@ -333,6 +333,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -340,6 +340,10 @@ msgstr "Safe Eyesஐ இடைநிறுத்துவதற்கான க
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "அடுத்த இடைவேளையின் காலத்திற்கு சமனான செயலற்ற நேரத்தை இடைவேளையாக கருதுக"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr "கணினி செயலற்ற நிலைக்கு வரும் வரை அடுத்த இடைவேளையை தாமதப்படுத்தவும்"
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Safe Eyes சின்னம்"
|
||||
|
|
|
@ -340,6 +340,10 @@ msgstr ""
|
|||
"Sıradaki mola süresine eşit miktarda boşta zaman geçtiyse bunu mola olarak "
|
||||
"değerlendir"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Tepsi simgesi"
|
||||
|
|
|
@ -333,6 +333,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -14,8 +14,8 @@ msgstr ""
|
|||
"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 3.1-dev\n"
|
||||
|
||||
# Short break
|
||||
|
@ -342,6 +342,10 @@ msgstr ""
|
|||
"Інтерпретувати час простою, що дорівнює часу до найближчої перерви, як "
|
||||
"перерву"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Значок в лотку"
|
||||
|
|
|
@ -340,6 +340,10 @@ msgstr ""
|
|||
"Diễn tả thời gian rỗi tương đương với thời gian nghỉ sắp tới như là một giờ "
|
||||
"nghỉ"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "Biểu tượng khay"
|
||||
|
|
|
@ -336,6 +336,10 @@ msgstr "暂停 Safe Eyes 的最短时间(秒)"
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr "将系统空闲时间作为下次休息时长来对待"
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr "托盘图标"
|
||||
|
|
|
@ -334,6 +334,10 @@ msgstr ""
|
|||
msgid "Interpret idle time equivalent to upcoming break duration as a break"
|
||||
msgstr ""
|
||||
|
||||
# plugin/smartpause
|
||||
msgid "Postpone the next break until the system becomes idle"
|
||||
msgstr ""
|
||||
|
||||
#: plugins/trayicon
|
||||
msgid "Tray Icon"
|
||||
msgstr ""
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"meta": {
|
||||
"name": "Smart Pause",
|
||||
"description": "Pause Safe Eyes if the system is idle",
|
||||
"version": "0.0.2"
|
||||
"version": "0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"python_modules": [],
|
||||
|
@ -25,6 +25,12 @@
|
|||
"label": "Interpret idle time equivalent to upcoming break duration as a break",
|
||||
"type": "BOOL",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"id": "postpone_if_active",
|
||||
"label": "Postpone the next break until the system becomes idle",
|
||||
"type": "BOOL",
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
}
|
|
@ -50,7 +50,7 @@ def __system_idle_time():
|
|||
Return the idle time if xprintidle is available, otherwise return 0.
|
||||
"""
|
||||
try:
|
||||
return int(subprocess.check_output(['xprintidle']).decode('utf-8')) / 1000 # Convert to seconds
|
||||
return int(subprocess.check_output(['xprintidle']).decode('utf-8')) / 1000 # Convert to seconds
|
||||
except BaseException:
|
||||
return 0
|
||||
|
||||
|
@ -81,18 +81,22 @@ def init(ctx, safeeyes_config, plugin_config):
|
|||
global context
|
||||
global enable_safe_eyes
|
||||
global disable_safe_eyes
|
||||
global postpone
|
||||
global idle_time
|
||||
global break_interval
|
||||
global waiting_time
|
||||
global interpret_idle_as_break
|
||||
global postpone_if_active
|
||||
logging.debug('Initialize Smart Pause plugin')
|
||||
context = ctx
|
||||
enable_safe_eyes = context['api']['enable_safeeyes']
|
||||
disable_safe_eyes = context['api']['disable_safeeyes']
|
||||
postpone = context['api']['postpone']
|
||||
idle_time = plugin_config['idle_time']
|
||||
interpret_idle_as_break = plugin_config['interpret_idle_as_break']
|
||||
postpone_if_active = plugin_config['postpone_if_active']
|
||||
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
|
||||
waiting_time = min(2, idle_time) # If idle time is 1 sec, wait only 1 sec
|
||||
|
||||
|
||||
def __start_idle_monitor():
|
||||
|
@ -169,3 +173,14 @@ def update_next_break(break_obj, dateTime):
|
|||
global next_break_duration
|
||||
next_break_time = dateTime
|
||||
next_break_duration = break_obj.time
|
||||
|
||||
|
||||
def on_start_break(break_obj):
|
||||
"""
|
||||
Lifecycle method executes just before the break.
|
||||
"""
|
||||
if postpone_if_active:
|
||||
# Postpone this break if the user is active
|
||||
system_idle_time = __system_idle_time()
|
||||
if system_idle_time < 2:
|
||||
postpone(2) # Postpone for 2 seconds
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
for filename in safeeyes/config/locale/*/LC_MESSAGES/safeeyes.po; do
|
||||
echo "$filename"
|
||||
msgmerge -U "$filename" safeeyes/config/locale/safeeyes.pot
|
||||
if [ -f "$filename~" ] ; then
|
||||
rm "$filename~"
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue