if it's a Bluetooth keyboard, then in the bluetooth system preference set that to show bluetooth in the menu bar, then you get a bluetooth dropdown which, when you select the device in the dropdown, will show you the battery level.How do I add battery percentage beside the time on the top of the screen?
I added the flag on the menu but I don't see any battery icon anywhere?
You need to click on the US flag, and then select "Open Keyboard Preferences". At the bottom of the dialog box which opens you will see keyboard battery percentage. Sort of an indirect way to show it, but I know of no other way to do it. I'm using the Apple Magic Keyboard rechargeable model.
I know that some Linux desktop machines are capable of detecting a connected UPS (Uninterruptible Power Supply) system and automatically show a battery icon in the status bar, same as if the machine were a laptop. I have a UPS connected to a different computer, but never tried to connect it to the iMac to see what happens... 🤷♂️ It's too much trouble to pick up the iMac and take it to the other room where the UPS is, or vice-versa.
You will see the battery indicator on an iMac if the UPS is capable of communicating status with the machine. I know APC UPS units do this via a USB cable. No special software is needed.