added adaptive quickshell

This commit is contained in:
wt committed 2026-11-17 18:15:16 +07:00
1 parent 6eb56d2065
commit 5b33a73fd8
189 files changed
+8678 -15

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
.pragma library
function timeoutMs(milliseconds, urgency) {
// Critical notifications require an explicit dismissal.
if (urgency === 2 || milliseconds === 0) return 0;
if (milliseconds < 0) return urgency === 0 ? 3000 : 6000;
return Math.max(1, Math.min(2147483647, Math.round(milliseconds)));
}
function upsert(history, entry) {
return [entry].concat(history.filter(old => old.key !== entry.key)).slice(0, 100);
}
function validate(document) {
if (!document || document.version !== 1 || !Array.isArray(document.entries) || document.entries.length > 100)
throw new Error("Invalid notification history schema");
const keys = [];
document.entries.forEach(entry => {
if (!entry || typeof entry.key !== "string" || !entry.key || entry.key.length > 128 || keys.includes(entry.key))
throw new Error("Invalid history key");
keys.push(entry.key);
for (const field of ["appName", "summary", "body", "state"]) {
if (typeof entry[field] !== "string" || entry[field].length > 8192)
throw new Error("Invalid history field: " + field);
}
if (entry.desktopEntry !== undefined && (typeof entry.desktopEntry !== "string" || entry.desktopEntry.length > 512))
throw new Error("Invalid desktop entry id");
if (entry.session !== undefined && (typeof entry.session !== "string" || !/^[0-9]+$/.test(entry.session)))
throw new Error("Invalid notification session");
if (entry.notificationId !== undefined && (!Number.isInteger(entry.notificationId) || entry.notificationId < 1))
throw new Error("Invalid backend id");
if (entry.deadline !== undefined && (!Number.isFinite(entry.deadline) || entry.deadline < 0))
throw new Error("Invalid deadline");
if (!Number.isFinite(entry.time) || ![0, 1, 2].includes(entry.urgency))
throw new Error("Invalid history metadata");
});
return document.entries;
}