Okay, I got it working. I wrote a VB script that changes the registry
entry and placed it in a new Windows sub-directory of the scripts
directory. The busy command including the path to the script is
currently hard-coded into the watchdog script. I know there is a
GetScriptPath() function which is supposed to do the magic, but I could
not switch the log level to debug quickly enough to see where that is
pointing. The patched Watchdog::IdleWatchdog looks like this:
Code:
--------------------
    sub IdleWatchdog {
        my $nCurTime;
  
        my $item;
        my @clients;
        my $curclient;
        my $action;
        my $nTimeDelay;
  
        #$g{log}->debug("Checking to see if scanner is running & if players are 
idle..");
        if ( Plugins::SrvrPowerCtrl::Block::IsBlocked() || 
Plugins::SrvrPowerCtrl::Util::AnyPlayersPlaying() || 
Plugins::SrvrPowerCtrl::Util::AnyPlayersUpdating() || 
Slim::Music::Import->stillScanning() ) {
                $g{log}->debug("Not idle condition..");
  
                # >> begin patch
                my $res;
                my $command;
                my @cmd;
  
                $command = "c:\\windows\\system32\\cscript.exe 
C:\\Programme\\SqueezeCenter\\server\\Plugins\\SrvrPowerCtrl\\scripts\\Windows\\ConfigureLO.vbs
 /Action:busy /Log:true";
                $g{log}->info("Now trying to execute $command");
  
                @cmd = split(' ', $command );
                $res = system @cmd[0..$#cmd];
  
                $g{log}->debug("Command returned $res");
                # >> end patch
  
                #Not idle...reset the timer to check again..
                $nIdlePlayersTimeCount = 0;
                return 0;
        }
  
        #We're idle..increment the idle count..
        #$g{log}->debug("Players are idle..");
        $nIdlePlayersTimeCount++;
  
        #Has the idle time-out period been exceeded?
        if ( $nIdlePlayersTimeCount >= $g{prefs}->nIdleWatchdogTimeout ) {
                $g{log}->debug("Players are idle and idle timeout of 
$nIdlePlayersTimeCount has elapsed..");
  
                $action = $g{prefs}->szIdleWatchdogAction;
  
                #This is just for testing...not a useful watchdog action..
                if ($action eq 'plugin_menu') {
                        @clients = Slim::Player::Client::clients();
                        foreach $curclient (@clients) {
                                
Plugins::SrvrPowerCtrl::Plugin::oursleepButtonHandler( $curclient );
                        }
                return;
                }
  
                $item = Plugins::SrvrPowerCtrl::Menu::findActionItem($action);
                if (!defined($item)) {
                        $g{log}->error( "Bad IdleWatchdog Action: $action");
                        return;
                }
  
                #restart the countdown for our eventual return from 
suspend/hibernate/SN..
                $nIdlePlayersTimeCount = 0;
  
                #cue up the requested action..
                $g{tPendingActionTimer} = Slim::Utils::Timers::setTimer( undef, 
time() + $nWatchdogActionDelay, 
\&Plugins::SrvrPowerCtrl::Plugin::performAction, ( $item ) );
  
        } else {
                $g{log}->debug( $g{prefs}->nIdleWatchdogTimeout - 
$nIdlePlayersTimeCount . " minutes left..");
        }
        return 1;
  }
--------------------
I have attached the Watchdog.pm, the ConfigureLO.vbs and my current
preferences. I need to run a few tests tomorrow with my notebook powered
down (so the server actually hibernates), but if everything continues to
work fine, the only thing left to do is to make the busy command
configurable and maybe adjust the log level of the command call from
info to debug.

In the process of trying to make this work, I've been experiencing two
minor problems.    
- Restarting the SqueezeCenter from SPC won't work for some unknown
  reason. I have meanwhile given the process owner administrative
  privileges, so that should not be the cause.
- When the Hibernate to SN action is performed, I see the following
  messages in my log file:  
Code:
--------------------
        [09-06-07 02:20:15.0005] Plugins::SrvrPowerCtrl::Util::__ANON__ (353) 
Now trying to execute c:\windows\system32\cscript.exe 
C:\Programme\SqueezeCenter\server\Plugins\SrvrPowerCtrl\scripts\Windows\ConfigureLO.vbs
 /Action:hibernate /Log:true
    [09-06-07 02:20:24.4647] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:24.4712] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:24.4766] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:24.4825] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:24.4883] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:24.5183] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:29.5646] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
    [09-06-07 02:20:29.5734] Slim::Web::JSONRPC::requestMethod (383) request 
not dispatchable!
--------------------
    
Last but not least I have been thinking about a new feature that could
possibly be built onto your plug-in. Is there a way to know when the
server is hibernated or shut down externally, e.g. by somebody pushing
the power button? It would be nice if the players could be changed over
to SN in that case, too.

Regards,
-- mvordeme


+-------------------------------------------------------------------+
|Filename: lightsout.zip                                            |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=7547|
+-------------------------------------------------------------------+

-- 
mvordeme

'last.fm' (http://www.last.fm/user/mvordeme) | scaleo home server 2105 |
squeezecenter 7.3.2 | server power control 7.3 |
squeezebox boom & duet | rotel rsp-1066 | rotel rmb-100 | phonar p-5
------------------------------------------------------------------------
mvordeme's Profile: http://forums.slimdevices.com/member.php?userid=22892
View this thread: http://forums.slimdevices.com/showthread.php?t=48521

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to