The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Pomodoro app and Omnifocus are a perfect couple! -help with applescript needed (http://forums.omnigroup.com/showthread.php?t=21401)

marekp 2011-06-16 02:47 AM

Pomodoro app and Omnifocus are a perfect couple! -help with applescript needed
 
Hi,

I started using the greatly designed Pomodoro App.
Pomodoro is a technique about getting totally focused on a task by committing to work on it for 25 minutes.

The app is basically a kitchen clock but with a lot of interesting features for productivity geeks and Omnifocus users :)

[b]For example, Pomodoro pulls the (flagged and due soon) ToDos from Omnifocus.[/b] You only have to hit a shotcut for pomodoro to show up, select a omnifocus task from a pulldown menu (with the arrow keys) and you can start focusing.

What's even better is that the app paste the 25 min intervals including the ToDO name in iCal afterwards. This is awesome for getting an overview on what you have worked on in one day and how much time it cost you. (There also people who make long term visualization out of this data.)

[b]I have just one small wish left: the Pomodoro app only pulls the name of the ToDos from Omnifocus but I would love to have it pull the Project name of the ToDo as well. -This would make the overview in iCal more structured as I could easily see how much time exactly I worked on a project.[/b]

Pomodoro uses an applescript to get the data out of Omnifocus. I tried to change it but I haven't succeeded so far as I'm completly new to applescript.
That's the orignal applescript the developer uses to get the ToDos out of Omnifocus:

Can anyone help me out here?

[code]
tell application "System Events" to if exists process "OmniFocus" then
tell application "OmniFocus"
tell default document
set due_soon to a reference to setting id "DueSoonInterval"
set due_soon_interval to ((value of due_soon) / days) as integer
set due_date to (current date) + due_soon_interval * days
get name of every flattened task whose completed is false and blocked is false and ((due date is less than or equal to due_date) or (flagged is true or flagged of containing project is true)) and status of containing project is active
end tell
end tell
end if
[/code]

I described my problem also in the Pomodoro Issue tracker forum here:
[url]https://github.com/ugol/pomodoro/issues/208[/url]

Developers' site with explanations and a free alpha version: [url]http://pomodoro.ugolandini.com/[/url]

Appstore link: [url]http://itunes.apple.com/en/app/pomodoro/id417574133?mt=12[/url]

Thanks!

Marek
PS: (it took me one Pomodoro (25 min) to write this forum post by the way:)

RobTrew 2011-06-20 05:50 AM

[QUOTE=marekp;98647]pull the Project name of the ToDo as well[/QUOTE]

I think this should work.

(Note that it truncates the Project name, to make sure that at least part of the Task name is visible).

[CODE]property MaxProjChars : 20

tell application "System Events" to if exists process "OmniFocus" then
tell application "OmniFocus"
tell default document
set due_soon to a reference to setting id "DueSoonInterval"
set due_soon_interval to ((value of due_soon) / days) as integer
set due_date to (current date) + due_soon_interval * days
tell (flattened tasks whose completed is false and blocked is false and ((due date is less than or equal to due_date) or (flagged is true or flagged of containing project is true)) and status of containing project is active)
set {lstProj, lstTasks} to {name of containing project, name}
end tell
repeat with i from 1 to length of lstTasks
set item i of lstTasks to "[" & my Truncate(item i of lstProj) & "]: " & item i of lstTasks
end repeat
return lstTasks
end tell
end tell
end if

on Truncate(strLong)
if length of strLong > MaxProjChars then
return text 1 thru MaxProjChars of strLong
else
return strLong
end if
end Truncate

[/CODE]

[COLOR="White"]--[/COLOR]

RobTrew 2011-06-20 08:43 AM

And a variant which sorts the tasks by flagged status and due date, and lists tasks (with due dates) under project headings.

[CODE]-- Sorts Flagged and Due Soon tasks by Due Date
-- and lists tasks, with due dates, under project headings

property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pDelim : "~|~"

