Skip to content

Commit

Permalink
Merge pull request #2588 from Heckie75/script.lockandenergycontrol.1.1.0
Browse files Browse the repository at this point in the history
[script.lockandenergycontrol] 1.1.0
  • Loading branch information
basrieter authored Feb 23, 2024
2 parents 8a36df0 + 8505f8f commit 40b82f8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
24 changes: 18 additions & 6 deletions script.lockandenergycontrol/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion script.lockandenergycontrol/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.lockandenergycontrol" name="Screen lock and energy control" version="1.0.0" provider-name="Heckie">
<addon id="script.lockandenergycontrol" name="Screen lock and energy control" version="1.1.0" provider-name="Heckie">
<requires>
<import addon="xbmc.python" version="3.0.0" />
</requires>
Expand All @@ -21,6 +21,9 @@
<website>https://github.com/Heckie75/kodi-addon-prevent-sleep-and-lock</website>
<source>https://github.com/Heckie75/kodi-addon-prevent-sleep-and-lock</source>
<news>
v1.1.0 (2023-11-30)
- New feature to prevent display off when audio is playing

v1.0.0 (2022-06-10)
- Initial version
</news>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
7 changes: 6 additions & 1 deletion script.lockandenergycontrol/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
</dependencies>
<enable>false</enable>
</setting>
<setting id="audio_displaysoff" type="boolean" label="32031" help="32039">
<level>3</level>
<default>false</default>
<control type="toggle" />
</setting>
<setting id="windows_unlock" type="boolean" label="32032" help="">
<level>0</level>
<default>false</default>
Expand All @@ -79,4 +84,4 @@
</group>
</category>
</section>
</settings>
</settings>

0 comments on commit 40b82f8

Please sign in to comment.