I wrote pi-automode for exactly that reason. Works well enough for me, YMMV.
https://github.com/czottmann/pi-automode