Well, TM doesn’t yet support calling command upon modification of the file, so it may not be quite possible yet.
Used here: https://github.com/wakatime/sublime-wakatime/blob/master/WakaTime.py#L243
I’m not sure how important this is to WakaTime’s accuracy, though it seems like it would be so it may have to wait for now.
Steven