IPCService: add state IPC call

This commit is contained in:
Ly-sec
2025-11-25 18:15:57 +01:00
parent 5a247f9de4
commit 8277ce1631
3 changed files with 50 additions and 47 deletions
-43
View File
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="256"
height="256"
viewBox="0 0 67.733334 67.733334"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="g1"
transform="matrix(1.1010869,0,0,1.1010869,-3.4238347,-3.4234893)">
<g
id="g55"
style="fill:#000000;fill-opacity:1"
transform="matrix(4.2055905,0,0,4.2055905,-14.788898,-180.43362)">
<path
id="path55"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:9.1;stroke-dasharray:none;paint-order:fill markers stroke"
d="m 11.646484,43.642578 a 7.3141356,7.3141356 0 0 0 -7.3124996,7.3125 7.3141356,7.3141356 0 0 0 7.3124996,7.314453 7.3141356,7.3141356 0 0 0 7.158204,-5.898437 6.2203302,6.2203302 0 0 1 -3.416016,3.464844 c 0.0015,0.277406 0.0039,0.53255 0.0039,0.726562 -0.739445,0 -1.375835,-0.101886 -1.921875,-0.271484 a 6.2203302,6.2203302 0 0 1 -0.441406,0.03516 6.2203302,6.2203302 0 0 1 -6.2207032,-6.220703 6.2203302,6.2203302 0 0 1 6.2207032,-6.220703 6.2203302,6.2203302 0 0 1 0.576172,0.02734 7.3141356,7.3141356 0 0 0 -1.958985,-0.269531 z" />
</g>
<path
id="path56"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.34608;stroke-miterlimit:9.1;paint-order:fill markers stroke"
d="m 42.66444,31.291474 c -1.802882,2.023105 -4.950139,2.492661 -8.5254,2.5028 -2.71816,-0.0077 -5.450476,-0.128227 -7.26956,-1.389551 -1.816542,0.324182 -2.579157,2.344033 -2.415866,4.702777 1.164647,16.822967 11.81672,15.734645 11.912198,15.707145 -7.793366,-3.802447 -6.516498,-10.00048 -6.772622,-11.975293 0.320928,3.34233 3.895926,12.856764 17.235494,12.856764 0,-4.009655 0.01992,-14.311035 -1.27908,-17.487024 -0.409124,-1.237312 -1.52526,-4.546963 -2.885164,-4.917618 z" />
<path
id="path57"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:3.76565;stroke-miterlimit:9.1;paint-order:fill markers stroke"
d="m 20.992013,16.087004 c 0.608944,1.865545 1.835334,3.704314 3.480086,4.401745 -0.458781,1.382804 -0.460831,3.024949 -0.460831,4.783126 0,4.927895 4.533698,8.919413 10.130359,8.938559 5.596664,-0.01912 10.130367,-4.010667 10.130367,-8.938559 0,-1.758177 -0.0021,-3.400322 -0.460833,-4.783126 1.644753,-0.697431 2.871142,-2.5362 3.480084,-4.401745 -1.987776,-0.0305 -5.150908,0.700757 -7.850047,0.786595 -1.351539,-0.351845 -3.086137,-0.545868 -5.299571,-0.548233 -2.213431,0.0024 -3.948027,0.196367 -5.299568,0.548233 -2.699135,-0.08584 -5.862266,-0.817187 -7.850046,-0.786595 z m 6.777419,4.648053 c 0.55547,-0.01383 1.299779,0.06204 2.304161,0.246319 0.672198,0.123302 1.523536,0.452402 2.034019,0.754813 0.950807,0.563264 1.073595,1.207697 2.034015,1.207697 0.96042,0 1.083207,-0.644433 2.034018,-1.207697 0.510483,-0.302418 1.361822,-0.631511 2.034021,-0.754813 4.591459,-0.842328 3.821732,0.523962 3.821732,2.836505 0,2.387132 -1.935155,4.32229 -4.322291,4.32229 -0.76295,-0.0037 -1.511332,-0.20934 -2.169091,-0.595905 -0.01546,0.03375 -0.02887,0.06484 -0.04768,0.09535 l -0.969338,1.573189 c -0.105239,0.171222 -0.243797,0.257467 -0.381378,0.254251 -0.13758,0.0031 -0.276139,-0.08303 -0.381378,-0.254251 l -0.969338,-1.573189 c -0.01871,-0.0305 -0.03212,-0.06159 -0.04768,-0.09535 -0.657763,0.386585 -1.406142,0.592188 -2.169091,0.595905 -2.387137,0 -4.32229,-1.935158 -4.32229,-4.32229 0,-1.806673 -0.466271,-3.033173 1.517569,-3.082814 z" />
<path
id="path58"
style="fill:none;stroke:#000000;stroke-width:1.22052;stroke-linecap:round;stroke-miterlimit:9.1;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
d="M 32.3042,25.300596 A 1.9914438,1.9914438 0 0 1 30.579559,26.29632 1.9914438,1.9914438 0 0 1 28.854918,25.300596" />
<path
id="path59"
style="fill:none;stroke:#000000;stroke-width:1.22052;stroke-linecap:round;stroke-miterlimit:9.1;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
d="M 39.428334,25.300596 A 1.9914438,1.9914438 0 0 1 37.703696,26.29632 1.9914438,1.9914438 0 0 1 35.979053,25.300596" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.2 KiB

+26
View File
@@ -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;
}
}
}
+24 -4
View File
@@ -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.