feat(bridge): establish local pi status bridge
Deliver the initial local bridge, Noctalia v4/v5 adapters, desktop client, service unit, tests, and implementation documentation for persistent Pi status and control.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export async function publishNoctaliaState(
|
||||
state,
|
||||
{ execute = async (command, args) => execFileAsync(command, args) } = {},
|
||||
) {
|
||||
if (!state || typeof state !== "object")
|
||||
throw new TypeError("state is required");
|
||||
const { state: bridgeState, projectLabel, attentionCount, detail } = state;
|
||||
if (
|
||||
typeof bridgeState !== "string" ||
|
||||
typeof projectLabel !== "string" ||
|
||||
!Number.isSafeInteger(attentionCount) ||
|
||||
typeof detail !== "string"
|
||||
) {
|
||||
throw new TypeError(
|
||||
"state must contain string state/projectLabel/detail and integer attentionCount",
|
||||
);
|
||||
}
|
||||
await execute("qs", [
|
||||
"-c",
|
||||
"noctalia-shell",
|
||||
"ipc",
|
||||
"call",
|
||||
"plugin:pi-status-bridge",
|
||||
"setBridgeState",
|
||||
bridgeState,
|
||||
projectLabel,
|
||||
String(attentionCount),
|
||||
detail,
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user