The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Script: custom OmniFocus action lists on the desktop, using Geektool (http://forums.omnigroup.com/showthread.php?t=19419)

sterlizzi 2010-12-28 04:17 PM

My OF Preferences
 
Rob,

My current preferences settings are:
[INDENT]"Due Soon" is in the next 2 days

Default Time For Due Dates: 5:00PM[/INDENT]
I will check over the next day and see what happens.

Anyhow, I love the Geeklets. Awesome work.


Steve

RobTrew 2010-12-29 01:17 AM

:-) I'm glad you find them useful.

Given that our settings look the same, if you did find that you were getting a mismatch, attention might focus next on the data. (Are non-default due times involved, for example).

(With my data the geeklet lists do seem to be reliably matching the red and orange badging in OF).

SpiralOcean 2010-12-31 02:33 PM

Bravo!

[QUOTE=RobTrew;90786]No formal documentation that I know of, but you can put a list of the fields and their types into the clipboard with code like:

[CODE]property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property plstResults : {}

on run
set text item delimiters to return
set str to ""
set lstTables to ({"Task", "ProjectInfo", "Context", "Folder"})
repeat with oTable in lstTables
set strSQL to "PRAGMA TABLE_INFO(" & oTable & ");"
RunSQL(strSQL)
set str to str & oTable & return & return & (plstResults as string) & return & return & return
end repeat
set text item delimiters to space

set the clipboard to str
end run

on RunSQL(strSQL)
set strCmd to "sqlite3 " & pstrDBPath & space & quoted form of strSQL

set plstResults to (paragraphs of (do shell script strCmd))
end RunSQL
[/CODE]

(Probably important to bear in mind that the schema can change, unannounced, between builds, and that reading the cache has been described on this forum as "at the deep end of not officially supported").[/QUOTE]

RobTrew 2010-12-31 04:42 PM

The other thing which may be useful to understand is the relationship between Applescript dates and the numeric datestamp strings in the cache. (Representing dates as a count of seconds since midnight at the start of 2001).

Here is a simple conversion function:

[CODE]property pdteBase : missing value

on SQL2ASDate(strDateStamp)
try
set intDate to (strDateStamp as integer)
on error
return missing value
end try
if pdteBase is missing value then
set pdteBase to current date
tell pdteBase
set {its year, its month, its day, its time} to {2001, 1, 1, 0}
end tell
end if
(pdteBase + intDate) as string
end SQL2ASDate

on AS2SQLDate(strDate)
try
set varDate to date strDate
on error
return "null"
end try

if pdteBase is missing value then
set pdteBase to current date
tell pdteBase
set {its year, its month, its day, its time} to {2001, 1, 1, 0}
end tell
end if
(varDate - pdteBase) as string
end AS2SQLDate[/CODE]

RobTrew 2011-01-17 12:50 PM

and if you want to to interpret these OmniFocus dates (dateStamp strings giving a number of seconds since midnight at the start of 1 Jan 2001) without resorting to Applescript date functions, you can keep to SQL with expressions like:

[CODE]select (strftime('%s','now') - strftime('%s','2001-01-01'));[/CODE]

for Now or Current Date,
or:

[CODE]select name, datetime(dateDue + strftime('%s','2001-01-01'), 'unixepoch') from task where dateDue is not null;[/CODE]

to convert a date field like dateDue to a human-readable string.

ryans 2011-03-21 10:18 AM

This could be really useful for other things except it appears to be saved as "Run Only". Was that intentional? It looks like people were able to view and edit earlier versions.

whpalmer4 2011-03-21 12:02 PM

You should be able to download the script, open up Applescript Editor (or Script Debugger, if you have it), and have it open the script (or select the script and right-click to bring up the contextual menu, then choose Open with->Applescript Editor). I just did it with version 1.2 of the script, linked from the very first post in this thread.

RobTrew 2011-03-21 12:13 PM

It's conceivable that earlier versions of OS X might have difficulty reading a .scpt file created under 10.6

I have now supplemented the existing .scpt with a plain text (.applescript) version.

(See the post at the start of this thread).

ryans 2011-03-21 12:19 PM

1 Attachment(s)
Interesting. Both fail for me:

AppleScript Editor 2.3 (118) "Open Unable to read the file because the script is not editable (it was saved as run-only)."

Script Debugger 4.5: "The document "GeekOFSQL.scpt" could not be opened.

Other scripts downloaded from the forums work well for me (including a random one I tried just now from the 'Copy last sent message to Clippings' thread), and I consider myself fairly proficient with AppleScript.

RobTrew 2011-03-21 12:34 PM

What is your OS version ?

(The recently added version is plain text, so you should have no difficulty with that).


All times are GMT -8. The time now is 10:58 PM.

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