One of the things I do is split all my programming tasks into two categories, requires concentration and (necessary) scutwork.
Then I work on one or the other entirely dependent on how I feel that day, so I'm productive even when I'm not mentally at 100%.
Good things for scutwork are documentation, updating dependencies, automating manual processes, checking backups, organising issues on the backlog etc, things I can comfortably do without requiring complete focus.
It definitely helps since I don't feel like I'm just present in front of the computer but getting things done (and things that are important to boot).