We present a method, based on the classical Green-Kubo theory of linear response, to compute the heat conductivity of extended systems, leveraging energy-density, rather than energy-current, fluctuations, thus avoiding the need to devise an analytical expression for the macroscopic energy flux. The implementation of this method requires the evaluation of the long-wavelength and low-frequency limits of a suitably defined correlation function, which we perform using a combination of recently-introduced cepstral-analysis and Bayesian extrapolation techniques.