This question already has an answer here:
Is there a way to force a specific program to use less than 100% processor time even when the CPU would be idle otherwise?
Using process priority, we can adjust how much resources a given program consumes in relation to other programs.
If the process priority of a program is set to 'below normal', the program will consume less CPU time while other programs require those resources.
However when the the processor is otherwise idle, a program may utilize the CPU at 100% regardless of its process priority; thus increasing power consumption and heat.
I would like to reduce the cpu use of certain programs under these circumstances, depending on whether these programs currently have focus.
For example I would like to force Firefox to use at most 1% of the CPU whenever it has lost focus for more than 1 minute.
Is there any way to do that?
(There may be specific solutions to find and unload resource intensive tabs in Firefox, but I am mainly looking for a general solution that works for all programs)