What can you do with a woodpecker pecking the trim along the edge of your roof!? I know it’s a mating thing for a while, but he’s damaging that trim.
I got my BB gun to see if I can hit him, but that’s a tall order. My tree sprayer with vinegar may help… We’ll see.
I got a pellet gun - the kind used in competitive shooting when I had a similar problem with 4 by 8 pieces of siding. These have rifled barrels and are very accurate out to about 50 feet. The completion officially is 10 meters ~33 feet.
Put a nail strip on the relevant edge(s). Make it an uncomfortable or painful perch. He may also be pointing out a rot problem in the wood under the roof for you - he wouldn’t be pecking if he didn’t think there was something tasty in there. Or replace the trim with Azek - no more pecking (woodpecker concussion-inducing).
It might be looking for food in rotten wood, in which case the answer is to fix the rot (and say Thank You for pointing out the problem).
Then there is drumming. Drumming is territorial display… keep away, this is MY space. My woodpecker drumming is generally on metal gutters, or perhaps downspouts, but that isn’t damaging. Around here is most often done by Flickers, a group of woodpeckers that mostly feed on the ground.
If the problem is resonant drumming, how about making the impacted area less resonant? Do something to the tapping is dulled. Of course you could learn to appreciate the sound of nature doing its thing. Drumming on my gutters makes me smile.