Caffeine is a tiny little app that keeps your Mac awake when needed; be it when you’re watching a video (for some reason, Adobe Flash doesn’t keep your Mac awake), reading something off your screen, or anything else.
It sits in the menu bar waiting to be summoned when needed, and dismissed just as easily.
Being the lazy type I am (thanks to the inevitable Quicksilver), dragging the mouse over to click the icon is just too much work. Below is an applescript which I run from Quicksilver with 3 key presses (I could set it as a trigger if I really wanted) and it switches it on or off, or even opens it if it’s not running.
tell application "System Events"
if exists (process "Caffeine") then
tell application "Caffeine"
if active is false then
turn on
else
turn off
end if
end tell
else
tell application "Caffeine" to activate
end if
end tell
This will launch the app if it’s not running. If it is running it’ll check to see if your Mac is on Caffeine (i.e. if it’s turned on) and carry out the required action.
This is all possible thanks to Caffeine being scriptable. It’s always great when developers add applescript support as well as others to their apps – it makes the Mac experience that bit more cosy.
You can download the applescript here
I’ve even added the right icon to the script 🙂
All that needs doing is setting up a trigger in Quicksilver, or placing it in
~/Library/Scripts/
.
Done!
4 comments for “Toggling Caffeine with Quicksilver to keep your Mac awake”