diff --git a/script.lockandenergycontrol/addon.py b/script.lockandenergycontrol/addon.py index 4c91f5dbc..e685fd870 100644 --- a/script.lockandenergycontrol/addon.py +++ b/script.lockandenergycontrol/addon.py @@ -6,13 +6,15 @@ class Monitor(xbmc.Monitor): - _powermanagement_displaysoff = 0 - _disabled_powermanagement_displaysoff = False - _windows_unlock = False def __init__(self) -> None: super().__init__() + self._powermanagement_displaysoff = 0 + self._disabled_powermanagement_displaysoff = False + self._windows_unlock = False + self._disable_displayoff_on_audio = False + self._player = xbmc.Player() self._update() def _update(self) -> None: @@ -22,6 +24,7 @@ def _update(self) -> None: 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 onSettingsChanged(self) -> None: @@ -57,14 +60,23 @@ def set_windows_unlock(self, value: bool) -> bool: def _prevent_powermanagement_displaysoff(self) -> None: - is_fullscreen = xbmc.getCondVisibility("System.IsFullscreen") - if is_fullscreen and self._disabled_powermanagement_displaysoff: + fullscreen = xbmc.getCondVisibility("System.IsFullscreen") + audio = self._player.isPlayingAudio() + + 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 is_fullscreen and not self._disabled_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 self.set_powermanagement_displaysoff(0) + + def reset_powermanagement_displaysoff(self) -> None: if self._powermanagement_displaysoff: diff --git a/script.lockandenergycontrol/addon.xml b/script.lockandenergycontrol/addon.xml index 4a45cbe35..447578b2b 100644 --- a/script.lockandenergycontrol/addon.xml +++ b/script.lockandenergycontrol/addon.xml @@ -1,5 +1,5 @@ - + @@ -21,6 +21,9 @@ https://github.com/Heckie75/kodi-addon-prevent-sleep-and-lock https://github.com/Heckie75/kodi-addon-prevent-sleep-and-lock +v1.1.0 (2023-11-30) +- New feature to prevent display off when audio is playing + v1.0.0 (2022-06-10) - Initial version diff --git a/script.lockandenergycontrol/resources/language/resource.language.de_de/strings.po b/script.lockandenergycontrol/resources/language/resource.language.de_de/strings.po index f992c1d9b..966fbc196 100644 --- a/script.lockandenergycontrol/resources/language/resource.language.de_de/strings.po +++ b/script.lockandenergycontrol/resources/language/resource.language.de_de/strings.po @@ -17,10 +17,18 @@ msgctxt "#32030" msgid "General" msgstr "Allgemein" +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" +msgctxt "#32033" +msgid "Deactivate sleep display on audio playback" +msgstr "Deaktiviere Ruhezustand des Bildschirms während der Audiowiedergabe" + msgctxt "#32130" msgid "Put display only in fullscreen mode to sleep" msgstr "Ruhezustand des Bildschirms bei Vollbild" diff --git a/script.lockandenergycontrol/resources/language/resource.language.en_gb/strings.po b/script.lockandenergycontrol/resources/language/resource.language.en_gb/strings.po index 59ebdfaea..59ebcc50e 100644 --- a/script.lockandenergycontrol/resources/language/resource.language.en_gb/strings.po +++ b/script.lockandenergycontrol/resources/language/resource.language.en_gb/strings.po @@ -17,10 +17,18 @@ msgctxt "#32030" msgid "General" msgstr "" +msgctxt "#32031" +msgid "Don't put display to sleep on audio playback" +msgstr "" + msgctxt "#32032" msgid "Prevent lock screen" msgstr "" +msgctxt "#32033" +msgid "Deactivate sleep display on audio playback" +msgstr "" + msgctxt "#32130" msgid "Put display only in fullscreen mode to sleep" msgstr "" diff --git a/script.lockandenergycontrol/resources/settings.xml b/script.lockandenergycontrol/resources/settings.xml index 66434cb57..dacf81ad4 100644 --- a/script.lockandenergycontrol/resources/settings.xml +++ b/script.lockandenergycontrol/resources/settings.xml @@ -68,6 +68,11 @@ false + + 3 + false + + 0 false @@ -79,4 +84,4 @@ - \ No newline at end of file +