Index: Slim/Plugin/DateTime/Plugin.pm =================================================================== --- Slim/Plugin/DateTime/Plugin.pm (revision 23187) +++ Slim/Plugin/DateTime/Plugin.pm (working copy) @@ -58,40 +58,15 @@ 'snooze' => sub { my $client = shift; - my $nextAlarm = Slim::Utils::Alarm->getNextAlarm($client); my $currentAlarm = Slim::Utils::Alarm->getCurrentAlarm($client); # snooze if alarm is currently playing if (defined $currentAlarm) { $currentAlarm->snooze; - # show time if brightness is zero - } elsif ($client->display->currBrightness() == 0) { - $client->showBriefly( dateTimeLines($client), { - 'brightness' => 'powerOn', - 'duration' => 3 - }); - - # display next alarm time if alarm is within the next 24h - } elsif (defined $nextAlarm && ($nextAlarm->nextDue - time < 86400)) { - - my $line = $client->symbols('bell'); - - # Remove seconds from alarm time - my $timeStr = Slim::Utils::DateTime::timeF($nextAlarm->time % 86400, $prefs->client($client)->timeformat, 1); - $timeStr =~ s/(\d?\d\D\d\d)\D\d\d/$1/; - $line .= " $timeStr"; - - # briefly display the next alarm - $client->showBriefly( - { - 'center' => [ - $client->string('ALARM_NEXT_ALARM'), - $line, - ] - }, - { 'duration' => 3 } - ); + # display info about next alarm and/or current time + } else { + showTimeOrAlarm($client); } }, ); @@ -220,6 +195,51 @@ return $display; } +sub showTimeOrAlarm { + my $client = shift; + + my $sbName = getDisplayName() . '::showTimeOrAlarm'; + + my $currentMode = Slim::Buttons::Common::mode($client); + my $currentSbName = $client->display->sbName; + $currentSbName = '' unless defined $currentSbName; + + my $nextAlarm = Slim::Utils::Alarm->getNextAlarm($client); + my $showAlarm = defined $nextAlarm && ($nextAlarm->nextDue - time < 86400); + + # Show time if it isn't already being displayed or it is but there's no next alarm + if (($currentMode !~ '\.datetime$' || $client->display->currBrightness() == 0) + && ($currentSbName ne $sbName || ! $showAlarm)) { + + $client->showBriefly( dateTimeLines($client), { + 'brightness' => 'powerOn', + 'duration' => 3, + 'name' => $sbName, + }); + + # display next alarm time if alarm is within the next 24h + } elsif ($showAlarm) { + + my $line = $client->symbols('bell'); + + # Remove seconds from alarm time + my $timeStr = Slim::Utils::DateTime::timeF($nextAlarm->time % 86400, $prefs->client($client)->timeformat, 1); + $timeStr =~ s/(\d?\d\D\d\d)\D\d\d/$1/; + $line .= " $timeStr"; + + # briefly display the next alarm + $client->showBriefly( + { + 'center' => [ + $client->string('ALARM_NEXT_ALARM'), + $line, + ] + }, + { 'duration' => 3, 'brightness' => 'powerOn'}, + ); + } +} + sub _flashAlarm { my $client = shift; Index: Slim/Buttons/Common.pm =================================================================== --- Slim/Buttons/Common.pm (revision 23187) +++ Slim/Buttons/Common.pm (working copy) @@ -1182,11 +1182,17 @@ 'datetime' => sub { my $client = shift; - # briefly display the time/date - $client->showBriefly( dateTime($client), { - 'brightness' => 'powerOn', - 'duration' => 3 - }); + # Use the DateTime plugin to display time/alarm info if it's available + if (exists $INC{'Slim/Plugin/DateTime/Plugin.pm'}) { + Slim::Plugin::DateTime::Plugin::showTimeOrAlarm($client); + + # otherwise just show the time and date + } else { + $client->showBriefly( dateTime($client), { + 'brightness' => 'powerOn', + 'duration' => 3 + }); + } }, 'textsize' => sub { @@ -2269,7 +2275,7 @@ my $line; - # Use the DateTime plugin to get the lines if its available + # Use the DateTime plugin to get the lines if it's available if (exists $INC{'Slim/Plugin/DateTime/Plugin.pm'}) { $line = Slim::Plugin::DateTime::Plugin::dateTimeLines($client); } else {