The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Pomodoro app and Omnifocus are a perfect couple! -help with applescript needed Thread Tools Search this Thread Display Modes
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 :)

For example, Pomodoro pulls the (flagged and due soon) ToDos from Omnifocus. 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.)

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.

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
I described my problem also in the Pomodoro Issue tracker forum here:
https://github.com/ugol/pomodoro/issues/208

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

Appstore link: http://itunes.apple.com/en/app/pomod...17574133?mt=12

Thanks!

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

Last edited by marekp; 2011-06-16 at 05:16 AM..
 
Quote:
Originally Posted by marekp View Post
pull the Project name of the ToDo as well
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
--

Last edited by RobTrew; 2011-06-20 at 06:39 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

Last edited by RobTrew; 2011-06-20 at 10:57 PM.. Reason: (display due dates & flagged status)(sort by effectiveDueDate)
 
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
thanks a lot again!

Marek
 
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.

https://github.com/ugol/pomodoro/issues/138


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))
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!

http://kouroshdini.com/2009/11/23/gt...-the-pomodoro/
 
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")
Attached Thumbnails
Click image for larger version

Name:	Post 3.png
Views:	429
Size:	22.4 KB
ID:	1939   Click image for larger version

Name:	Post 2.png
Views:	439
Size:	24.0 KB
ID:	1940   Click image for larger version

Name:	Hybrid of Post 2 and 3.png
Views:	412
Size:	15.7 KB
ID:	1941  
 
Something like the following ?

(Note that AppStore-purchased copies of OmniFocus won't be able to run this without modification)

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

Last edited by RobTrew; 2011-06-28 at 12:24 AM..
 
Quote:
Originally Posted by RobTrew View Post
Something like the following ?
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!
Attached Thumbnails
Click image for larger version

Name:	Post 7.png
Views:	567
Size:	30.1 KB
ID:	1943  
 
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.
 
Post 5 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:

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

then you will need to edit it to:

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppleScript Help Needed - Delete Empty Rows lesbrown OmniOutliner 3 for Mac 4 2011-09-22 06:35 AM
Checklists (again), Omnifocus, Alternatives and 'Perfect' philrob Applying OmniFocus 5 2011-02-16 04:37 AM
Workflow Omnifocus and iCal - a perfect system Lasse OmniFocus Extras 2 2010-07-06 05:15 AM
AppleScript help needed for ow5 & oo3 sangheeta AppleScripting Omni Apps 3 2008-04-03 01:04 PM


All times are GMT -8. The time now is 01:35 AM.


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