Index: Plugins/DateTime/Plugin.pm =================================================================== --- Plugins/DateTime/Plugin.pm (revision 2702) +++ Plugins/DateTime/Plugin.pm (working copy) @@ -63,6 +63,9 @@ sub setMode { my $client = shift; $client->lines(\&lines); + + # setting this param will call client->update() frequently + $client->param('modeUpdateInterval', 1); # seconds } our %functions = ( @@ -196,6 +199,9 @@ sub setScreensaverDateTimeMode() { my $client = shift; $client->lines(\&screensaverDateTimelines); + + # setting this param will call client->update() frequently + $client->param('modeUpdateInterval', 1); # seconds } sub screensaverDateTimelines { Index: Slim/Player/Squeezebox2.pm =================================================================== --- Slim/Player/Squeezebox2.pm (revision 2702) +++ Slim/Player/Squeezebox2.pm (working copy) @@ -162,15 +162,11 @@ return 'squeezebox2'; }; -# only refresh if we're in a screen that needs it (this knowledge needs to be moved to the mode...) +# SB2 does not need an update here, so a noop is OK sub refresh { - my $client = shift; - if (Slim::Buttons::Playlist::showingNowPlaying($client) || !$client->power()) { - $client->update(); - } + # my $client = shift; } - # in order of preference based on whether we're connected via wired or wireless... sub formats { my $client = shift; Index: Slim/Buttons/Common.pm =================================================================== --- Slim/Buttons/Common.pm (revision 2702) +++ Slim/Buttons/Common.pm (working copy) @@ -1046,6 +1046,9 @@ my $fun = $modes{$setmode}; &$fun($client,'push'); + + # some modes require periodic updates + startPeriodicUpdates($client); } sub popMode { @@ -1124,6 +1127,34 @@ return @line; } +# if and only if the mode has set the modeUpdateInterval parameter, +# call $client->update every modeUpdateInterval seconds. +sub startPeriodicUpdates { + my $client = shift; + # unset any previous timers + Slim::Utils::Timers::killTimers($client, \&_periodicUpdate); + my $interval = $client->param('modeUpdateInterval'); + return unless $interval; + Slim::Utils::Timers::setTimer($client, Time::HiRes::time() + $interval, + \&_periodicUpdate, + $client); +} + +sub _periodicUpdate { + my $client = shift; + my $interval = $client->param('modeUpdateInterval'); + # if interval is not set, we have left the mode that needed the update + return unless $interval; + # do the update + $client->update(); + # do it again at the next period + Slim::Utils::Timers::setTimer($client, Time::HiRes::time() + $interval, + \&_periodicUpdate, + $client); +} + + + 1; __END__ Index: Slim/Buttons/Playlist.pm =================================================================== --- Slim/Buttons/Playlist.pm (revision 2702) +++ Slim/Buttons/Playlist.pm (working copy) @@ -174,6 +174,9 @@ my $how = shift; $client->lines(\&lines); if ($how ne 'pop') { jump($client); } + + # update client every second in this mode + $client->param('modeUpdateInterval', 1); # seconds } sub jump {