Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[script.timers] 3.9.0 #2535

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions script.timers/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.timers" name="Timers" version="3.8.0" provider-name="Heckie">
<addon id="script.timers" name="Timers" version="3.9.0" provider-name="Heckie">
<requires>
<import addon="xbmc.python" version="3.0.0" />
</requires>
Expand Down Expand Up @@ -66,6 +66,11 @@
<website>https://github.com/Heckie75/kodi-addon-timers</website>
<source>https://github.com/Heckie75/kodi-addon-timers</source>
<news>
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

Expand All @@ -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
</news>
<assets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -273,6 +281,10 @@ msgctxt "#32093"
msgid "Standby TV via CEC"
msgstr ""

msgctxt "#32094"
msgid "Restart Kodi"
msgstr ""

msgctxt "#32095"
msgid "Low volume"
msgstr ""
Expand All @@ -289,6 +301,10 @@ msgctxt "#32098"
msgid "Timer Notifications"
msgstr ""

msgctxt "#32099"
msgid "Reboot system"
msgstr ""

msgctxt "#32100"
msgid "Timer starts"
msgstr ""
Expand Down
19 changes: 14 additions & 5 deletions script.timers/resources/lib/timer/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down
15 changes: 12 additions & 3 deletions script.timers/resources/lib/timer/scheduleraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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()")
Expand All @@ -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()")
Expand Down
8 changes: 8 additions & 0 deletions script.timers/resources/lib/timer/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions script.timers/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@
<option label="32071">0</option>
<option label="32082">1</option>
<option label="32083">2</option>
<option label="32094">7</option>
<option label="32084">3</option>
<option label="32085">4</option>
<option label="32086">5</option>
<option label="32099">8</option>
<option label="32093">6</option>
</options>
</constraints>
Expand Down Expand Up @@ -739,6 +741,11 @@
<dependency type="visible" on="property" operator="!is" name="infobool">system.isstandalone</dependency>
</dependencies>
</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="32384">
<level>3</level>
<default>false</default>
Expand Down
Loading