mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-30 16:25:35 +00:00
feat: implement OS notifications on Linux
using "notify-send" wrapper Related: status-im/status-desktop#2520
This commit is contained in:
parent
ec90b2107d
commit
c96e2601d0
@ -14,6 +14,12 @@ static const UINT NOTIFYICONID = 0;
|
||||
static std::pair<HWND, OSNotification *> HWND_INSTANCE_PAIR;
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QDebug>
|
||||
#endif
|
||||
|
||||
using namespace Status;
|
||||
|
||||
OSNotification::OSNotification(QObject *parent)
|
||||
@ -158,6 +164,20 @@ void OSNotification::showNotification(const QString& title,
|
||||
|
||||
#elif defined Q_OS_MACOS
|
||||
showNotificationMacOs(title, message, identifier);
|
||||
#elif defined Q_OS_LINUX
|
||||
static QString notifyExe = QStandardPaths::findExecutable(QStringLiteral("notify-send"));
|
||||
if (notifyExe.isEmpty()) {
|
||||
qWarning() << "'notify-send' not found; OS notifications will not work";
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList args; // spec https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html
|
||||
args << QStringLiteral("-a") << QStringLiteral("nim-status"); // appname; w/o .desktop extension
|
||||
args << QStringLiteral("-c") << QStringLiteral("im"); // category; generic "im" category
|
||||
args << title; // summary
|
||||
args << message; // body
|
||||
|
||||
QProcess::execute(notifyExe, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -168,4 +188,4 @@ void OSNotification::showIconBadgeNotification(int notificationsCount)
|
||||
#elif defined Q_OS_MACOS
|
||||
showIconBadgeNotificationMacOs(notificationsCount);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user