diff --git a/Caffeine Controls No Growl.alfredextension b/Caffeine Controls No Growl.alfredextension deleted file mode 100644 index 999e234..0000000 Binary files a/Caffeine Controls No Growl.alfredextension and /dev/null differ diff --git a/Caffeine Controls.alfredextension b/Caffeine Controls.alfredextension deleted file mode 100644 index 40307aa..0000000 Binary files a/Caffeine Controls.alfredextension and /dev/null differ diff --git a/Caffeine.alfredworkflow b/Caffeine.alfredworkflow new file mode 100644 index 0000000..49bf1cb Binary files /dev/null and b/Caffeine.alfredworkflow differ diff --git a/README.md b/README.md index d936d67..bba8c06 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,32 @@ -Caffeine Controls for Alfred -============ +# Caffeine Controls for Alfred -An AppleScript so you can easily control Caffeine from [Alfred App](http://alfredapp.com/). You will need Alfred and the Powerpack to use this. +Easily control Caffeine from [Alfred App](http://alfredapp.com/). You will need Alfred and the Powerpack to use this. Simply type `caff` and toggle caffeine on and off. Need caffeine on for 'x' amount of minutes? No problem, just type `caff 5` and it will run automatically for 5 minutes then turn off. Enjoy. -Installation ----------------- +## Installation -To install Caffeine Controls in Alfred double click on the extension file. +To install Caffeine Controls in Alfred double click on the workflow file. -How to use ----------------- +## Command List +``` +caff :: Toggle caffeine on and off +caff 5 :: Turn caffeine on for 5 minutes (the # can be changed to any number) +caff quit :: Quit caffeine (can also use 'caff end' or 'caff exit') +``` -Once installed with Alfred you can run the following commands +## Download - caff :: Toggle caffeine on and off - caff on :: Turn caffeine on indefinitely - caff 5 :: Turn caffeine on for 5 minutes (the # can be changed to any number) - caff off :: Turn caffeine off - caff quit :: Quit caffeine (can also use 'caff end' or 'caff exit') - caff start :: Start caffeine (can also use 'caff init') +[Caffeine Controls](https://github.com/phpfunk/alfred-caffeine-controls/archive/v2.zip) -Notes ----------------- -If caffeine is not active and you turn it on with either 'caff on' or 'caff #' or 'caff', it will automatically start the Caffeine application for you. You do not have to call 'caff start' first. - -Big thanks to [pfburno](https://github.com/pfbruno) for his contributions and ideas for this extension (initial growl integration, toggle and easy-to-use turn on for 'x' minutes approach). - - -Growl vs. No Growl ----------------- -Two versions of the extension are available, one with Growl and one without. If you wish to use the one without Growl please install the 'Caffeine Controls No Growl.alfredextension' file. +## Version History ## -Download ----------------- -[Caffeine Controls](https://github.com/phpfunk/alfred-caffeine-controls/downloads) +### 2.0.1 - January 21, 2013 +* Update bundle ID +### 2.0.0 - January 13, 2013 -## Version History ## +* Updated for version 2 of Alfred and simplified the command list. +* Added notification support for Mountain Lion ### 1.2.3 - August 2, 2012### diff --git a/caff-command.txt b/caff-command.txt new file mode 100644 index 0000000..663848e --- /dev/null +++ b/caff-command.txt @@ -0,0 +1,29 @@ +on alfred_script(q) + + tell application "Caffeine" + if (active is false) then + if q is not equal to "" then + try + (q as real) div 1 + turn on for (q * 60) + if q is equal to "1" then + set s to "" + else + set s to "s" + end if + return "Caffeine started for " & q & " minute" & s & "." + on error + turn on + return "Caffeine started for an indefinite amount of time." + end try + else + turn on + return "Caffeine started for an indefinite amount of time." + end if + else + turn off + return "Caffeine has been turned off." + end if + end tell + +end alfred_script \ No newline at end of file diff --git a/caff-quit-command.txt b/caff-quit-command.txt new file mode 100644 index 0000000..1da1db9 --- /dev/null +++ b/caff-quit-command.txt @@ -0,0 +1,7 @@ +on alfred_script(q) + + tell application "Caffeine" + quit + end tell + +end alfred_script \ No newline at end of file diff --git a/source.txt b/source.txt deleted file mode 100644 index 4a58a09..0000000 --- a/source.txt +++ /dev/null @@ -1,95 +0,0 @@ -### Controls #### -# on -# 5 -# 2h -# off -# quit or end or exit or kill -# start or init -# no argument will toggle Caffeine on and off -################################ -# On Indefinitely: caff on -# On for 5 Minutes: caff 5 -# On for 2 Hours: caff 2h -# Off: caff off -# Quit App: caff quit or caff end or caff exit or caff kill -# Start App: caff start or caff init -# Toggle: caff -################################ -# If you turn caffeine on and it's not started it will -# start automatically for you first. No need to call -# caff start first. - -on sendMsg(msg) - tell application "System Events" - set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 - end tell - - if isRunning then - tell application id "com.Growl.GrowlHelperApp" - set the allNotificationsList to {"Caffeine Notification"} - set the enabledNotificationsList to {"Caffeine Notification"} - register as application "Caffeine Controls" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Caffeine" - notify with name "Caffeine Notification" title "Caffeine" description msg application name "Caffeine Controls" icon of application "Caffeine" - end tell - end if -end sendMsg - -on alfred_script(q) --- add hours-detection here - if q contains "h" then - set text item delimiters to "h" - set hours to text item 1 of q - if hours > 0 then - set q to (hours * 60) - end if - end if --- original code below - set msg to "" - set s to {"start", "init"} - set e to {"quit", "kill", "end", "exit"} - - tell application "Caffeine" - if q is in e then - set msg to "Bye Bye, see you next time." - quit - else if q is equal to "" or q is missing value or q is equal to "on" or q is equal to "off" then - if (active is false or q is equal to "on") and q is not equal to "off" then - set again to "" - if active is true then - set again to " again ;)" - end if - set msg to "Turned on indefinitely" & again - turn on - else - set again to "" - if active is false then - set again to " again ;)" - end if - set msg to "Turned off" & again - turn off - end if - else if q is in s then - set msg to "Application started" - activate - else - try - (q as real) div 1 - turn on for (q * 60) - if q is equal to "1" then - set s to "" - else - set s to "s" - end if - set msg to "Turned on for " & q & " minute" & s - on error - set msg to "Turned on indefinitely" - turn on - end try - end if - end tell - - if msg is not equal to "" then - sendMsg(msg) - end if - -end alfred_script \ No newline at end of file