Skip to content

Commit 40bfcf5

Browse files
authored
[script.timers] 3.9.0 (#2535)
1 parent eeb0ae8 commit 40bfcf5

File tree

7 files changed

+79
-19
lines changed

7 files changed

+79
-19
lines changed

script.timers/addon.xml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.timers" name="Timers" version="3.8.0" provider-name="Heckie">
2+
<addon id="script.timers" name="Timers" version="3.9.0" provider-name="Heckie">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0" />
55
</requires>
@@ -66,6 +66,11 @@
6666
<website>https://github.com/Heckie75/kodi-addon-timers</website>
6767
<source>https://github.com/Heckie75/kodi-addon-timers</source>
6868
<news>
69+
v3.9.0 (2023-11-11)
70+
- Add new system action 'restart Kodi'
71+
- Add new extra feature to prevent display off when audio is playing
72+
- Bugfix: Prevent exception in fader context
73+
6974
v3.8.0 (2023-08-06)
7075
- Context menu quicktimer: Added dialog if item is already scheduled and ask to replace or delete
7176

@@ -84,16 +89,6 @@ v3.5.0 (2023-02-07)
8489
- New feature: System action to put playing device on standby via a CEC peripheral
8590
- Fixed issue so that favourites can be scheduled again
8691

87-
v3.4.0 (2023-01-10)
88-
- New feature: Media action in order to pause audio or video, feature request #21
89-
- Refactoring: moved state to timer object
90-
- Reorganized setting levels (simple, standard, advanced, expert)
91-
- Introduced logging (see kodi.log)
92-
93-
v3.3.1 (2022-11-26)
94-
- Bugfix: scheduled timers stop working that are scheduled after Sunday (week change Sun -> Mon)
95-
- Refactoring
96-
9792
Complete changelog see https://github.com/Heckie75/kodi-addon-timers
9893
</news>
9994
<assets>

script.timers/resources/language/resource.language.de_de/strings.po

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ msgctxt "#32030"
7777
msgid "Presets"
7878
msgstr "Voreinstellungen"
7979

80+
msgctxt "#32031"
81+
msgid "Don't put display to sleep on audio playback"
82+
msgstr "Ruhezustand des Bildschirms bei Audiowiedergabe vermeiden"
83+
8084
msgctxt "#32032"
8185
msgid "Prevent lock screen"
8286
msgstr "Verhindere Bildschirmsperre"
@@ -105,6 +109,10 @@ msgctxt "#32038"
105109
msgid "Presets for snooze timer"
106110
msgstr "Voreinstellungen für Schlummern"
107111

112+
msgctxt "#32039"
113+
msgid "Deactivate sleep display on audio playback"
114+
msgstr "Deaktiviere Ruhezustand des Bildschirms während der Audiowiedergabe"
115+
108116
msgctxt "#32040"
109117
msgid "and"
110118
msgstr "und"
@@ -273,6 +281,10 @@ msgctxt "#32093"
273281
msgid "Standby TV via CEC"
274282
msgstr "Standby TV via CEC"
275283

284+
msgctxt "#32094"
285+
msgid "Restart Kodi"
286+
msgstr "Kodi neu starten"
287+
276288
msgctxt "#32095"
277289
msgid "Low volume"
278290
msgstr "Niedrige Lautstärke"
@@ -289,6 +301,10 @@ msgctxt "#32098"
289301
msgid "Timer Notifications"
290302
msgstr "Benachrichtigungen anzeigen"
291303

304+
msgctxt "#32099"
305+
msgid "Reboot system"
306+
msgstr "System neu starten"
307+
292308
msgctxt "#32100"
293309
msgid "Timer starts"
294310
msgstr "Timer gestartet"

script.timers/resources/language/resource.language.en_gb/strings.po

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ msgctxt "#32030"
7777
msgid "Presets"
7878
msgstr ""
7979

80+
msgctxt "#32031"
81+
msgid "Don't put display to sleep on audio playback"
82+
msgstr ""
83+
8084
msgctxt "#32032"
8185
msgid "Prevent lock screen"
8286
msgstr ""
@@ -105,6 +109,10 @@ msgctxt "#32038"
105109
msgid "Presets for snooze timer"
106110
msgstr ""
107111

112+
msgctxt "#32039"
113+
msgid "Deactivate sleep display on audio playback"
114+
msgstr ""
115+
108116
msgctxt "#32040"
109117
msgid "and"
110118
msgstr ""
@@ -273,6 +281,10 @@ msgctxt "#32093"
273281
msgid "Standby TV via CEC"
274282
msgstr ""
275283

284+
msgctxt "#32094"
285+
msgid "Restart Kodi"
286+
msgstr ""
287+
276288
msgctxt "#32095"
277289
msgid "Low volume"
278290
msgstr ""
@@ -289,6 +301,10 @@ msgctxt "#32098"
289301
msgid "Timer Notifications"
290302
msgstr ""
291303

304+
msgctxt "#32099"
305+
msgid "Reboot system"
306+
msgstr ""
307+
292308
msgctxt "#32100"
293309
msgid "Timer starts"
294310
msgstr ""

script.timers/resources/lib/timer/scheduler.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self) -> None:
3434

