Skip to main content

用于通过 dbus 发送桌面通知的实用程序。

项目描述

桌面通知

用于通过 dbus 发送桌面通知的实用程序。支持 replace_id、提示和操作(需要主循环)。

包使用

基本通知:

notify = desktop_notify.aio.Notify('summary', 'body')
await notify.show()
notify = desktop_notify.glib.Notify('summary', 'body')
notify.set_on_show(callback) # optional
notify.show()
# or
notify.show_async()

与服务器一起使用:

server = desktop_notify.aio.Server('app_name')
notify = server.Notify('summary')
await notify.show()

配置通知。

您可以通过默认属性设置器notify.body = 'body'或使用流利的设置器设置通知选项:

notify.set_id(0)\
	.set_icon('icon')\
	.set_timeout(10000) # ms

额外选项

提示

对于使用提示的工作,请使用以下方法:

notify.set_hint(key, value)
notify.get_hint(key)
notify.del_hint(key)

行动

要使用动作和事件,您需要指定通知服务器主循环。

您可以添加或删除操作:

notify.add_action(desktop_notify.Action('label', callback))
notify.del_action(desktop_notify.Action('label', callback))

还支持on_showon_close事件:

notify.set_on_show(callback(notify))
notify.set_on_close(callback(notify, close_reason))

控制台使用

usage: desktop-notify [--help] [--icon ICON] [--id REPLACE_ID] [--timeout TIMEOUT]
               [--hints key:value [key:value ...]]
               Summary [Body]

Send desktop notification. Returns created notification's id.

positional arguments:
  Summary               The summary text briefly describing the notification.
  Body                  The optional detailed body text. Can be empty.

optional arguments:
  --help                show this help message and exit
  --icon ICON, -i ICON  The optional program icon of the calling application.
                        Should be either a file path or a name in a
                        freedesktop.org-compliant icon theme.
  --id REPLACE_ID       An optional ID of an existing notification that this
                        notification is intended to replace.
  --timeout TIMEOUT, -t TIMEOUT
                        The timeout time in milliseconds since the display of
                        the notification at which the notification should
                        automatically close.
  --hints key:signature:value [key:signature:value ...], -h key:signature:value [key:signature:value ...]
                        use "--" to separate hints list from positional args

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

desktop-notify-1.3.3.tar.gz (7.8 kB 查看哈希

已上传 source

内置分布

desktop_notify-1.3.3-py3-none-any.whl (9.9 kB 查看哈希)

已上传 py3