View Full Version : Geek Tool and OF export
zsteir
2007-09-25, 11:00 AM
Dear All,
I'm a geektool and OF fan, but an applescript novice. Can someone point to an applescript that pulls out the next actions from a OF document? I can then put them to a text file and display on the desktop via GeekTool.
Any help would be appreciated.
zsteir
RobTrew
2007-09-26, 08:31 AM
You may be able to use or modify this.
zsteir
2007-09-26, 01:48 PM
THanks!
zsteir
You may be able to use or modify this.
RobTrew
2007-09-28, 11:45 AM
Or perhaps this, which gives a cleaner listing, includes due dates and postpended names of containing projects, and creates a file on the user desktop.
kev21986
2009-04-06, 04:41 AM
Is there a way to only grab active actions? That script grabs actions from projects that are on hold.
RobTrew
2009-04-06, 01:53 PM
You can test a Section to see whether its Status property has the value Active.
Zettt
2009-10-25, 10:58 AM
Hi,
Thank you for the script. I modified it and wrote three versions of it.
I just wanted to share them with other OmniFocus users. :)
geekcomputers
2009-11-15, 09:30 AM
Forgive me I have never used apple scripts before, do I just run them or do I need to do something from within the application?
Thanks in advance
phatuser
2009-11-21, 10:34 AM
OK, I have the "ListNext" script working, it generates a text file with my next options, but how do I make it work with GeekTool? I have selected file and shell with that script and it doenst display anything... im a bit lost, any help?
Craig
2009-11-21, 04:09 PM
Does it work to put this as the command in your GeekTool settings?
osascript ~/PathToYourScript/YourScriptName.scpt
whpalmer4
2009-11-21, 08:00 PM
That script has some problems if you've got characters that are special to the Unix shell in any of your actions. I would suggest replacing these two lines:
set strCmd to ("echo " & quote & strList & quote & " > " & POSIX path of (path to desktop) as string) & "NextActions.txt"
do shell script strCmd
with
set fRef to (open for access ((POSIX path of (path to desktop) as string) & "NextActions.txt") with write permission)
write strList to fRef
close access fRef
Then the world will be safer for actions that have characters like '(', ')', ':', etc. in them :)
Zettt
2009-11-21, 10:08 PM
phatuser: You need to create another Geeklet which reads the text file.
Something like:
cat that/text/file.txt
Should work.
RobTrew
2011-01-12, 09:26 PM
I notice that the ListNext script (for writing a list of next actions to a file) has been downloaded quite a lot over the years.
As of OmniFocus ver. 1.8, it can be written much more simply, without recursion. Adopting WhPalmer4's improvement to allow for special characters when writing the file, the whole script could now be abbreviated to something like:
on run
-- GET THE DUE DATES, NAMES, AND CONTAINING PROJECTS OF ALL NEXT ACTIONS
tell application id "com.omnigroup.omnifocus"
tell default document
set refTasks to a reference to (flattened tasks where next is true)
set {lstDue, lstTask, lstProject} to {due date, name, name of its containing project} of refTasks
end tell
end tell
-- BUILD A LINE OF TEXT FOR EACH ACTION
set str to "Next" & return
repeat with i from 1 to length of lstTask
set {dteDue, strName, strProject} to {item i of lstDue, item i of lstTask, item i of lstProject}
set strDue to ""
if dteDue is not missing value then set strDue to short date string of dteDue
set str to str & tab & strDue & tab & strName
if strProject ≠ strName then set str to str & " [" & strProject & "]"
set str to str & return
end repeat
set fRef to (open for access ((POSIX path of (path to desktop) as string) & "NextActions.txt") with write permission)
write str to fRef
close access fRef
end run
RobTrew
2011-01-12, 09:39 PM
For a GeekTool list, you could run this even simpler version (which just returns a string value, rather than writing out a file).
If the script is called ListNext03.scpt you could install it in your OmniFocus script directory, and run it from GeekTool with a command like:
osascript ~/Library/Scripts/Applications/Omnifocus/ListNext03.scpt | tr '\r' '\n'
(piping it through tr to convert applescript's return characters to shell-compatible newline characters).
--
BrianM
2011-01-13, 09:09 AM
These scripts are wonderful! Do you know if there is a way to list tasks only in a specific Perspective? Being able to export a list of actions in a particular Perspective is the only thing missing here.
Thank you for making these available!
RobTrew
2011-01-13, 09:49 AM
Do you know if there is a way to list tasks only in a specific Perspective? Being able to export a list of actions in a particular Perspective is the only thing missing here.
The OmniFocus applescript library doesn't directly offer a list of tasks in exchange for a perspective name, but you can certainly define custom lists by editing the clause in the script above which reads:
flattened tasks where next is true
and you can use a post on this forum (http://bit.ly/OF-QL) (which lists applescript clauses for the OF various filters) as a cookbook from which to assemble your own recipes. For example:
flattened tasks where (flagged is true) and (estimated minutes <= 30)
or
flattened projects where ((status is active) or (status is on hold) and ((effectively hidden of its folder is false) or (its folder is missing value)))
(You can use the Where in OF (http://bit.ly/OF-Find) script to test these recipes before using them in a custom applescript).
--
BrianM
2011-01-13, 10:52 AM
Thanks so much for your quick reply. I'm playing around a little and I think I can get it to work for what I need, but I'm getting an error when running some of the scripts using osascript:
osascript: couldn't save changes to script /Users/brian/Library/Scripts/Applications/Omnifocus/ListNextFile03.scpt: error 4294965546.
I haven't been able to figure out what is causing this. Any ideas?
RobTrew
2011-01-13, 11:00 AM
This version allows for a variety of custom task lists, and can be used either to create text files, or for displaying lists in Geektool windows.
If you install it in your OmniFocus script folder as:
~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt
you can then run it from the Terminal (or in Geektool) with arguments specifying the query and the list header (optionally redirecting the output into a text file).
(Note that the query and header should be enclosed in single quotes)
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt 'flagged is true' 'Flagged' > FlaggedTasks.txt
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt 'next is true' 'Next actions' > NextActions.txt
For use with Geektool, there is no need to redirect to a text file. Just give the query and the header
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt '((due date ≤ soon) or (flagged is true))' 'Soon and Flagged'
If no arguments are supplied, the script still defaults to outputting a Next Actions list.
For details of the queries corresponding to OF filter settings, see the FAQ (http://bit.ly/OF-QL) on this forum. The terms now and soon can both be used in queries involving dates. Soon will be interpreted in accordance with your setting under:
OF > Preferences > Data > Due "Soon" is in the next N days
--
RobTrew
2011-01-13, 11:11 AM
osascript: couldn't save changes to script /Users/brian/Library/Scripts/Applications/Omnifocus/ListNextFile03.scpt: error 4294965546.
I haven't been able to figure out what is causing this. Any ideas?
Sounds like you may also have the script open in your applescript editor. Closing it before using osascript should fix it.
See, however, the new script, above, which allows you to to give custom queries as arguments on the command line. This may save you customizing your own scripts.
BrianM
2011-01-13, 12:39 PM
You were right that I needed to close Script Editor; now it works fine.
And this new script is PERFECT for what I need - I can just recreate my perspectives using the correct fields and it works just like I want. THANK YOU!
Now I guess I need to actually DO some of the items on my list instead of messing around with scripts. :-)
RobTrew
2011-01-14, 10:58 AM
I can just recreate my perspectives using the correct fields
If you want to adjust the set of fields that are displayed for your chosen set of records, you can experiment with the OF-AQL (http://bit.ly/OF-AQL)script, which uses queries which start with SELECT field1, field2, ... fieldn
--
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.