on run
set lstLines to paragraphs of (do shell script "sqlite3 -separator " & quoted form of pDelim & space & pstrDBPath & space & quoted form of ¬
"SELECT proj.name, tsk.name, tsk.effectiveFlagged, strftime('%m/%d/%Y', tsk.effectivedateDue + strftime('%s','2001-01-01'), 'unixepoch')
FROM (task t left join projectinfo p on t.containingprojectinfo=p.pk) tsk join task proj on proj.projectinfo=tsk.pk
WHERE (folderEffectiveActive is null or folderEffectiveActive = 1) and (status is null or status = \"active\")
and tsk.dateCompleted is null and tsk.blocked=0 and (tsk.isDueSoon=1 or tsk.effectiveFlagged=1)
ORDER BY tsk.effectiveFlagged DESC, tsk.effectivedateDue, proj.name")

set {lstTasks, strLastProj} to {{}, ""}
set {strDlm, text item delimiters} to {text item delimiters, pDelim}
repeat with oLine in lstLines
set {strProj, strTask, strFlagged, strDue} to text items of oLine

if strProj ≠ strLastProj then
set end of lstTasks to do shell script "echo " & quoted form of strProj & " | tr '[:lower:]' '[:upper:]'"
set strLastProj to strProj
end if

if strFlagged ≠ "0" then
set strFlag to "• [!!] "
else
set strFlag to "• "
end if

if strDue ≠ "" then set strDue to "[" & strDue & "] "

set end of lstTasks to strFlag & strDue & strTask
end repeat
set text item delimiters to strDlm
return lstTasks
end run

[/CODE]

marekp 2011-06-25 07:13 AM

RobTrew thank you so much!
I haven't get notified by email so please excuse my late reply.

Your first script works perfectly for me and does what I wanted.
I think the second one is great too because it unclutteres the list by having a header in Pomodoro. But then I don't have the Project name pasted to iCal later on (which I want for getting an overview on what projects I worked on).

So I'm super happy about the first one. Though, I adjusted it to my needs a bit:

This script is a modified version of RobTrew and it returns now also "next actions" of every active project, tasks which have a flagged parent task and it ignores tasks in the "Someday/Maybe" folder. I also added a ▶ symbol to have a clear visual separator between project and tasks.

[code]
property MaxProjChars : 20

tell application "System Events" to if exists process "OmniFocus" then
tell application "OmniFocus"
tell default document
set due_soon to a reference to setting id "DueSoonInterval"
set due_soon_interval to ((value of due_soon) / days) as integer
set due_date to (current date) + due_soon_interval * days
tell (flattened tasks whose completed is false and blocked is false and ((due date is less than or equal to due_date) or (next is true and name of folder of containing project is not "Someday/Maybe") or (flagged is true or flagged of containing project is true or flagged of parent task is true)) and status of containing project is active)
set {lstProj, lstTasks} to {name of containing project, name}
end tell
repeat with i from 1 to length of lstTasks
set item i of lstTasks to my Truncate(item i of lstProj) & " ▶" & item i of lstTasks
end repeat
return lstTasks
end tell
end tell
end if

on Truncate(strLong)
if length of strLong > MaxProjChars then
return text 1 thru MaxProjChars of strLong
else
return strLong
end if
end Truncate
[/code]

thanks a lot again!

Marek

skillet 2011-06-25 01:59 PM

This is absolutely great! I use this application daily with Pomodoro and love what you came up with RobTrew!

Thanks marekp you beat me to posting something similar. Also just in case anyone stumbles across this thread you can modify the script used in this app by right clicking on the Pomodoro app and choosing "Show Package Contents" and gong to the resource folder and then changing the script called "getToDoListFromOmniFocus.applescript"

You have to of course save the script and then close and reopen Pomodoro for this to work.

[url]https://github.com/ugol/pomodoro/issues/138[/url]


Since it is somewhat related to this post, I use the following script to display in large print in QuickSilver the time the Pomodoro will be done for quick reverence.

[CODE]on getTimeInHoursAndMinutes(aDate)
set ts to time string of aDate

set hm to text 1 thru word 2 of ts
if ((count ts's words) is 4) then set hm to hm & space & word 4 of ts

return hm
end getTimeInHoursAndMinutes


--say "I will have a five minute window at " & getTimeInHoursAndMinutes((current date) + 25 * minutes) & " thanks" using "Alex"

tell application "Quicksilver" to show large type (my getTimeInHoursAndMinutes((current date) + 25 * minutes))[/CODE]

I have QuicKeys start ProTimers (which is free in the app store) since it has a larger count down and then stop it for breaks and start my break counter.

The great thing about this in addition to its size is that it shows you how much overtime you have done on your break and Pomodoro if you break the Pomodoro rule.

I can send you the details of how it starts and stops them, and how it handles interruptions if you are interested. Thanks both for helping me out a bunch with this post!

[url]http://kouroshdini.com/2009/11/23/gtd-omnifocus-and-pomodoros-part-i-introducing-the-pomodoro/[/url]

skillet 2011-06-27 02:04 PM

3 Attachment(s)
Is there a way to combine the second and third post?

To get something like this
[SINGLE-ACTIONS LIST]
[SINGLE-ACTIONS LIST]: Action 1 (06/25/2011)(!!)
[SINGLE-ACTIONS LIST]: Action 2 (!!)
[Daily Projects]
[Daily Projects]: Action 1 (06/23/2011)
[Daily Projects]: Action 1 (06/23/2011)(!!)
[Daily Projects]: Action 2 (06/23/2011)(!!)

Most of the time I would probably just select the project but some actions I could probably spend the entire 25 minutes on one action in a project. The due date and flag is a very nice touch as well.

I spent a while trying to do this myself but post 3 boggles me in the voodoo it is doing.

Especially this part[CODE] set lstLines to paragraphs of (do shell script "sqlite3 -separator " & quoted form of pDelim & space & pstrDBPath & space & quoted form of ¬
"SELECT proj.name, tsk.name, tsk.effectiveFlagged, strftime('%m/%d/%Y', tsk.effectivedateDue + strftime('%s','2001-01-01'), 'unixepoch')\n\t\tFROM (task t left join projectinfo p on t.containingprojectinfo=p.pk) tsk join task proj on proj.projectinfo=tsk.pk\n\t\tWHERE (folderEffectiveActive is null or folderEffectiveActive = 1) and (status is null or status = \"active\") \n\t\t\tand tsk.dateCompleted is null and tsk.blocked=0 and (tsk.isDueSoon=1 or tsk.effectiveFlagged=1)\n\t\tORDER BY tsk.effectiveFlagged DESC, tsk.effectivedateDue, proj.name")
[/CODE]

RobTrew 2011-06-28 12:15 AM

Something like the following ?

(Note that AppStore-purchased copies of OmniFocus won't be able to run this without [URL="http://forums.omnigroup.com/showthread.php?t=21458"]modification[/URL])

[CODE]-- Sorts Flagged and Due Soon tasks by Due Date
-- and lists tasks, with due dates, under project headings

property MaxProjChars : 15

property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pDelim : "~|~"

on run
set lstLines to paragraphs of (do shell script "sqlite3 -separator " & quoted form of pDelim & space & pstrDBPath & space & quoted form of ¬
"SELECT proj.name, tsk.name, tsk.effectiveFlagged, strftime('%m/%d/%Y', tsk.effectivedateDue + strftime('%s','2001-01-01'), 'unixepoch')
FROM (task t left join projectinfo p on t.containingprojectinfo=p.pk) tsk join task proj on proj.projectinfo=tsk.pk
WHERE (folderEffectiveActive is null or folderEffectiveActive = 1) and (status is null or status = \"active\")
and tsk.dateCompleted is null and tsk.blocked=0 and (tsk.isDueSoon=1 or tsk.effectiveFlagged=1)
ORDER BY tsk.effectiveFlagged DESC, tsk.effectivedateDue, proj.name")

set {lstTasks, strLastProj} to {{}, ""}
set {strDlm, text item delimiters} to {text item delimiters, pDelim}
repeat with oLine in lstLines
set {strProj, strTask, strFlagged, strDue} to text items of oLine

if strProj ≠ strLastProj then
set end of lstTasks to do shell script "echo " & quoted form of strProj & " | tr '[:lower:]' '[:upper:]'"
set strLastProj to strProj
end if

if strFlagged ≠ "0" then
set strFlag to "(!!) "
else
set strFlag to ""
end if

if strDue ≠ "" then set strDue to "(" & strDue & ") "

set end of lstTasks to "[" & Truncate(strProj) & "]: " & strTask & space & strDue & strFlag
end repeat
set text item delimiters to strDlm
return lstTasks
end run

on Truncate(strLong)
if length of strLong > MaxProjChars then
return text 1 thru MaxProjChars of strLong
else
return strLong
end if
end Truncate[/CODE]

skillet 2011-06-28 02:28 AM

1 Attachment(s)
[QUOTE=RobTrew;99012]Something like the following ?
[/QUOTE]

This is awesome, it shows most of the task, and the due date & flags are out of the way but yet get recorded in iCal. They also show up in the same order they do in in OmniFocus with the due date and flags after the action name.

Very cool thank you very much!

mikegibb 2011-06-29 06:15 AM

I've installed the script in my OF scripts folder and in the "start" script for Pomodoro, but I can't get the script to work. Can someone please explain how to install the script? Thanks.

RobTrew 2011-06-29 08:52 AM

[URL="http://forums.omnigroup.com/showpost.php?p=98933&postcount=5"]Post 5[/URL] above contains the basic instructions.

If you bought OmniFocus through the Mac App Store, and are using one of the scripts above which contains the string:

[I]"~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"[/I]

then you will need to edit it to:

"~/Library/Caches/com.omnigroup.OmniFocus.MacAppStore/OmniFocusDatabase2"


All times are GMT -8. The time now is 08:01 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.