  We study the relation between the thermodynamics and field equations of
generalized gravity theories on the dynamical trapping horizon with sphere
symmetry. We assume the entropy of dynamical horizon as the Noether charge
associated with the Kodama vector and point out that it satisfies the second
law when a Gibbs equation holds. We generalize two kinds of Gibbs equations to
Gauss-Bonnet gravity on any trapping horizon. Based on the quasi-local
gravitational energy found recently for $f(R)$ gravity and scalar-tensor
gravity in some special cases, we also build up the Gibbs equations, where the
nonequilibrium entropy production, which is usually invoked to balance the
energy conservation, is just absorbed into the modified Wald entropy in the FRW
spacetime with slowly varying horizon. Moreover, the equilibrium thermodynamic
identity remains valid for $f(R)$ gravity in a static spacetime. Our work
provides an alternative treatment to reinterpret the nonequilibrium correction
and supports the idea that the horizon thermodynamics is universal for
generalized gravity theories.

General Relativity and Quantum Cosmology