#!/usr/bin/env python3 """Real Wayland/read-only native discovery, then recording adapters for all writes.""" import json,os,subprocess,tempfile,time from pathlib import Path ROOT=Path(__file__).resolve().parents[1] BASE=['quickshell','ipc','--path',str(ROOT/'quickshell'),'call'] def ipc(target,method,*args): r=subprocess.run(BASE+[target,method,*map(str,args)],capture_output=True,text=True) return json.loads(r.stdout) if r.returncode==0 and r.stdout.strip() else None def state():return ipc('controlTest','snapshot') or {} def wait(check,label): end=time.monotonic()+15 while time.monotonic()s['screenWidth']/2 and s['x']+s['width']<=s['screenWidth'] and s['y']+s['height']<=s['screenHeight'] wait(lambda:ipc('controlTest','inject'),'inject recording adapters') wait(lambda:not state()['busy'] and state()['state']['brightness']['available'],'fixture providers') 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) assert state()['streams']==['Fixture player'],'only playback streams are listed: '+str(state()['streams']) 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') assert ipc('controlTest','connectFixtures') for name,key in [('nightLightToggle','nightLight'),('dndToggle','dnd')]: assert ipc('controlTest','click',name) wait(lambda:not state()['busy'] and state()['state'][key]['enabled'],key+' readback') failure=events.with_suffix('.fail');failure.touch() assert ipc('controlTest','click','dndToggle') wait(lambda:not state()['busy'] and bool(state()['error']),'provider error') assert state()['state']['dnd']['enabled'] and ipc('controlTest','checked','dndToggle'),'Failed request changed displayed real state' assert ipc('controlTest','slider','brightnessSlider') wait(lambda:not state()['busy'] and bool(state()['error']),'brightness error') assert ipc('controlTest','value','brightnessSlider')==state()['state']['brightness']['value'],'Failed brightness request changed display' failure.unlink();assert ipc('controlTest','click','dndToggle') wait(lambda:not state()['busy'] and not state()['error'] and not state()['state']['dnd']['enabled'],'provider recovery') assert ipc('controlTest','slider','brightnessSlider') wait(lambda:not state()['busy'] and state()['state']['brightness']['value']>60,'brightness readback') assert ipc('controlTest','click','power-reboot');assert state()['power']=='reboot' assert not any(json.loads(line)['action']=='power' for line in events.read_text().splitlines()) assert ipc('controlTest','click','powerCancel');assert state()['power']=='' assert ipc('controlTest','click','power-shutdown');ipc('controlTest','pressEscape');wait(lambda:state()['power']=='','Escape cancels pending power') assert ipc('controlcenter','status')['opened'] assert ipc('controlTest','click','power-reboot');assert ipc('controlTest','click','powerConfirm') wait(lambda:not state()['busy'],'recorded confirmation') actions=[json.loads(line) for line in events.read_text().splitlines()] power=[a for a in actions if a['action']=='power'];assert len(power)==1 and power[0]['value']=='reboot' and power[0]['confirmed'] is True ipc('controlcenter','close');time.sleep(.3);ipc('controlcenter','open');time.sleep(.35) assert ipc('controlTest','screenshot',str(ROOT/'.cache/controlcenter-preview.png')) ipc('controlTest','outside');wait(lambda:not state()['windowVisible'],'outside closes') for monitor in monitors: subprocess.run(['hyprctl','dispatch','focusmonitor',monitor['name']],check=True,capture_output=True) wait(lambda:state()['active']==monitor['name'],'active monitor event') ipc('controlcenter','open');wait(lambda:state()['windowVisible'],'mapped on output');time.sleep(.3) assert ipc('controlcenter','status')['screen']==monitor['name'] s=state();assert s['x']>=0 and s['x']+s['width']<=s['screenWidth'] and s['y']+s['height']<=s['screenHeight'] ipc('controlcenter','close');wait(lambda:not state()['windowVisible'],'close before monitor switch') pref('animation.reducedMotion',True) for _ in range(3): ipc('controlcenter','open');wait(lambda:state()['windowVisible'],'reduced motion open') 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')