From 7f9704a441c393f8b3974195a1bfd5354879849d Mon Sep 17 00:00:00 2001 From: Heckie75 Date: Sat, 11 Nov 2023 09:28:37 +0100 Subject: [PATCH] [script.timers] 3.9.0 --- script.timers/addon.xml | 17 ++++++----------- .../resource.language.de_de/strings.po | 16 ++++++++++++++++ .../resource.language.en_gb/strings.po | 16 ++++++++++++++++ .../resources/lib/timer/scheduler.py | 19 ++++++++++++++----- .../resources/lib/timer/scheduleraction.py | 15 ++++++++++++--- script.timers/resources/lib/timer/timer.py | 8 ++++++++ script.timers/resources/settings.xml | 7 +++++++ 7 files changed, 79 insertions(+), 19 deletions(-) diff --git a/script.timers/addon.xml b/script.timers/addon.xml index acae01758..11f3ee0b8 100644 --- a/script.timers/addon.xml +++ b/script.timers/addon.xml @@ -1,5 +1,5 @@ - + @@ -66,6 +66,11 @@ https://github.com/Heckie75/kodi-addon-timers https://github.com/Heckie75/kodi-addon-timers +v3.9.0 (2023-11-11) +- Add new system action 'restart Kodi' +- Add new extra feature to prevent display off when audio is playing +- Bugfix: Prevent exception in fader context + v3.8.0 (2023-08-06) - Context menu quicktimer: Added dialog if item is already scheduled and ask to replace or delete @@ -84,16 +89,6 @@ v3.5.0 (2023-02-07) - New feature: System action to put playing device on standby via a CEC peripheral - Fixed issue so that favourites can be scheduled again -v3.4.0 (2023-01-10) -- New feature: Media action in order to pause audio or video, feature request #21 -- Refactoring: moved state to timer object -- Reorganized setting levels (simple, standard, advanced, expert) -- Introduced logging (see kodi.log) - -v3.3.1 (2022-11-26) -- Bugfix: scheduled timers stop working that are scheduled after Sunday (week change Sun -> Mon) -- Refactoring - Complete changelog see https://github.com/Heckie75/kodi-addon-timers diff --git a/script.timers/resources/language/resource.language.de_de/strings.po b/script.timers/resources/language/resource.language.de_de/strings.po index 3d953f08d..ea469e4d6 100644 --- a/script.timers/resources/language/resource.language.de_de/strings.po +++ b/script.timers/resources/language/resource.language.de_de/strings.po @@ -77,6 +77,10 @@ msgctxt "#32030" msgid "Presets" msgstr "Voreinstellungen" +msgctxt "#32031" +msgid "Don't put display to sleep on audio playback" +msgstr "Ruhezustand des Bildschirms bei Audiowiedergabe vermeiden" + msgctxt "#32032" msgid "Prevent lock screen" msgstr "Verhindere Bildschirmsperre" @@ -105,6 +109,10 @@ msgctxt "#32038" msgid "Presets for snooze timer" msgstr "Voreinstellungen für Schlummern" +msgctxt "#32039" +msgid "Deactivate sleep display on audio playback" +msgstr "Deaktiviere Ruhezustand des Bildschirms während der Audiowiedergabe" + msgctxt "#32040" msgid "and" msgstr "und" @@ -273,6 +281,10 @@ msgctxt "#32093" msgid "Standby TV via CEC" msgstr "Standby TV via CEC" +msgctxt "#32094" +msgid "Restart Kodi" +msgstr "Kodi neu starten" + msgctxt "#32095" msgid "Low volume" msgstr "Niedrige Lautstärke" @@ -289,6 +301,10 @@ msgctxt "#32098" msgid "Timer Notifications" msgstr "Benachrichtigungen anzeigen" +msgctxt "#32099" +msgid "Reboot system" +msgstr "System neu starten" + msgctxt "#32100" msgid "Timer starts" msgstr "Timer gestartet" diff --git a/script.timers/resources/language/resource.language.en_gb/strings.po b/script.timers/resources/language/resource.language.en_gb/strings.po index a0d919b33..930bf4165 100644 --- a/script.timers/resources/language/resource.language.en_gb/strings.po +++ b/script.timers/resources/language/resource.language.en_gb/strings.po @@ -77,6 +77,10 @@ msgctxt "#32030" msgid "Presets" msgstr "" +msgctxt "#32031" +msgid "Don't put display to sleep on audio playback" +msgstr "" + msgctxt "#32032" msgid "Prevent lock screen" msgstr "" @@ -105,6 +109,10 @@ msgctxt "#32038" msgid "Presets for snooze timer" msgstr "" +msgctxt "#32039" +msgid "Deactivate sleep display on audio playback" +msgstr "" + msgctxt "#32040" msgid "and" msgstr "" @@ -273,6 +281,10 @@ msgctxt "#32093" msgid "Standby TV via CEC" msgstr "" +msgctxt "#32094" +msgid "Restart Kodi" +msgstr "" + msgctxt "#32095" msgid "Low volume" msgstr "" @@ -289,6 +301,10 @@ msgctxt "#32098" msgid "Timer Notifications" msgstr "" +msgctxt "#32099" +msgid "Reboot system" +msgstr "" + msgctxt "#32100" msgid "Timer starts" msgstr "" diff --git a/script.timers/resources/lib/timer/scheduler.py b/script.timers/resources/lib/timer/scheduler.py index 94d530637..993bc3c23 100644 --- a/script.timers/resources/lib/timer/scheduler.py +++ b/script.timers/resources/lib/timer/scheduler.py @@ -34,6 +34,7 @@ def __init__(self) -> None: self._powermanagement_displaysoff = 0 self._disabled_powermanagement_displaysoff = False + self._disable_displayoff_on_audio = False self._windows_unlock = False self._player = Player() @@ -164,6 +165,7 @@ def _update_from_storage(scheduled_timers: 'list[Timer]') -> 'list[Timer]': self._windows_unlock = addon.getSettingBool("windows_unlock") self._powermanagement_displaysoff = addon.getSettingInt( "powermanagement_displaysoff") + self._disable_displayoff_on_audio = addon.getSettingBool("audio_displaysoff") self.reset_powermanagement_displaysoff() def start(self) -> None: @@ -200,8 +202,7 @@ def start(self) -> None: if self._windows_unlock != prev_windows_unlock: prev_windows_unlock = set_windows_unlock(self._windows_unlock) - if self._powermanagement_displaysoff: - self._prevent_powermanagement_displaysoff() + self._prevent_powermanagement_displaysoff() wait = min(CHECK_INTERVAL, interval if interval >= MIN_INTERVAL else MIN_INTERVAL, ( self.action.upcoming_event - now.dt).total_seconds() if self.action.upcoming_event else MIN_INTERVAL) @@ -211,10 +212,18 @@ def start(self) -> None: def _prevent_powermanagement_displaysoff(self) -> None: - if is_fullscreen() and self._disabled_powermanagement_displaysoff: - self.reset_powermanagement_displaysoff() + fullscreen = is_fullscreen() + audio = self._player.isPlayingAudio() - elif not is_fullscreen() and not self._disabled_powermanagement_displaysoff: + if self._disabled_powermanagement_displaysoff and ((fullscreen and not audio) \ + or (not self._powermanagement_displaysoff and (not self._disable_displayoff_on_audio or not audio)) \ + or (not self._powermanagement_displaysoff and not fullscreen and self._disable_displayoff_on_audio and not audio) \ + or (not self._disable_displayoff_on_audio and fullscreen)): + self.reset_powermanagement_displaysoff() + + elif not self._disabled_powermanagement_displaysoff and \ + ((self._powermanagement_displaysoff and not fullscreen) \ + or (self._disable_displayoff_on_audio and audio)): self._disabled_powermanagement_displaysoff = True set_powermanagement_displaysoff(0) diff --git a/script.timers/resources/lib/timer/scheduleraction.py b/script.timers/resources/lib/timer/scheduleraction.py index a9b7ef616..5e3ecb37c 100644 --- a/script.timers/resources/lib/timer/scheduleraction.py +++ b/script.timers/resources/lib/timer/scheduleraction.py @@ -16,6 +16,8 @@ SYSTEM_ACTION_HIBERNATE, SYSTEM_ACTION_POWEROFF, SYSTEM_ACTION_QUIT_KODI, + SYSTEM_ACTION_RESTART_KODI, + SYSTEM_ACTION_REBOOT_SYSTEM, SYSTEM_ACTION_SHUTDOWN_KODI, SYSTEM_ACTION_STANDBY, TIMER_WEEKLY, Timer) @@ -166,8 +168,7 @@ def _handleSystemAction() -> None: addon = xbmcaddon.Addon() lines = list() lines.append(addon.getLocalizedString(32270)) - lines.append(addon.getLocalizedString( - 32081 + self.timerWithSystemAction.system_action)) + lines.append(self.timerWithSystemAction.format("$P")) lines.append(addon.getLocalizedString(32271)) abort = xbmcgui.Dialog().yesno(heading="%s: %s" % (addon.getLocalizedString(32256), self.timerWithSystemAction.label), message="\n".join(lines), @@ -248,7 +249,7 @@ def getFaderInterval(self) -> float: vol_max = self.fader.return_vol if self.fader.fade == FADE_OUT_FROM_CURRENT else self.fader.vol_max vol_diff = vol_max - self.fader.vol_min - return delta_end_start/vol_diff + return delta_end_start / vol_diff if vol_diff != 0 else None def _setTimerToPlayAny(self, timer: Timer) -> None: @@ -370,6 +371,10 @@ def _performSystemAction() -> None: showNotification(self.timerWithSystemAction, msg_id=32083) xbmc.executebuiltin("Quit()") + elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_RESTART_KODI: + showNotification(self.timerWithSystemAction, msg_id=32094) + xbmc.executebuiltin("RestartApp()") + elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_STANDBY: showNotification(self.timerWithSystemAction, msg_id=32084) xbmc.executebuiltin("Suspend()") @@ -382,6 +387,10 @@ def _performSystemAction() -> None: showNotification(self.timerWithSystemAction, msg_id=32086) xbmc.executebuiltin("Powerdown()") + elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_REBOOT_SYSTEM: + showNotification(self.timerWithSystemAction, msg_id=32099) + xbmc.executebuiltin("Reboot()") + elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_CEC_STANDBY: showNotification(self.timerWithSystemAction, msg_id=32093) xbmc.executebuiltin("CECStandby()") diff --git a/script.timers/resources/lib/timer/timer.py b/script.timers/resources/lib/timer/timer.py index 923ef6471..819f82589 100644 --- a/script.timers/resources/lib/timer/timer.py +++ b/script.timers/resources/lib/timer/timer.py @@ -23,6 +23,8 @@ SYSTEM_ACTION_HIBERNATE = 4 SYSTEM_ACTION_POWEROFF = 5 SYSTEM_ACTION_CEC_STANDBY = 6 +SYSTEM_ACTION_RESTART_KODI = 7 +SYSTEM_ACTION_REBOOT_SYSTEM = 8 MEDIA_ACTION_NONE = 0 MEDIA_ACTION_START_STOP = 1 @@ -232,6 +234,12 @@ def _systemActionStr(self) -> str: elif self.system_action == SYSTEM_ACTION_CEC_STANDBY: return self._addon.getLocalizedString(32093) + elif self.system_action == SYSTEM_ACTION_RESTART_KODI: + return self._addon.getLocalizedString(32094) + + elif self.system_action == SYSTEM_ACTION_REBOOT_SYSTEM: + return self._addon.getLocalizedString(32099) + else: return self._addon.getLocalizedString(32071) diff --git a/script.timers/resources/settings.xml b/script.timers/resources/settings.xml index 0e6c73df5..7ab588c59 100644 --- a/script.timers/resources/settings.xml +++ b/script.timers/resources/settings.xml @@ -490,9 +490,11 @@ + + @@ -739,6 +741,11 @@ system.isstandalone + + 3 + false + + 3 false