whatcable README

项目的 README,来自 github.com/darrylmorley/whatcable。合并为一个 markdown 文件:README.md。

WhatCable

What can this USB-C cable actually do?

Website: whatcable.uk (overview, screenshots, and CLI docs)

A small macOS menu bar app that tells you, in plain English, what each USB-C cable plugged into your Mac can actually do, and why your Mac might be charging slowly.

USB-C hides a lot under one connector. Anything from a USB 2.0 charge-only cable to a 240W / 40 Gbps Thunderbolt 4 cable, all looking identical in your drawer. macOS already exposes the relevant info via IOKit; WhatCable surfaces it as a friendly menu bar popover.

Part of a family: WhatBattery for battery health and charging, WhatPort for every port at once.

WhatCable - Know what your USB-C cable can really do | Product Hunt

Latest release Platform License: MIT WhatCable Pro

WhatCable popover

What it shows

Per port, in plain English:

Click the gear icon in the popover header to open Settings, where you can:

Right-click the menu bar icon for Refresh, a Keep window open toggle (handy for screenshots and demos), and Settings…. The Pro screens (Power Monitor, Negotiation Diagnostics, Display Diagnostics, Saved Cables) and Licence… live here too. Below those: Check for Updates…, Contribute Diagnostic Data…, About, WhatCable on GitHub, and Quit.

WhatCable Pro

WhatCable is free and open source. If you find it useful, you can support the project by picking up WhatCable Pro. Pro is for finding the weak link in a connection and keeping the evidence: live measurements, per-connection diagnostics, and a history of how each cable performs. It unlocks:

One-time purchase, works on up to 2 Macs. See whatcable.uk/pro for details.

Buy WhatCable Pro

Install

Visit whatcable.uk for an overview and screenshots, or install directly below.

Download the latest WhatCable.zip from the Releases page, unzip, and drag WhatCable.app to /Applications.

The app is signed with a Developer ID and notarised by Apple, so there are no Gatekeeper warnings.

It's not on the Mac App Store on purpose. Most of what WhatCable reads would in fact survive the App Sandbox: we tested it, and the IOKit registry reads come back identical either way. What the sandbox does block is the SMC access behind Pro's live power metering, and the bundled whatcable CLI doesn't fit the store's install model. So it ships signed and notarised outside the store instead.

Requires macOS 14 (Sonoma) or later, Apple Silicon only. This is measured, not assumed: every Intel Mac in the community diagnostic corpus reports its USB-C port-controller services as empty, so the USB-PD state and cable e-marker data WhatCable depends on are not published on those machines through any public IOKit accessor. Thunderbolt fabric data is still present on Intel; it is the port-controller layer that is missing.

Note: The manual install gives you the menu bar app only. The whatcable CLI is bundled inside the .app and is not on your PATH by default. If you want to use it from the shell, see the Command-line interface section below for how to add it to your PATH. Or install via Homebrew, which sets up the CLI automatically.

Homebrew

brew install --cask darrylmorley/whatcable/whatcable

This installs the menu bar app and symlinks the whatcable CLI into your PATH.

Homebrew, CLI only (no menu bar app)

If you don't want the menu bar app, install just the command-line tool:

brew install darrylmorley/whatcable/whatcable-cli

Same signed and notarised binary, packaged on its own. Useful in terminal-only or scripting environments. Pick one of the two Homebrew installs (both ship the same whatcable binary).

Homebrew 6 may warn about untrusted third-party taps on first install. If an existing install starts complaining about an untrusted tap, run brew trust darrylmorley/whatcable or see https://docs.brew.sh/Tap-Trust for details.

Command-line interface

A whatcable binary ships alongside the menu bar app, driven by the same diagnostic engine:

$ whatcable

USB-C Port 1
  ✓ Charging well at 96W
  Cable: 5A, 100W, USB4 40 Gbps
  Charger: 5V / 9V / 15V / 20V PDOs

USB-C Port 2
  ! Cable is limiting charging speed
  Cable: 3A, 60W, USB 2.0
  Device: External SSD, USB 10 Gbps

Flags:

whatcable                # human-readable summary of every port
whatcable --json         # structured JSON, pipe into jq
whatcable --watch        # stream updates as cables come and go (Ctrl+C to exit)
whatcable --raw          # include underlying IOKit properties
whatcable --report       # open a pre-filled GitHub issue for the connected cable
whatcable --test-kit     # run diagnostic probes and submit anonymised data
whatcable --no-usb-probe # skip deep USB probing (for KVM switches and hubs that misbehave)
whatcable --desktop      # launch the GUI app in Dock mode
whatcable --popover      # launch the GUI app in menu bar mode
whatcable --version
whatcable --help

Pro from the command line:

whatcable --monitor                        # Pro: live power telemetry (Ctrl+C to exit)
whatcable --monitor-json                   # Pro: live power telemetry as newline-delimited JSON
whatcable --dashboard                      # Pro: full-screen TUI dashboard (Tab cycles screens, q quits)
whatcable --activate XXXX-XXXX-XXXX-XXXX   # validate and store a Pro licence
whatcable --licence                        # show current licence status
whatcable --deactivate                     # remove the stored licence
whatcable --pro                            # show Pro features, open purchase page

The CLI prints a one-line Pro hint at the end of plain text output for unlicensed users. Run whatcable --silence-pro-hints to hide it (or --show-pro-hints to bring it back). Suppressed automatically when output is piped, redirected, or used with --json.

If you installed the .app manually rather than via Homebrew, the CLI lives at WhatCable.app/Contents/Helpers/whatcable. To run it from the shell, add the folder it lives in to your PATH. The preferred way is a file in /etc/paths.d, which macOS reads to build the PATH for every user:

echo '/Applications/WhatCable.app/Contents/Helpers' | sudo tee /etc/paths.d/uk.whatcable > /dev/null

The file holds just that one path, written as is: don't escape spaces or add a trailing slash. If you keep WhatCable somewhere other than /Applications, use that folder instead. The change takes effect in new terminal windows; check it with which whatcable. Writing to /etc/paths.d needs sudo, so WhatCable never does it for you: it never asks for admin rights.

Alternatively, symlink the CLI into a folder that's already on your PATH. This works straight away in the current terminal. /usr/local/bin is on the default PATH; if it doesn't exist yet on your Mac, the first line creates it:

sudo mkdir -p /usr/local/bin
sudo ln -s /Applications/WhatCable.app/Contents/Helpers/whatcable /usr/local/bin/whatcable

The Homebrew install puts the CLI on your PATH for you automatically.

How it works

WhatCable reads four families of IOKit services. No entitlements, no private APIs, no helper daemons:

Service What it gives us
AppleHPMInterfaceType10/11/12 (M3-era), AppleHPMInterfaceType18 (MacBook Neo A-series), AppleTCControllerType10/11 (M1 / M2) Per-port state: connection, transports, plug orientation, e-marker presence. Type11 is what M2 MacBook Air uses for its MagSafe 3 port.
IOPortFeaturePowerSource Full PDO list from the connected source, with the live "winning" PDO
IOPortTransportComponentCCUSBPDSOP, ...SOPp, ...SOPpp PD Discover Identity VDOs from the port partner (SOP), the cable's near-end e-marker (SOP'), and the far-end e-marker (SOP'') if present
XHCI controller subtree Each connected USB device is paired to its physical port via the XHCI port node's UsbIOPort registry path, falling back to a bus-index derived from the controller's locationID upper byte and the port's hpm SPMI ancestor on machines that don't expose UsbIOPort.

Cable speed and power decoding follow the USB Power Delivery spec (aligned to USB-PD R3.2 V1.2, March 2026). Vendor names come from a bundled SQLite database (whatcable.db) that merges USB-IF's published vendor list, the community usb.ids list, and a curated set of cable fingerprints reported by users.

Build from source

swift build                  # compile everything
swift run WhatCable          # run the menu bar app (dev mode, no widget or bundle structure)
swift run whatcable-cli      # run the CLI
swift test                   # run the test suite

Requires Swift 5.9+ (Xcode 15+). Note: swift run WhatCable launches a working dev build but without the widget extension or proper .app bundle. For a distributable build, use the build scripts below.

Build a distributable .app

./scripts/smoke-test.sh

Builds, signs, notarises (if configured), and smoke-tests the app. Produces dist/WhatCable.app and dist/WhatCable.zip. Safe to run on any branch, any time. Does not touch the Homebrew tap.

Modes:

Configuration Result
No .env Ad-hoc signed. Works locally; Gatekeeper warns on other Macs.
.env with DEVELOPER_ID Developer ID signed + hardened runtime.
.env with DEVELOPER_ID + NOTARY_PROFILE Full notarisation + stapled ticket. Gatekeeper-clean for everyone.

Cutting a release:

# write release-notes/v<version>.md first, then:
./scripts/release.sh <version>

The wrapper does the whole pipeline: bumps the version, runs build-app.sh (which builds, signs, notarises, smoke-tests, and bumps the local cask), tags and pushes the commit, creates the GitHub release with the notes file, verifies the uploaded asset's sha matches the local zip, copies the notes into the tap, and pushes the tap. Use --dry-run first to validate state. Requires gh (auth'd) and the env vars from .env.example.

One-time setup for full notarisation:

# 1. Find your signing identity
security find-identity -v -p codesigning

# 2. Store notarytool credentials in the keychain
xcrun notarytool store-credentials "WhatCable-notary" \
    --apple-id "[email protected]" \
    --team-id "ABCDE12345" \
    --password "<app-specific-password>"   # generate at appleid.apple.com

# 3. Create your .env from the template
cp .env.example .env
# ...and fill in DEVELOPER_ID

Caveats

Linux port

@abrauchli built a Rust port for Linux called usbeehive, which also (optionally) installs a D-Bus backend for the GNOME Shell extension usbee. See the project repos for installation instructions. Usbeehive reads from the kernel's typec sysfs interface rather than IOKit, so it's an independent implementation rather than a fork. It started life as a whatcable crate on crates.io before being renamed to avoid confusion with this repo.

The other half of the question

WhatCable can tell you a charger negotiated 60W when your Mac wanted 96W. It cannot tell you what that has been doing to the battery on the other end of the cable, because that is a different part of the Mac and out of scope here.

WhatBattery covers that side: unrounded battery health, live charge and discharge in watts, per-cell readings from the pack, and what happened to the charge while the Mac was asleep. Same developer, same read-only approach, same Apple Silicon and macOS 14 floor.

WhatPort is the port-side companion: protocol, speed, lane status and live power draw for every port on your Mac at once, where WhatCable focuses on the cable in one of them.

Privacy

WhatCable reads USB-C port state directly from IOKit on your Mac. All of that happens locally. Nothing is sent anywhere automatically.

Cable reports: If you use the "Report this cable" button on an e-marked cable, WhatCable builds a pre-filled GitHub issue containing the cable's vendor ID, product ID, and capability flags (VDOs). Your browser opens with that data in the issue form. Nothing is submitted until you click the button in GitHub yourself. Once submitted, the issue is public.

Update checks: WhatCable checks the GitHub Releases API for a newer version when it starts, every six hours, and when you open the menu if it hasn't checked in the last 30 minutes. No personal data or hardware info is included in that request.

Diagnostic data: Settings has an opt-in Contribute Diagnostic Data button. When you press it, WhatCable collects raw IOKit registry properties about your Mac's USB ports, power and connected hardware, a list of the driver classes present, and your macOS version, chip type and Mac model identifier, then submits them to help improve hardware coverage. Your Mac's own identifiers are left out. It only runs when you click it; nothing is collected or sent unless you choose to.

Contributing

Issues and PRs welcome. The code is small and tries to stay readable.

Where to start:

Module Role
Sources/WhatCable/ Main menu bar app UI (SwiftUI popover, settings, notifications)
Sources/WhatCableCore/ Shared diagnostic logic, PD bit decoding, text formatting
Sources/WhatCableDarwinBackend/ IOKit watchers (port state, PD identity, power sources, USB devices, Thunderbolt fabric)
Sources/WhatCableAppKit/ Plugin registry and extension points (hooks for Pro features, CLI commands, menu items)
Sources/WhatCablePlugins/ Pro features (power metering, licence, cable and display diagnostics, liquid detection)
Sources/WhatCableWidget/ WidgetKit extension (small/medium/large desktop widgets)
Sources/WhatCableCLI/ CLI binary, shares Core/Backend/Plugins with the app

Translations

Read TRANSLATIONS.md first: it covers the terminology policy (technical labels stay in English) and which languages have an active maintainer who reviews changes.

WhatCable uses .lproj/.strings files for localisation. There is one set, shared by the app, the CLI, the widget and notifications, under Sources/WhatCableCore/Resources/<lang>.lproj/ (Localizable.strings, plus Localizable.stringsdict for plural forms).

