From 4904d075aec91457157e97007ca2977c225dfa91 Mon Sep 17 00:00:00 2001 From: Peter Fajdiga Date: Mon, 28 Aug 2023 23:53:11 +0200 Subject: [PATCH] show a notification if window rules JSON invalid --- package/contents/code/main.qml | 11 +++++++++++ src/extern.d.ts | 1 + src/world/ClientManager.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/package/contents/code/main.qml b/package/contents/code/main.qml index 98a7acc..704e3d6 100644 --- a/package/contents/code/main.qml +++ b/package/contents/code/main.qml @@ -1,5 +1,6 @@ import QtQuick 2.15 import org.kde.kwin 3.0 +import org.kde.notification 1.0 import "./main.js" as Karousel Item { @@ -16,4 +17,14 @@ Item { qmlBase.karouselInstance.destroy(); print("script stopped"); } + + Notification { + id: notificationInvalidWindowRules + componentName: "plasma_workspace" + eventId: "notification" + title: "Karousel" + text: "Your Window Rules JSON is malformed, please review your Karousel configuration" + flags: Notification.Persistent + urgency: Notification.HighUrgency + } } diff --git a/src/extern.d.ts b/src/extern.d.ts index 2b190b4..3a027b3 100644 --- a/src/extern.d.ts +++ b/src/extern.d.ts @@ -1,4 +1,5 @@ declare const qmlBase; +declare const notificationInvalidWindowRules; declare const console; declare const KWin; declare const Qt; diff --git a/src/world/ClientManager.ts b/src/world/ClientManager.ts index 4ab7d3b..20dc29c 100644 --- a/src/world/ClientManager.ts +++ b/src/world/ClientManager.ts @@ -15,6 +15,7 @@ class ClientManager { try { parsedWindowRules = JSON.parse(config.windowRules); } catch (error: any) { + notificationInvalidWindowRules.sendEvent(); console.log("failed to parse windowRules:", error); } this.windowRuleEnforcer = new WindowRuleEnforcer(parsedWindowRules);