3535
self._powermanagement_displaysoff = 0
3636
self._disabled_powermanagement_displaysoff = False
37+
self._disable_displayoff_on_audio = False
3738
self._windows_unlock = False
3839

3940
self._player = Player()
@@ -164,6 +165,7 @@ def _update_from_storage(scheduled_timers: 'list[Timer]') -> 'list[Timer]':
164165
self._windows_unlock = addon.getSettingBool("windows_unlock")
165166
self._powermanagement_displaysoff = addon.getSettingInt(
166167
"powermanagement_displaysoff")
168+
self._disable_displayoff_on_audio = addon.getSettingBool("audio_displaysoff")
167169
self.reset_powermanagement_displaysoff()
168170

169171
def start(self) -> None:
@@ -200,8 +202,7 @@ def start(self) -> None:
200202
if self._windows_unlock != prev_windows_unlock:
201203
prev_windows_unlock = set_windows_unlock(self._windows_unlock)
202204

203-
if self._powermanagement_displaysoff:
204-
self._prevent_powermanagement_displaysoff()
205+
self._prevent_powermanagement_displaysoff()
205206

206207
wait = min(CHECK_INTERVAL, interval if interval >= MIN_INTERVAL else MIN_INTERVAL, (
207208
self.action.upcoming_event - now.dt).total_seconds() if self.action.upcoming_event else MIN_INTERVAL)
@@ -211,10 +212,18 @@ def start(self) -> None:
211212

212213
def _prevent_powermanagement_displaysoff(self) -> None:
213214

214-
if is_fullscreen() and self._disabled_powermanagement_displaysoff:
215-
self.reset_powermanagement_displaysoff()
215+
fullscreen = is_fullscreen()
216+
audio = self._player.isPlayingAudio()
216217

217-
elif not is_fullscreen() and not self._disabled_powermanagement_displaysoff:
218+
if self._disabled_powermanagement_displaysoff and ((fullscreen and not audio) \
219+
or (not self._powermanagement_displaysoff and (not self._disable_displayoff_on_audio or not audio)) \
220+
or (not self._powermanagement_displaysoff and not fullscreen and self._disable_displayoff_on_audio and not audio) \
221+
or (not self._disable_displayoff_on_audio and fullscreen)):
222+
self.reset_powermanagement_displaysoff()
223+
224+
elif not self._disabled_powermanagement_displaysoff and \
225+
((self._powermanagement_displaysoff and not fullscreen) \
226+
or (self._disable_displayoff_on_audio and audio)):
218227
self._disabled_powermanagement_displaysoff = True
219228
set_powermanagement_displaysoff(0)
220229