To add a new language:

  1. Copy en.lproj/Localizable.strings into a new <lang>.lproj/ directory next to it
  2. Translate the values (leave the keys as-is)
  3. Make sure format specifiers (%@, %lld, %1$@, etc.) match the English originals exactly
  4. Run plutil -lint on your files to check for syntax errors
  5. Copy en.lproj/Localizable.stringsdict too and translate the plural forms (one/few/many/other, whichever your language uses)
  6. Add the language code to CFBundleLocalizations in scripts/smoke-test.sh

The Settings language picker builds itself from the bundled .lproj resources, so a new language appears there automatically once the files are in place.

Diagnostic data

The single most helpful thing you can do is hit Contribute Diagnostic Data in Settings. It runs a short set of probes that read the hardware data macOS already publishes about your Mac's ports, power and connected devices, then submits the results. The whole process takes a few seconds, nothing is sent without your explicit click, and no personal information is included.

More device data means better hardware coverage, fewer edge-case bugs, and more accurate diagnostics for everyone. If you have unusual hardware (docks, hubs, TB5 gear, high-wattage chargers), your report is especially valuable.

Cable reports are also very welcome. If you have an e-marked cable, use the "Report this cable" button in the app (or whatcable --report from the CLI) to submit its fingerprint. These reports build the bundled cable database so WhatCable can show brand and model info for known cables. Every report you submit helps other users identify their cables at a glance.

Research references

Some comments and docs cite files under research/ (for example research/displays/display-node-keys.md). That folder is my private research library, built from raw diagnostic dumps off real machines, and it is not part of this repo. The references stay so each decision names its evidence, even where you cannot open it. Comments may likewise name private notes, tooling and rules, which are not part of this repo either.

Credits

Built by Darryl Morley.

Contributors:

Beta testers:

Sponsors:

Thanks to everyone who has filed cable reports, bug reports, and IOKit dumps. These contributions directly improve the cable database and help WhatCable handle more hardware correctly.

Inspired by every time someone has asked "is this cable any good?".

whatcable (darrylmorley/whatcable)

正在搜索数据库…

这是什么?一款 macOS 菜单栏应用,用通俗的语言告诉你插在 Mac 上的每根 USB-C 线到底能干什么,以及为什么你的 Mac 充电可能很慢。
它是菜单栏应用,还是终端工具?两者都是。你既有菜单栏弹窗,又有基于同一套诊断引擎的 whatcable 命令行工具。手动安装时,命令行工具留在 .app 里,不会加入你的 PATH;用 Homebrew 安装则会自动把它链接到 PATH 中。
读取线缆数据需要特殊权限或辅助工具吗?不需要。它直接读取四类 IOKit 服务——不需要授权、不调用私有 API,也没有后台辅助进程。速度和功率的解析遵循 USB Power Delivery 规范,对齐到 R3.2 V1.2 版本。
所有插上的线缆它都能识别吗?不完全是。只有内置芯片的线缆才会显示 E-marker 详情,而大多数低于 60 W 的线缆没有芯片。有些线缆只有在另一端插上充电器或设备后才会暴露芯片信息——如果线缆空载时只显示基础信息,请接上设备后再查一次。
关于一根线缆,它具体能告诉我什么?连接状态、传输协议和插头方向、完整的功率传输档位列表及当前生效的 PDO、线缆的 E-marker 数据,还有厂商名称——这些来自一个内置的 SQLite 数据库,合并了 USB-IF 官方列表、社区 usb.ids 列表以及用户上报的线缆特征。
它能发现线缆虚标功率的情况吗?能发现一部分。它会交叉比对线缆、接口和充电器各自上报的信息,所以如果一根声称 240W / 40 Gbps 的线缆实际只协商出更低的规格,它会指出哪里不一致;另外有一张可信度信号卡片,会标记零 VID 之类的异常。不过它无法验证线缆皮里面的实际接线。
它支持 Linux 吗?这个应用不支持,不过 @abrauchli 用 Rust 独立移植了一个叫 usbeehive 的版本——用 cargo install usbeehive 即可安装。它读取的是内核的 typec sysfs 接口而不是 IOKit,所以是独立实现,并非分支复刻。
同一作者还有其他相关应用吗?有,它属于一个系列:WhatBattery 负责电池健康和充电,WhatPort 可以同时查看所有接口。
大小
18.9 MB
星标
9.1K
时长
7个月
提交 · 90 天