kernel-based thermal control (based on @crpalmer's work)