Last active
December 21, 2015 20:39
-
-
Save dkordik/6363065 to your computer and use it in GitHub Desktop.
SleepWatcher setup for Hue lights to turn off and on when my screen does. SleepWatcher lets you run arbitrary commands on wake/sleep/displaydim/displayundim. It can be found here: http://www.bernhard-baehr.de/ - get an API key for your Hue by following these steps: http://developers.meethue.com/gettingstarted.html
This file contains hidden or 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
| #!/bin/bash | |
| APIKEY="newdeveloper" | |
| function turnOff { | |
| curl -X PUT -d"{\"on\": false }" http://192.168.2.142/api/$APIKEY/lights/$1/state | |
| } | |
| turnOff 1 | |
| turnOff 3 |
This file contains hidden or 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
| #!/bin/bash | |
| APIKEY="newdeveloper" | |
| function turnOn { | |
| curl -X PUT -d"{\"on\": true }" http://192.168.2.142/api/$APIKEY/lights/$1/state | |
| } | |
| turnOn 1 | |
| turnOn 3 |
This file contains hidden or 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
| #this goes in: /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist | |
| #start daemon with: launchctl load /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>de.bernhard-baehr.sleepwatcher</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/local/sbin/sleepwatcher</string> | |
| <string>-V</string> | |
| <string>-s /etc/rc.sleep</string> | |
| <string>-w /etc/rc.wakeup</string> | |
| <string>-S /Users/dkordik/.displaysleep</string> | |
| <string>-W /Users/dkordik/.displaywake</string> | |
| </array> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| <key>KeepAlive</key> | |
| <true/> | |
| </dict> | |
| </plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment