Commit bd5078d8 authored by Nate Graham's avatar Nate Graham Committed by Fushan Wen
Browse files

kded: don't show "connection activated" notifications on launch/login

The daemon connects to NetworkManager::ActiveConnection::stateChanged
signals to show notifications, and this signal gets emitted when the
daemon launches to first make its connection. As a result, every time
the user logs in or the plasma-nm kded module is restarted (manually or
due to a crash), a "Connection activated" notification is shown. This is
annoying and redundant since the connection was made with no user action
taken; the user *expects* background processes to work normally and does
not need to be explicitly notified of it.

Plasma-nm already has some logic to suppress these notifications that
would be sent within the first 10 seconds after waking up from sleep,
but it does not handle the case of the same thing happening right when
the daemon is launched (e.g. on login).

This commit makes it handle that use case as well, with the same
approach: suppressing "activated" notifications sent within the first 10

BUG: 399973
FIXED-IN: 5.24.2
parent b0fa9a20
Pipeline #140072 passed with stage
in 1 minute and 30 seconds
......@@ -52,6 +52,11 @@ Notification::Notification(QObject *parent)
// After 10 seconds we can consider it to not have "just launched" anymore
QTimer::singleShot(10s, this, [this]() {
m_justLaunched = false;
void Notification::deviceAdded(const QString &uni)
......@@ -317,6 +322,16 @@ void Notification::onActiveConnectionStateChanged(NetworkManager::ActiveConnecti
const QString connectionId = ac->id();
if (state == NetworkManager::ActiveConnection::Activated) {
// Don't send notifications about activated connections just because the
// daemon was launched as these were not explicitly user-initiated actions,
// and notifications for automatic actions and background processes are
// annoying and unnecessary
if (m_justLaunched) {
qCDebug(PLASMA_NM_KDED_LOG) << "Not emitting connection activated notification as the daemon was just launched";
// Also don't notify for re-made connections after waking up from sleep
auto foundConnection = std::find_if(m_activeConnectionsBeforeSleep.constBegin(), m_activeConnectionsBeforeSleep.constEnd(), [ac](const QString &uuid) {
return uuid == ac->uuid();
......@@ -43,6 +43,7 @@ private:
QHash<QString, KNotification *> m_notifications;
bool m_preparingForSleep = false;
bool m_justLaunched = true;
QStringList m_activeConnectionsBeforeSleep;
QTimer *m_checkActiveConnectionOnResumeTimer = nullptr;
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