This seems like something that I ought to be able to do with Keyboard Maestro instead of needing a separate app for it, but I'm not sure how to do it.
It occurs to me that someone may have already invented this wheel, and if so I'm hoping they'll read this and share their solution.
Here are the two ideas that I've come up with… in a theoretical sense (versus the "I have actually written this and have it working" sense):
The Easy-But-Annoying Way…
It seems like the easiest way to do this it to have Keyboard Maestro do some sort of
Pause for X seconds when an app loses focus, and then quit the app.
Create another macro for when the app gains focus which cancels the previous macro, and it seems like you're on your way.
BUT! …the thing I wouldn't like about this method is that Keyboard Maestro's menu bar icon would be flashing the entire time that the first macro running
Pause for X seconds. That would be annoying.
The Write A Timestamp To A Temp File Way…
The only other idea that I have is for 1 macro which would write a timestamp to a temp file, and then have another macro which would check the temp file to see if the elapsed time since that timestamp had exceeded the idle time.
Assuming that the second macro ran, say, once a minute, you might end up with your app running for, say, almost 11 minutes when you wanted it to quit after 10, but that doesn't seem like a huge deal.
You'd also need a third macro that would delete the temp file whenever the app took focus.
BUT… this seems hacky and terrible, like there has to be a more elegant way to do it.
Anyone cracked this nut?
(Yes, I realize I could have downloaded, installed, and configured “Quitter” in the time it wrote to write this post. But it's the principle of the thing…)