For longer, 2-3 day tasks, I completely log off and don't connect to the world until it's done. This means avoiding any network tool through the evenings and mornings until the stretch is over. Easier said than done. Some of my family and friends think I'm weird or get frustrated by my inaccessibility. But they get over it.
After a 2-3 day deep binge like the OP I also face challenges moving from one discipline (say programming) to another (a marketing video). One tool I use is yoga. For a while I had a daily meditation habit going but it's been replaced with 2-3x / week hot yoga. I find it has a way of cleansing my mind and energizing me for the next thing. I also go on fat bike rides to unlock the power nature's constant stimuli has on your mind as Cal talks about in the book.
I use a kitchen timer, too, which has minutes and seconds (e.g., digital).
Some tasks with too much inertia/resistence I ask: "Can I work on this for 5 minutes? 2 minutes? 15 seconds?"
That will build momentum and show that it's often not as hard as it seems when you're on the other side of history.
If you're interested in improving your productivity by simplifying your work, it is a good book.
But like all self-help books its effect wears off over time.
Keep in mind that Cal Newport is an academic at MIT. He has autonomy, he works in a field he loves etc. For other people his point of view is valuable, but his advice IMHO is not that easy to follow. You may need to improvise and find your own way.
That said, task switching is a practical reality, so coping strategies are important, too.
For help with that, check out Cal Newport's "Deep Work: Rules for Focused Success in a Distracted World" (https://www.amazon.com/Deep-Work-Focused-Success-Distracted/...). Full disclosure: He and I share a literary agent.