script.timers/resources/lib/timer/scheduleraction.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
SYSTEM_ACTION_HIBERNATE,
1717
SYSTEM_ACTION_POWEROFF,
1818
SYSTEM_ACTION_QUIT_KODI,
19+
SYSTEM_ACTION_RESTART_KODI,
20+
SYSTEM_ACTION_REBOOT_SYSTEM,
1921
SYSTEM_ACTION_SHUTDOWN_KODI,
2022
SYSTEM_ACTION_STANDBY, TIMER_WEEKLY,
2123
Timer)
@@ -166,8 +168,7 @@ def _handleSystemAction() -> None:
166168
addon = xbmcaddon.Addon()
167169
lines = list()
168170
lines.append(addon.getLocalizedString(32270))
169-
lines.append(addon.getLocalizedString(
170-
32081 + self.timerWithSystemAction.system_action))
171+
lines.append(self.timerWithSystemAction.format("$P"))
171172
lines.append(addon.getLocalizedString(32271))
172173
abort = xbmcgui.Dialog().yesno(heading="%s: %s" % (addon.getLocalizedString(32256), self.timerWithSystemAction.label),
173174
message="\n".join(lines),
@@ -248,7 +249,7 @@ def getFaderInterval(self) -> float:
248249
vol_max = self.fader.return_vol if self.fader.fade == FADE_OUT_FROM_CURRENT else self.fader.vol_max
249250
vol_diff = vol_max - self.fader.vol_min
250251

251-
return delta_end_start/vol_diff
252+
return delta_end_start / vol_diff if vol_diff != 0 else None
252253

253254
def _setTimerToPlayAny(self, timer: Timer) -> None:
254255

@@ -370,6 +371,10 @@ def _performSystemAction() -> None:
370371
showNotification(self.timerWithSystemAction, msg_id=32083)
371372
xbmc.executebuiltin("Quit()")
372373

374+
elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_RESTART_KODI:
375+
showNotification(self.timerWithSystemAction, msg_id=32094)
376+
xbmc.executebuiltin("RestartApp()")
377+
373378
elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_STANDBY:
374379
showNotification(self.timerWithSystemAction, msg_id=32084)
375380
xbmc.executebuiltin("Suspend()")
@@ -382,6 +387,10 @@ def _performSystemAction() -> None:
382387
showNotification(self.timerWithSystemAction, msg_id=32086)
383388
xbmc.executebuiltin("Powerdown()")
384389

390+
elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_REBOOT_SYSTEM:
391+
showNotification(self.timerWithSystemAction, msg_id=32099)
392+
xbmc.executebuiltin("Reboot()")
393+
385394
elif self.timerWithSystemAction.system_action == SYSTEM_ACTION_CEC_STANDBY:
386395
showNotification(self.timerWithSystemAction, msg_id=32093)
387396
xbmc.executebuiltin("CECStandby()")

script.timers/resources/lib/timer/timer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
SYSTEM_ACTION_HIBERNATE = 4
2424
SYSTEM_ACTION_POWEROFF = 5
2525
SYSTEM_ACTION_CEC_STANDBY = 6
26+
SYSTEM_ACTION_RESTART_KODI = 7
27+
SYSTEM_ACTION_REBOOT_SYSTEM = 8
2628

2729
MEDIA_ACTION_NONE = 0
2830
MEDIA_ACTION_START_STOP = 1
@@ -232,6 +234,12 @@ def _systemActionStr(self) -> str:
232234
elif self.system_action == SYSTEM_ACTION_CEC_STANDBY:
233235
return self._addon.getLocalizedString(32093)
234236

237+
elif self.system_action == SYSTEM_ACTION_RESTART_KODI:
238+
return self._addon.getLocalizedString(32094)
239+
240+
elif self.system_action == SYSTEM_ACTION_REBOOT_SYSTEM:
241+
return self._addon.getLocalizedString(32099)
242+
235243
else:
236244
return self._addon.getLocalizedString(32071)
237245

script.timers/resources/settings.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,11 @@
490490
<option label="32071">0</option>
491491
<option label="32082">1</option>
492492
<option label="32083">2</option>
493+
<option label="32094">7</option>
493494
<option label="32084">3</option>
494495
<option label="32085">4</option>
495496
<option label="32086">5</option>
497+
<option label="32099">8</option>
496498
<option label="32093">6</option>
497499
</options>
498500
</constraints>
@@ -739,6 +741,11 @@
739741
<dependency type="visible" on="property" operator="!is" name="infobool">system.isstandalone</dependency>
740742
</dependencies>
741743
</setting>
744+
<setting id="audio_displaysoff" type="boolean" label="32031" help="32039">
745+
<level>3</level>
746+
<default>false</default>
747+
<control type="toggle" />
748+
</setting>
742749
<setting id="windows_unlock" type="boolean" label="32032" help="32384">
743750
<level>3</level>
744751
<default>false</default>

0 commit comments

Comments
 (0)