Last active
December 13, 2023 04:05
-
-
Save cdzombak/100b63db2f20fa275fe9f163cebb5a60 to your computer and use it in GitHub Desktop.
OmniFocus-style deferred tasks for Things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.dzombak.things-deferred</string> | |
<key>LimitLoadToSessionType</key> | |
<string>Aqua</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/osascript</string> | |
<string>/Users/cdzombak/code/DeferredThings.scpt</string> | |
</array> | |
<key>RunAtLoad</key> | |
<false/> | |
<key>StandardErrorPath</key> | |
<string>/tmp/com.dzombak.things-deferred.stderr</string> | |
<key>StandardOutPath</key> | |
<string>/tmp/com.dzombak.things-deferred.stdout</string> | |
<key>StartCalendarInterval</key> | |
<dict> | |
<key>Hour</key> | |
<integer>0</integer> | |
<key>Minute</key> | |
<integer>1</integer> | |
</dict> | |
</dict> | |
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
on replace_chars(this_text, search_string, replacement_string) | |
set AppleScript's text item delimiters to the search_string | |
set the item_list to every text item of this_text | |
set AppleScript's text item delimiters to the replacement_string | |
set this_text to the item_list as string | |
set AppleScript's text item delimiters to "" | |
return this_text | |
end replace_chars | |
tell application "System Events" | |
tell process "Things3" | |
set frontmost to true | |
click menu item "Update with Things Cloud" of menu "File" of menu bar 1 | |
end tell | |
end tell | |
delay 5 | |
tell application "Things3" | |
set goAgain to true | |
repeat while goAgain is true | |
set goAgain to false | |
repeat with thisToDo in to dos of list "Today" | |
set currentTagNames to tag names of thisToDo | |
set newTagNames to currentTagNames | |
if currentTagNames contains "Deferred 💤, " then | |
set newTagNames to my replace_chars(currentTagNames, "Deferred 💤, ", "") | |
else if currentTagNames contains ", Deferred 💤" then | |
set newTagNames to my replace_chars(currentTagNames, ", Deferred 💤", "") | |
else if currentTagNames contains "Deferred 💤" then | |
set newTagNames to my replace_chars(currentTagNames, "Deferred 💤", "") | |
end if | |
if newTagNames ≠ currentTagNames then | |
set tag names of thisToDo to newTagNames | |
move thisToDo to list "Anytime" | |
set goAgain to true | |
exit repeat | |
end if | |
end repeat | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment