added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,32 @@
|
||||
.pragma library
|
||||
|
||||
function localUrl(value) {
|
||||
if (typeof value !== "string" || value.length > 16384 || value.includes("\u0000"))
|
||||
throw new Error("Invalid wallpaper path");
|
||||
if (value === "") return "";
|
||||
let path = value;
|
||||
if (value.startsWith("file://")) {
|
||||
try { path = decodeURIComponent(value.slice(7)); }
|
||||
catch (e) { throw new Error("Invalid file URL"); }
|
||||
}
|
||||
if (!path.startsWith("/") || path.startsWith("//") || path.includes("\u0000"))
|
||||
throw new Error("Choose an absolute local file path");
|
||||
return "file://" + path.split("/").map(segment => encodeURIComponent(segment)).join("/");
|
||||
}
|
||||
|
||||
function validate(wallpapers) {
|
||||
if (!wallpapers || Array.isArray(wallpapers) || typeof wallpapers !== "object")
|
||||
throw new Error("Invalid wallpaper preferences");
|
||||
const outputs = Object.keys(wallpapers);
|
||||
if (outputs.length > 64) throw new Error("Too many wallpaper overrides");
|
||||
outputs.forEach(name => {
|
||||
if (!name || name.length > 256) throw new Error("Invalid output name");
|
||||
localUrl(wallpapers[name]);
|
||||
});
|
||||
return wallpapers;
|
||||
}
|
||||
|
||||
function sourceFor(wallpapers, output) {
|
||||
wallpapers = wallpapers || {};
|
||||
return localUrl(Object.prototype.hasOwnProperty.call(wallpapers, output) ? wallpapers[output] : wallpapers["*"] || "");
|
||||
}
|
||||
Reference in new issue
Block a user