Answer omarchy-shell calls over the shell's own socket (#13435)
* Answer omarchy-shell calls over the shell's own socket Every omarchy-shell call started a qs ipc client, ~45ms of startup for one IPC call: a theme switch makes two, and every script-driven OSD, toggle refresh and lock query paid it too. The shell now serves a socket in XDG_RUNTIME_DIR, named from its config path and Wayland display as qs ipc selects its instance, and omarchy-shell tries it first through socat, which starts in ~5ms. First-party handlers register as ShellIpc, an IpcHandler that qs ipc still reaches, and the socket calls only the functions a handler declares with their exact argument count, allowed by name so QObject methods such as destroy() stay out of reach. When the shell ran nothing it answers SKIP, and omarchy-shell asks qs ipc for its exact answer, so errors, third-party plugins and an unreachable socket behave as before. A call that may have run is never retried: a timeout or a connection closed without an answer reports the shell as not responding. omarchy-shell shell ping takes ~13-18ms instead of ~61ms, and omarchy-osd reaches the screen in ~36ms instead of ~77ms. Output and exit status match the qs ipc path across 26 calls, errors and quiet mode included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Only accept whole socket replies and retry only unmade connections A reply cut off after its OK prefix passed for the whole answer, and an empty reply with socat failing was retried through qs ipc although the request might already have been delivered. An answer now counts only once its record separator arrived. socat's own errors join the reply, so only its connect error, a socket nothing listens on, falls back to qs ipc beside an explicit SKIP; anything else is reported as not responding rather than retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
616feda103
commit
c231097df7
27 files changed
+356
-23
No files matched your search
+36
-2
@@ -1579,6 +1579,40 @@ ShellRoot {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ IPC socket
|
||||
//
|
||||
// omarchy-shell reaches the shell here first: a qs ipc client costs ~45ms
|
||||
// to start per call, socat ~5ms. A request is target, method and arguments
|
||||
// separated by unit separators and ended by a record separator. The reply is
|
||||
// "OK" and the output, or "SKIP" when nothing ran (no such target or
|
||||
// function, or the wrong number of arguments), which omarchy-shell hands to
|
||||
// qs ipc for its exact answer. The socket sits in XDG_RUNTIME_DIR, private
|
||||
// to the user like qs ipc's own. Like qs ipc, it belongs to one shell: the
|
||||
// one running this config on this display. omarchy-shell derives the same
|
||||
// name from the same two values.
|
||||
readonly property string ipcSocketPath: Quickshell.env("XDG_RUNTIME_DIR") + "/omarchy-shell-"
|
||||
+ Qt.md5(shell.omarchyPath + "/shell\n" + Quickshell.env("WAYLAND_DISPLAY")).slice(0, 16) + ".sock"
|
||||
|
||||
SocketServer {
|
||||
active: shell.omarchyPath !== ""
|
||||
path: shell.ipcSocketPath
|
||||
|
||||
handler: Socket {
|
||||
id: connection
|
||||
|
||||
parser: SplitParser {
|
||||
splitMarker: "\u001e"
|
||||
onRead: function(data) {
|
||||
var fields = String(data).split("\u001f")
|
||||
var result = fields.length >= 2 ? IpcRegistry.call(fields[0], fields[1], fields.slice(2)) : { ran: false }
|
||||
connection.write(result.ran ? "OK\u001f" + result.output + "\u001e" : "SKIP\u001e")
|
||||
connection.flush()
|
||||
connection.connected = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------- image selector IPC
|
||||
|
||||
function imagePickerItem() {
|
||||
@@ -1586,7 +1620,7 @@ ShellRoot {
|
||||
return loader && loader.item ? loader.item : null
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
ShellIpc {
|
||||
target: "image-selector"
|
||||
|
||||
function open(imageDirs: string,
|
||||
@@ -1637,7 +1671,7 @@ ShellRoot {
|
||||
|
||||
// ---------------------------------------------------------- shell IPC
|
||||
|
||||
IpcHandler {
|
||||
ShellIpc {
|
||||
target: "shell"
|
||||
|
||||
function ping(): string {
|
||||
|
||||
Reference in new issue
Block a user