On earth, as far a we know, there are two main ways that bacteria gain energy.
First, there is Photosynthesis, the transition of light into chemical based energies such as ATP.
Second, there are chemical processes in which the cell breaks down a variety of molecules down to gain energy from the reactions. A example of this is Chemosynthesis.
Is it possible for their to be a bacteria or type of organism that gains energy from thermal energy?
For example, there could be a bacteria that lives in a volcanic area, somewhere hot enough that there is a excess of thermal energy. Would there be a way for such a cell to use this thermal energy in much the same way that some cells use Sunlight in Photosynthesis?