Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Check UPS, batteries and input devices using Unhidden

By: hoakley
8 July 2024 at 14:30

Sometimes developing software is a journey of exploration without a clear destination. A couple of weeks ago, I wrote about how log entries from Battery Center revealed useful information about input devices like keyboards and mice, and Uninterruptible Power Supplies (UPS). Several of you remarked that it would be useful to have a utility to provide easy access to those. This is my first progress report, and comes complete with a first version of that utility, Unhidden.

Battery Center

It turns out that those log entries from the com.apple.BatteryCenter don’t come from macOS itself, but from one of three new Private Frameworks added to macOS Sonoma: BatteryCenter itself, and two supporting frameworks BatteryCenterUI and BatteryUIKit. In Ventura and earlier, similar log entries came from com.apple.iohid, although those weren’t as extensive.

Battery Center appears to support Battery widgets in /System/Library/CoreServices/Batteries.app named BatteriesAvocadoWidget, and offered in Sonoma’s new range of widgets.

unhidwidgets

Thus, com.apple.BatteryCenter periodically checks known connected input devices (‘HID’ for Human Interface Devices), UPS, and internal batteries in Mac notebooks, and publishes lists of information in the log. That data is used by the background service app Batteries.app to feed the data displayed in the Battery widgets available in Sonoma.

Unless your Mac has a Battery widget installed, perhaps on its Desktop, Battery Center entries don’t appear in its log. When you do add a Battery widget to the Desktop, though, checks are made every few seconds, and their results written to the log, and those continue even after removing the widget, at least until the next time that Mac is shut down or restarted.

Third-party software isn’t supposed to access private services like Battery Center, so creating an independent utility to perform similar functions would have to capture its own data. However, given access to the log, it’s possible to read Battery Center’s entries there instead.

Unhidden

This initial version does one job: each time you open a new window in the app, it displays the most recent results obtained by Battery Center, across all the devices that it checks. There are three essential requirements:

  • The Mac must be running macOS Sonoma or later (including Sequoia betas); this works on both Intel and Apple silicon Macs.
  • The user must have admin privileges, as those are required to access the log.
  • Battery Center must be running. This normally requires that a Battery widget has been installed since the last time that Mac started up, unless it’s already running.

Each time Unhidden opens a fresh window, it inspects the log for Battery Center entries. It initially checks the last 5 seconds, then increases the time period up to a maximum of half an hour. It then either reports that it can’t find any entries from Battery Center, or it displays them in the window.

unhidden1

Standard display gives all key results obtained in compact lines. If those aren’t clear or large enough, there’s optional Large Text.

unhidden2

Supported devices

Unhidden has been tested with the following:

  • Apple wireless Magic Keyboards, both operating on battery and when connected by their charging cable
  • Apple wireless Magic Mice, both operating on battery and when connected by their charging cable
  • Apple wireless Magic Trackpad 2, both operating on battery and when connected by their charging cable
  • Supported UPS connected by a USB cable
  • Standard Mac notebook internal batteries, both charging and not.

The range of peripherals is wide, and to make it easy to report problems with other devices, and errors, Unhidden has a Debug Mode. To enter that, it must be selected in Settings, the app quit, and opened again. Instead of seeing normal results in its window, Debug Mode displays the original raw log entries, together with a button to save those in a text file. Please add problem entries to this article as comments, or send them to me by email (address in the About page), so that Unhidden can accommodate more devices correctly.

Download

Unhidden version 1.0 is now available only from here for the time being: unhidden01

Future

I’d really like to discover a way of activating Battery Center without having to fiddle with widgets, something I’ll be looking at next. There are several alternative ways to present these results, and to check them at regular intervals, perhaps presenting changes graphically. Please let me know where you’d like Unhidden to go, if you’re interested in my developing it any further.

❌
❌