1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

clipboard: introduce native clipboard, clip-persist, clip-storage functionality

This commit is contained in:
bbedward
2025-12-11 09:41:07 -05:00
parent 7c88865d67
commit 6d62229b5f
41 changed files with 4372 additions and 547 deletions

View File

@@ -24,6 +24,7 @@ Singleton {
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
property var pendingRequests: ({})
property var clipboardRequestIds: ({})
property int requestIdCounter: 0
property bool shownOutdatedError: false
property string updateCommand: "dms update"
@@ -179,17 +180,19 @@ Singleton {
parser: SplitParser {
onRead: line => {
if (!line || line.length === 0) {
if (!line || line.length === 0)
return;
}
console.log("DMSService: Request socket <<", line);
try {
const response = JSON.parse(line);
const isClipboard = clipboardRequestIds[response.id];
if (isClipboard)
delete clipboardRequestIds[response.id];
else
console.log("DMSService: Request socket <<", line);
handleResponse(response);
} catch (e) {
console.warn("DMSService: Failed to parse request response:", line, e);
console.warn("DMSService: Failed to parse request response");
}
}
}
@@ -209,17 +212,16 @@ Singleton {
parser: SplitParser {
onRead: line => {
if (!line || line.length === 0) {
if (!line || line.length === 0)
return;
}
console.log("DMSService: Subscribe socket <<", line);
try {
const response = JSON.parse(line);
if (!line.includes("clipboard"))
console.log("DMSService: Subscribe socket <<", line);
handleSubscriptionEvent(response);
} catch (e) {
console.warn("DMSService: Failed to parse subscription event:", line, e);
console.warn("DMSService: Failed to parse subscription event");
}
}
}
@@ -394,11 +396,14 @@ Singleton {
request.params = params;
}
if (callback) {
if (callback)
pendingRequests[id] = callback;
}
console.log("DMSService.sendRequest: Sending request id=" + id + " method=" + method);
if (method.startsWith("clipboard")) {
clipboardRequestIds[id] = true;
} else {
console.log("DMSService.sendRequest: Sending request id=" + id + " method=" + method);
}
requestSocket.send(request);
}