Skip to content

Replace claude -p music refresh with zero-token OS-level detection - #50

Merged
bearmug merged 1 commit into
mainfrom
feature/zero-token-music-refresh
Feb 6, 2026
Merged

Replace claude -p music refresh with zero-token OS-level detection#50
bearmug merged 1 commit into
mainfrom
feature/zero-token-music-refresh

Conversation

@bearmug

@bearmug bearmug commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New bin/refresh-music.sh — pure bash script that detects now-playing music via macOS native APIs (osascript for Spotify/Apple Music, nowplaying-cli for YouTube Music/browser-based players) instead of spawning claude -p with Chrome MCP
  • Daemon light-cycle updated — replaced the claude -p music call (~5K tokens/call) with refresh-music.sh (0 tokens), cutting daemon token usage by ~50% for music users (~135K → 0 tokens/hour)
  • Skip-if-unchanged optimization — compares title + artist + icon with current bridge data, exits early if nothing changed
  • Silent fallback: if OS-level detection fails, the full refresh cycle (every ~4.5min) still handles music via Chrome MCP

Test plan

  • bash plugins/claude-status-hub/tests/test-music-refresh.sh — 14 new tests (Spotify, Apple Music, YouTube Music detection, skip-if-unchanged, foreground preservation, truncation, fallback)
  • bash plugins/claude-status-hub/tests/run-tests.sh — all 176 tests across 11 test files pass
  • Manual: with Spotify open, run bin/refresh-music.sh → verify /tmp/status-hub.json updated
  • Manual: with YouTube Music + nowplaying-cli installed → same check
  • Manual: with no music playing → script exits silently, bridge unchanged

The daemon's light-cycle music refresh was spawning `claude -p` every ~90s
just to run JavaScript via Chrome MCP, costing ~5K tokens per call (~135K
tokens/hour for active music users). This replaces it with a pure bash
script using macOS native APIs (osascript for Spotify/Apple Music,
nowplaying-cli for browser-based players), reducing daemon token usage
by ~50% for music users.
@bearmug
bearmug merged commit 7d1756c into main Feb 6, 2026
1 check passed
@bearmug
bearmug deleted the feature/zero-token-music-refresh branch February 6, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant