PDA

View Full Version : Sleep time event



Philip Meyer
2008-06-18, 00:27
Is there some callback that occurs when the sleep time reaches 0? I had a look, but couldn't find anything. I was trying to update ExecuteScript plugin such that I could send my server into suspend mode when this happened.

bklaas
2008-06-18, 09:16
it's in Slim::Control::Commands::sleepCommand, which uses this helper function as a callback in the timer

sub _sleepPowerOff {
my $client = shift;

$log->debug("Begin Function");

$client->sleepTime(0);
$client->currentSleepTime(0);

Slim::Control::Request::executeRequest($client, ['stop']);
Slim::Control::Request::executeRequest($client, ['power', 0]);
}

peterw
2008-06-18, 09:44
Is there some callback that occurs when the sleep time reaches 0? I had a look, but couldn't find anything. I was trying to update ExecuteScript plugin such that I could send my server into suspend mode when this happened.

FWIW, I found that the sleep timer cuts players off ~30 seconds earlier than you might expect. See "Fade Curves" on http://www.tux.org/~peterw/slim/SleepFade.html

Philip Meyer
2008-06-18, 12:34
>Slim::Control::Request::executeRequest($client, ['stop']);
>Slim::Control::Request::executeRequest($client, ['power', 0]);

When the sleep timer is met, this helper function executes a stop command and then a power command.

I want to subscribe a callback method for when the sleep timeout occurs, not the commands that the sleep timeout event issues. Something like:

Slim::Control::Request::subscribe(\&commandCallbackSleep, [['sleeptime']]);

However, there doesn't appear to be such a command to subscribe to.

Could the helper function issue an executeRequest for a new command 'sleeptime'? Perhaps move the stop and power commands into the 'sleeptime' command.

gharris999
2008-06-27, 08:16
Phil: did you happen to file an enhancement request on this?

Philip Meyer
2008-06-27, 12:18
>Phil: did you happen to file an enhancement request on this?
No I didn't - do you think it would be useful too?

gharris999
2008-06-27, 19:14
I donno. What do you think of this? http://forums.slimdevices.com/showpost.php?p=315362&postcount=28

Philip Meyer
2008-06-28, 05:11
>I donno. What do you think of this?
>http://forums.slimdevices.com/showpost.php?p=315362&postcount=28

Ah yes, that would be good. I've been trying to extend KDF's Execute plugin to do a shutdown when sleep finishes. If you were to add it to your plugin, I'd be able to get rid of a plugin and it would save me the bother ;)

Enhancement 8594 raised.