Create a Widget the Displays Stats

I wanted to be able to use Drafts to have a widget that displays the stats or word count of a specific document file. I wanted to be able to have an updated word count to use during NaNoWriMo. Is this possible?

If it is possible, how would I set that up? I’m still fairly new to Drafts and I’m having trouble figuring it out.

The only way I can think of to accomplish something like that with Drafts would be:

  • Add a widget that displays the content of a specific draft.
  • Write an action that reads the file, calculates a word count, and updates the content of that specific draft.

That said, there’s nothing automatic about that. The action would need to be run periodically to update the content of the draft and, thus, the widget. Drafts is not really setup around programming dynamic content in widgets.

You might be better off with a tool like Scriptable that lets you write your own dynamic widget content that is updated by the app itself.

1 Like

I’m wondering if such a Scriptable widget could have touch targets that kick off Drafts action. For example my “create a draft for today” action.

(I’d actually want multiple tap targets, each running an action, as a I’d also want “create a meeting draft”.)

I raise this as such a thing would be more generally useful. Maybe Drafts can already do actions directly from a widget. But I think you, @agiletortoise, would have mentioned the possibility if it were so.

Note: The documentation for /runAction’s first example doesn’t actually have an action it. I note this in passing as that is how I’d use something like Launcher to kick off Drafts actions from a widget.

It is referenced in the documentation. The grid widget supports actions and there is a section on “Using Actions with Widgets”.

In reference to your follow up post, this morning I saw your Tweet to Launcher about debugging
a Drafts URL. A simple URL works for me to run an action, though x-callback does not return with my example and I wouldn’t expect a launcher to support it as it is an intermediary app rather than a destination app.



I assume that there is some complexity to your URL, but are you just getting the launch iasue with one Drafts run action URL in Launcher, or any?


I think it was the percent encoding of the URL that in other contexts wasn’t necessary. Same old story. :slight_smile:

Launcher is nice because it is denser than the Drafts widget - or can be.

I’ll experiment some more.

1 Like