Skip to content

Show the headset's battery on the tray icon - #1

Merged
steeben merged 5 commits into
mainfrom
tray-battery-indicator
Oct 22, 2026
Merged

steeben merged 5 commits into
mainfrom
tray-battery-indicator

Conversation

@steeben

@steeben steeben commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Requested by Stephen · project thread

What

The notification-area icon can show the headset's battery instead of Neap's glyph. Settings gets two cards, both hidden where the desktop shows no tray icons:

  • Icon by the clock: Neap / Battery / Percentage (segmented, default Battery).
  • Low battery: a 5 to 50% slider (default 20%). It only shows while Battery or Percentage is chosen. At or below this level the icon turns red.

Battery is a monochrome battery in the taskbar's shade, filled to the charge. The fill turns red at the low level, and a bolt shows while charging. Percentage is the charge as a number, as large as fits, and turns red at the low level too. With no reading, a settling one, or Neap chosen, the icon goes back to Neap's glyph, so an empty bar or a stale number never stands in for "unknown". The tooltip still gives the charge in words.

How

  • Neap.Core/Connection/TrayBattery.cs decides whether to draw the battery, how full, and whether it is low, with TrayBatteryTests.
  • Neap.Desktop/TrayBatteryPicture.cs renders it to a 32 px bitmap. Edges sit on even pixels so it stays sharp when halved to 16 px.
  • MainWindow.Tray.cs redraws the icon only when what it shows changes. The taskbar shade is read once at startup and again when Windows reports a colour change.
  • New settings are tray_icon and tray_warn_at in app-settings.json. Strings are in Resources.resw, and there is a CHANGELOG line.

Verified

  • Linux: dotnet build src/Neap.Desktop -c Release -f net10.0, 1253 Core tests passing, and dotnet format --verify-no-changes clean on the four projects.
  • Icons were rendered headlessly and checked at 32 and 16 px on dark and light backgrounds. The Settings page was checked in a pretend-mode snapshot.
  • Not yet checked on Windows, where the Windows target, the real tray and the hardware come in. It still needs a Windows build and a run with the headset.

Generated by Claude Code

The icon by the clock can now draw the battery instead of Neap's glyph:
either a battery filled to the charge or the charge as a number, chosen
on the Settings page. Either turns red at a low level the person sets
(20% by default), and the battery shows a bolt while charging. With no
reading, a settling one, or "Neap" chosen, the icon is Neap's glyph, so
an empty bar or a stale number never stands in for "unknown".

When to draw it, how full and whether it is low is decided in Core
(TrayBattery) with tests; the desktop only renders it, at 32 px on even
pixels so it stays sharp halved to 16, in the taskbar's shade.
@steeben steeben self-assigned this Oct 22, 2026
The repository keeps its design choices in DECISIONS.md; this one sets
out the styles considered, the default, and the user-set low level.
Two more choices for the icon by the clock: a headset with a battery in
its bottom-right corner, and a headset with the charge as a number there.
Both cut a gap around the corner so the two read apart, and turn red at
the low level like the other styles. While the headset is known to be
away (nothing plugged in, or a transmitter with the headset off or out
of range) they draw a faint headset struck through; while Neap is still
asking, or the settings are out of reach with sound still playing, the
glyph stands in, as it does for the other styles.

With five choices, the Settings card lists them as rows under its name
rather than as segments.
The headset and number style says whose charge it is, the exact charge,
and when the headset is disconnected, so it serves a new install best.
…ray icon

Two fixed steps replace the low battery setting: orange says charge soon,
red says charge now, with nothing to tune. On power the charge keeps the
taskbar's shade. The Settings card is renamed "System tray icon", the
name people know the area by, and its line says when the colours change,
now that there is no setting that does.
@steeben
steeben merged commit a103b40 into main Oct 22, 2026
2 checks passed
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