This question should be made before deciding to pollute the environment with hydrocarbons! The Sun could give all the required energy, but sadly even having it so close, the most part gets wasted day after day in exchange for more damage to the environment, quality of life and health.
Anyway the Sun will always be in the galaxy's center during some thousand million years more, providing near 385 yottawatts of vast power. Only taking a bit of it, there's enough for every possible machine or device and much, much more.
And then, what is the estimation? The last calculations are normally saying that 5.000.000.000 years more. Nature, as always, achieves aspects that could seem impossible of being proposed. The energy source is capable of staying on during five thousand million years or more!
Now, it could be interesting to think about how much energy was completely missed by contemporary societies and past ones. Fortunately, Nature didn't make that mistake from the beginning! We should take example.