FWIW this is relatively straightforward to do in Linux, at least as a quick hack. I used this for the bones of a fully automated time tracker, because I suck at counting hours.
Anyway, here are a couple of magic incantations:
xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}") WM_NAME
xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}") WM_CLASS
These divulge the application name and window name of your frontmost window each time they're called.There's also the xprintidle command (may need to be installed). With these three pieces together, you can create a little background daemon that monitors what you're up to at any given moment.