Because the macOS knowledgeC.db
only tails the last month of usage data, longterm analytics isn't possible. Here, a script triggered by LaunchAgent observing two sqlite DBs (knowledgeC and Calendar) inserts data into a persistent database. Use at your own peril.
In order for the script to have access to those system DBs, you need to give zsh full disk access.
Run the nice-application-names.sh
manually to get a table of better names that are more legible than the com.apple.Safari
identifiers.
Got inspired to do this by https://rud.is/b/2019/10/28/spelunking-macos-screentime-app-usage-with-r/.