Skip to content

Instantly share code, notes, and snippets.

@bachya
Created September 5, 2014 05:24
Show Gist options
  • Save bachya/22541a8b15d5963988ab to your computer and use it in GitHub Desktop.
Save bachya/22541a8b15d5963988ab to your computer and use it in GitHub Desktop.
(*
### SCRIPT NAME
OmniFocus+
### DESCRIPTION
Allows for smarter task entry on OS X: if OmniFocus is running, use
Applescript to add the task; otherwise, use the user's Mail Drop
email address.
### INSTALLATION
1. Download the .alfredworkflow file somewhere on your filesystem.
2. Double click on it.
3. You should be good to go. :)
### LICENSE
(The MIT License)
Copyright © 2014 Aaron Bach [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
author: Aaron Bach
date: July 27, 2014
version: 1.0.0
*)
-- The Mail Drop address to use
set mailDropAddress to "YOUR MAIL DROP ADDRESS"
-- DO NOT CHANGE BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING.
-- Determine whether OmniFocus is running.
tell application "System Events"
set omnifocusActive to count (every process whose name is "OmniFocus")
end tell
if omnifocusActive > 0 then
-- OmniFocus is running, so insert a task into it directly.
tell application "OmniFocus" to tell document 1
make new inbox task with properties {name:"{query}"}
end tell
else
-- OmniFocus isn't running, so use the Mail Drop method.
do shell script "mail -s \"{query}\" " & mailDropAddress & " < /dev/null"
end if
return "{query}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment