the totally awesome blink(1) mk2 |
On a smaller scale, I've set up some proximity automation on my computer that's pretty fun. When I walk away from my computer, it turns on the screensaver. If Skype is running, it sets me to invisible. It HipChat is running, it shuts down. And if my blink(1) is attached, it turns yellow to signify that I'm away. (It's on a USB extension cable so I can mount it higher where people can see it.)
If you haven't seen blink(1), it's very cool - double-sided LED USB key. Can set to any color you want on each side, blink in patterns, etc. Connects to IFTTT and email programs and you can also address it from Terminal or AppleScript. (You have to check the "Enable API Server" - most people miss that and think that they can't run Blink1Control and issue cURL commands at the same time.)
And then when I walk back up to my computer, it kills the screensaver. If Skype is running, it sets me to available. If it's between 8 and 5 on a weekday, HipChat starts. Microsoft Office syncs (first checking to see if it's in offline or online mode). And if my blink(1) is attached, it turns it back to green.
Oh, and my screensaver (Soundstream) is noise activated so that the patterns change depending on the amount of noise nearly in our open air office. That's kind of fun.
So how do I accomplish all this? A few neat tricks. First a program called Proximity. You introduce your Bluetooth phone to Proximity and then every so often it pings to see if your phone is around. If it senses a change, it runs the Applescript you've identified. Future places I should probably go are ignoring mouse and keyboard inputs and muting the entire computer.
Here are my scripts:
SCREENSAVER-START
try
do shell script "curl 'http://localhost:8934/blink1/fadeToRGB?rgb=%23FFFF00'"
tell application id "com.apple.ScreenSaver.Engine" to launch
if application "Skype" is running then
tell application "Skype" to send command "SET USERSTATUS invisible" script name "invisible"
end if
if application "HipChat" is running then tell application "HipChat" to quit
end try
SCREENSAVER-STOP
try
do shell script "curl 'http://localhost:8934/blink1/fadeToRGB?rgb=%2300FF00'"
tell application id "com.apple.ScreenSaver.Engine" to quit
tell application "Microsoft Outlook"
if working offline is true then
set working offline to false
sync
set working offline to true
else
tell application "Microsoft Outlook" to sync
end if
end tell
if application "Skype" is running then
tell application "Skype" to send command "SET USERSTATUS online" script name "online"
end if
set x to weekday of (current date) as integer
set y to hours of (current date) as integer
if x > 1 and x < 7 then
if y > 8 and y < 17 then
try
tell application "HipChat" to activate
end try
end if
end if
end tryThe reason that Microsoft Outlook has to check to see if it's online or not is because I have another script that is running that takes it in and out of offline mode automatically. That allows my outgoing messages to temporarily be held and it prevents new messages from being pulled in too frequently. (Otherwise Exchange delivers them immediately and it's distracting. Email doesn't need to be that quick. Yes, I have my notifications turned off, but I actually spend a lot of time in email. It's easier if it's not filling up as I empty it. It's also nice to have some forced delay before my messages go out, in case I change my mind about a message or to avoid email pingpong.)
OUTLOOK
repeat 100 times
log "Sync at - " & (current date)
tell application "Microsoft Outlook" to set working offline to false
tell application "Microsoft Outlook" to sync
delay 5
tell application "Microsoft Outlook" to set working offline to true
delay 600
end repeat
log "** Final at - " & (current date)
tell application "Microsoft Outlook" to set working offline to false
tell application "Microsoft Outlook" to sync
No comments:
Post a Comment