shortcuts: sleep timer: allow omitting number of minutes

'sleep' can now appear in the data field of a 'time' shortcut
without being followed by a number, allowing you to stop a
running timer, or to start a new one using the default sleep
timer duration (the duration setting can already be added to
the Shortcuts menu as well).

Also see here:
https://forums.rockbox.org/index.php/topic,54312.msg250940.html

Change-Id: I9d0e62ef1b6187c35133067349729a4d94273c7a
This commit is contained in:
Christian Soffke 2024-05-11 18:18:51 +02:00
parent b8b4fdd999
commit f631bfe5b4
3 changed files with 50 additions and 17 deletions

View file

@ -520,8 +520,8 @@ static int seconds_to_min(int secs)
/* A string representation of either whether a sleep timer will be started or
canceled, and how long it will be or how long is remaining in brackets */
static char* sleep_timer_getname(int selected_item, void * data,
char *buffer, size_t buffer_len)
char* sleep_timer_getname(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)selected_item;
(void)data;
@ -537,7 +537,7 @@ static char* sleep_timer_getname(int selected_item, void * data,
return buffer;
}
static int sleep_timer_voice(int selected_item, void*data)
int sleep_timer_voice(int selected_item, void*data)
{
(void)selected_item;
(void)data;
@ -555,7 +555,7 @@ static int sleep_timer_voice(int selected_item, void*data)
}
/* If a sleep timer is running, cancel it, otherwise start one */
static int toggle_sleeptimer(void)
int toggle_sleeptimer(void)
{
set_sleeptimer_duration(get_sleep_timer() ? 0
: global_settings.sleeptimer_duration);