todorowww / dbus-notify
D-Bus 通知库,为 Derick Rethans 的 D-Bus PHP 扩展
0.3
2018-04-28 21:21 UTC
Requires
- php: >=5.5.0
- ext-dbus: *
- ext-xml: *
- lib-libxml: *
This package is auto-updated.
Last update: 2024-09-12 09:49:24 UTC
README
D-Bus Notify
此类利用 Derick Rethans 的 PHP 扩展 D-Bus。为了使用此类,您需要此扩展。
您可以从 nephre 获取它,并且可以在那里找到编译说明。
安装
通过以下命令安装此库的最新版本
composer require todorowww/dbus-notify
基本用法
use todorowww\DBusNotify;
// Instantiate DBusNotify class
$Notify = new DBusNotify();
$icon = "path/to/your/desired/icon.png";
$summary = "Notification message summary (title)";
$body = "Notification message body";
$Notify->notify($appName, $icon, $summary, $body);
响应操作
use todorowww\DBusNotify;
// Instantiate DBusNotify class
$Notify = new DBusNotify();
$icon = "path/to/your/desired/icon.png";
$summary = "Notification message summary (title)";
$body = "Notification message body";
$actions = [
"ok" => "OK",
"cancel" => "Cancel"
];
$Notify->notify($appName, $icon, $summary, $body, $actions);
$Notify->waitForAction(myCallback, 30); // Wait for 30 seconds before timing out
当用户点击按钮或关闭通知时,myCallback 将被触发。操作信息将作为函数的参数传递。