The first think you might need to fix is your sleep, second is your environment and your eating habits / patterns.
You can only tackle motivation issues when you're not feeling bad.
My trick is to imagine the end-result of what I am currently working on, it pushes me to get the reward of seeing it finished.
Of course it works only if I expect to be proud of the result.