
If you do a lot of automated command-line scripts, you probably also generate a lot of mail to /var/mail. You can also change the status of the status button from “success” to “failure” depending on your script’s exit code.Ĭommand-line mail on OS X: re-alpine and Geektool Using ANSI color codes can make those scripts even more useful. GeekTool is a great way to display the results of little scripts on your desktop. Here’s a simple AppleScript to use with GeekTool to put your inbox on the Desktop.
#Geektool templates how to#
Here’s how to do it with Python and GeekTool. But sometimes you just want to know if the time is today, or yesterday, or two days ago. There are a lot of desktop clocks that show the absolute time. Put a relative clock on your Desktop with GeekTool Rather than “tomorrow at time” use “time tomorrow”. More GeekTool icalBuddy and eventsFrom/toĪli Rantakari’s icalBuddy has an error in the documentation for the “eventsFrom/to” command-line option. Put this above the “if options.xml” so that the script can print out the pruned tree as XML: That’s easy enough with getElementsByTagName. The next step is to get only the tasks with the desired tag(s). You can run the above script just make sure you add “-xml” as an option so that it displays the resulting XML. It fixes the minidom’s toprettyxml so that it doesn’t add unwanted whitespace to textnodes. The “prettyXML” function is based on a regular expression by BrendanM. When a parent has a child appended to it at a lower recursion level, there’s no need to pass the parent back up the chain: XML nodes in Python are objects, and objects are passed by reference.When the first item is popped out of the list at any recursion level, all other recursion levels immediately “get” the new version of the list.This function makes heavy use of the fact that in Python, lists and objects are passed through functions by reference rather than by copy. And if the indentation level drops below the current recursion level, it returns to the caller. It steps through each line in the TaskPaper file(s) and either adds it to the parent element as a project, task, or note or, if the indentation level has increased, it recursively calls itself again with the latest item as the new parent. The meat of this section of the script is parseTasks. noteValue = taskDocument.createTextNode(taskLine).item = taskDocument.createElement('note').taskValue = taskDocument.createTextNode(taskLine).taskLine, tags, done = parseTask(taskLine).item = taskDocument.createElement('task').item = taskDocument.createElement('project').parseTasks(taskLines, item, taskIndent).indentation = len(re.findall('^\t+', line))ĭef parseTasks(taskLines, parent, indentation=0):.projectList = taskDocument.documentElement.Since TaskPaper documents are hierarchical, a recursive function based on the indentation level should, and did, work great. Once in XML, I can manipulate it in Python like any XML document. Step one was to convert the TaskPaper document to XML. I decided to write the script in two steps.

Nothing special here, it just sets up the command-line options and loops through the TaskPaper files to read them in. tasks = tasks + codecs.open(file, 'r', 'utf-8').read().parser.add_option('-x', '-xml', help='show XML version of TaskPaper document', action='store_true').parser.add_option('-t', '-tag', help='show tasks with tag(s)', action='append').
