So this may not apply to your case in specific, but hey, lots of people read these posts. There's probably at least a handful of people helped by each of the responses in this thread, so maybe mine will help too.

So my first major period of work-malaise was ended by switching jobs. I decided if I didn't find my job fulfilling and interesting enough to work on, I would go out and find a job that I could be excited about.

It helped; everything felt new, and if I wasn't super productive right off the jump, well, I was learning a lot of new things and no one expected me to be productive.

The next time I got into a work-funk, where it felt like I wasn't getting anything done and I had trouble being excited about the work, I thought about changing jobs again. But my job was objectively good, I liked my coworkers, there were plenty of opportunities for exciting work, and there was nothing about it I particularly disliked. I just felt like I wasn't particularly happy, like I was spinning my wheels and not really getting anywhere in life.

So I left work well enough alone, and took a step back to look at my life and think about my identity and figure out what made me happy.

I decided I needed three things: home, community, and quests.

I am, deep down, a nester, a home-body. I need a space I feel like I belong in, that's mine and no one else's. Archimedes' "a place to stand". So I bought a home, committed to it, and started changing it to suit me better. Set up a private home office, a workshop, started reshaping the yard and planting an orchard. I hope to be there the rest of my life. The very idea of a place to be, forever, gives me a sort of stable comfort and happiness.

But while a part of me would love to be a hermit, I do want a sense of community, like I am connected to the people around me. So in addition to starting a family, I also do what I can to get involved. I started volunteering at a local food pantry and with the town's Rec board to put on local events; I ran for local office once. Even if I like to spend a lot of time by myself doing my own thing, it's nice to meet people, to feel like I know the people around me and they know me, at least a little.

Deep down, though, I do want a quest. I want to work on something meaningful. Something that it's worth working towards even if I never achieve it. Something that, if I gasped out "finish my work" on my deathbed, someone else would reasonably consider devoting their own life to the project as well. I haven't figured out that last part yet. Maybe it will end up being something I quit my job to do, either a job itself or a pursuit in retirement.

But in the meanwhile, formalizing my life in this way helps me take the pressure off at work. I enjoy my job, I think it's useful, and I take pride in my work from time to time, but it's ultimately just a job.

I still fall into a work-funk from time to time -- these last two years especially -- but when it happens it is no longer the existential crisis it was the first couple of times. I have other parts of my life I can work on and take pride in instead, it's not me failing at my one big thing. It makes it easier to just focus on making a little bit of incremental progress on my job every day until the malaise passes and work become fun again.