Using Quickshell Build in stuff for battery

This commit is contained in:
Honney
2026-08-21 22:07:56 +02:00
parent f11ddfb7fe
commit 2b4d3cd911
2 changed files with 27 additions and 96 deletions
+11 -16
View File
@@ -1,7 +1,6 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
import "../../../config"
import "../states/Battery"
@@ -38,7 +37,7 @@ MouseArea {
font.family: Config.font
color: (
BatteryState.charging ? (
BatteryState.percentage == 100 ? Colors.secondary :
BatteryState.full ? Colors.secondary :
Colors.tertiary
) :
BatteryState.percentage <= 5 ? Colors.errorContainer :
@@ -90,7 +89,7 @@ MouseArea {
color: (
BatteryState.percentage <= 5 ? Colors.errorContainer :
BatteryState.charging ? (
BatteryState.percentage == 100 ? Colors.secondary :
BatteryState.full ? Colors.secondary :
Colors.tertiary
) :
BatteryState.percentage < 10 ? "yellow" :
@@ -136,7 +135,7 @@ MouseArea {
font.family: Config.font
}
Text {
text: "charging: " + BatteryState.charging
text: "State: " + BatteryState.state
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
@@ -144,7 +143,7 @@ MouseArea {
font.family: Config.font
}
Text {
text: "energy: " + BatteryState.energy
text: "energy: " + Math.round(BatteryState.energy*10)/10 + " W"
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
@@ -152,7 +151,10 @@ MouseArea {
font.family: Config.font
}
Text {
text: "voltage: " + BatteryState.voltage
text: (
BatteryState.hour_to_empty > 0 ? "Remaining: " + BatteryState.hour_to_empty + "h " + BatteryState.min_to_empty + "min" :
BatteryState.min_to_empty > 0 ? "Remaining: " + BatteryState.min_to_empty + "min" :
"NaN")
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
@@ -160,7 +162,7 @@ MouseArea {
font.family: Config.font
}
Text {
text: "charge_cycle: " + BatteryState.charge_cycle
text: "Usage: " + BatteryState.energy_rate_formated + " W"
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
@@ -168,15 +170,8 @@ MouseArea {
font.family: Config.font
}
Text {
text: "time_to_empty: " + BatteryState.time_to_empty + "h"
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: Config.font_size_tiny(bar.height)
font.family: Config.font
}
Text {
text: "energy_rate: " + BatteryState.energy_rate + "W"
text: "Health: " + BatteryState.health + " %"
visible: BatteryState.healthSupported
wrapMode: Text.WordWrap
color: Colors.primary
anchors.horizontalCenter: parent.horizontalCenter