configurable polling intervals and thresholds per module
This commit is contained in:
parent
0eaba947f4
commit
7a4e1859a9
11 changed files with 64 additions and 32 deletions
|
|
@ -19,8 +19,10 @@ M.BarSection {
|
|||
readonly property var dev: UPower.displayDevice
|
||||
readonly property real pct: (dev?.percentage ?? 0) * 100
|
||||
readonly property bool charging: dev?.state === UPowerDeviceState.Charging
|
||||
readonly property bool _critical: pct < 15 && !charging
|
||||
property color _stateColor: charging ? M.Theme.base0B : _critical ? M.Theme.base09 : pct < 30 ? M.Theme.base0A : M.Theme.base08
|
||||
readonly property int _critThresh: M.Modules.battery.critical || 15
|
||||
readonly property int _warnThresh: M.Modules.battery.warning || 25
|
||||
readonly property bool _critical: pct < _critThresh && !charging
|
||||
property color _stateColor: charging ? M.Theme.base0B : _critical ? M.Theme.base09 : pct < _warnThresh ? M.Theme.base0A : M.Theme.base08
|
||||
property real _blinkOpacity: 1
|
||||
|
||||
SequentialAnimation {
|
||||
|
|
@ -37,11 +39,11 @@ M.BarSection {
|
|||
onChargingChanged: { _warnSent = false; _critSent = false; }
|
||||
onPctChanged: {
|
||||
if (charging) return;
|
||||
if (pct < 15 && !_critSent) {
|
||||
if (pct < _critThresh && !_critSent) {
|
||||
_critSent = true; _warnSent = true;
|
||||
_notif.command = ["notify-send", "--urgency=critical", "--icon=battery-low", "--category=device", "Very Low Battery", "Connect to power now!"];
|
||||
_notif.running = true;
|
||||
} else if (pct < 25 && !_warnSent) {
|
||||
} else if (pct < _warnThresh && !_warnSent) {
|
||||
_warnSent = true;
|
||||
_notif.command = ["notify-send", "--icon=battery-caution", "--category=device", "Low Battery"];
|
||||
_notif.running = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue