Commit e0aca8f8 authored by Christian Muehlhaeuser's avatar Christian Muehlhaeuser Committed by Kurt Hindenburg
Browse files

Add support for OSC-777 notifications

Implement OSC-777, which lets you trigger a system notification.
Already supported by other terminals like kitty, foot, urxvt.

You can easily try this out by running this in your bash:

printf '\x1b]777;notify;Hello;World\x1b\\'

See:
https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm/docs/ControlSequences.md#OSC
https://github.com/kovidgoyal/kitty/blob/9d98aa315922119e8a845046416432548d665b36/kitty/window.py#L811
(cherry picked from commit 6ba3cbb1)
parent 020a914b
Pipeline #265002 failed with stage
in 3 minutes and 5 seconds
......@@ -1146,3 +1146,13 @@ Comment[x-test]=xxA session has exited with non-zero statusxx
Comment[zh_CN]=会话以非零状态退出
Comment[zh_TW]=工作階段以不正常狀態(非零值)結束
Action=None
[Event/ProcessNotification]
Name=Process Triggered a Notification in a Focused Session
Comment=Notification emitted by a process in a focused session
Action=None
[Event/ProcessNotificationHidden]
Name=Process Triggered a Notification in a Non-Focused Session
Comment=Notification emitted by a process in a non-focused session
Action=Popup
......@@ -20,6 +20,7 @@
// KDE
#include <KLocalizedString>
#include <KNotification>
// Konsole
#include "EscapeSequenceUrlExtractor.h"
......@@ -1108,6 +1109,29 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
colorTable[c] = QColor();
}
}
if (attribute == 777) {
// Notification
auto params = value.split(QLatin1Char(';'));
if (params.length() < 1 || params[0] != QLatin1String("notify")) {
return;
}
const auto hasFocus = _currentScreen->currentTerminalDisplay()->hasFocus();
KNotification *notification = nullptr;
if (params.length() >= 3) {
notification =
KNotification::event(hasFocus ? QStringLiteral("ProcessNotification") : QStringLiteral("ProcessNotificationHidden"), params[1], params[2]);
} else {
notification = KNotification::event(hasFocus ? QStringLiteral("ProcessNotification") : QStringLiteral("ProcessNotificationHidden"), params[1]);
}
notification->setDefaultAction(i18n("Show session"));
connect(notification, &KNotification::defaultActivated, this, [this, notification]() {
_currentScreen->currentTerminalDisplay()->notificationClicked(notification->xdgActivationToken());
});
return;
}
if (value == QLatin1String("?")) {
// pass terminator type indication here, because OSC response terminator
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment