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.
@@ -35,10 +35,23 @@ function Get-HudDpi {
35
35
  return 96
36
36
  }
37
37
 
38
+ function Clamp-HudUserScale([double]$Value) {
39
+ if ([double]::IsNaN($Value) -or [double]::IsInfinity($Value) -or $Value -le 0) { return 1.0 }
40
+ return [math]::Round([math]::Max(0.5, [math]::Min(3.0, $Value)), 2)
41
+ }
42
+
38
43
  function Update-HudDpiScale {
39
44
  $dpi = [math]::Max(96, (Get-HudDpi))
40
45
  $script:hudDpi = [int]$dpi
41
- $script:hudScale = [double]$script:hudDpi / 96.0
46
+ $script:hudDpiScale = [double]$script:hudDpi / 96.0
47
+ $userScale = if ($DockWindowHandle -ne 0) {
48
+ 1.0
49
+ } elseif ($null -ne $script:hudUserScale -and $script:hudUserScale -gt 0) {
50
+ Clamp-HudUserScale $script:hudUserScale
51
+ } else {
52
+ 1.0
53
+ }
54
+ $script:hudScale = $script:hudDpiScale * $userScale
42
55
  }
43
56
 
44
57
  function Scale-HudValue([double]$Value) {
@@ -48,6 +61,18 @@ function Scale-HudValue([double]$Value) {
48
61
  return $scaled
49
62
  }
50
63
 
64
+ function Scale-HudDpiValue([double]$Value) {
65
+ if ($Value -eq 0) { return 0 }
66
+ $baseScale = if ($null -ne $script:hudDpiScale -and $script:hudDpiScale -gt 0) {
67
+ [double]$script:hudDpiScale
68
+ } else {
69
+ [double]$script:hudScale
70
+ }
71
+ $scaled = [int][math]::Round($Value * $baseScale)
72
+ if ($Value -gt 0) { return [math]::Max(1, $scaled) }
73
+ return $scaled
74
+ }
75
+
51
76
  function New-HudPadding([int]$Left, [int]$Top, [int]$Right, [int]$Bottom) {
52
77
  return [System.Windows.Forms.Padding]::new(
53
78
  (Scale-HudValue $Left),
@@ -898,10 +923,17 @@ public static class AiBatterySvgIcons {
898
923
  return $true
899
924
  }
900
925
 
926
+ function Resolve-HudCodexIconDark {
927
+ $mode = ([string]$script:hudCodexIconMode).Trim().ToLowerInvariant()
928
+ if ($mode -eq "black") { return $true }
929
+ if ($mode -eq "white") { return $false }
930
+ return [bool]$script:hudDarkText
931
+ }
932
+
901
933
  function Draw-BrandIcon($Graphics, [string]$Provider, [single]$X, [single]$Y, [single]$Size, [bool]$Running = $true) {
902
934
  $pixelSize = [math]::Max(8, [int][math]::Round($Size))
903
935
  if (Initialize-BrandSvgRenderer) {
904
- $iconBitmap = [AiBatterySvgIcons]::GetBrandIcon($Provider, $pixelSize, $Running, [bool]$script:hudDarkText)
936
+ $iconBitmap = [AiBatterySvgIcons]::GetBrandIcon($Provider, $pixelSize, $Running, (Resolve-HudCodexIconDark))
905
937
  if ($iconBitmap) {
906
938
  $state = $Graphics.Save()
907
939
  try {
@@ -1000,11 +1032,11 @@ function Draw-HorizontalBrandHud($Graphics, [int]$Width, [int]$Height, $Texts, $
1000
1032
  $slotStep = Scale-HudValue 64
1001
1033
  $meterOffsetX = Scale-HudValue 24
1002
1034
  $meterW = Scale-HudValue 30
1003
- $meterH = [math]::Max(6, (Scale-HudValue 6))
1035
+ $meterH = [math]::Max(4, (Scale-HudValue 6))
1004
1036
  if (($meterH % 2) -ne 0) { $meterH += 1 }
1005
1037
  $contentH = Scale-HudValue 26
1006
1038
  $originY = [int][math]::Floor(($Height - $contentH) / 2)
1007
- $pctFontSize = [single][math]::Max(10, (Scale-HudValue 11))
1039
+ $pctFontSize = [single][math]::Max(6, (Scale-HudValue 11))
1008
1040
  $pctFont = [System.Drawing.Font]::new("Segoe UI", $pctFontSize, [System.Drawing.FontStyle]::Bold, [System.Drawing.GraphicsUnit]::Pixel)
1009
1041
  $pctFlags = [System.Windows.Forms.TextFormatFlags]::HorizontalCenter -bor [System.Windows.Forms.TextFormatFlags]::VerticalCenter -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix
1010
1042
 
@@ -1049,7 +1081,7 @@ function Draw-HorizontalBrandHud($Graphics, [int]$Width, [int]$Height, $Texts, $
1049
1081
 
1050
1082
  if ($null -ne $percent) {
1051
1083
  $clamped = [math]::Max(0, [math]::Min(100, [int]$percent))
1052
- $inset = [math]::Max(2, (Scale-HudValue 2))
1084
+ $inset = if ($meterH -le 4) { 1 } else { [math]::Max(2, (Scale-HudValue 2)) }
1053
1085
  $innerW = [math]::Max(2, $meterW - ($inset * 2))
1054
1086
  $innerH = [math]::Max(2, $meterH - ($inset * 2))
1055
1087
  $fillW = [int][math]::Round(($clamped / 100.0) * $innerW)
@@ -1089,7 +1121,7 @@ function Draw-HorizontalBrandHud($Graphics, [int]$Width, [int]$Height, $Texts, $
1089
1121
  (Scale-HudValue 15)
1090
1122
  )
1091
1123
  $pctBackColor = if ($script:hudContrastBackdrop -or (-not $script:hudTransparentSurface)) {
1092
- [System.Drawing.Color]::FromArgb(28, 28, 32)
1124
+ if ($script:hudDarkText) { [System.Drawing.Color]::FromArgb(244, 244, 248) } else { [System.Drawing.Color]::FromArgb(28, 28, 32) }
1093
1125
  } elseif ($script:hudDarkText) {
1094
1126
  [System.Drawing.Color]::FromArgb(254, 254, 254)
1095
1127
  } else {
@@ -1250,7 +1282,7 @@ function Draw-FittedRailText($Graphics, [string]$Text, [string]$Family, [single]
1250
1282
  $drawFlags = [System.Windows.Forms.TextFormatFlags]::HorizontalCenter -bor [System.Windows.Forms.TextFormatFlags]::VerticalCenter -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix -bor [System.Windows.Forms.TextFormatFlags]::PreserveGraphicsTranslateTransform
1251
1283
  $fitLimit = if ($FitMaxWidth -gt 0) { $FitMaxWidth } else { [math]::Max(10, $Rect.Width - 6) }
1252
1284
  $px = $StartPx
1253
- $minPx = [single][math]::Max(7.0, (Scale-HudValue 7))
1285
+ $minPx = [single][math]::Max(5.5, (Scale-HudValue 7))
1254
1286
  $drawFont = $null
1255
1287
  try {
1256
1288
  while ($true) {
@@ -1351,7 +1383,7 @@ function Draw-VerticalRailHud($Graphics, [int]$Width, [int]$Height, $Texts, $Cus
1351
1383
  # 2. Vertical battery gauge (centered slim rail + bottom-to-top fill)
1352
1384
  $cx = [int][math]::Floor($Width / 2)
1353
1385
  $railW = [math]::Max(2, (Scale-HudValue 2))
1354
- $barW = [math]::Max(6, (Scale-HudValue 8))
1386
+ $barW = [math]::Max(4, (Scale-HudValue 8))
1355
1387
  $railBrush = [System.Drawing.SolidBrush]::new($(if ($script:hudDarkText) { [System.Drawing.Color]::FromArgb(180, 180, 188) } else { [System.Drawing.Color]::FromArgb(84, 84, 94) }))
1356
1388
  try {
1357
1389
  $Graphics.FillRectangle($railBrush, [int]($cx - [math]::Floor($railW / 2)), $y, $railW, $batH)
@@ -1411,22 +1443,22 @@ function Format-DetailResetText([string]$Value) {
1411
1443
  function Get-HorizontalDetailCardLayout($Texts) {
1412
1444
  $rows = if ($Texts -and $Texts.Rows -and $Texts.Rows.Count -gt 0) { $Texts.Rows } else { @() }
1413
1445
  $rowCount = [math]::Max(1, $rows.Count)
1414
- $padX = Scale-HudValue 14
1415
- $padY = Scale-HudValue 8
1416
- $rowH = Scale-HudValue 36
1417
- $footerH = Scale-HudValue 34
1418
- $nameW = Scale-HudValue 52
1419
- $barX = $padX + $nameW + (Scale-HudValue 12)
1420
- $barW = Scale-HudValue 116
1421
- $barH = Scale-HudValue 8
1422
- $pctX = $barX + $barW + (Scale-HudValue 10)
1423
- $pctW = Scale-HudValue 40
1424
- $resetX = $pctX + $pctW + (Scale-HudValue 14)
1425
-
1426
- $metaFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1446
+ $padX = Scale-HudDpiValue 14
1447
+ $padY = Scale-HudDpiValue 8
1448
+ $rowH = Scale-HudDpiValue 36
1449
+ $footerH = Scale-HudDpiValue 34
1450
+ $nameW = Scale-HudDpiValue 52
1451
+ $barX = $padX + $nameW + (Scale-HudDpiValue 12)
1452
+ $barW = Scale-HudDpiValue 116
1453
+ $barH = Scale-HudDpiValue 8
1454
+ $pctX = $barX + $barW + (Scale-HudDpiValue 10)
1455
+ $pctW = Scale-HudDpiValue 40
1456
+ $resetX = $pctX + $pctW + (Scale-HudDpiValue 14)
1457
+
1458
+ $metaFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudDpiValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1427
1459
  $flags = [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix
1428
- $resetW = Scale-HudValue 48
1429
- $weekW = Scale-HudValue 46
1460
+ $resetW = Scale-HudDpiValue 48
1461
+ $weekW = Scale-HudDpiValue 46
1430
1462
  $extraW = 0
1431
1463
  $hasWeek = $false
1432
1464
  try {
@@ -1435,27 +1467,27 @@ function Get-HorizontalDetailCardLayout($Texts) {
1435
1467
  if ($p.ResetValue) {
1436
1468
  $resetDisplay = Format-DetailResetText ([string]$p.ResetValue)
1437
1469
  $sz = [System.Windows.Forms.TextRenderer]::MeasureText($resetDisplay, $metaFont, [System.Drawing.Size]::new(512, 64), $flags)
1438
- $resetW = [math]::Max($resetW, [int]$sz.Width + (Scale-HudValue 2))
1470
+ $resetW = [math]::Max($resetW, [int]$sz.Width + (Scale-HudDpiValue 2))
1439
1471
  }
1440
1472
  if ($p.WeekValue) {
1441
1473
  $hasWeek = $true
1442
1474
  $sz = [System.Windows.Forms.TextRenderer]::MeasureText([string]$p.WeekValue, $metaFont, [System.Drawing.Size]::new(512, 64), $flags)
1443
- $weekW = [math]::Max($weekW, [int]$sz.Width + (Scale-HudValue 2))
1475
+ $weekW = [math]::Max($weekW, [int]$sz.Width + (Scale-HudDpiValue 2))
1444
1476
  }
1445
1477
  if (-not $p.ResetValue -and -not $p.WeekValue -and $p.ExtraText) {
1446
1478
  $sz = [System.Windows.Forms.TextRenderer]::MeasureText([string]$p.ExtraText, $metaFont, [System.Drawing.Size]::new(512, 64), $flags)
1447
- $extraW = [math]::Max($extraW, [int]$sz.Width + (Scale-HudValue 2))
1479
+ $extraW = [math]::Max($extraW, [int]$sz.Width + (Scale-HudDpiValue 2))
1448
1480
  }
1449
1481
  }
1450
1482
  } finally {
1451
1483
  $metaFont.Dispose()
1452
1484
  }
1453
1485
 
1454
- $metaGap = Scale-HudValue 14
1486
+ $metaGap = Scale-HudDpiValue 14
1455
1487
  $weekX = $resetX + $resetW + $metaGap
1456
1488
  $metaRight = if ($hasWeek) { $weekX + $weekW } else { $resetX + [math]::Max($resetW, $extraW) }
1457
1489
  $metaRight = [math]::Max($metaRight, ($resetX + $extraW))
1458
- $width = [math]::Max((Scale-HudValue 400), ($metaRight + $padX))
1490
+ $width = [math]::Max((Scale-HudDpiValue 400), ($metaRight + $padX))
1459
1491
  # Shift week/reset right if card hit minimum width so right edge stays balanced.
1460
1492
  $extraShift = ($width - $padX) - $metaRight
1461
1493
  if ($extraShift -gt 0) {
@@ -1491,12 +1523,12 @@ function Get-HorizontalDetailCardSize($Texts) {
1491
1523
  }
1492
1524
 
1493
1525
  function Get-HorizontalDetailFooterRects([int]$Width, [int]$Height) {
1494
- $footerH = Scale-HudValue 34
1526
+ $footerH = Scale-HudDpiValue 34
1495
1527
  $y = $Height - $footerH
1496
- $btnW = Scale-HudValue 86
1528
+ $btnW = Scale-HudDpiValue 86
1497
1529
  return @{
1498
- Refresh = [System.Drawing.Rectangle]::new((Scale-HudValue 14), $y, $btnW, $footerH)
1499
- Quit = [System.Drawing.Rectangle]::new(($Width - $btnW - (Scale-HudValue 14)), $y, $btnW, $footerH)
1530
+ Refresh = [System.Drawing.Rectangle]::new((Scale-HudDpiValue 14), $y, $btnW, $footerH)
1531
+ Quit = [System.Drawing.Rectangle]::new(($Width - $btnW - (Scale-HudDpiValue 14)), $y, $btnW, $footerH)
1500
1532
  }
1501
1533
  }
1502
1534
 
@@ -1505,9 +1537,12 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1505
1537
  $Graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
1506
1538
  $Graphics.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::ClearTypeGridFit
1507
1539
 
1508
- $bgPath = New-RoundedRectPath ([single]0.5) ([single]0.5) ([single]($Width - 1)) ([single]($Height - 1)) ([single](Scale-HudValue 10))
1509
- $bgBrush = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(38, 38, 43))
1510
- $borderPen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(72, 72, 78), 1.0)
1540
+ $lightCard = [bool]$script:hudDarkText
1541
+ $cardBack = if ($lightCard) { [System.Drawing.Color]::FromArgb(246, 246, 250) } else { [System.Drawing.Color]::FromArgb(38, 38, 43) }
1542
+ $cardBorder = if ($lightCard) { [System.Drawing.Color]::FromArgb(204, 204, 212) } else { [System.Drawing.Color]::FromArgb(72, 72, 78) }
1543
+ $bgPath = New-RoundedRectPath ([single]0.5) ([single]0.5) ([single]($Width - 1)) ([single]($Height - 1)) ([single](Scale-HudDpiValue 10))
1544
+ $bgBrush = [System.Drawing.SolidBrush]::new($cardBack)
1545
+ $borderPen = [System.Drawing.Pen]::new($cardBorder, 1.0)
1511
1546
  try {
1512
1547
  $Graphics.FillPath($bgBrush, $bgPath)
1513
1548
  $Graphics.DrawPath($borderPen, $bgPath)
@@ -1518,9 +1553,9 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1518
1553
  }
1519
1554
 
1520
1555
  $layout = Get-HorizontalDetailCardLayout $Texts
1521
- $nameFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudValue 13), [System.Drawing.FontStyle]::Bold, [System.Drawing.GraphicsUnit]::Pixel)
1522
- $metaFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1523
- $footerFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1556
+ $nameFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudDpiValue 13), [System.Drawing.FontStyle]::Bold, [System.Drawing.GraphicsUnit]::Pixel)
1557
+ $metaFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudDpiValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1558
+ $footerFont = [System.Drawing.Font]::new("Segoe UI", [single](Scale-HudDpiValue 12), [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
1524
1559
  $leftFlags = [System.Windows.Forms.TextFormatFlags]::Left -bor [System.Windows.Forms.TextFormatFlags]::VerticalCenter -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix
1525
1560
  $rightFlags = [System.Windows.Forms.TextFormatFlags]::Right -bor [System.Windows.Forms.TextFormatFlags]::VerticalCenter -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix
1526
1561
  $centerFlags = [System.Windows.Forms.TextFormatFlags]::HorizontalCenter -bor [System.Windows.Forms.TextFormatFlags]::VerticalCenter -bor [System.Windows.Forms.TextFormatFlags]::SingleLine -bor [System.Windows.Forms.TextFormatFlags]::NoPadding -bor [System.Windows.Forms.TextFormatFlags]::NoPrefix
@@ -1533,8 +1568,16 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1533
1568
  $parts = $row.Parts
1534
1569
  $running = [bool]$parts.Running
1535
1570
  $percent = $parts.Percent
1536
- $primaryColor = if ($running) { [System.Drawing.Color]::FromArgb(245, 245, 247) } else { [System.Drawing.Color]::FromArgb(161, 161, 170) }
1537
- $metaColor = if ($running) { [System.Drawing.Color]::FromArgb(161, 161, 170) } else { [System.Drawing.Color]::FromArgb(142, 142, 147) }
1571
+ $primaryColor = if ($lightCard) {
1572
+ if ($running) { [System.Drawing.Color]::FromArgb(24, 24, 28) } else { [System.Drawing.Color]::FromArgb(110, 110, 118) }
1573
+ } else {
1574
+ if ($running) { [System.Drawing.Color]::FromArgb(245, 245, 247) } else { [System.Drawing.Color]::FromArgb(161, 161, 170) }
1575
+ }
1576
+ $metaColor = if ($lightCard) {
1577
+ if ($running) { [System.Drawing.Color]::FromArgb(96, 96, 106) } else { [System.Drawing.Color]::FromArgb(132, 132, 140) }
1578
+ } else {
1579
+ if ($running) { [System.Drawing.Color]::FromArgb(161, 161, 170) } else { [System.Drawing.Color]::FromArgb(142, 142, 147) }
1580
+ }
1538
1581
 
1539
1582
  $label = switch ([string]$row.Provider) {
1540
1583
  "claude" { "Claude" }
@@ -1546,8 +1589,18 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1546
1589
 
1547
1590
  $barY = [single]($y + (($layout.RowH - $layout.BarH) / 2.0))
1548
1591
  $trackPath = New-RoundedRectPath ([single]$layout.BarX) $barY ([single]$layout.BarW) ([single]$layout.BarH) ([single]($layout.BarH / 2.0))
1549
- $trackBrush = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb($(if ($running) { 26 } else { 15 }), 255, 255, 255))
1550
- $trackPen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb($(if ($running) { 36 } else { 61 }), 255, 255, 255), 1.0)
1592
+ $trackFill = if ($lightCard) {
1593
+ if ($running) { [System.Drawing.Color]::FromArgb(224, 224, 232) } else { [System.Drawing.Color]::FromArgb(232, 232, 238) }
1594
+ } else {
1595
+ [System.Drawing.Color]::FromArgb($(if ($running) { 26 } else { 15 }), 255, 255, 255)
1596
+ }
1597
+ $trackStroke = if ($lightCard) {
1598
+ [System.Drawing.Color]::FromArgb(196, 196, 204)
1599
+ } else {
1600
+ [System.Drawing.Color]::FromArgb($(if ($running) { 36 } else { 61 }), 255, 255, 255)
1601
+ }
1602
+ $trackBrush = [System.Drawing.SolidBrush]::new($trackFill)
1603
+ $trackPen = [System.Drawing.Pen]::new($trackStroke, 1.0)
1551
1604
  try {
1552
1605
  $Graphics.FillPath($trackBrush, $trackPath)
1553
1606
  $Graphics.DrawPath($trackPen, $trackPath)
@@ -1560,17 +1613,17 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1560
1613
  if ($null -ne $percent) {
1561
1614
  $clamped = [math]::Max(0, [math]::Min(100, [int]$percent))
1562
1615
  $fillW = [single](($clamped / 100.0) * $layout.BarW)
1563
- if ($clamped -gt 0 -and $fillW -lt (Scale-HudValue 4)) { $fillW = [single](Scale-HudValue 4) }
1616
+ if ($clamped -gt 0 -and $fillW -lt (Scale-HudDpiValue 4)) { $fillW = [single](Scale-HudDpiValue 4) }
1564
1617
  if ($fillW -gt 0.5) {
1565
1618
  $fillPath = New-RoundedRectPath ([single]$layout.BarX) $barY $fillW ([single]$layout.BarH) ([single]($layout.BarH / 2.0))
1566
1619
  $fillColor = if (-not $running) {
1567
- [System.Drawing.Color]::FromArgb(161, 161, 170)
1620
+ if ($lightCard) { [System.Drawing.Color]::FromArgb(148, 148, 156) } else { [System.Drawing.Color]::FromArgb(161, 161, 170) }
1568
1621
  } elseif ($clamped -le 20) {
1569
- [System.Drawing.Color]::FromArgb(255, 69, 58)
1622
+ if ($lightCard) { [System.Drawing.Color]::FromArgb(220, 38, 38) } else { [System.Drawing.Color]::FromArgb(255, 69, 58) }
1570
1623
  } elseif ($clamped -le 40) {
1571
- [System.Drawing.Color]::FromArgb(255, 159, 10)
1624
+ if ($lightCard) { [System.Drawing.Color]::FromArgb(217, 119, 6) } else { [System.Drawing.Color]::FromArgb(255, 159, 10) }
1572
1625
  } else {
1573
- [System.Drawing.Color]::FromArgb(48, 209, 88)
1626
+ if ($lightCard) { [System.Drawing.Color]::FromArgb(34, 178, 72) } else { [System.Drawing.Color]::FromArgb(48, 209, 88) }
1574
1627
  }
1575
1628
  $fillBrush = [System.Drawing.SolidBrush]::new($fillColor)
1576
1629
  try {
@@ -1605,7 +1658,8 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1605
1658
  }
1606
1659
 
1607
1660
  $divY = $Height - $layout.FooterH
1608
- $divPen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(62, 62, 68), 1.0)
1661
+ $divColor = if ($lightCard) { [System.Drawing.Color]::FromArgb(216, 216, 224) } else { [System.Drawing.Color]::FromArgb(62, 62, 68) }
1662
+ $divPen = [System.Drawing.Pen]::new($divColor, 1.0)
1609
1663
  try {
1610
1664
  $Graphics.DrawLine($divPen, $layout.PadX, $divY, ($Width - $layout.PadX), $divY)
1611
1665
  } finally {
@@ -1613,9 +1667,11 @@ function Draw-HorizontalDetailCard($Graphics, [int]$Width, [int]$Height, $Texts)
1613
1667
  }
1614
1668
 
1615
1669
  $rects = Get-HorizontalDetailFooterRects $Width $Height
1616
- $footerColor = [System.Drawing.Color]::FromArgb(200, 200, 206)
1617
- [System.Windows.Forms.TextRenderer]::DrawText($Graphics, "Refresh", $footerFont, $rects.Refresh, $footerColor, $leftFlags)
1618
- [System.Windows.Forms.TextRenderer]::DrawText($Graphics, "Quit", $footerFont, $rects.Quit, $footerColor, $rightFlags)
1670
+ $footerColor = if ($lightCard) { [System.Drawing.Color]::FromArgb(48, 48, 56) } else { [System.Drawing.Color]::FromArgb(200, 200, 206) }
1671
+ $refreshText = if (Get-Command Get-HudUiText -ErrorAction SilentlyContinue) { Get-HudUiText "Refresh" "새로고침" } else { "Refresh" }
1672
+ $quitText = if (Get-Command Get-HudUiText -ErrorAction SilentlyContinue) { Get-HudUiText "Quit" "종료" } else { "Quit" }
1673
+ [System.Windows.Forms.TextRenderer]::DrawText($Graphics, $refreshText, $footerFont, $rects.Refresh, $footerColor, $leftFlags)
1674
+ [System.Windows.Forms.TextRenderer]::DrawText($Graphics, $quitText, $footerFont, $rects.Quit, $footerColor, $rightFlags)
1619
1675
  } finally {
1620
1676
  $nameFont.Dispose()
1621
1677
  $metaFont.Dispose()
@@ -6,6 +6,7 @@ import { atomicRename } from "../../core/atomic-rename.js";
6
6
  import { windowsAutostartCleanupScript } from "./autostart-cleanup.js";
7
7
  import { cliError, cliText, helpText, invalidChoice, requiredValue } from "../../core/cli-help.js";
8
8
  import { errorText } from "../../core/cli-messages.js";
9
+ import { providerId } from "../../core/display-config.js";
9
10
 
10
11
  export function buildWindowsAutostartScript({
11
12
  hudSourceDir,
@@ -90,6 +91,22 @@ function normalizeHudBackdropOption(value) {
90
91
  throw invalidChoice("--backdrop", "on, off", "hud");
91
92
  }
92
93
 
94
+ function parseWindowsScaleValue(raw, optionName) {
95
+ const named = { small: 0.85, medium: 1, default: 1, large: 1.25, xl: 1.5 };
96
+ const key = String(raw || "").trim().toLowerCase();
97
+ const value = Object.hasOwn(named, key) ? named[key] : Number(key);
98
+ if (!Number.isFinite(value) || value < 0.5 || value > 3) {
99
+ throw invalidChoice(optionName, "0.5..3.0 (or small, medium, large, xl)", "hud");
100
+ }
101
+ return Math.round(value * 100) / 100;
102
+ }
103
+
104
+ function normalizeCodexIconOption(value, optionName = "--codex-icon") {
105
+ const normalized = String(value || "").trim().toLowerCase();
106
+ if (["white", "black"].includes(normalized)) return normalized;
107
+ throw invalidChoice(optionName, "white, black", "hud");
108
+ }
109
+
93
110
  function optionValue(cliArgs, index) {
94
111
  return requiredValue(cliArgs, index, "hud");
95
112
  }
@@ -123,6 +140,14 @@ function describeWindowsHudOptions(filteredArgs) {
123
140
  const m = String(value || "").toLowerCase();
124
141
  if (["icon", "horizontal"].includes(m)) descriptions.push("icon panel");
125
142
  else if (m === "rail") descriptions.push("vertical rail panel");
143
+ else if (m === "floating") descriptions.push("stack panel");
144
+ i += 1;
145
+ } else if (option === "-scale") {
146
+ const n = Number(value);
147
+ if (Number.isFinite(n) && n > 0) descriptions.push(`scale ${Math.round(n * 100)}%`);
148
+ i += 1;
149
+ } else if (option === "-codexicon") {
150
+ if (value === "white" || value === "black") descriptions.push(`codex icon ${value}`);
126
151
  i += 1;
127
152
  }
128
153
  }
@@ -138,12 +163,14 @@ function hasHudOption(filteredArgs, option) {
138
163
  const HUD_PASSTHROUGH_OPTIONS_WITH_VALUE = new Set([
139
164
  "-batterycommand",
140
165
  "-batterycommandbase64",
166
+ "-codexicon",
141
167
  "-initialjsonbase64",
142
168
  "-interval",
143
169
  "-mode",
144
170
  "-opacity",
145
171
  "-position",
146
172
  "-readypath",
173
+ "-scale",
147
174
  "-width"
148
175
  ]);
149
176
 
@@ -162,6 +189,10 @@ function parseWindowsHudArgs(cliArgs) {
162
189
  let backdropMode = null;
163
190
  let transparentMode = null;
164
191
  let layoutMode = null;
192
+ let scaleValue = null;
193
+ let codexIcon = null;
194
+ let intervalValue = null;
195
+ let provider = "all";
165
196
  let foreground = false;
166
197
  let once = false;
167
198
  let stop = false;
@@ -254,6 +285,43 @@ function parseWindowsHudArgs(cliArgs) {
254
285
  i += 1;
255
286
  } else if (lowerArg.startsWith("--text=") || lowerArg.startsWith("--hud-text=")) {
256
287
  setTextMode(arg.slice(arg.indexOf("=") + 1));
288
+ } else if (lowerArg === "--scale" || lowerArg === "--size" || lowerArg === "-scale") {
289
+ scaleValue = parseWindowsScaleValue(optionValue(cliArgs, i, arg), arg);
290
+ i += 1;
291
+ } else if (lowerArg.startsWith("--scale=") || lowerArg.startsWith("--size=")) {
292
+ const eq = arg.indexOf("=");
293
+ scaleValue = parseWindowsScaleValue(arg.slice(eq + 1), arg.slice(0, eq));
294
+ } else if (lowerArg === "--codex-icon" || lowerArg === "-codexicon") {
295
+ codexIcon = normalizeCodexIconOption(optionValue(cliArgs, i, arg), arg);
296
+ i += 1;
297
+ } else if (lowerArg.startsWith("--codex-icon=")) {
298
+ codexIcon = normalizeCodexIconOption(arg.slice(arg.indexOf("=") + 1), "--codex-icon");
299
+ } else if (lowerArg === "--interval" || lowerArg === "-interval") {
300
+ const value = Number(optionValue(cliArgs, i, arg));
301
+ if (!Number.isFinite(value) || value < 1) {
302
+ throw cliError("--interval must be at least 1 second.", "--interval은 1초 이상이어야 합니다.", "hud");
303
+ }
304
+ intervalValue = Math.round(value);
305
+ i += 1;
306
+ } else if (lowerArg.startsWith("--interval=")) {
307
+ const value = Number(arg.slice(arg.indexOf("=") + 1));
308
+ if (!Number.isFinite(value) || value < 1) {
309
+ throw cliError("--interval must be at least 1 second.", "--interval은 1초 이상이어야 합니다.", "hud");
310
+ }
311
+ intervalValue = Math.round(value);
312
+ } else if (lowerArg === "--provider" || arg === "-p") {
313
+ const next = providerId(String(optionValue(cliArgs, i, arg)).trim().toLowerCase());
314
+ if (!["all", "codex", "claude", "antigravity"].includes(next)) {
315
+ throw invalidChoice(arg, "all, codex, claude, gemini", "hud");
316
+ }
317
+ provider = next;
318
+ i += 1;
319
+ } else if (lowerArg.startsWith("--provider=")) {
320
+ const next = providerId(arg.slice(arg.indexOf("=") + 1).trim().toLowerCase());
321
+ if (!["all", "codex", "claude", "antigravity"].includes(next)) {
322
+ throw invalidChoice("--provider", "all, codex, claude, gemini", "hud");
323
+ }
324
+ provider = next;
257
325
  } else if (lowerArg === "--backdrop") {
258
326
  const next = cliArgs[i + 1];
259
327
  const backdropValue = next && !String(next).startsWith("-") ? optionalBackdropValue(next) : null;
@@ -341,6 +409,9 @@ function parseWindowsHudArgs(cliArgs) {
341
409
 
342
410
  const filteredArgs = [...passthroughArgs];
343
411
  if (layoutMode !== null && !hasHudOption(filteredArgs, "-Mode")) filteredArgs.push("-Mode", layoutMode);
412
+ if (scaleValue !== null && !hasHudOption(filteredArgs, "-Scale")) filteredArgs.push("-Scale", String(scaleValue));
413
+ if (codexIcon !== null && !hasHudOption(filteredArgs, "-CodexIcon")) filteredArgs.push("-CodexIcon", codexIcon);
414
+ if (intervalValue !== null && !hasHudOption(filteredArgs, "-Interval")) filteredArgs.push("-Interval", String(intervalValue));
344
415
  if (backdropMode !== null) filteredArgs.push("-Backdrop", backdropMode);
345
416
  if (textMode !== null) filteredArgs.push("-Text", textMode);
346
417
  if (transparentMode !== null) filteredArgs.push("-Transparent", transparentMode);
@@ -352,6 +423,10 @@ function parseWindowsHudArgs(cliArgs) {
352
423
  stop,
353
424
  subcommand,
354
425
  autostartAction,
426
+ provider,
427
+ scale: scaleValue,
428
+ codexIcon,
429
+ interval: intervalValue,
355
430
  dockConsole,
356
431
  dockDetach,
357
432
  dockPosition,
@@ -405,6 +480,7 @@ const {
405
480
  stop,
406
481
  subcommand,
407
482
  autostartAction,
483
+ provider = "all",
408
484
  dockConsole,
409
485
  dockDetach,
410
486
  dockPosition,
@@ -422,9 +498,12 @@ const nodePath = process.execPath;
422
498
  const batteryJs = path.join(scriptDir, "ai-battery.js");
423
499
  const configuredCommand = process.env.AI_BATTERY_COMMAND || process.env.CLAUDEX_BATTERY_COMMAND;
424
500
  const envPrefix = useWsl ? wslEnvPrefix() : "";
501
+ const providerCommandArgs = provider && provider !== "all"
502
+ ? (useWsl ? ` --provider ${shellQuote(provider)}` : ` --provider ${psSingleQuote(provider)}`)
503
+ : "";
425
504
  const batteryCommand = configuredCommand || (useWsl
426
- ? `${envPrefix ? `${envPrefix} ` : ""}HOME=${shellQuote(os.homedir())} ${shellQuote(nodePath)} ${shellQuote(batteryJs)} --json`
427
- : `& ${psSingleQuote(nodePath)} ${psSingleQuote(batteryJs)} --json`);
505
+ ? `${envPrefix ? `${envPrefix} ` : ""}HOME=${shellQuote(os.homedir())} ${shellQuote(nodePath)} ${shellQuote(batteryJs)} --json${providerCommandArgs}`
506
+ : `& ${psSingleQuote(nodePath)} ${psSingleQuote(batteryJs)} --json${providerCommandArgs}`);
428
507
  const batteryCommandBase64 = Buffer.from(batteryCommand, "utf8").toString("base64");
429
508
 
430
509
  function writeDockLauncherMarker(stage) {
@@ -994,7 +1073,7 @@ const wasRunning = (!foreground && !once && !stop && !dockWindowHandle)
994
1073
  : false;
995
1074
  const initialJson = (stop || dockWindowHandle || (configuredCommand && !useWsl))
996
1075
  ? null
997
- : prefetchInitialJson(batteryCommand, useWsl, batteryJs);
1076
+ : prefetchInitialJson(batteryCommand, useWsl, batteryJs, provider && provider !== "all" ? ["--provider", provider] : []);
998
1077
  const readyPath = (!useWsl && process.platform === "win32" && !foreground && !once && !stop && !dockWindowHandle)
999
1078
  ? path.join(os.tmpdir(), `ai-battery-hud-ready-${process.pid}-${Date.now()}.json`)
1000
1079
  : null;
@@ -1074,7 +1153,7 @@ if (readyPath && !waitForFile(readyPath)) {
1074
1153
  const action = wasRunning ? (detail ? "updated" : "restarted") : "started";
1075
1154
  console.log(`HUD: ${action}${detail ? ` · ${detail}` : ""}`);
1076
1155
  if (!wasRunning) {
1077
- console.log(cliText("Drag to move. Right-click to exit.", "드래그로 이동 · 우클릭으로 종료"));
1156
+ console.log(cliText("Drag to move, drag corners or right-click to resize and switch black/white.", "드래그로 이동 · 모서리·우클릭으로 크기·흑백 전환"));
1078
1157
  }
1079
1158
  }
1080
1159
  if (readyPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Tiny terminal battery meter for local Codex, Claude Code and Gemini CLI usage.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -33,6 +33,7 @@
33
33
  "bin/ai-battery-hud",
34
34
  "bin/ai-battery-hud.js",
35
35
  "bin/ai-battery-macos-status.applescript",
36
+ "bin/ai-battery-macos-rail.applescript",
36
37
  "bin/ai-battery-hud.ps1",
37
38
  "lib/**/*.js",
38
39
  "lib/**/*.ps1",
@@ -60,7 +61,7 @@
60
61
  "smoke:codex-fullscreen-win": "node ./scripts/windows-codex-fullscreen-check.mjs",
61
62
  "smoke:wsl-win": "bash ./scripts/wsl-windows-rowpty-smoke.sh",
62
63
  "smoke:linux": "node ./scripts/linux-gnome-menu-check.mjs",
63
- "check": "node --check ./bin/ai-battery.js && node --check ./bin/ai-battery-hud.js && node --check ./bin/ai-battery-run-win.js && node --check ./bin/ai-battery-tmux.js && node --check ./bin/terminal-compositor.js && node --check ./lib/cli.js && node --check ./lib/core/atomic-rename.js && node --check ./lib/core/cli-help.js && node --check ./lib/core/cli-messages.js && node --check ./lib/core/cli-output.js && node --check ./lib/core/cli-wrappers.js && node --check ./lib/core/config-editor.js && node --check ./lib/core/diagnostics.js && node --check ./lib/core/display-config.js && node --check ./lib/core/integration-files.js && node --check ./lib/core/shared-bar.js && node --check ./lib/core/terminal.js && node --check ./lib/core/tmux-status.js && node --check ./lib/core/uninstall.js && node --check ./lib/core/usage-store.js && node --check ./lib/providers/antigravity.js && node --check ./lib/hud/launcher.js && node --check ./lib/platforms/process-scanner.js && node --check ./lib/platforms/windows/codex-runner.js && node --check ./lib/platforms/windows/hud-launcher.js && node --check ./lib/platforms/windows/shared-bar-platform.js && node --check ./lib/platforms/windows/wt-bar.js && node --check ./lib/platforms/windows/wt-fragment.js && node --check ./lib/platforms/windows/wt-keybinding.js && node --check ./lib/platforms/linux/hud.js && node --check ./lib/platforms/linux/panel.js && node --check ./lib/platforms/linux/panel-snapshot.js && node --check ./lib/platforms/linux/gnome.js && node --check ./lib/platforms/linux/gnome-control.js && node --check ./lib/platforms/linux/gnome-extension/extension.js && node --test",
64
+ "check": "node --check ./bin/ai-battery.js && node --check ./bin/ai-battery-hud.js && node --check ./bin/ai-battery-run-win.js && node --check ./bin/ai-battery-tmux.js && node --check ./bin/terminal-compositor.js && node --check ./lib/cli.js && node --check ./lib/core/atomic-rename.js && node --check ./lib/core/cli-help.js && node --check ./lib/core/cli-messages.js && node --check ./lib/core/cli-output.js && node --check ./lib/core/cli-wrappers.js && node --check ./lib/core/config-editor.js && node --check ./lib/core/diagnostics.js && node --check ./lib/core/display-config.js && node --check ./lib/core/integration-files.js && node --check ./lib/core/shared-bar.js && node --check ./lib/core/terminal.js && node --check ./lib/core/tmux-status.js && node --check ./lib/core/uninstall.js && node --check ./lib/core/usage-store.js && node --check ./lib/providers/antigravity.js && node --check ./lib/hud/launcher.js && node --check ./lib/platforms/process-scanner.js && node --check ./lib/platforms/windows/codex-runner.js && node --check ./lib/platforms/windows/hud-launcher.js && node --check ./lib/platforms/windows/shared-bar-platform.js && node --check ./lib/platforms/windows/wt-bar.js && node --check ./lib/platforms/windows/wt-fragment.js && node --check ./lib/platforms/windows/wt-keybinding.js && node --check ./lib/platforms/linux/hud.js && node --check ./lib/platforms/linux/panel.js && node --check ./lib/platforms/linux/rail.js && node --check ./lib/platforms/linux/panel-snapshot.js && node --check ./lib/platforms/linux/gnome.js && node --check ./lib/platforms/linux/gnome-control.js && node --check ./lib/platforms/linux/gnome-extension/extension.js && node --test",
64
65
  "test": "node --test"
65
66
  },
66
67
  "engines": {