You can try pomodoro timers technique. You try to focus for only 25 minutes at a time and then give yourself some slack. Hopefully after you will see what you achieved in those 25 focused minutes will motivate you to repeat that exercise. I use FocusBit app for that, but there're plenty of pomodoro timers, you name it. The main trick is to get a ticking timer in front of you if nothing else can motivate you.