I'm using Ubuntu 20.04 LTS and I use a Sony Dualshock 3 Controller to play a few games on Steam. As I tend to use the controller wirelessly for long periods of time, it's not uncommon to have the controller suddenly dying on me when the battery gets really discharged.
I searched around the internet but couldn't find a way to check how much battery left I had on the controller. Is there any native way to check a PS3 controller's battery, or some script I could use?
You can simply use the Dual Shock 4 battery percentage extension for Gnome. Although the name mentions DS4, it also supports DS3 (which I am using) and should soon support DS5 with recent kernels.
Behind the scenes, this extension simply relies on the power supply subsystem, and more specifically the file located at: