Skip to content

Commit

Permalink
fix: show battery charging icon correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Feb 12, 2024
1 parent 2aff41c commit 3656c46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/client-api/src/desktop/current-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export async function setWindowStyles(styles: Partial<WindowStyles>) {
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),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export async function createBatteryProvider(
get state() {
return batteryVariables().state;
},
get isCharging() {
return batteryVariables().isCharging;
},
get timeTillEmpty() {
return batteryVariables().timeTillEmpty;
},
Expand Down
21 changes: 16 additions & 5 deletions packages/desktop/resources/sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -126,17 +129,25 @@ window/bar:
template/battery:
providers: ['battery']
styles: |
position: relative;
.charging-icon {
position: absolute;
left: 6.5px;
top: 2px;
}
template: |
<!-- Show icon for whether battery is charging. -->
@if (battery.isCharging) {<i class="nf nf-fa-bolt charging-icon"></i>}
<!-- Show icon for how much of the battery is charged. -->
@if (battery.chargePercent > 90) {<i class="nf nf-fa-battery_4"></i>}
@else if (battery.chargePercent > 70) {<i class="nf nf-fa-battery_3"></i>}
@else if (battery.chargePercent > 40) {<i class="nf nf-fa-battery_2"></i>}
@else if (battery.chargePercent > 20) {<i class="nf nf-fa-battery_1"></i>}
@else {<i class="nf nf-fa-battery_0"></i>}
<!-- Show icon for whether battery is charging. -->
@if (battery.isCharging) {<i class="nf nf-fa-bolt"></i>}
{{ Math.round(battery.chargePercent) }}%
template/weather:
Expand Down

0 comments on commit 3656c46

Please sign in to comment.