Created
April 25, 2013 16:17
-
-
Save mburtscher/5461009 to your computer and use it in GitHub Desktop.
Turn screen on/off if one of the specified machines is online.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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