Commit a4e0e6dd authored by Jonas Neugebauer's avatar Jonas Neugebauer

Two new Things scripts

New
- Add Task from Mail: Adds a task with a link to the currently selected mail
- Contacts: Add contacts to things or cleanup contacts without tasks

Changed
- Show Today Tasks: Indention
parent b0fd79cf
(*
Adds a new task to Things. (For use with Alfredapp: alfredapp.com and Arimail: airmail.com)
*)
property TAGS : "Airmail,Import,Mail"
property ADD_CONTACT : true
property TASK_PREFIX : "Act on: "
on alfred_script(q)
tell application "Airmail 2"
set theSubject to subject of selected message
set theMessage to selectedMessageUrl
set theSender to sender of selected message
end tell
if ADD_CONTACT then
tell application "Contacts"
set theNames to name of (people whose value of emails contains theSender)
if (count theNames) is 0 then
set theSender to null
else
set theSender to first item of theNames
end if
end tell
else
set theSender to null
end if
tell application "Things"
set theTodo to make new to do with properties {name:TASK_PREFIX & theSubject, notes:theMessage & return, status:open, tag names:tags} at end of list "Inbox"
if theSender is not null then
set theContact to add contact named theSender
move theTodo to theContact
end if
end tell
return TASK_PREFIX & theSubject
end alfred_script
\ No newline at end of file
(*
Adds a contact with the name q to the list of contacts in Things.
If q is empty or the keyword "clean", all contacts without assigned tasks
are removed from Things.
*)
on alfred_script(q)
if q is "clean" or q is "" then
tell application "Things"
set theContacts to contacts
repeat with aContact in theContacts
set theTodos to (every to do of aContact whose status is open)
if (count of theTodos) is 0 then
delete aContact
end if
end repeat
end tell
return "Contacts cleaned"
else
tell application "Things" to set newContact to add contact named q
if newContact is missing value then
return "Error: No contact named " & q & " found"
else
return "Contact " & q & " added"
end if
end if
end alfred_script
\ No newline at end of file
(* Displays a dialog with a list of all tasks in the today list*) set grwlTitle to "0 Tasks for today"set taskList to "No tasks left for today" tell application "Things" set todayCount to (count to do of list "Today") set todayTasks to to dos of list "Today" if todayCount is greater than 0 then set grwlTitle to (todayCount & " tasks for today") as text set taskList to "" repeat with taskItem in todayTasks set taskName to name of taskItem if taskList is "No tasks left for today" then set taskList to "- " & taskName else set taskList to taskList & return & "- " & taskName end if end repeat end ifend tell display dialog grwlTitle & return & taskList with title "ShowTodayTasks"
\ No newline at end of file
(*
Displays a dialog with a list of all tasks in the today list
*)
set grwlTitle to "0 Tasks for today"
set taskList to "No tasks left for today"
tell application "Things"
set todayCount to (count to do of list "Today")
set todayTasks to to dos of list "Today"
if todayCount is greater than 0 then
set grwlTitle to (todayCount & " tasks for today") as text
set taskList to ""
repeat with taskItem in todayTasks
set taskName to name of taskItem
if taskList is "No tasks left for today" then
set taskList to "- " & taskName
else
set taskList to taskList & return & "- " & taskName
end if
end repeat
end if
end tell
display dialog grwlTitle & return & taskList with title "ShowTodayTasks"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment