How to display word count in OBS Studio?

What I’m trying to do

So the short version: I had this silly idea for a writing stream where I show only the word count in my current document. Make it a “number go up” stream, if you will. OBS could theoretically capture and display this number in two-to-three ways:

  1. If I could have a panel or side dock that just showed the word count as a big number, I could use window capture to display it.
  2. If I could export the number to a text file as I write, OBS could import that file as a “text source.”
    1. Corollary: If I could export the number to an HTML file, I could import it as a browser source.

Things I have tried

  1. Looking for relevant Obsidian plugins.
    1. I found one that shows your daily writing progress, which is nice, but the UI is too small to turn it into something that looks good on stream.
  2. Looking for scripts in various languages that can do live word count from files. So far, I haven’t found anything that looks right, keeping in mind that I’m not really a programmer.
    1. But seriously, even a bash script would do.
  3. Googling and even Duckduckgoing like mad for any sort of plugin for OBS Studio, Streamer.bot, and the Elgato Stream Deck. (2 PC setup. My streaming PC is still on Windows.)
  4. I tried to see if I might be able to do it with VS Code. It’s probably possible, but I have no idea how.

Being that I’m Not A Programmer™, it’s entirely possible that I missed something. Has anyone tried doing anything like this with Obsidian before?

I don’t know if this makes for very interesting watching, but the Better Wordcount Plugin can keep track of statistics. But I don’t know if that’s live or every time you load the vault.

I checked that one out, but it wasn’t quite right for me. I actually cobbled together a working solution with two bash scripts, and a random Python package I found on the internet.

Once I’m more or less happy with it, I’m going to put it on GitHub and write a tutorial for anyone who wants to try it out. Mostly I’m hoping a real programmer will get mad and make an Obsidian plugin I can use instead, but we’ll cross that hypothetical bridge if we ever get to it.

Okay, as I said, I’ve put a working script together that reads the word count of all markdown files in a given folder (and markdown files immediate sub-folders), and writes those numbers to text files that OBS can use as text sources.

I just run the script via Obsidian’s Terminal plugin for convenience when I want to stream, and I get a nice little number-go-up effect as I type. It is now all written in Bash and only uses default GNU utilities so it should be compatible with any Linux distro. On Windows, it should work with WSL.

If you want to use the script for yourself, it’s available on GitHub.

Still hoping that a real programmer will come along and make a better version, though.