Distorted black holes emit ringdown gravitational waves consisting of a discrete set of quasinormal-mode frequencies. Measuring the quasinormal-mode frequencies allows us to probe rich physics in the strong-field regime. To extract physics from the ringdown signals, we need to compute the quasinormal-mode frequencies of black hole under different circumstances. However, most of the existing methods can compute the quasinormal-mode frequencies of limited black-hole models, hindering our ability to probe physics. In this talk, I will present a powerful method that solves the linearized Einstein equations for the quasinormal-mode frequencies of a perturbed black hole using spectral decompositions. Our method works directly with the metric perturbations. Through spectral decompositions, our method transforms the resulting coupled partial differential equations into a linear algebra problem. Our method does not require the decoupling of the linearized field equations into master equations through special master functions, or the separation of the differential equation into a radial and angular sector, making the method extremely convenient. More importantly, our method can be straightforwardly adapted to study general black holes and in a wide class of modified gravity theories. Applying our method to the Kerr black hole in general relativity, we can accurately compute the 022-mode frequency up to dimensionless spin of 0.95, with a relative error in the real and imaginary parts smaller than 1e-3. We perform Bayesian inference on the ringdown signal of GW150914, the first detected gravitational-wave event, using the frequency computed by our method. The resulting posteriors are almost identical to those obtained using the frequency computed by solving the Teukolsky equation using Leaver's method. The close consistency indicates that our method can compute quasinormal-mode frequencies that are accurate enough to be applied to analyze real ringdown signals.