I think @rinigus wrote zgovernor for this exact type of issue.
It is specific to SailfishOS in that it listens for mce for screen on/off events
But you configure in an ini file what to do for these events, e.g. configure those exact cpufreq and online setting. This means that you can have other settings than the one set on boot even with the screen on.
(BTW @rinigus is there a reason this can’t be published in chum now that you removed the tama .ini file from the spec?)