I do not have a complete answer for you. But I've developed this simple hack that worked quite well for me. That is, before working on anything, play a little game or solve a puzzle. I learned this after reading "Originals: How Non-Conformists Move the World"[1] by Adam Grant. You can watch his TED talk here [2] to get some ideas.
How do I know it work? This might be survivorship bias but whatever, I believe it worked for me. After practicing this for around a year, I developed a custom 3D visualization for our 3D scanner[3] which greatly improved the UX. Our customers loved it. We even filed a patent for it (pending though)[4]
For me, that little puzzle is usually a leetcode[5] problem, or to solve a non-trivial rubik (my humble collection here[6]).