From 8277ce163139ff7f60b533a612143220196db0af Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Tue, 25 Nov 2025 18:15:57 +0100 Subject: [PATCH] IPCService: add state IPC call --- Assets/noctalia-shape.svg | 43 --------------------------------- Commons/Settings.qml | 26 ++++++++++++++++++++ Services/Control/IPCService.qml | 28 ++++++++++++++++++--- 3 files changed, 50 insertions(+), 47 deletions(-) delete mode 100644 Assets/noctalia-shape.svg diff --git a/Assets/noctalia-shape.svg b/Assets/noctalia-shape.svg deleted file mode 100644 index 631dabf53..000000000 --- a/Assets/noctalia-shape.svg +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 0ec81bd36..2bbb1bae8 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -5,6 +5,8 @@ import Quickshell import Quickshell.Io import "../Helpers/QtObj2JS.js" as QtObj2JS import qs.Commons +import qs.Services.Power +import qs.Services.System import qs.Services.UI Singleton { @@ -1143,4 +1145,28 @@ Singleton { const widgetAfter = JSON.stringify(widget); return (widgetAfter !== widgetBefore); } + + function buildStateSnapshot() { + try { + const settingsData = QtObj2JS.qtObjectToPlainObject(adapter); + const shellStateData = (typeof ShellState !== "undefined" && ShellState.data) ? QtObj2JS.qtObjectToPlainObject(ShellState.data) || {} : {}; + + return { + settings: settingsData, + state: { + doNotDisturb: NotificationService.doNotDisturb, + noctaliaPerformanceMode: PowerProfileService.noctaliaPerformanceMode, + barVisible: BarService.isVisible, + display: shellStateData.display || {}, + wallpapers: shellStateData.wallpapers || {}, + notificationsState: shellStateData.notificationsState || {}, + changelogState: shellStateData.changelogState || {}, + colorSchemesList: shellStateData.colorSchemesList || {} + } + }; + } catch (error) { + Logger.e("Settings", "Failed to build state snapshot:", error); + return null; + } + } } diff --git a/Services/Control/IPCService.qml b/Services/Control/IPCService.qml index 4b3a51b4d..856311d3a 100644 --- a/Services/Control/IPCService.qml +++ b/Services/Control/IPCService.qml @@ -96,7 +96,7 @@ Item { root.withTargetScreen(screen => { var launcherPanel = PanelService.getPanel("launcherPanel", screen); if (!launcherPanel?.windowActive || (launcherPanel?.windowActive && !launcherPanel?.activePlugin)) - launcherPanel?.toggle(); + launcherPanel?.toggle(); launcherPanel?.setSearchText(""); }); } @@ -104,7 +104,7 @@ Item { root.withTargetScreen(screen => { var launcherPanel = PanelService.getPanel("launcherPanel", screen); if (!launcherPanel?.windowActive || (launcherPanel?.windowActive && launcherPanel?.searchText.startsWith(">clip"))) - launcherPanel?.toggle(); + launcherPanel?.toggle(); launcherPanel?.setSearchText(">clip "); }); } @@ -112,7 +112,7 @@ Item { root.withTargetScreen(screen => { var launcherPanel = PanelService.getPanel("launcherPanel", screen); if (!launcherPanel?.windowActive || (launcherPanel?.windowActive && launcherPanel?.searchText.startsWith(">calc"))) - launcherPanel?.toggle(); + launcherPanel?.toggle(); launcherPanel?.setSearchText(">calc "); }); } @@ -120,7 +120,7 @@ Item { root.withTargetScreen(screen => { var launcherPanel = PanelService.getPanel("launcherPanel", screen); if (!launcherPanel?.windowActive || (launcherPanel?.windowActive && launcherPanel?.searchText.startsWith(">emoji"))) - launcherPanel?.toggle(); + launcherPanel?.toggle(); launcherPanel?.setSearchText(">emoji "); }); } @@ -380,6 +380,26 @@ Item { } } + IpcHandler { + target: "state" + + // Returns all settings and shell state as JSON + function all(): string { + try { + var snapshot = Settings.buildStateSnapshot(); + if (!snapshot) { + throw new Error("State snapshot unavailable"); + } + return JSON.stringify(snapshot, null, 2); + } catch (error) { + Logger.e("IPC", "Failed to serialize state:", error); + return JSON.stringify({ + "error": "Failed to serialize state: " + error + }, null, 2); + } + } + } + /** * For IPC calls on multi-monitors setup that will open panels on screen, * we need to open a QS PanelWindow and wait for it's "screen" property to stabilize.