From 3656c46da9b9aa039a8f23f11b07c4647d1f8e5f Mon Sep 17 00:00:00 2001 From: Lars Berger Date: Mon, 12 Feb 2024 16:54:15 +0800 Subject: [PATCH] fix: show battery charging icon correctly --- .../client-api/src/desktop/current-window.ts | 4 ++-- .../battery/create-battery-provider.ts | 3 +++ packages/desktop/resources/sample-config.yaml | 21 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/client-api/src/desktop/current-window.ts b/packages/client-api/src/desktop/current-window.ts index 40acb228..06c9c027 100644 --- a/packages/client-api/src/desktop/current-window.ts +++ b/packages/client-api/src/desktop/current-window.ts @@ -60,8 +60,8 @@ export async function setWindowStyles(styles: Partial) { const window = await getCurrentWindow(); await Promise.all([ - window.setSkipTaskbar(!styles.showInTaskbar ?? false), - window.setResizable(styles.resizable ?? false), + window.setSkipTaskbar(styles.showInTaskbar === true), + window.setResizable(styles.resizable === true), setWindowZOrder(window, styles.zOrder), ]); } diff --git a/packages/client-api/src/providers/battery/create-battery-provider.ts b/packages/client-api/src/providers/battery/create-battery-provider.ts index 6fa377e1..2093e0d7 100644 --- a/packages/client-api/src/providers/battery/create-battery-provider.ts +++ b/packages/client-api/src/providers/battery/create-battery-provider.ts @@ -40,6 +40,9 @@ export async function createBatteryProvider( get state() { return batteryVariables().state; }, + get isCharging() { + return batteryVariables().isCharging; + }, get timeTillEmpty() { return batteryVariables().timeTillEmpty; }, diff --git a/packages/desktop/resources/sample-config.yaml b/packages/desktop/resources/sample-config.yaml index cd8e1a17..88248423 100644 --- a/packages/desktop/resources/sample-config.yaml +++ b/packages/desktop/resources/sample-config.yaml @@ -96,10 +96,13 @@ window/bar: justify-self: end; display: flex; + .template { + margin-left: 20px; + } + i { color: #7481b2e1; - margin-left: 20px; - margin-right: 6px; + margin-right: 7px; } template/memory: @@ -126,7 +129,18 @@ window/bar: template/battery: providers: ['battery'] + styles: | + position: relative; + + .charging-icon { + position: absolute; + left: 6.5px; + top: 2px; + } template: | + + @if (battery.isCharging) {} + @if (battery.chargePercent > 90) {} @else if (battery.chargePercent > 70) {} @@ -134,9 +148,6 @@ window/bar: @else if (battery.chargePercent > 20) {} @else {} - - @if (battery.isCharging) {} - {{ Math.round(battery.chargePercent) }}% template/weather: