从 bash 脚本激活 KDE 4 通知

发布于 2024-08-04 02:08:24 字数 170 浏览 14 评论 0原文

我有一个由 crontab 激活并在后台运行的 bash 脚本。我想添加在执行期间发送通知的功能。我的 KDE 4 桌面有一个精美的通知系统,可以从托盘栏中弹出非模式消息,这非常适合我的需求。所以我正在寻找一种从 bash 脚本生成这些通知的方法,但我对 KDE 平台几乎一无所知,所以我陷入了困境。有人能指出我的解决方案吗?

I have a bash script activated by crontab and running in background. I would like to add to it the ability to send notifications during the execution. My KDE 4 desktop has a fancy notification system which pops out non-modal messages from the tray bar, and this would be perfect for my needs. So I was searching for a way to generate these notifications from a bash scripts, but I have almost no knowledge of the KDE platform and so I'm stuck. Can anybody point me to a solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

窝囊感情。 2024-08-11 02:08:24

可以使用kdialog的被动弹出选项。

kdialog --passivepopup <text> <timeout>

例子:

kdialog --passivepopup 'This is a notification' 5

kdialog's passive popup option can be used.

kdialog --passivepopup <text> <timeout>

Example:

kdialog --passivepopup 'This is a notification' 5
眸中客 2024-08-11 02:08:24

您还可以使用 notify-send (在基于 Debian 的系统上,安装 libnotify-bin 软件包):

notify-send -i 'dialog-information' 'Summary' '<b><font color=red>Message body.'

据我所知,这应该适用于多个窗口管理器(例如如 KDE 和 Gnome)。

编辑:消息的 HTML 格式仅适用于某些通知守护程序,因此应避免。

You may also use notify-send (on Debian-based systems, install the libnotify-bin package):

notify-send -i 'dialog-information' 'Summary' '<b><font color=red>Message body.'

To my best knowledge, this should work on several window managers (such as KDE and Gnome).

Edit: HTML formatting of the message will only work with certain notification daemons and should thus be avoided.

司马昭之心 2024-08-11 02:08:24
kdialog --passivepopup 'message including html' timeout

是 KDE 的一个选项,其中不需要超时。您甚至可以通过添加标题 (--title) 等来调整它 -->看
kdialog --help

一方面值得一提的是,kdialog 安装在我的 openSuSE KDE4 系统上,而在这里没有安装 notification-send。

另一方面,notify-send 的优点是您可以在不同的桌面环境中使用它

kdialog --passivepopup 'message including html' timeout

is an option for KDE where the timeout is not necessary. you can tune this even with adding a headline (--title) and so on --> see
kdialog --help

on the one hand it is worth mentioning, that kdialog was installed on my openSuSE KDE4 system whereas notify-send is not installed here.

on the other hand the advantage of notify-send is that you can use it with different desktop environments

梦回梦里 2024-08-11 02:08:24

确认通知发送适用于 XFCE4(基于 Debian 的 Mint),但 对我不起作用。由于某种原因,它使消息正文文本变成深灰色(几乎难以辨认),因此我将该 html 保留下来,标题(“摘要”)和正文文本都显示为白色。

很酷的是,您可以输入您喜欢的图标的绝对路径 -
例如 -i '~/myapps/foobarapp/icons/64x64/64x64.png'

Confirm that notify-send works with XFCE4 (Debian-based Mint), except the <b><font color=red> didn't work for me. For some reason it made the Message body text dark grey (virtually illegible), so I left that html out and the header ('Summary') and body text both come up white.

What is cool is that you can put an absolute path to the icon your prefer --
e.g. -i '~/myapps/foobarapp/icons/64x64/64x64.png'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文