In this talk, we will first discuss rigidity of Einstein four-manifolds using a simple observation for Berger curvature decomposition. The observation also leads to an alternative proof of Derdzinski's classical Weitzenbock formula for Einstein four-manifolds, and we extend it to a class of canonical metrics, which are called generalized quasi-Einstein metrics, or ``Einstein metrics" on smooth metric measure spaces. As applications we will discuss rigidity of four-dimensional gradient shrinking Ricci solitons of half harmonic Weyl curvature, and four-dimensional cscK gradient Ricci solitons. We will also discuss rigidity of conformally Einstein metrics of half nonnegative isotropic curvature. This is partially joint with Jiayong Wu and William Wylie.