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:
mxandClaude Opus 5.5 committed 2026-10-17 20:52:14 +02:00
1 parent 0dcf37346c
commit 11bdc4c751
32 files changed
+2147 -355

No files matched your search

+8 -3
View File
@@ -70,11 +70,16 @@ console.log('Phase 5 preference merging, validation and immutable bar editing/re
assert.throws(() => api.update(phase5, 'bar.modules', {}), /must be an array/);
assert.equal(api.update(phase5, 'bar.modules', [{id:'nowPlaying',position:'right',enabled:true}]).bar.modules[0].id, 'nowPlaying');
const phase7=api.load(defaults,{schemaVersion:3,controlCenter:{modules:[]},dock:{pinnedApps:['keep.desktop']},future:{keep:true}});
assert.equal(phase7.controlCenter.version,1);assert(phase7.controlCenter.modules.length>0);assert.equal(phase7.dock.pinnedApps[0],'keep.desktop');assert(phase7.future.keep);
assert.equal(phase7.controlCenter.version,2);assert(phase7.controlCenter.modules.length>0);assert.equal(phase7.dock.pinnedApps[0],'keep.desktop');assert(phase7.future.keep);
assert.equal(api.load(defaults,{controlCenter:{version:1,modules:[]}}).controlCenter.modules.length,0);
const customCenter=api.load(defaults,{controlCenter:{modules:[{id:'custom',enabled:false,metadata:'preserved'}]}});
assert.equal(customCenter.controlCenter.modules[0].metadata,'preserved');assert.equal(customCenter.controlCenter.modules.length,1);
for(const controlCenter of [{version:2},{version:1,width:100},{version:1,modules:[{id:'audio',enabled:true},{id:'audio',enabled:false}]}])assert.throws(()=>api.load(defaults,{controlCenter}));
assert.equal(customCenter.controlCenter.modules[0].metadata,'preserved');assert.equal(customCenter.controlCenter.modules.map(m=>m.id).join(),'custom,caffeine');
for(const controlCenter of [{version:3},{version:1,width:100},{version:2,modules:[{id:'output',enabled:true},{id:'output',enabled:false}]},{version:2,modules:[{id:'wifi',enabled:true,w:5}]},{version:2,modules:[{id:'wifi',enabled:true,h:0}]},{version:2,modules:[{id:'wifi',enabled:true,w:1.5}]}])assert.throws(()=>api.load(defaults,{controlCenter}));
// Version 1 splits the combined cards in place, keeps enabled state and offers Caffeine.
const v1=api.load(defaults,{controlCenter:{version:1,modules:[{id:'connectivity',enabled:true},{id:'media',enabled:true},{id:'audio',enabled:false},{id:'notifications',enabled:true}]}}).controlCenter;
assert.equal(v1.version,2);assert.equal(v1.modules.map(m=>m.id+':'+m.enabled).join(),'wifi:true,bluetooth:true,network:true,media:true,output:false,input:false,notifications:true,caffeine:true');
assert.equal(JSON.stringify(api.load(defaults,{controlCenter:{version:2,modules:[{id:'wifi',enabled:true,w:4,h:1}]}}).controlCenter.modules),'[{"id":"wifi","enabled":true,"w":4,"h":1}]');
assert.equal(api.load(defaults,{controlCenter:{version:2,modules:[]}}).controlCenter.modules.length,0);
for(const system of [{brightness:{setCommand:'sh -c'}},{nightLight:{temperature:0}},{power:{lockCommand:['']}}])assert.throws(()=>api.load(defaults,{system}));
console.log('Phase 7 one-time module migration, intentional empty layouts, provider validation and preservation passed.');
+42
View File
@@ -0,0 +1,42 @@
const assert = require('assert'), fs = require('fs'), path = require('path'), vm = require('vm');
const api = vm.createContext({});
vm.runInContext(fs.readFileSync(path.join(__dirname, '../quickshell/controlcenter/GridLogic.js'), 'utf8'), api);
const ids = plan => plan.items.map(i => i.id + '@' + i.col + ',' + i.row + ':' + i.w + 'x' + i.h).join(' ');
// First fit in list order; small tiles backfill gaps beside larger ones.
let plan = api.pack([{id: 'wifi', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'bt', w: 1, h: 1}, {id: 'dnd', w: 1, h: 1}, {id: 'sound', w: 4, h: 1}]);
assert.equal(ids(plan), 'wifi@0,0:2x1 media@2,0:2x2 bt@0,1:1x1 dnd@1,1:1x1 sound@0,2:4x1');
assert.equal(plan.rows, 3);
plan = api.pack([{id: 'a', w: 3, h: 1}, {id: 'b', w: 2, h: 1}, {id: 'c', w: 1, h: 1}]);
assert.equal(ids(plan), 'a@0,0:3x1 b@0,1:2x1 c@3,0:1x1');
// Sizes clamp to 1..4 cells.
assert.equal(ids(api.pack([{id: 'x', w: 9, h: 0}, {id: 'y', w: 1.4, h: 4.6}])), 'x@0,0:4x1 y@0,1:1x4');
assert.equal(api.pack([]).rows, 0);
// Hit testing covers spanned cells.
plan = api.pack([{id: 'wifi', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'bt', w: 1, h: 1}]);
assert.equal(api.at(plan, 3, 1).id, 'media');
assert.equal(api.at(plan, 3, 2), null);
// Dragging onto a tile takes its place in either direction; onto itself is a no-op.
const order = ['wifi', 'media', 'bt'];
assert.equal(api.reorder(order, plan, 'bt', 0, 0).join(), 'bt,wifi,media');
assert.equal(api.reorder(order, plan, 'wifi', 0, 1).join(), 'media,bt,wifi');
assert.equal(api.reorder(order, plan, 'wifi', 1, 0).join(), 'wifi,media,bt');
// Empty space puts it after the last tile before that cell.
assert.equal(api.reorder(order, plan, 'wifi', 1, 1).join(), 'media,bt,wifi');
assert.equal(api.reorder(order, plan, 'bt', 0, 5).join(), 'wifi,media,bt');
assert.equal(api.reorder(order, plan, 'nope', 0, 0).join(), order.join());
// Resizing rounds to whole cells within 1..4.
assert.equal(JSON.stringify(api.resize({w: 1, h: 1}, 50, 0, 80, 68, 10)), '{"w":2,"h":1}');
assert.equal(JSON.stringify(api.resize({w: 2, h: 2}, -30, 400, 80, 68, 10)), '{"w":2,"h":4}');
assert.equal(JSON.stringify(api.resize({w: 1, h: 1}, -500, -500, 80, 68, 10)), '{"w":1,"h":1}');
// Geometry: an expanded tile pushes down everything from its bottom row.
plan = api.pack([{id: 'out', w: 2, h: 1}, {id: 'media', w: 2, h: 2}, {id: 'a', w: 1, h: 1}, {id: 'b', w: 4, h: 1}]);
let g = api.geometry(plan, 80, 68, 10);
assert.equal(JSON.stringify(g.tiles.media), '{"x":180,"y":0,"w":170,"h":146}');
assert.equal(g.height, 3 * 78 - 10);
g = api.geometry(plan, 80, 68, 10, {out: 100});
assert.equal(g.tiles.out.h, 68 + 110);
assert.equal(g.tiles.media.y, 0);
assert.equal(g.tiles.a.y, 78 + 110);
assert.equal(g.tiles.b.y, 156 + 110);
assert.equal(g.height, 3 * 78 - 10 + 110);
console.log('Control Center grid packing, hit testing, reordering, resizing and expansion geometry passed.');
+40 -5
View File
@@ -41,6 +41,15 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
assert ipc('controlTest','click','volumeMute');wait(lambda:state()['muted'],'mute click')
assert ipc('controlTest','slider','volumeSlider');wait(lambda:state()['volume']>.6,'volume slider')
assert ipc('controlTest','click','microphoneMute');wait(lambda:state()['microphone'],'microphone click')
# Per-app volume: right click extends Sound with the app streams.
assert ipc('controlTest','rightClick','outputTile');wait(lambda:state()['extras'].get('output',0)>0,'Sound extends')
time.sleep(.4)
t=next(i for i in state()['tiles'] if i['id']=='input');assert t['row']>0
assert ipc('controlTest','slider','appSlider-Fixture player');wait(lambda:state()['streamVolume']>.6,'app volume slider')
assert ipc('controlTest','click','appMute-Fixture player');wait(lambda:state()['streamMuted'],'app mute')
assert ipc('controlTest','rightClick','outputTile');wait(lambda:not state()['extras'].get('output',0),'Sound folds back')
assert ipc('controlTest','click','caffeineToggle');wait(lambda:state()['caffeine'] and state()['caffeineRunning'],'Caffeine on')
assert ipc('controlTest','click','caffeineToggle');wait(lambda:not state()['caffeine'] and not state()['caffeineRunning'],'Caffeine off')
assert ipc('controlTest','click','wifiToggle');wait(lambda:not state()['wifi'],'Wi-Fi toggle')
assert ipc('controlTest','click','bluetoothToggle');wait(lambda:not state()['bluetooth'],'Bluetooth toggle')
assert ipc('controlTest','click','bluetoothToggle')
@@ -84,12 +93,38 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'reduced motion close')
pref('animation.reducedMotion',False)
ipc('controlcenter','open');ipc('launcher','open');wait(lambda:not ipc('controlcenter','status')['opened'],'launcher exclusivity');ipc('launcher','close')
# Edit mode: drag to reorder, resize from the handle, remove and add, Escape leaves it.
ipc('controlcenter','open');wait(lambda:state()['windowVisible'],'reopen for editing');time.sleep(.4)
assert ipc('controlTest','click','controlEdit');wait(lambda:state()['editing'],'edit mode')
time.sleep(.6);assert ipc('controlTest','screenshot',str(ROOT/'.cache/controlcenter-editing.png'))
s=state();tiles={t['id']:t for t in s['tiles']};step=s['cellWidth']+10
bt,wifi=tiles['bluetooth'],tiles['wifi']
assert ipc('controlTest','drag','controlMove-bluetooth',(wifi['col']-bt['col'])*step,(wifi['row']-bt['row'])*78)
ids=lambda:[m['id'] for m in state()['modules']]
wait(lambda:ids().index('bluetooth')<ids().index('wifi'),'drag reorders')
time.sleep(.3)
assert ipc('controlTest','drag','controlResize-wifi',step,78)
wait(lambda:any(m['id']=='wifi' and m.get('w')==3 and m.get('h')==2 for m in state()['modules']),'resize to 3x2')
assert next(t for t in state()['tiles'] if t['id']=='wifi')['w']==3
assert ipc('controlTest','click','controlRemove-dnd')
wait(lambda:not next(m for m in state()['modules'] if m['id']=='dnd')['enabled'],'remove badge')
assert not any(t['id']=='dnd' for t in state()['tiles'])
assert ipc('controlTest','click','controlAdd-dnd')
wait(lambda:any(t['id']=='dnd' for t in state()['tiles']),'add from tray')
ipc('controlTest','pressEscape');wait(lambda:not state()['editing'],'Escape leaves edit mode')
assert ipc('controlcenter','status')['opened']
time.sleep(.6);assert ipc('controlTest','screenshot',str(ROOT/'.cache/controlcenter-edited.png'))
assert ipc('controlTest','click','controlEdit');wait(lambda:state()['editing'],'edit mode again')
assert ipc('controlTest','click','controlReset')
wait(lambda:all('w' not in m for m in state()['modules']) and ids()[0]=='wifi','reset layout')
assert ipc('controlTest','click','controlEdit');wait(lambda:not state()['editing'],'done')
ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'close after editing')
ipc('shell','openSettings','controlcenter');wait(lambda:state()['settingsVisible'],'module editor opens');time.sleep(.3)
second=state()['modules'][1]['id']
assert ipc('controlTest','settingsDrag','control-drag-connectivity','control-drag-'+second)
wait(lambda:state()['modules'][1]['id']=='connectivity','visual module reorder')
assert ipc('controlTest','settingsClick','control-enable-audio')
wait(lambda:not next(m for m in state()['modules'] if m['id']=='audio')['enabled'],'visual module toggle')
assert ipc('controlTest','settingsDrag','control-drag-wifi','control-drag-'+second)
wait(lambda:state()['modules'][1]['id']=='wifi','visual module reorder')
assert ipc('controlTest','settingsClick','control-enable-output')
wait(lambda:not next(m for m in state()['modules'] if m['id']=='output')['enabled'],'visual module toggle')
ipc('shell','close');wait(lambda:not state()['settingsVisible'],'settings closes')
for page in ['controlcenter','audio','network','bluetooth','displays','notifications','power']:
ipc('shell','openSettings',page);time.sleep(.3)
@@ -101,4 +136,4 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-controls-') as tmp:
shell.terminate();shell.wait(timeout=5)
if original:subprocess.run(['hyprctl','dispatch','focusmonitor',original],capture_output=True)
text=log.read_text();assert 'WARN' not in text and 'ERROR' not in text,text
print('PASS: native read-only discovery, active-monitor placement, system pill, recording audio/network/Bluetooth/display/DND actions, power confirmation/cancel, outside/Escape/exclusivity, settings, clean logs.')
print('PASS: native read-only discovery, active-monitor placement, system pill, recording audio/per-app volume/Caffeine/network/Bluetooth/display/DND actions, grid edit mode (drag, resize, remove, add, reset), power confirmation/cancel, outside/Escape/exclusivity, settings, clean logs.')