summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-24 15:25:55 +0800
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-24 15:25:55 +0800
commit054567de9dd9b67c52091b4a17dfcdc5cd72a6c7 (patch)
tree1703d593fec33923ce0925154d29fedb3c7ca4a3 /modules
parentdev: update run script (diff)
downloadcaelestia-shell-054567de9dd9b67c52091b4a17dfcdc5cd72a6c7.tar.gz
caelestia-shell-054567de9dd9b67c52091b4a17dfcdc5cd72a6c7.tar.bz2
caelestia-shell-054567de9dd9b67c52091b4a17dfcdc5cd72a6c7.zip
feat: bar battery
Diffstat (limited to 'modules')
-rw-r--r--modules/bar/components/StatusIcons.qml34
1 files changed, 32 insertions, 2 deletions
diff --git a/modules/bar/components/StatusIcons.qml b/modules/bar/components/StatusIcons.qml
index 38d6166..17cc892 100644
--- a/modules/bar/components/StatusIcons.qml
+++ b/modules/bar/components/StatusIcons.qml
@@ -3,6 +3,7 @@ import "root:/services"
import "root:/utils"
import "root:/config"
import Quickshell
+import Quickshell.Services.UPower
import QtQuick
Item {
@@ -12,8 +13,8 @@ Item {
property color colour: Colours.palette.m3secondary
clip: true
- implicitWidth: vertical ? Math.max(network.implicitWidth, bluetooth.implicitWidth, devices.implicitWidth) : network.implicitWidth + bluetooth.implicitWidth + bluetooth.anchors.leftMargin + (repeater.count > 0 ? devices.implicitWidth + devices.anchors.leftMargin : 0)
- implicitHeight: vertical ? network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) : Math.max(network.implicitHeight, bluetooth.implicitHeight, devices.implicitHeight)
+ implicitWidth: vertical ? Math.max(network.implicitWidth, bluetooth.implicitWidth, devices.implicitWidth, battery.implicitWidth) : network.implicitWidth + bluetooth.implicitWidth + bluetooth.anchors.leftMargin + (repeater.count > 0 ? devices.implicitWidth + devices.anchors.leftMargin : 0) + (battery.active ? battery.implicitWidth + battery.anchors.leftMargin : 0)
+ implicitHeight: vertical ? network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) + (battery.active ? battery.implicitHeight + battery.anchors.topMargin : 0) : Math.max(network.implicitHeight, bluetooth.implicitHeight, devices.implicitHeight, battery.implicitHeight)
MaterialIcon {
id: network
@@ -65,6 +66,35 @@ Item {
}
}
+ Loader {
+ id: battery
+
+ anchors.left: root.vertical ? undefined : repeater.count > 0 ? devices.right : bluetooth.right
+ anchors.leftMargin: root.vertical ? 0 : Appearance.padding.smaller
+ anchors.top: root.vertical ? repeater.count > 0 ? devices.bottom : bluetooth.bottom : undefined
+ anchors.topMargin: root.vertical ? Appearance.padding.smaller : 0
+
+ anchors.horizontalCenter: root.vertical ? devices.horizontalCenter : undefined
+ anchors.verticalCenter: root.vertical ? undefined : devices.verticalCenter
+
+ active: UPower.displayDevice.isLaptopBattery
+ asynchronous: true
+
+ sourceComponent: MaterialIcon {
+ text: {
+ const device = UPower.displayDevice;
+ const perc = device.percentage;
+ const charging = device.changeRate >= 0;
+ if (perc === 1)
+ return charging ? "battery_charging_full" : "battery_full";
+ const level = Math.floor(perc * 7);
+ return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`;
+ }
+ color: UPower.displayDevice.percentage > 0.2 ? root.colour : Colours.palette.m3error
+ fill: 1
+ }
+ }
+
Behavior on implicitWidth {
NumberAnimation {
duration: Appearance.anim.durations.normal