mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-10 04:49:19 -08:00
fix: battery
This commit is contained in:
parent
1ba98534eb
commit
b0b1afc339
10 changed files with 169 additions and 42 deletions
|
|
@ -11,7 +11,7 @@ Loader {
|
|||
sourceComponent: batIcon
|
||||
|
||||
function findClosestIndex(percent) {
|
||||
return Math.round(percent/10)
|
||||
return Math.round(percent*10)
|
||||
}
|
||||
|
||||
property list<string> percentIcons: [
|
||||
|
|
@ -42,26 +42,27 @@ Loader {
|
|||
function getTimeLeft(allSeconds, filling) {
|
||||
const hours = Math.floor(allSeconds / 3600)
|
||||
const minutes = Math.floor((allSeconds % 3600) / 60)
|
||||
const seconds = Math.floor((allSeconds % 3600) / 60) / 60
|
||||
const fillString = filling ? "full" : "empty"
|
||||
|
||||
return `${hours}h${minutes}m${seconds}s remain until ${fillString}`
|
||||
return `${hours}h${minutes}m remain until ${fillString}`
|
||||
}
|
||||
|
||||
function getTimeLeftT() {
|
||||
if (mainBat.timeToEmpty == 0) {
|
||||
if (mainBat.timeToEmpty != 0) {
|
||||
return getTimeLeft(mainBat.timeToEmpty, false)
|
||||
} else if (mainBat.timeToFull == 0) {
|
||||
} else if (mainBat.timeToFull != 0) {
|
||||
return getTimeLeft(mainBat.timeToFull, true)
|
||||
} else {
|
||||
return "full!"
|
||||
}
|
||||
}
|
||||
|
||||
function changeRate() {
|
||||
return `${Math.round(mainBat.changeRate)}W`
|
||||
return `${Math.round(mainBat.changeRate*100)/100}W`
|
||||
}
|
||||
|
||||
function energyLeft() {
|
||||
return `${Math.round(mainBat.energy)}Wh`
|
||||
return `${Math.round(mainBat.energy*100)/100}Wh total`
|
||||
}
|
||||
|
||||
function getTooltip() {
|
||||
|
|
@ -74,13 +75,13 @@ Loader {
|
|||
MarginWrapperManager { margin: 10 }
|
||||
Text {
|
||||
color: Stylix.base05
|
||||
text: `${getIcon(mainBat.percentage)} ${Math.round(mainBat.percentage)} %`
|
||||
text: `${getIcon(mainBat.percentage)} ${mainBat.percentage*100} %`
|
||||
|
||||
ToolTip {
|
||||
id: dismissTooltip
|
||||
visible: false
|
||||
delay: 500
|
||||
timeout: 1000
|
||||
timeout: 5000
|
||||
text: getTooltip()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue