No description
  • Swift 98.4%
  • Shell 1.6%
Find a file
blackruby f6345a83b0 Fix frozen menu bar label: flush the status window after every redraw
Timer fetches were updating attributedTitle while idle, but AppKit left
the status item window undisplayed until the next interaction (App Nap),
so the bar appeared to refresh only on click. Mark the button
needsDisplay and synchronously flush its window after each redraw; add a
`label` log category recording redraw/skip decisions.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-26 17:23:55 +01:00
Resources EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
Sources Fix frozen menu bar label: flush the status window after every redraw 2026-10-26 17:23:55 +01:00
Tests/PriceKitTests EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
.gitignore EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
build-app.sh EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
Package.swift EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
PROJECT.md EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00
README.md Menu bar: real color coin logos by default, monochrome template behind a Settings toggle 2026-10-25 21:27:18 +01:00
test.sh EthTonBar: ETH + TON prices in the macOS menu bar 2026-10-25 20:55:02 +01:00

EthTonBar

A macOS menu bar app that shows the USD prices of Ethereum and Toncoin (now called Gram). Both coins come from one CoinGecko request per refresh; clicking the menu bar item opens a panel with 1h/24h/7d change, 24h high/low, market cap, volume and a 7-day sparkline. Requires macOS 14 or later. No Dock icon, no telemetry, no third-party packages.

Menu bar

◆ $3,412 ▽ $5.43 when live, ◆ ? ▽ ? when not. The menu bar shows the real Ethereum and TON/Gram badges by default; unchecking Settings ▸ "Color coin logos" switches to the monochrome template icons that the system tints for light and dark menu bars. A coin shows ? instead of a price or a stale number when:

  • there is no internet connection,
  • it has never been fetched successfully,
  • the last fetch is older than 2 × refresh interval + 60 s, or
  • CoinGecko's own last_updated is more than 15 minutes behind.

The last-known price appears in the panel, labelled as such, but never in the menu bar.

Panel

┌──────────────────────────────────────────────┐
│ Updated 19:56:12 · CoinGecko                  │
├──────────────────────────────────────────────┤
│ (◆) Ethereum ETH                  $3,412.18   │
│     24h +2.31%  1h −0.12%  7d +5.04%          │
│     H $3,450.12 · L $3,301.00                 │
│     MCap $411.2B · Vol $18.3B                 │
│     ╱╲__╱╲╱‾╲_╱                              │
│ (▽) Toncoin TON · Gram                $5.43   │
│     …                                         │
├──────────────────────────────────────────────┤
│ Refresh Now                              ⌘R   │
│ View on CoinGecko                         ▸   │
│ Settings                                  ▸   │
│ Quit EthTonBar                           ⌘Q   │
└──────────────────────────────────────────────┘

Network and battery

One request per refresh fetches both coins. Nothing else talks to the network.

Interval Max requests/hour (awake, online, visible) Notes
1 min 60
2 min (default) 30 0 while asleep, offline, screen off, or menu bar hidden
5 min 12
15 min 4 Opening the panel fetches if data is ≥ 60 s old

Polling is suspended entirely (timer invalidated, not skipped) while offline, the system or displays are asleep, the user session is inactive, or the status item is not visible. On resume there is a 3 s delay after wake and network reconnect. A hard floor keeps every request at least 30 s apart, including Refresh Now and panel-open. Failed fetches back off 30, 60, 120 … up to 900 s; a Retry-After from a 429 overrides the backoff. The 7-day sparkline payload is requested at most once per hour.

CoinGecko's public API is rate-limited. If you have a demo key, requests will use it:

defaults write dev.ruben.ethtonbar coingeckoDemoAPIKey CG-xxxx
defaults delete dev.ruben.ethtonbar coingeckoDemoAPIKey   # stop using it

Preferences

All keys live in dev.ruben.ethtonbar. Setting a value back to its default removes the key. Everything is also reachable from Settings in the panel.

Key Default Reset
refreshIntervalSeconds (60/120/300/900) 120 defaults delete dev.ruben.ethtonbar refreshIntervalSeconds
menuBarCoins (array of coin ids) both defaults delete dev.ruben.ethtonbar menuBarCoins
showDollarSign true defaults delete dev.ruben.ethtonbar showDollarSign
showChangeInMenuBar false defaults delete dev.ruben.ethtonbar showChangeInMenuBar
colorMenuBarIcons true defaults delete dev.ruben.ethtonbar colorMenuBarIcons

Open at Login is managed by SMAppService, not stored in defaults.

Install and run

./build-app.sh
open dist/EthTonBar.app

If Gatekeeper complains about the ad-hoc signature:

xattr -d com.apple.quarantine dist/EthTonBar.app

Useful one-shots:

dist/EthTonBar.app/Contents/MacOS/EthTonBar --status          # one fetch, prints both coins
dist/EthTonBar.app/Contents/MacOS/EthTonBar --render-icons /tmp/etb   # PNGs of the artwork

Open at Login requires the app to be in /Applications.

Development

./test.sh

PriceKit holds every user-visible string and every decision about when to fetch or whether to show ?, as pure functions that take now: Date. EthTonBar is AppKit and networking glue only. To watch the request log:

log stream --predicate 'subsystem == "dev.ruben.ethtonbar"' --level info

Data and trademarks

Prices come from CoinGecko. The Ethereum and TON logos are trademarks of their respective owners.