dirty, but well let's leave room for improvements :-)

changed Watchdog.pm:
add the following at the beginning:

use Win32::TieRegistry;

and the modify the following:

sub IdleWatchdog {
        my $nCurTime;

        my $item;
        my @clients;
        my $curclient;
        my $action;
        my $nTimeDelay;
        my $key;

        #$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..");
                #Not idle...reset the timer to check again..
                $Registry->Delimiter("/"); 
                $key=$Registry->{"LMachine/SOFTWARE/AxoNet Software
GmbH/LightsOut/"}; 
                $key->{"/Action"} = [ pack("L",0), "REG_DWORD" ]; 
                undef $key; 

                return 0;
        }

        #We're idle..increment the idle count..
        #$g{log}->debug("Players are idle..");
        $nIdlePlayersTimeCount++;
        $Registry->Delimiter("/"); 
        $key=$Registry->{"LMachine/SOFTWARE/AxoNet Software GmbH/LightsOut/"};

        $key->{"/Action"} = [ pack("L",2), "REG_DWORD" ]; 
        undef $key; 

It's all done in perl. no external scripts etc. Works for me at the
moment.

possible improvements:

seperate from SvrPowerControl and do simple "interface with LO" plugin.
This would only include watchdog (as implemented here or in Prevent
Windows Shutdown Plugin) and registry modification according to idle
status.

offer selection for standby / hibernate / in plugin config. would be as
easy as exchanging 1,2,3 literally ;-)

Integrate in SvrPowerControl to automatically include registry
modifications if process "LightsOutService.exe" is running -> absolutely
no configuration necessary. Here we would have to check the acutal value
set in the LO Plugin (registry key) before altering it to 0 to prevent
shutdown. If it's been saved somewhere we can reset it in idle condition
to whatever it was before. That would be my prefered way. Maybe i'll try
something like this next week. For now I'm pretty happy with what we've
got so far.

Alex


-- 
psixilambda
------------------------------------------------------------------------
psixilambda's Profile: http://forums.slimdevices.com/member.php?userid=30773
View this thread: http://forums.slimdevices.com/showthread.php?t=48521

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to