[ 已解决 ] 关于 kde notification 的两个问题

kde notification,就是屏幕右下角的那个弹窗,因为一些原因,我希望对它做一些调整:

  1. 时长,弹出后很快就消失了,不超过 3 秒,能让它持续个十来秒再消失么?
  2. 超链接,下划线是有,但是点击超链接依然无法直接在浏览器中打开,这算是设计思路还是 bug?
    对于第二个问题,我查阅了 Mailinglist Archive: opensuse-kde ,文中提到 NotificationDelegate.qml 这个文件,但我的 kde 环境是 4.10.5,该文件中已包含“textFormat: TextEdit.RichText”这一行,超链接还是无法正常工作。

以上两个问题,求指导。

  1. 可以。

/usr/share/kde4/apps/plasma/plasmoids/org.kde.notifications/contents/ui/LastNotificationPopup.qml:
lastNotificationTimer.interval = Math.max(4000, Math.min(60*1000, notificationsModel.get(0).expireTimeout))

expireTimeout 值是应用程序可以设置的 popup 弹出窗口消失的时间。

默认的算法是这样:

先把 1 分钟(1000 毫秒 = 1 秒,60 x 1 秒 = 1 分)和应用程序设置的值取最小,

再把得到的值和 4 秒取最大。

看上去如果应用程序不设置,这个弹出窗口的消失时间是 1 分钟,够长了,所以不知道你是哪个应用程序发出的通知。

debug 过程:

  • 安装一个能给 KDE 发通知的东西:notify-send 命令

sudo zypper in libnotify-tools

然后

$ notify-send --help
-t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.

关键词是 expire 或者是 time,同时也证明了应用程序是可以设置弹出窗口时间的。

然后找到那个 notifications 的位置:

find /usr -name "org.kde.notifications"

我这是马后炮,你可能需要自己一点点缩小范围,从这个开始:

[code]
$ find /usr -name "*notication*"
[/code]

cd 过去,在文件中查找:

[code]
$ grep -r "expire" .

找到函数,阅读,理解。

  1. git.reviewboard.kde.org/r/111828/diff/#index_header

是 bug,照着改即可。(root 权限,sudo vi)

然后在任何一个弹出的通知上面右键「删除通知」,再在「系统托盘」上面右键「系统托盘设置」,勾选「通知」再加回来即可。

测试:

notify-send

notify-send “Google” “visit google.com” -t 30000

1赞

两个问题全部解决!
发通知的软件是 Kopete,不过我用
find /usr -name "notification"
没找到与之有关的目录,于是我直接把 4000 改了。

请问第二个问题的
plasma/generic/applets/notifications/contents/ui/LastNotificationPopup.qml
在哪里?
哦,找到了,就在二楼第二行