我很难找到关于如何为plasmoids写通知的任何文献或例子。
我的等离子体可以在满足某些条件时显示通知和声音警报,但我不知道如何:
到目前为止,这是我的(删节)代码:
PlasmaCore.DataSource {
id: notificationSource
engine: "notifications"
}
SoundEffect {
id: notificationSound
source: plasmoid.file("data", "beep-alarm.wav")
loops: SoundEffect.Infinite
}
function createNotification(text) {
var service = notificationSource.serviceForSource("notification");
var operation = service.operationDescription("createNotification");
operation["appName"] = root.appName;
operation["appIcon"] = plasmoid.configuration.icon;
operation.summary = root.title;
operation["body"] = '<b>' + text + '</b>';
operation["expireTimeout"] = 0;
operation["isPersistent"] = 'isPersistent';
operation["urgency"] = 2;
var tmp = service.startOperationCall(operation);
if (plasmoid.configuration.alarmEnabled) {
notificationSound.play();
}
}
Plasmoid.compactRepresentation: Item {
...
PlasmaComponents.Label {
text: {
if (Number(root.x) >= plasmoid.configuration.y) {
root.createNotification(root.x);
}
root.x
}
}
...
}