battery: use internal notification service instead of shelling out to notify-send
This commit is contained in:
parent
bc2d54c07a
commit
88f14b26cd
3 changed files with 31 additions and 9 deletions
|
|
@ -1,8 +1,7 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.Notifications
|
||||
import Quickshell.Services.UPower
|
||||
import "." as S
|
||||
|
||||
|
|
@ -63,18 +62,14 @@ QtObject {
|
|||
if (root.percent < root.critThresh && !root._critSent) {
|
||||
root._critSent = true;
|
||||
root._warnSent = true;
|
||||
_notifProc.command = ["notify-send", "--urgency=critical", "--icon=battery-low", "--category=device", "Very Low Battery", "Connect to power now!"];
|
||||
_notifProc.running = true;
|
||||
S.NotifService.send("Very Low Battery", "Connect to power now!", NotificationUrgency.Critical, "battery-low");
|
||||
} else if (root.percent < root.warnThresh && !root._warnSent) {
|
||||
root._warnSent = true;
|
||||
_notifProc.command = ["notify-send", "--icon=battery-caution", "--category=device", "Low Battery"];
|
||||
_notifProc.running = true;
|
||||
S.NotifService.send("Low Battery", "", NotificationUrgency.Normal, "battery-caution");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property var _notifProc: Process {}
|
||||
|
||||
function fmtTime(secs) {
|
||||
if (!secs || secs <= 0)
|
||||
return "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue