5

I'd like to display event counts in a conky window. Things like tasks scheduled for today, within the next 3 days, 15 days, count of pending todo items, etc. Since conky doesn't "talk" org-mode, the next best way is to call a shell script and use its output.

Can I call emacs in batch mode for this? Is there an org-agenda function that prints event counts? Should I do my own parsing instead?

2
  • I am unaware of a built-in counting function. If all you need is the raw data that goes into an agenda buffer, the following example can be used to extract that data normally created with the org-agenda-list function. The example creates a buffer for displaying purposes, but that step can be eliminated and the parsing/counting can be done with just the list -- without actually creating a display buffer. The org-agenda-files are opened/accessed/queried during this process. emacs.stackexchange.com/a/12563/2287 This process could be done in batch mode, though I've never tried it.
    – lawlist
    Nov 16, 2015 at 3:35
  • The last section of the example in the following link demonstrates how to query/use the text-properties within the list of raw data -- emacs.stackexchange.com/a/17903/2287 -- the relevant section is labeled BEGIN modification through to END modification.
    – lawlist
    Nov 16, 2015 at 3:40

1 Answer 1

2

A lot of org logic is bound up in large functions (i.e. org-agenda-list), so you probably need to write your own functions with a bunch of duplicated logic. org-map-entries might be a useful starting point for you (use the 'agenda scope). You can work out match patterns (http://orgmode.org/worg/org-tutorials/advanced-searching.html) over scheduled or deadline dates for your counting conditions and simply look at the length of the returned list or do aggregation within your map function using org-get-deadline-time and other functions.

I would suggest invoking emacs --batch --script ~/.emacs.d/init.el --eval "(prin1 (my-counting-function))" and examine only stdout. Replace with your own init location (since it otherwise would not be loaded in batch mode).

An example count of headings scheduled today:

(length (org-map-entries nil "SCHEDULED=\"<today>\"" 'agenda))
1
  • The only point in calling emacs would be if org already shipped with useful functions for my purposes. Emacs being rather heavy, even in batch mode, I will probably write my own lightweight parsing in something else. I will leave the question open for now.
    – mkaito
    Nov 18, 2015 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.