I personally draw inspiration from John Carmack. I've understood his approach to be basically just stare at your problem and ignore everything else until you make a little bit of progress. The answer is there.
Sounds like a bit of a chicken-and-egg problem. My main issue is to even get myself to sit and stare at the work to be done. It has been really frustrating seeing the lengths I go to, consciously or unconsciously, to procrastinate.
I used to work a non tech office job, one day it became so unbearable, I was literally falling asleep and was no longer able to bring myself to do the job at all, because of how much mental effort was required for even the smallest things. I stood up and quit.
I think it's mostly about accepting that you are the one in control. The problem of "getting yourself to do something" is poorly formulated, as though some other person was in charge of your actions that you have to convince to do what you want.
This confused conviction is the real problem. There is no other you to convince. The same you that you are bargaining with to do the thing is the same you that's doing the bargaining. You can at any moment just do it.
That's really nice but not really true. There is another you that you need to convince to do boring stuff. That's our own body fighting against doing that stuff. Will is a finite resource.
Not to say he's unproductive, because he's a beast, but I don't think he's a good example. Carmack got to work on really cool things which he loved (games) most of which were in his own company so he also had a stake on that.
Afterwards he had money to work on other stuff he was passionate about (rockets, VR, etc.) in his own terms.
It's much harder to draw motivation to meaningless work.
The issue is if even thinking about staring at the problem is already giving you PTSD. If I’m at a point where staring at the problem is fine, there isn’t much of an issue to begin with.
Carmack also has an insane net worth and has the freedom to pick and choose the problems he stares at, and set the time tables for a solution. I wouldn't suggest this method if you're some random mid-level programmer.
Sorry I was looking for a transcript, but if you have 5 hours to listen you'll find it in here: https://lexfridman.com/john-carmack/. It's an awesome interview if you haven't heard it anyway.