Lay the Control Center out as a resizable, editable grid
Modules are tiles on a 4-column grid, each 1x1 to 4x4 and adapting its layout to its size. Edit Controls in the panel reorders by dragging, resizes from a corner handle, removes with a badge and adds from a tray. Connectivity splits into Wi-Fi, Bluetooth and Network tiles and Audio into Sound and Microphone; right-clicking Sound extends it with output devices and a volume slider per app. Adds a Caffeine tile. Config version 2 migrates existing layouts in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0dcf37346c
commit
11bdc4c751
32 files changed
+2147
-355
No files matched your search
@@ -87,9 +87,9 @@ function validate(c) {
|
||||
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
|
||||
const notes=c.notifications;
|
||||
if(!notes || ["enabled","doNotDisturb","criticalInDnd"].some(k=>typeof notes[k]!=="boolean") || !["slide","drop","fade","shrink"].includes(notes.animation) || !["top-right","top-center"].includes(notes.position) || !Number.isInteger(notes.timeout) || notes.timeout<1000 || notes.timeout>30000 || !Number.isInteger(notes.maxPopups) || notes.maxPopups<1 || notes.maxPopups>6)throw Error("Invalid notification preferences");
|
||||
if(c.controlCenter.version !== 1 || !Number.isFinite(c.controlCenter.width) || c.controlCenter.width < 320 || c.controlCenter.width > 600 || !Array.isArray(c.controlCenter.modules))throw Error("Invalid Control Center configuration");
|
||||
if(c.controlCenter.version !== 2 || !Number.isFinite(c.controlCenter.width) || c.controlCenter.width < 320 || c.controlCenter.width > 600 || !Array.isArray(c.controlCenter.modules))throw Error("Invalid Control Center configuration");
|
||||
const controlIds=new Set();
|
||||
for(const m of c.controlCenter.modules) { if(!m || typeof m.id!=="string" || controlIds.has(m.id) || typeof m.enabled!=="boolean")throw Error("Invalid Control Center module"); controlIds.add(m.id); }
|
||||
for(const m of c.controlCenter.modules) { if(!m || typeof m.id!=="string" || controlIds.has(m.id) || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)))throw Error("Invalid Control Center module"); controlIds.add(m.id); }
|
||||
for(const group of [c.system.brightness,c.system.nightLight]) for(const key of ["statusCommand","setCommand"])if(!Array.isArray(group[key]) || group[key].some(v=>typeof v!=="string" || !v.length))throw Error("Provider command must be an argument array");
|
||||
if(typeof c.system.brightness.device!=="string" || !c.system.brightness.device || !Number.isInteger(c.system.nightLight.temperature) || c.system.nightLight.temperature<1000 || c.system.nightLight.temperature>6500 || !Array.isArray(c.system.power.lockCommand) || c.system.power.lockCommand.some(v=>typeof v!=="string" || !v.length))throw Error("Invalid system provider settings");
|
||||
if(!Number.isInteger(c.metrics.interval) || c.metrics.interval<1 || c.metrics.interval>30)throw Error("Invalid metrics geometry or interval");
|
||||
@@ -123,6 +123,24 @@ function load(defaults, user) {
|
||||
migrated.controlCenter.modules = defaults.controlCenter.modules;
|
||||
migrated.controlCenter.version = 1;
|
||||
}
|
||||
// Version 2 lays modules on a grid: the combined Connectivity and Audio
|
||||
// cards split into their own tiles, in place, and Caffeine is offered.
|
||||
if (migrated.controlCenter.version === 1 && Array.isArray(migrated.controlCenter.modules)) {
|
||||
const parts = {connectivity: ["wifi", "bluetooth", "network"], audio: ["output", "input"]};
|
||||
const old = migrated.controlCenter.modules, modules = [];
|
||||
for (const m of old) {
|
||||
if (!m || !parts[m.id]) {
|
||||
modules.push(m);
|
||||
continue;
|
||||
}
|
||||
for (const id of parts[m.id])
|
||||
if (!old.some(o => o && o.id === id) && !modules.some(o => o && o.id === id))
|
||||
modules.push({id: id, enabled: m.enabled});
|
||||
}
|
||||
if (old.length && !modules.some(m => m && m.id === "caffeine"))
|
||||
modules.push({id: "caffeine", enabled: true});
|
||||
migrated.controlCenter = Object.assign({}, migrated.controlCenter, {version: 2, modules: modules});
|
||||
}
|
||||
migrated.schemaVersion = 3;
|
||||
return validate(merge(defaults, migrated));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user