My suggestion is to put a begin-page-hook to the output routine.

aren't page styles precisely this?

 It works very well.

yeah, colors (or grey) too.

 The only problem was where to execute the macro. I attached it to the
 page style, but what happens if someone says "\thispagestyle ..."?

Doesn' fancyhdr allow to redefine `standard' page styles? Or _you_
redefine standard page styles by simply adding a cs (empty by default)
that will do the job?

I thought latex2e user interface was more or less frozen, maybe your
query should be taken into consideration for the architecture of
latex2e* page templates?

Thierry