It makes inotifywait log not only filename & action, but also timestamp. The script compares the timestamp with current unixtime and if the delta is less than 2 sec, it runs make html. But before that it sleeps 1 second to let file operatinos end. For the next modified files the timestamp will be old, the delta will be more than 2 seconds, and nothing will be done.

I found this way was the least CPU consuming and the most reliable.

I also tried running a simple Python script, but this meant if I pasted something as big as jQueryUI into the folder, a thousand processes were spawned and then became zombies.