I was in a rut for years because my work was my identity and I wasn’t where I wanted to be (thank you effective altruism for the identity crisis lol). When I moved out to California I quit drinking (for a while, quit again more recently), focused on exercising, and set a goal of not seeing my whole identity as a software developer. It helped so much with my physical and mental health, and in turn that helped me with my work life.
Honestly if you just view work as a source of income to do the things you want to do, and get out and be a bit more active, you could get out of the rut pretty quickly.
And if you don’t care for any of these suggestions - just stay positive these things are temporary and you’ll feel better in time anyway :) We all have these moments.