diff --git a/Bar/Right.qml b/Bar/Right.qml index a4608d4..093d19d 100644 --- a/Bar/Right.qml +++ b/Bar/Right.qml @@ -15,6 +15,12 @@ Row { required property HyprlandMonitor monitor + spacing: 10 + + Battery { + exclusiveMonitor: root.monitor + } + Bluetooth { exclusiveMonitor: root.monitor } diff --git a/Bar/Right/Battery.qml b/Bar/Right/Battery.qml new file mode 100644 index 0000000..3b5f605 --- /dev/null +++ b/Bar/Right/Battery.qml @@ -0,0 +1,28 @@ +pragma ComponentBehavior: Bound +import QtQuick +import Quickshell +import Quickshell.Services.UPower +import "../../Color.js" as Colors +import "../../Components/" +import "../../Services/" +import "Bluetooth" + +Container { + id: root + + animOffset: 160 + boxColor: Colors.green + boxHeight: 25 + boxWidth: 40 + defaultItem: icon + exclusiveToScreen: true + forceHidden: BatteryManager.battery.isLaptopBattery + + Component { + id: icon + + CenteredText { + text: BatteryManager.batteryPercentage + } + } +} diff --git a/Services/BatteryManager.qml b/Services/BatteryManager.qml new file mode 100644 index 0000000..c99c28c --- /dev/null +++ b/Services/BatteryManager.qml @@ -0,0 +1,23 @@ +pragma Singleton +import QtQuick +import Quickshell +import Quickshell.Services.UPower + +Singleton { + id: root + + property UPowerDevice battery: Upower.displayDevice + property bool batteryInUse: root.batteryPresent && root.batteryLaptop + property bool batteryLaptop: root.battery.isLaptopBattery + property double batteryPercentage: root.battery.percentage + property bool batteryPresent: root.battery.ready + + function getBatteryIcon() { + let battery = root.battery; + if (battery.state = UpowerDeviceState.Charging) { + return "󰂄"; + } + if (battery.state = UpowerDeviceState.Discharging) { + } + } +} diff --git a/Services/qmldir b/Services/qmldir index b6984ea..6e2dbe3 100644 --- a/Services/qmldir +++ b/Services/qmldir @@ -4,3 +4,4 @@ singleton NotificationManager 1.0 NotificationManager.qml singleton WorkspaceManager 1.0 WorkspaceManager.qml singleton BluetoothManager 1.0 BluetoothManager.qml singleton MprisManager 1.0 MprisManager.qml +singleton BatteryManager 1.0 BatteryManager.qml