App Usage Tracker with Keyboard Maestro
Here’s another nugget I (apparently) never shared on this blog for tracking time spent on something.
Keyboard Maestro has a nifty trigger for “every time an app activates”. This can be used to write the current time plus some more information to a variable, which is then written to a file. This way you can track the time spent using a specific app.
The result of this action is saved to a different variable, which is embedded in a different macro to write the variable containing all that time information to a file:
Note: Set this group of macros to disabled if you’re not using it. Otherwise Keyboard Maestro will continue adding stuff to the variable and its memory usage is going to increase gradually.
You can also directly append text to the file by using:
echo "$KMVar_KMTimeTracker" >> $HOME/Desktop/Application\ Usage.txt
This would make the second macro unnecessary, but also put more pressure on hard disk writes. There’s also less memory being used.
You can improve this even further by adding a delay check. So that app switches that take less than 5 seconds (so you’re actually spending time in the app) are not counted. You do this by adding a new variable that reads “Current Application” to a variable. After a delay you add an
if to see if the current app is still the current app…
You also might want to add a similar macro that writes to a variable when you left an app.
I stop writing now. Too many ideas.1
Mad scientist with an emphasis on mad. ↩