ai-battery 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.js CHANGED
@@ -102,7 +102,7 @@ const CODEX_PREFERRED_BACKUP_SUFFIX = ".ai-battery-original-link";
102
102
  const CODEX_TIMESTAMP_BACKUP_MARKER = ".ai-battery-backup-";
103
103
  const CODEX_STATUS_LINE = STATUS_LINE_ITEMS;
104
104
  const DEFAULT_STATUSLINE_HEADER_COLUMN_GUARD = 2;
105
- const CODEX_MENU_BAR_COLOR = "#000000";
105
+ const CODEX_MENU_BAR_COLOR = "#FFFFFF";
106
106
  const CLAUDE_MENU_BAR_COLOR = "#D97706";
107
107
  const MENU_BAR_WHITE = "#FFFFFF";
108
108
  const MENU_DETAIL_GREEN = "#30D158";
@@ -130,6 +130,11 @@ function parseArgs(argv) {
130
130
  menuBar: false,
131
131
  menuBarImage: false,
132
132
  menuDetailImage: false,
133
+ railImage: false,
134
+ railScale: 1,
135
+ railText: null,
136
+ panelText: null,
137
+ codexIcon: null,
133
138
  hudState: false,
134
139
  silent: false,
135
140
  force: false,
@@ -278,6 +283,35 @@ function parseArgs(argv) {
278
283
  } else if (arg === "--menu-detail-image") {
279
284
  args.menuDetailImage = true;
280
285
  args.style = "plain";
286
+ } else if (arg === "--rail-image") {
287
+ args.railImage = true;
288
+ args.style = "plain";
289
+ } else if (arg === "--rail-scale") {
290
+ const value = Number(requiredValue(argv, i, args.command));
291
+ if (!Number.isFinite(value) || value < 0.5 || value > 3) {
292
+ throw cliError("--rail-scale must be between 0.5 and 3.0.", "--rail-scale은 0.5에서 3.0 사이여야 합니다.", args.helpTopic);
293
+ }
294
+ args.railScale = value;
295
+ i += 1;
296
+ } else if (arg === "--rail-text") {
297
+ const value = String(requiredValue(argv, i, args.command)).trim().toLowerCase();
298
+ if (!["white", "black"].includes(value)) throw invalidChoice(arg, "white, black", args.helpTopic);
299
+ args.railText = value;
300
+ i += 1;
301
+ } else if (arg === "--panel-text") {
302
+ const value = String(requiredValue(argv, i, args.command)).trim().toLowerCase();
303
+ if (!["white", "black"].includes(value)) throw invalidChoice(arg, "white, black", args.helpTopic);
304
+ args.panelText = value;
305
+ i += 1;
306
+ } else if (arg === "--codex-icon") {
307
+ const value = String(requiredValue(argv, i, args.command)).trim().toLowerCase();
308
+ if (!["white", "black"].includes(value)) throw invalidChoice(arg, "white, black", args.helpTopic);
309
+ args.codexIcon = value;
310
+ i += 1;
311
+ } else if (arg.startsWith("--codex-icon=")) {
312
+ const value = arg.slice(arg.indexOf("=") + 1).trim().toLowerCase();
313
+ if (!["white", "black"].includes(value)) throw invalidChoice("--codex-icon", "white, black", args.helpTopic);
314
+ args.codexIcon = value;
281
315
  } else if (arg === "--hud-state") {
282
316
  args.hudState = true;
283
317
  args.style = "plain";
@@ -5313,27 +5347,36 @@ function menuBatteryColor(percent, running = true) {
5313
5347
  return MENU_DETAIL_GREEN;
5314
5348
  }
5315
5349
 
5316
- function renderMenuBarSvgIcon(icon, x, y, height) {
5350
+ function resolveCodexMenuBarColor(codexIcon) {
5351
+ const mode = String(codexIcon || process.env.AI_BATTERY_CODEX_ICON_COLOR || "").trim().toLowerCase();
5352
+ if (mode === "black") return "#000000";
5353
+ if (mode === "white") return "#FFFFFF";
5354
+ return CODEX_MENU_BAR_COLOR;
5355
+ }
5356
+
5357
+ function renderMenuBarSvgIcon(icon, x, y, height, colorOverride = null) {
5317
5358
  const scale = height / icon.viewBox;
5318
5359
  const paths = icon.paths || [{ d: icon.path }];
5360
+ const fillColor = colorOverride || icon.color;
5319
5361
  const renderedPaths = paths.map((iconPath) => {
5320
5362
  const ruleAttrs = [
5321
5363
  iconPath.fillRule ? ` fill-rule="${iconPath.fillRule}"` : "",
5322
5364
  iconPath.clipRule ? ` clip-rule="${iconPath.clipRule}"` : ""
5323
5365
  ].join("");
5324
- return `<path d="${iconPath.d}" fill="${icon.color}"${ruleAttrs}/>`;
5366
+ return `<path d="${iconPath.d}" fill="${fillColor}"${ruleAttrs}/>`;
5325
5367
  }).join("");
5326
5368
  return `<g transform="translate(${x} ${y}) scale(${scale})">${renderedPaths}</g>`;
5327
5369
  }
5328
5370
 
5329
- function menuBarImageIcon(provider, x, y) {
5371
+ function menuBarImageIcon(provider, x, y, { codexIcon = null } = {}) {
5330
5372
  if (provider === "antigravity") {
5331
5373
  const svg = fs.readFileSync(path.join(scriptDir(), "..", "docs", "antigravity-icon.svg"), "utf8");
5332
5374
  return svg.replace(/<svg\b[^>]*>/, `<svg x="${x}" y="${y}" width="19" height="19" viewBox="0 0 180 180" fill="none" xmlns="http://www.w3.org/2000/svg">`);
5333
5375
  }
5334
5376
  const height = provider === "codex" ? 19 : 17;
5335
5377
  const iconY = provider === "codex" ? y - 0.5 : y;
5336
- if (provider === "codex") {
5378
+ const codexColor = resolveCodexMenuBarColor(codexIcon);
5379
+ if (provider === "codex" && codexColor !== "#000000") {
5337
5380
  const pngIconPath = codexMenuBarPngIconPath();
5338
5381
  if (pngIconPath) {
5339
5382
  return `<image x="${x}" y="${iconY}" width="${height}" height="${height}" href="${imageDataUri(pngIconPath)}"/>`;
@@ -5343,15 +5386,18 @@ function menuBarImageIcon(provider, x, y) {
5343
5386
  const icon = provider === "codex"
5344
5387
  ? (codexMenuBarSvgIcon() || MENU_BAR_BRAND_ICONS.codex)
5345
5388
  : (MENU_BAR_BRAND_ICONS[provider] || MENU_BAR_BRAND_ICONS.codex);
5346
- return renderMenuBarSvgIcon(icon, x, iconY, height);
5389
+ return renderMenuBarSvgIcon(icon, x, iconY, height, provider === "codex" ? codexColor : null);
5347
5390
  }
5348
5391
 
5349
- function renderMenuBarImage(snapshot) {
5392
+ function renderMenuBarImage(snapshot, { codexIcon = null, text = null } = {}) {
5350
5393
  const startX = 0;
5351
5394
  const endPadding = 0;
5352
5395
  const providerWidth = 56;
5353
5396
  const providerContentWidth = 48;
5354
5397
  const height = 24;
5398
+ const textMode = String(text || process.env.AI_BATTERY_PANEL_TEXT || "white").trim().toLowerCase();
5399
+ const darkText = textMode === "black" || textMode === "dark";
5400
+ const effectiveCodexIcon = codexIcon || (darkText ? "black" : null);
5355
5401
  const visibleResults = orderResults(snapshot.results.filter(Boolean), configuredProviderOrder());
5356
5402
  const width = visibleResults.length
5357
5403
  ? startX + ((visibleResults.length - 1) * providerWidth) + providerContentWidth + endPadding
@@ -5366,32 +5412,35 @@ function renderMenuBarImage(snapshot) {
5366
5412
  const meterY = 3;
5367
5413
  const meterWidth = 24;
5368
5414
  const meterHeight = 5;
5369
- const meterStroke = 1.1;
5415
+ const meterStroke = 1;
5370
5416
  const meterInnerX = meterX + 2;
5371
- const meterInnerY = meterY + 1.7;
5417
+ const meterInnerY = meterY + 2;
5372
5418
  const meterInnerWidth = meterWidth - 4;
5373
- const meterInnerHeight = meterHeight - 3.4;
5419
+ const meterInnerHeight = meterHeight - 3;
5374
5420
  const fillWidth = percent === null ? 0 : Math.max(percent > 0 ? 2 : 0, Math.round((percent / 100) * meterInnerWidth));
5375
- const fill = menuBatteryColor(percent, running);
5421
+ const fill = darkText && (!running || typeof percent !== "number") ? "#5C5C66" : menuBatteryColor(percent, running);
5376
5422
  const label = percent === null ? "--" : `${Math.round(percent)}%`;
5377
5423
  const labelX = meterX + (meterWidth / 2);
5378
- const textFill = running ? MENU_BAR_WHITE : MENU_DIM_TEXT;
5424
+ const textFill = darkText
5425
+ ? (running ? "#141418" : "#5C5C66")
5426
+ : (running ? MENU_BAR_WHITE : MENU_DIM_TEXT);
5427
+ const outlineStroke = darkText ? "#141418" : MENU_BAR_WHITE;
5379
5428
  const outlineOpacity = running ? MENU_BAR_OUTLINE_OPACITY : MENU_DIM_OUTLINE_OPACITY;
5380
5429
 
5381
- items.push(menuBarImageIcon(result.provider, x, 3));
5382
- items.push(`<rect x="${meterX}" y="${meterY}" width="${meterWidth}" height="${meterHeight}" rx="2.5" fill="none" stroke="${MENU_BAR_WHITE}" stroke-opacity="${outlineOpacity}" stroke-width="${meterStroke}"/>`);
5430
+ items.push(menuBarImageIcon(result.provider, x, 3, { codexIcon: effectiveCodexIcon }));
5431
+ items.push(`<rect x="${meterX + 0.5}" y="${meterY + 0.5}" width="${meterWidth - 1}" height="${meterHeight}" rx="2.5" fill="none" stroke="${outlineStroke}" stroke-opacity="${outlineOpacity}" stroke-width="${meterStroke}"/>`);
5383
5432
  if (fillWidth > 0) {
5384
- items.push(`<rect x="${meterInnerX}" y="${meterInnerY}" width="${fillWidth}" height="${meterInnerHeight}" rx="0.8" fill="${fill}"/>`);
5433
+ items.push(`<rect x="${meterInnerX}" y="${meterInnerY}" width="${fillWidth}" height="${meterInnerHeight}" rx="0.5" fill="${fill}"/>`);
5385
5434
  }
5386
- items.push(`<text x="${labelX}" y="21" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif" font-size="9.5" font-weight="650" fill="${textFill}">${svgEscape(label)}</text>`);
5435
+ items.push(`<text x="${labelX}" y="21.5" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Ubuntu', 'Noto Sans', sans-serif" font-size="10.5" font-weight="700" fill="${textFill}">${svgEscape(label)}</text>`);
5387
5436
  });
5388
5437
 
5389
5438
  if (!items.length) {
5390
- items.push(`<text x="9" y="16" font-family="-apple-system, BlinkMacSystemFont, sans-serif" font-size="11" font-weight="650" fill="${MENU_BAR_WHITE}">AI --</text>`);
5439
+ items.push(`<text x="9" y="16" font-family="-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Ubuntu', 'Noto Sans', sans-serif" font-size="11" font-weight="650" fill="${darkText ? "#141418" : MENU_BAR_WHITE}">AI --</text>`);
5391
5440
  }
5392
5441
 
5393
5442
  const svg = [
5394
- `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`,
5443
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" text-rendering="geometricPrecision" shape-rendering="geometricPrecision">`,
5395
5444
  ...items,
5396
5445
  "</svg>",
5397
5446
  ""
@@ -5523,14 +5572,145 @@ function renderMenuDetailImage(snapshot) {
5523
5572
  throw new Error("Could not write macOS menu detail image");
5524
5573
  }
5525
5574
 
5526
- function desktopHudSnapshot(provider = "all") {
5575
+ function railProviderTag(provider) {
5576
+ if (provider === "codex") return "CDX";
5577
+ if (provider === "claude") return "CLD";
5578
+ if (provider === "antigravity") return "AGY";
5579
+ return "AI";
5580
+ }
5581
+
5582
+ function railProviderTagColor(provider, running, darkText = false) {
5583
+ if (provider === "antigravity") {
5584
+ if (darkText) return running ? "#2563EB" : "#4B76C8";
5585
+ return running ? "#60A5FA" : "#4C84CC";
5586
+ }
5587
+ if (provider === "claude") {
5588
+ if (darkText) return running ? "#D97706" : "#B47030";
5589
+ return running ? "#F97316" : "#CC6E2A";
5590
+ }
5591
+ if (darkText) return running ? "#141418" : "#5C5C66";
5592
+ return running ? "#FFFFFF" : "#CCCCD4";
5593
+ }
5594
+
5595
+ function railWindowParts(limit, fallbackLabel, fallbackValue, preferPercent = false) {
5596
+ if (!limit) return { label: fallbackLabel, value: fallbackValue };
5597
+ const label = limit.windowMinutes ? shortWindow(limit.windowMinutes) : (limit.id || fallbackLabel);
5598
+ const value = preferPercent
5599
+ ? (typeof limit.remainingPercent === "number" ? `${Math.round(limit.remainingPercent)}%` : resetClock(limit))
5600
+ : (label === "5h" ? resetClock(limit) : (typeof limit.remainingPercent === "number" ? `${Math.round(limit.remainingPercent)}%` : resetClock(limit)));
5601
+ return { label, value: value || fallbackValue };
5602
+ }
5603
+
5604
+ function renderRailImage(snapshot, { scale = 1, backdrop = false, text = null } = {}) {
5605
+ const safeScale = Number.isFinite(Number(scale)) ? clamp(Number(scale), 0.5, 3) : 1;
5606
+ const textMode = String(text || process.env.AI_BATTERY_RAIL_TEXT || "white").trim().toLowerCase();
5607
+ const darkText = textMode === "black" || textMode === "dark";
5608
+ const visibleResults = orderResults(snapshot.results.filter(Boolean), configuredProviderOrder());
5609
+ const width = 44;
5610
+ const padY = 8;
5611
+ const tagH = 14;
5612
+ const tagGap = 3;
5613
+ const batH = 30;
5614
+ const batGap = 3;
5615
+ const pctH = 14;
5616
+ const pctGap = 2;
5617
+ const lblH = 10;
5618
+ const valH = 12;
5619
+ const pairGap = 3;
5620
+ const divGap = 11;
5621
+ const blockH = (tagH + tagGap) + (batH + batGap) + (pctH + pctGap) + (lblH + valH + pairGap) + (lblH + valH);
5622
+ const count = Math.max(1, visibleResults.length);
5623
+ const height = (padY * 2) + (count * blockH) + (Math.max(0, count - 1) * divGap);
5624
+ const scaledWidth = Math.max(24, Math.round(width * safeScale));
5625
+ const scaledHeight = Math.max(32, Math.round(height * safeScale));
5626
+ const centerX = width / 2;
5627
+ const sansFont = "-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Ubuntu', 'Noto Sans', sans-serif";
5628
+ const monoFont = "'SF Mono', 'Cascadia Mono', 'JetBrains Mono', 'Ubuntu Mono', monospace";
5629
+ const items = backdrop
5630
+ ? [`<rect x="0.5" y="0.5" width="${width - 1}" height="${height - 1}" rx="8" fill="#1C1C20" fill-opacity="0.92" stroke="#44444A" stroke-width="1"/>`]
5631
+ : [];
5632
+
5633
+ if (!visibleResults.length) {
5634
+ items.push(`<text x="${centerX}" y="${Math.round(height / 2) + 4}" text-anchor="middle" font-family="${monoFont}" font-size="10.5" font-weight="700" fill="${darkText ? "#6C6C74" : "#9A9AA4"}">AI--</text>`);
5635
+ } else {
5636
+ let y = padY;
5637
+ visibleResults.forEach((result, index) => {
5638
+ if (index > 0) {
5639
+ const divY = y + Math.floor(divGap / 2) + 0.5;
5640
+ items.push(`<line x1="6" y1="${divY}" x2="${width - 6}" y2="${divY}" stroke="${darkText ? "#AAAAB4" : "#4A4A54"}" stroke-width="1"/>`);
5641
+ y += divGap;
5642
+ }
5643
+ const running = result.running === true;
5644
+ const percent = typeof result.percentRemaining === "number" ? clamp(result.percentRemaining, 0, 100) : null;
5645
+ const primaryColor = running
5646
+ ? (darkText ? "#141418" : "#F5F5F7")
5647
+ : (darkText ? "#6C6C74" : "#9A9AA4");
5648
+ const mutedColor = darkText ? "#787880" : "#80808A";
5649
+ const trackColor = darkText ? "#B4B4BC" : "#54545E";
5650
+ const tag = railProviderTag(result.provider);
5651
+ const tagColor = railProviderTagColor(result.provider, running, darkText);
5652
+
5653
+ items.push(`<text x="${centerX}" y="${y + 11}" text-anchor="middle" font-family="${monoFont}" font-size="11.5" font-weight="700" fill="${tagColor}">${svgEscape(tag)}</text>`);
5654
+ y += tagH + tagGap;
5655
+
5656
+ items.push(`<rect x="${centerX - 1}" y="${y}" width="2" height="${batH}" rx="1" fill="${trackColor}"/>`);
5657
+ if (percent !== null) {
5658
+ const fillH = percent > 0 ? Math.max(2, Math.round((percent / 100) * batH)) : 0;
5659
+ if (fillH > 0) {
5660
+ const fillColor = menuBatteryColor(percent, running);
5661
+ items.push(`<rect x="${centerX - 4}" y="${y + batH - fillH}" width="8" height="${fillH}" rx="1.5" fill="${fillColor}"/>`);
5662
+ }
5663
+ }
5664
+ y += batH + batGap;
5665
+
5666
+ const pctText = percent === null ? "--%" : `${Math.round(percent)}%`;
5667
+ const pctColor = running ? menuBatteryColor(percent, true) : primaryColor;
5668
+ items.push(`<text x="${centerX}" y="${y + 11}" text-anchor="middle" font-family="${sansFont}" font-size="10.5" font-weight="700" fill="${pctColor}">${svgEscape(pctText)}</text>`);
5669
+ y += pctH + pctGap;
5670
+
5671
+ const primary = railWindowParts(result.primary, "5h", "--:--", false);
5672
+ items.push(`<text x="${centerX}" y="${y + 8}" text-anchor="middle" font-family="${sansFont}" font-size="8.5" font-weight="500" fill="${mutedColor}">${svgEscape(primary.label)}</text>`);
5673
+ y += lblH;
5674
+ items.push(`<text x="${centerX}" y="${y + 10}" text-anchor="middle" font-family="${monoFont}" font-size="9.5" font-weight="500" fill="${primaryColor}">${svgEscape(primary.value)}</text>`);
5675
+ y += valH + pairGap;
5676
+
5677
+ const secondary = railWindowParts(result.secondary, "7d", "--%", true);
5678
+ items.push(`<text x="${centerX}" y="${y + 8}" text-anchor="middle" font-family="${sansFont}" font-size="8.5" font-weight="500" fill="${mutedColor}">${svgEscape(secondary.label)}</text>`);
5679
+ y += lblH;
5680
+ items.push(`<text x="${centerX}" y="${y + 10}" text-anchor="middle" font-family="${monoFont}" font-size="9.5" font-weight="500" fill="${primaryColor}">${svgEscape(secondary.value)}</text>`);
5681
+ y += valH;
5682
+ });
5683
+ }
5684
+
5685
+ const svg = [
5686
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${scaledWidth}" height="${scaledHeight}" viewBox="0 0 ${width} ${height}" text-rendering="geometricPrecision" shape-rendering="geometricPrecision">`,
5687
+ ...items,
5688
+ "</svg>",
5689
+ ""
5690
+ ].join("\n");
5691
+
5692
+ for (const root of [stateDir(), path.join(os.tmpdir(), "ai-battery")]) {
5693
+ const filePath = path.join(root, "hud-rail.svg");
5694
+ try {
5695
+ fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
5696
+ fs.writeFileSync(filePath, svg, "utf8");
5697
+ return filePath;
5698
+ } catch {
5699
+ // Fall back to the next writable location.
5700
+ }
5701
+ }
5702
+ throw new Error("Could not write HUD rail image");
5703
+ }
5704
+
5705
+ function desktopHudSnapshot(provider = "all", { codexIcon = null } = {}) {
5527
5706
  const args = parseArgs(["--provider", provider]);
5528
5707
  const snapshot = collect(args);
5529
5708
  return {
5530
5709
  generatedAt: snapshot.generatedAt,
5531
5710
  state: renderHudState(snapshot),
5532
- panelImage: renderMenuBarImage(snapshot),
5711
+ panelImage: renderMenuBarImage(snapshot, { codexIcon }),
5533
5712
  detailImage: renderMenuDetailImage(snapshot),
5713
+ railImage: renderRailImage(snapshot),
5534
5714
  text: renderLine(snapshot, { ...args, style: "plain" }),
5535
5715
  rows: snapshot.results.filter(Boolean).map((result) => ({
5536
5716
  provider: result.provider,
@@ -5558,8 +5738,9 @@ function render(snapshot, args) {
5558
5738
  snapshot = { ...snapshot, results: orderResults(snapshot.results, configuredProviderOrder()) };
5559
5739
  if (args.json) return JSON.stringify(snapshot, null, 2);
5560
5740
  if (args.hudState) return renderHudState(snapshot);
5561
- if (args.menuBarImage) return renderMenuBarImage(snapshot);
5741
+ if (args.menuBarImage) return renderMenuBarImage(snapshot, { codexIcon: args.codexIcon, text: args.panelText });
5562
5742
  if (args.menuDetailImage) return renderMenuDetailImage(snapshot);
5743
+ if (args.railImage) return renderRailImage(snapshot, { scale: args.railScale, text: args.railText });
5563
5744
  if (args.menuBar) return renderMenuBar(snapshot);
5564
5745
 
5565
5746
  const maxWidth = args.maxWidth
@@ -6038,6 +6219,7 @@ export {
6038
6219
  renderHudState,
6039
6220
  renderMenuBarImage,
6040
6221
  renderMenuDetailImage,
6222
+ renderRailImage,
6041
6223
  rowptyDiagnostic,
6042
6224
  sameFilePath,
6043
6225
  teardownResultFailed,
@@ -163,28 +163,45 @@ export function helpText(command = "", { env = process.env, platform = process.p
163
163
  ].join("\n\n");
164
164
  }
165
165
  if (command === "hud") {
166
- return [usage("hud [start|stop|status] [options]"),
166
+ const isDesktop = ["darwin", "linux"].includes(platform);
167
+ return [usage(isDesktop ? "hud [start|stop|status|rail] [options]" : "hud [start|stop|status|icon|rail|stack] [options]"),
167
168
  t("Desktop usage display for Linux, macOS, Windows and WSL.", "Linux·macOS·Windows·WSL용 데스크톱 사용량 표시입니다."),
168
169
  `${t("Commands", "명령")}:\n${rows([
169
170
  ["start", "Start the display (default)", "사용량 표시 시작 (기본)"],
170
171
  ["stop", "Stop the display", "사용량 표시 종료"],
171
172
  ["status", "Show display status", "실행 상태 확인"],
172
- ["autostart on|off|status", "Manage login startup", "로그인 시 자동 실행 관리"]
173
+ ["autostart on|off|status", "Manage login startup", "로그인 시 자동 실행 관리"],
174
+ ...(isDesktop
175
+ ? [["rail", "Show the floating vertical rail panel", "세로 레일 패널 표시"]]
176
+ : [
177
+ ["icon", "Show the horizontal icon panel (default)", "가로 아이콘 패널 표시 (기본)"],
178
+ ["rail", "Show the floating vertical rail panel", "세로 레일 패널 표시"],
179
+ ["stack", "Show the stacked detail panel", "스택 상세 패널 표시"]
180
+ ])
173
181
  ])}`,
174
- options(["darwin", "linux"].includes(platform) ? [
182
+ options(isDesktop ? [
183
+ ["light|dark, black|white", "Panel/rail text color (default: white)", "패널·레일 글자색 선택 (기본: white)"],
184
+ ["--scale factor", "Rail size scale (0.5..3.0, small|large|xl)", "레일 크기 배율 (0.5..3.0, small|large|xl)"],
185
+ ["--codex-icon white|black", "Codex panel icon color (default: white)", "Codex 패널 아이콘 색상 (기본: white)"],
175
186
  ["--interval seconds", "Refresh interval (default: 2s)", "갱신 간격 (기본: 2초)"], providers,
176
187
  ["--once", "Print panel text once", "패널 텍스트 한 번 출력"],
177
188
  ["--foreground", "Run in the foreground", "포그라운드에서 실행"]
178
189
  ] : [
179
- ["icon|rail|stack", "Choose icon (default), vertical rail, or stack panel", "아이콘(기본)·세로 레일·스택 패널 선택"],
180
- ["light|dark", "Match light or dark taskbar colors", "밝은·어두운 작업 표시줄에 맞춤"],
181
- ["black|white", "Choose text color", "글자색 선택"],
190
+ ["light|dark, black|white", "Switch black/white text for light or dark backgrounds", "밝은·어두운 배경에 맞춰 흑백 글자 전환"],
191
+ ["--scale factor", "HUD size scale (0.5..3.0, small|large|xl)", "HUD 크기 배율 (0.5..3.0, small|large|xl)"],
192
+ ["--codex-icon white|black", "Codex icon color (auto|white|black)", "Codex 아이콘 색상 (자동|white|black)"],
182
193
  ["--backdrop [on|off]", "Toggle the background", "배경 표시 설정"],
194
+ ["--interval seconds", "Refresh interval (default: 2s)", "갱신 간격 (기본: 2초)"],
195
+ providers,
196
+ ["--once", "Print panel text once", "패널 텍스트 한 번 출력"],
197
+ ["--foreground", "Run in the foreground", "포그라운드에서 실행"],
183
198
  ["--dock-console", "Attach to the current terminal", "현재 터미널에 연결"],
184
199
  ["--dock-window HWND", "Attach to a specific window", "지정한 창에 연결"],
185
200
  ["--dock-position bottom|tabs", "Choose the docking position", "표시 위치 선택"]
186
201
  ]),
187
- examples(["ai-battery hud", "ai-battery hud rail", "ai-battery hud stack", "ai-battery hud autostart on"])
202
+ examples(isDesktop
203
+ ? ["ai-battery hud", "ai-battery hud rail", "ai-battery hud rail --scale 1.25", "ai-battery hud autostart on"]
204
+ : ["ai-battery hud", "ai-battery hud rail", "ai-battery hud stack", "ai-battery hud autostart on"])
188
205
  ].join("\n\n");
189
206
  }
190
207
  return [
@@ -112,7 +112,6 @@ export function editDisplayConfig(initialConfig, { input = process.stdin, output
112
112
  lines = [fit(`${selected + 1}/${order.length} [${providers[order[selected]] ? "x" : " "}] ${providerLabel(order[selected])}`), help].slice(0, Math.max(1, height));
113
113
  }
114
114
  } else {
115
- const isSidePosition = barPosition === "left" || barPosition === "right";
116
115
  const fullHelp = t("↑↓ select · Enter save · Esc cancel · Tab switch", "↑↓ 선택 · Enter 저장 · Esc 취소 · Tab 전환");
117
116
  const compactHelp = t("↑↓ select · Enter save · Esc cancel · Tab", "↑↓ 선택 · Enter 저장 · Esc 취소 · Tab");
118
117
  const help = [fullHelp, compactHelp, "↑↓ · Enter · Esc · Tab"].find(text => visibleWidth(text) <= availableWidth)
@@ -124,15 +123,35 @@ export function editDisplayConfig(initialConfig, { input = process.stdin, output
124
123
  const line = width >= 24 && height >= 10 ? `│ ${padded} │` : text;
125
124
  return index === positionSelected && color ? `\x1b[36m${line}\x1b[0m` : line;
126
125
  });
127
- const buildSideMockup = () => {
128
- if (!isSidePosition || width < 28 || height < 16) return [];
126
+ const buildPositionMockup = () => {
127
+ if (width < 28 || height < 16) return [];
129
128
  const frameW = Math.min(availableWidth, width);
130
- const sideW = 5;
131
- const workW = Math.max(8, frameW - sideW - 3);
132
129
  const padCell = (raw, w) => {
133
130
  const clipped = truncateMiddleVisible(raw, w);
134
131
  return clipped + " ".repeat(Math.max(0, w - visibleWidth(clipped)));
135
132
  };
133
+ const border = s => color ? `\x1b[2m${s}\x1b[0m` : s;
134
+ const v = border("│");
135
+ if (barPosition === "top" || barPosition === "bottom") {
136
+ const innerW = Math.max(12, frameW - 2);
137
+ const barRaw = color
138
+ ? " \x1b[32mGemini 50%\x1b[0m \x1b[2m│\x1b[0m 5h 18:34 \x1b[2m│\x1b[0m 7d 74%"
139
+ : " Gemini 50% │ 5h 18:34 │ 7d 74%";
140
+ const barRow = `${v}${padCell(barRaw, innerW)}${v}`;
141
+ const workRows = [
142
+ `${v}${padCell(color ? "\x1b[2m $ codex\x1b[0m" : " $ codex", innerW)}${v}`,
143
+ `${v}${" ".repeat(innerW)}${v}`,
144
+ `${v}${" ".repeat(innerW)}${v}`
145
+ ];
146
+ const top = border(`┌${"─".repeat(innerW)}┐`);
147
+ const mid = border(`├${"─".repeat(innerW)}┤`);
148
+ const bottom = border(`└${"─".repeat(innerW)}┘`);
149
+ return barPosition === "top"
150
+ ? [top, barRow, mid, ...workRows, bottom]
151
+ : [top, ...workRows, mid, barRow, bottom];
152
+ }
153
+ const sideW = 5;
154
+ const workW = Math.max(8, frameW - sideW - 3);
136
155
  const centerCell = (raw, w) => {
137
156
  const clipped = truncateMiddleVisible(raw, w);
138
157
  const len = visibleWidth(clipped);
@@ -160,14 +179,12 @@ export function editDisplayConfig(initialConfig, { input = process.stdin, output
160
179
  : " ".repeat(workW)
161
180
  ));
162
181
  const isLeft = barPosition === "left";
163
- const border = s => color ? `\x1b[2m${s}\x1b[0m` : s;
164
182
  const top = isLeft
165
183
  ? border(`┌${"─".repeat(sideW)}┬${"─".repeat(workW)}┐`)
166
184
  : border(`┌${"─".repeat(workW)}┬${"─".repeat(sideW)}┐`);
167
185
  const bottom = isLeft
168
186
  ? border(`└${"─".repeat(sideW)}┴${"─".repeat(workW)}┘`)
169
187
  : border(`└${"─".repeat(workW)}┴${"─".repeat(sideW)}┘`);
170
- const v = border("│");
171
188
  const body = mockSideRows.map((sideCell, idx) => (
172
189
  isLeft
173
190
  ? `${v}${sideCell}${v}${mockWorkRows[idx]}${v}`
@@ -181,7 +198,7 @@ export function editDisplayConfig(initialConfig, { input = process.stdin, output
181
198
  `╭─${title}${"─".repeat(Math.max(0, width - 3 - visibleWidth(title)))}╮`,
182
199
  ...items,
183
200
  `╰${"─".repeat(width - 2)}╯`,
184
- ...buildSideMockup(),
201
+ ...buildPositionMockup(),
185
202
  help
186
203
  ];
187
204
  } else if (height >= 8) {
@@ -19,6 +19,7 @@ const ps1Path = path.join(scriptDir, "ai-battery-hud.ps1");
19
19
  const windowsHudSourceDir = path.resolve(scriptDir, "../lib/platforms/windows/hud");
20
20
  const windowsHudMainPath = path.join(windowsHudSourceDir, "main.ps1");
21
21
  const macStatusPath = path.join(scriptDir, "ai-battery-macos-status.applescript");
22
+ const macRailPath = path.join(scriptDir, "ai-battery-macos-rail.applescript");
22
23
 
23
24
  function commandExists(command) {
24
25
  const result = spawnSync(command, ["-NoProfile", "-Command", "$PSVersionTable.PSVersion.Major"], {
@@ -118,12 +119,12 @@ function isDirectRun() {
118
119
  }
119
120
  }
120
121
 
121
- function prefetchInitialJson(command, useWslCommand, batteryModulePath = path.join(scriptDir, "ai-battery.js")) {
122
+ function prefetchInitialJson(command, useWslCommand, batteryModulePath = path.join(scriptDir, "ai-battery.js"), extraArgs = []) {
122
123
  if (process.env.AI_BATTERY_HUD_NO_PREFETCH) return null;
123
124
 
124
125
  const result = useWslCommand
125
126
  ? spawnSync("bash", ["-lc", command], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 6000 })
126
- : spawnSync(process.execPath, [batteryModulePath, "--json"], {
127
+ : spawnSync(process.execPath, [batteryModulePath, "--json", ...extraArgs], {
127
128
  encoding: "utf8",
128
129
  stdio: ["ignore", "pipe", "ignore"],
129
130
  timeout: 6000,
@@ -170,7 +171,7 @@ const {
170
171
  macHudCommandMatches,
171
172
  macHudPidsFromPsOutput,
172
173
  runMacHud
173
- } = createMacHudPlatform({ macStatusPath, relevantEnvPrefix, scriptDir, shellQuote });
174
+ } = createMacHudPlatform({ macStatusPath, macRailPath, relevantEnvPrefix, scriptDir, shellQuote });
174
175
  const {
175
176
  describeWindowsHudOptions,
176
177
  parseWindowsHudArgs,
@@ -21,12 +21,13 @@ function call(name, method, cancellable = null) {
21
21
  }
22
22
 
23
23
  function artwork(actor, file, description) {
24
- const scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
25
- if (actor._artwork === `${file}:${scale}`) return;
24
+ const themeScale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
25
+ const renderScale = Math.max(2, themeScale);
26
+ if (actor._artwork === `${file}:${renderScale}`) return;
26
27
  let pixbuf = GdkPixbuf.Pixbuf.new_from_file(file);
27
28
  const width = pixbuf.width;
28
29
  const height = pixbuf.height;
29
- if (scale !== 1) pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(file, width * scale, height * scale, false);
30
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(file, width * renderScale, height * renderScale, false);
30
31
  const content = St.ImageContent.new_with_preferred_size(width, height);
31
32
  const format = pixbuf.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888;
32
33
  if (content.set_bytes) {
@@ -38,7 +39,7 @@ function artwork(actor, file, description) {
38
39
  actor.set_content(content);
39
40
  actor.set_size(width, height);
40
41
  actor.accessible_name = description;
41
- actor._artwork = `${file}:${scale}`;
42
+ actor._artwork = `${file}:${renderScale}`;
42
43
  }
43
44
 
44
45
  export default class AiBattery extends Extension {
@@ -83,7 +84,7 @@ export default class AiBattery extends Extension {
83
84
  const icon = new St.Widget({ content_gravity: Clutter.ContentGravity.RESIZE_FILL, y_align: Clutter.ActorAlign.CENTER });
84
85
  button.add_child(icon);
85
86
  button.menu.actor.set_style("-arrow-border-width: 0; -arrow-border-color: transparent;");
86
- button.menu.box.set_style("background-color: #26262a; color: #f5f5f7; border: 0; border-radius: 10px; padding: 6px 0;");
87
+ button.menu.box.set_style("padding: 6px 0;");
87
88
  const item = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false });
88
89
  item.set_style("padding: 0;");
89
90
  const detail = new St.Widget({ content_gravity: Clutter.ContentGravity.RESIZE_FILL });
@@ -95,7 +96,7 @@ export default class AiBattery extends Extension {
95
96
  button.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
96
97
  const refresh = button.menu.addAction("Refresh", () => call(name, "Refresh").catch(console.error));
97
98
  const quit = button.menu.addAction("Quit AI Battery", () => call(name, "Quit").catch(console.error));
98
- for (const action of [refresh, quit]) action.set_style("font-size: 13px; color: #f5f5f7; padding: 4px 12px; margin: 0; min-height: 0;");
99
+ for (const action of [refresh, quit]) action.set_style("font-size: 13px; padding: 4px 12px; margin: 0; min-height: 0;");
99
100
  button.menu.connect("open-state-changed", (_menu, open) => {
100
101
  if (open) call(name, "Refresh", this._cancellable).catch(() => {});
101
102
  });