Once I realised that it was, for lack of a better term, 'caring' for work that shouldn't really be cared for that was the problem, I got much happier. Became very laissez-faire, committed only to doing a good job and not associating myself with the company. Don't be loyal, just be professional in other words, and live for the time when you are not at work.
Seems to be working for me so far. My work and mood has improved, which leads to better things both at work and home.