-
Notifications
You must be signed in to change notification settings - Fork 87
MacOSBinaries
PowerKit includes native macOS binaries for efficient metric collection. These binaries use Apple's private frameworks and APIs to gather system information that would be slow or impossible to obtain through shell commands.
| Binary | Plugin | Framework | Purpose |
|---|---|---|---|
powerkit-temperature |
temperature | IOKit | CPU/GPU temperature via SMC |
powerkit-gpu |
gpu | IOKit | GPU utilization metrics |
powerkit-microphone |
microphone | CoreAudio | Microphone mute status |
powerkit-nowplaying |
nowplaying | ScriptingBridge | Now playing media info |
powerkit-brightness |
brightness | DisplayServices | Screen brightness level |
Shell-based approaches for these metrics have significant limitations on macOS:
| Metric | Shell Approach | Problems | Native Solution |
|---|---|---|---|
| Temperature | osx-cpu-temp |
Requires third-party install, slow | Direct SMC access via IOKit |
| GPU |
ioreg parsing |
Complex, unreliable for M-series | Direct IOKit queries |
| Microphone | osascript |
Slow AppleScript execution | CoreAudio API |
| Now Playing | osascript |
Slow, requires app-specific scripts | ScriptingBridge |
| Brightness | ioreg |
Stale values on Apple Silicon | DisplayServices API |
Binaries are not included in the repository - they are downloaded on-demand from GitHub Releases when you enable a plugin that requires them.
How it works:
- PowerKit detects which binaries are missing during startup
- A single popup appears listing all missing binaries
- You can choose to:
- [Y]es: Download all binaries
- [S]elect: Choose which binaries to download individually
- [N]o: Skip (won't prompt again for 24h)
- Downloaded binaries are stored in
bin/directory - Your decision is cached for 24 hours
No manual installation required!
If you declined to download binaries and want to be prompted again:
# Clear all binary decisions
rm -f ~/.cache/tmux-powerkit/data/binary_decision_*
# Clear tracking files
rm -f /tmp/powerkit_missing_binaries /tmp/powerkit_binary_pending_all
# Reload tmux to trigger prompt
tmux source ~/.tmux.confOr run the prompt manually:
~/.tmux/plugins/tmux-powerkit/bin/powerkit-binary-prompt \
"powerkit-gpu:gpu powerkit-temperature:temperature"If automatic download fails, you can manually download binaries from:
https://github.com/fabioluciano/tmux-powerkit/releases/latest
Download the appropriate binary for your architecture:
-
powerkit-*-darwin-arm64for Apple Silicon (M1/M2/M3) -
powerkit-*-darwin-amd64for Intel Macs
Place in ~/.tmux/plugins/tmux-powerkit/bin/ and make executable:
chmod +x ~/.tmux/plugins/tmux-powerkit/bin/powerkit-*Source code is available in src/native/macos/:
cd ~/.tmux/plugins/tmux-powerkit/src/native/macos
# Build all binaries
make all
# Build specific binary
make powerkit-temperature
make powerkit-gpu
make powerkit-microphone
make powerkit-nowplaying
make powerkit-brightness
# Clean build artifacts
make clean
# Copy to bin directory
cp powerkit-* ../../bin/- Xcode Command Line Tools
- macOS SDK 10.15+
# Install Xcode Command Line Tools
xcode-select --installReads CPU and GPU temperatures from the System Management Controller (SMC).
Source: src/native/macos/powerkit-temperature.m
Frameworks:
- Foundation
- IOKit
Usage:
./powerkit-temperature [source]Arguments:
| Argument | Description |
|---|---|
| (none) | Auto-detect highest CPU temperature |
cpu |
CPU cluster temperature |
gpu |
GPU temperature |
auto |
Same as no argument |
Output:
45.2
SMC Keys:
| Chip Type | CPU Key | GPU Key |
|---|---|---|
| Apple Silicon (M1/M2/M3) | Tp0f |
Tg0j |
| Intel | TC0P |
TG0D |
Example:
# Auto-detect
./powerkit-temperature
# Output: 48.5
# CPU specific
./powerkit-temperature cpu
# Output: 52.1
# GPU specific
./powerkit-temperature gpu
# Output: 45.8Reads GPU utilization metrics using IOKit.
Source: src/native/macos/powerkit-gpu.m
Frameworks:
- Foundation
- IOKit
Usage:
./powerkit-gpuOutput:
Device Utilization %:42
Notes:
- Works with both integrated and discrete GPUs
- On Apple Silicon, reports unified GPU utilization
- On Intel Macs with discrete GPU, reports discrete GPU when active
Example:
./powerkit-gpu
# Output: Device Utilization %:42Detects microphone mute status using CoreAudio.
Source: src/native/macos/powerkit-microphone.m
Frameworks:
- Foundation
- CoreAudio
- AudioToolbox
Usage:
./powerkit-microphoneOutput:
muted
or
unmuted
Notes:
- Checks the system-wide default input device
- Returns "muted" if input volume is 0 or mute is enabled
- Returns "unmuted" otherwise
Example:
./powerkit-microphone
# Output: unmutedGets currently playing media information using ScriptingBridge.
Source: src/native/macos/powerkit-nowplaying.m
Frameworks:
- Foundation
- ScriptingBridge
Usage:
./powerkit-nowplayingOutput:
artist|||track|||album
Fields are separated by ||| delimiter.
Supported Applications:
- Apple Music
- Spotify
- Other apps that support macOS Media Player APIs
Notes:
- Returns empty fields if no media is playing
- Handles special characters in track/artist names
- Falls back gracefully if music apps aren't running
Example:
./powerkit-nowplaying
# Output: The Beatles|||Hey Jude|||Past Masters
# No music playing:
# Output: ||||||Each plugin has fallback behavior when native binaries are unavailable:
| Plugin | Fallback Method |
|---|---|
| temperature |
osx-cpu-temp, smctemp, iStats
|
| gpu | Returns inactive state (no fallback) |
| microphone | Returns inactive state (no fallback) |
| nowplaying | Returns inactive state (no fallback) |
| brightness |
ioreg (may have stale values on Apple Silicon) |
Plugins without fallbacks will prompt you to download the binary when first used.
chmod +x ~/.tmux/plugins/tmux-powerkit/bin/powerkit-*- Check macOS version compatibility
- Rebuild from source:
cd ~/.tmux/plugins/tmux-powerkit/src/native/macos make clean && make all cp powerkit-* ../../bin/
Some binaries may require additional permissions:
- Temperature: May need Full Disk Access on some systems
- Microphone: May trigger microphone access prompt
If you see "bad CPU type" errors:
# Check binary architecture
file ~/.tmux/plugins/tmux-powerkit/bin/powerkit-temperature
# Rebuild for your architecture
cd ~/.tmux/plugins/tmux-powerkit/src/native/macos
make clean && make all
cp powerkit-* ../../bin/If automatic download fails:
- Check your internet connection
- Verify GitHub releases are accessible:
curl -I https://github.com/fabioluciano/tmux-powerkit/releases/latest
- Try manual download from releases page
- Or build from source (see above)
If the download popup doesn't appear:
# Clear any stale state
rm -f /tmp/powerkit_missing_binaries /tmp/powerkit_binary_pending_all
rm -f ~/.cache/tmux-powerkit/data/binary_decision_*
# Ensure binaries are missing
rm -f ~/.tmux/plugins/tmux-powerkit/bin/powerkit-{gpu,temperature,microphone,nowplaying,brightness}
# Reload tmux
tmux source ~/.tmux.confIf you closed the popup with Ctrl+C before making a choice:
- The popup should appear again on next tmux refresh (no decision was saved)
- If it doesn't, clear the tracking files as shown above
On some systems, SMC access may be restricted:
-
Check System Integrity Protection (SIP) status:
csrutil status
-
The binary uses documented IOKit APIs and should work with SIP enabled
The pre-built binaries are unsigned. macOS Gatekeeper may block them on first run:
- Right-click the binary and select "Open"
- Or allow in System Preferences → Security & Privacy
All source code is available in src/native/macos/ for review:
powerkit-temperature.mpowerkit-gpu.mpowerkit-microphone.mpowerkit-nowplaying.mpowerkit-brightness.m
For maximum security, build the binaries yourself:
cd ~/.tmux/plugins/tmux-powerkit/src/native/macos
make clean && make all
cp powerkit-* ../../bin/-
Create source file in
src/native/macos/:// powerkit-example.m #import <Foundation/Foundation.h> int main(int argc, char *argv[]) { @autoreleasepool { // Your code here printf("result\n"); } return 0; }
-
Add to
src/native/macos/Makefile:powerkit-example: powerkit-example.m $(CC) $(CFLAGS) -framework Foundation -o $@ $<
-
Build:
cd src/native/macos make powerkit-example cp powerkit-example ../../bin/ -
Update
.releasercto include in GitHub releases
cd bin
# Test each binary
./powerkit-temperature
./powerkit-gpu
./powerkit-microphone
./powerkit-nowplaying
./powerkit-brightness- PluginTemperature - Temperature monitoring
- PluginGpu - GPU utilization
- PluginMicrophone - Microphone status
- PluginNowplaying - Now playing media
- Troubleshooting - General troubleshooting