nova-shell/shell/modules/BatteryModule.qml

49 lines
1.6 KiB
QML

import QtQuick
import Quickshell
import "." as M
import "../services" as S
import "../applets" as C
M.BarModule {
id: root
spacing: S.Theme.moduleSpacing
active: S.Modules.battery.enable && S.BatteryService.available
tooltip: "Battery: " + Math.round(S.BatteryService.percent) + "%" + (S.BatteryService.charging ? " (charging)" : "")
panelNamespace: "nova-battery"
panelTitle: "Battery"
panelContentWidth: 240
panelComponent: Component {
C.BatteryApplet {
width: parent.width
active: root._showPanel
accentColor: root.accentColor
}
}
property real _blinkOpacity: 1
M.PulseAnimation on _blinkOpacity {
running: S.BatteryService.critical
minOpacity: 0.45
}
M.BarIcon {
icon: {
if (S.BatteryService.charging)
return "\uDB80\uDC84";
const icons = ["\uDB80\uDC8E", "\uDB80\uDC7A", "\uDB80\uDC7B", "\uDB80\uDC7C", "\uDB80\uDC7D", "\uDB80\uDC7E", "\uDB80\uDC7F", "\uDB80\uDC80", "\uDB80\uDC81", "\uDB80\uDC82", "\uDB85\uDFE2"];
return icons[Math.min(10, Math.floor(S.BatteryService.percent / 10))];
}
color: S.BatteryService.stateColor
opacity: root._blinkOpacity
font.pixelSize: S.Theme.fontSize + 2
anchors.verticalCenter: parent.verticalCenter
}
M.BarLabel {
label: Math.round(S.BatteryService.percent) + "%"
minText: "100%"
color: S.BatteryService.stateColor
opacity: root._blinkOpacity
anchors.verticalCenter: parent.verticalCenter
}
}