Skip to content

Instantly share code, notes, and snippets.

@mburtscher
Created April 25, 2013 16:17
Show Gist options
  • Save mburtscher/5461009 to your computer and use it in GitHub Desktop.
Save mburtscher/5461009 to your computer and use it in GitHub Desktop.
Turn screen on/off if one of the specified machines is online.
#!/usr/bin/php
<?php
$hosts = array(
"192.168.10.11",
"192.168.10.12",
"192.168.10.13",
"192.168.10.14",
"192.168.10.15",
"192.168.10.16",
"192.168.10.17",
"192.168.10.18",
"192.168.10.19",
);
$online = false;
foreach($hosts as $host)
{
$result = shell_exec("ping -c 1 -W 1 " . $host);
if(strstr($result, "1 received"))
{
$online = true;
break;
}
}
if($online)
{
exec("xset dpms force on; xset s reset");
}
else
{
exec("xset dpms force off");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment