Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
8.4 KiB
Python
150 lines
8.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Opt-in live Hyprland dock test. Uses temporary preferences and disposable windows."""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import time
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
BASE=['quickshell','ipc','--path',str(ROOT/'quickshell'),'call']
|
|
FIXTURE=ROOT/'tests/dock-fixture'
|
|
IDENT='org.glassMxrph.DockFixture'
|
|
OTHER=IDENT+'Other'
|
|
def ipc(target,method,*args):
|
|
result=subprocess.run(BASE+[target,method,*map(str,args)],capture_output=True,text=True)
|
|
return json.loads(result.stdout) if result.returncode==0 and result.stdout.strip() else None
|
|
|
|
def eventually(check,label,timeout=8):
|
|
end=time.monotonic()+timeout
|
|
while time.monotonic()<end:
|
|
try:
|
|
if check():return
|
|
except (ValueError,KeyError,TypeError,IndexError,AttributeError,FileNotFoundError):pass
|
|
time.sleep(.08)
|
|
raise AssertionError(label+': '+str(ipc('dock','status')))
|
|
|
|
def pref(key,value):
|
|
assert ipc('shell','setPreference','dock.'+key,json.dumps(value)),key
|
|
|
|
def fixture_call(method,*args):
|
|
result=subprocess.run(['quickshell','ipc','--path',str(FIXTURE),'call','fixture',method,*map(str,args)],capture_output=True,text=True)
|
|
assert result.returncode==0,result.stderr
|
|
|
|
def item():return next(i for i in ipc('dock','status')['items'] if i['id']==IDENT)
|
|
def menu():return ipc('dockTest','rows') or []
|
|
|
|
if ipc('shell','status'):
|
|
raise SystemExit('An instance already uses this source path. Test an isolated copy; do not stop a live shell.')
|
|
log=ROOT/'.cache/dock-runtime.log';log.parent.mkdir(exist_ok=True)
|
|
with tempfile.TemporaryDirectory(prefix='glassmxrph-dock-') as tmp:
|
|
temp=Path(tmp);apps=temp/'data/applications';apps.mkdir(parents=True)
|
|
eventfile=temp/'events';helper=temp/'launch.py'
|
|
helper.write_text('import pathlib,sys\nwith pathlib.Path(sys.argv[1]).open("a") as f:f.write(sys.argv[2]+"\\n")\n')
|
|
for ident in [IDENT,OTHER]:
|
|
(apps/(ident+'.desktop')).write_text(f'''[Desktop Entry]
|
|
Type=Application
|
|
Name=Dock Fixture {ident[-5:]}
|
|
Exec=python3 {helper} {eventfile} open
|
|
Icon=preferences-system
|
|
StartupWMClass={ident}
|
|
Actions=NewWindow;
|
|
|
|
[Desktop Action NewWindow]
|
|
Name=New Test Window
|
|
Exec=python3 {helper} {eventfile} action
|
|
''')
|
|
env=dict(os.environ,XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state',XDG_DATA_HOME=tmp+'/data',GLASSMXRPH_DOCK_TESTING='1',QT_QPA_PLATFORMTHEME='',QT_NO_XDG_DESKTOP_PORTAL='1')
|
|
cfg=temp/'config/glassMxrph/config.json';cfg.parent.mkdir(parents=True)
|
|
cfg.write_text(json.dumps({'schemaVersion':3,'dock':{'showRunningApps':False,'pinnedApps':[IDENT+'.desktop',OTHER+'.desktop']}}))
|
|
shell=fixture=None
|
|
try:
|
|
with log.open('w') as out:
|
|
shell=subprocess.Popen([str(ROOT/'scripts/glassmxrph'),'run'],env=env,stdout=out,stderr=subprocess.STDOUT)
|
|
eventually(lambda:ipc('shell','status')['ready'],'config ready')
|
|
eventually(lambda:len(ipc('dockTest','snapshot')['icons'])==2,'pinned icons')
|
|
assert item()['running']==0 and item()['matched']
|
|
assert ipc('dockTest','click',IDENT,1)
|
|
eventually(lambda:'open' in eventfile.read_text(),'launch desktop entry')
|
|
assert ipc('dockTest','click',IDENT,2)
|
|
eventually(lambda:ipc('dock','status')['opened'],'context menu')
|
|
ipc('launcher','open')
|
|
eventually(lambda:not ipc('dock','status')['opened'] and ipc('launcher','status')['opened'],'launcher closes dock popup')
|
|
ipc('launcher','close')
|
|
time.sleep(.3)
|
|
assert ipc('dockTest','click',IDENT,2)
|
|
eventually(lambda:ipc('dock','status')['opened'],'reopen after launcher')
|
|
eventually(lambda:any(r['id']=='action:NewWindow' for r in menu()),'advertised action')
|
|
time.sleep(.3)
|
|
assert ipc('dockTest','row','action:NewWindow')
|
|
eventually(lambda:'action' in eventfile.read_text(),'desktop action invocation')
|
|
assert ipc('dockTest','drag',IDENT,OTHER)
|
|
eventually(lambda:ipc('dock','status')['items'][0]['id']==OTHER,'drag reorder')
|
|
eventually(lambda:json.loads(cfg.read_text())['dock']['pinnedApps'][0]==OTHER+'.desktop','pin order persisted')
|
|
assert ipc('dock','move',IDENT,OTHER)
|
|
fixture=subprocess.Popen(['quickshell','--path',str(FIXTURE)],env=env,stdout=out,stderr=subprocess.STDOUT)
|
|
eventually(lambda:item()['running']==1,'native window matching')
|
|
assert ipc('dockTest','click',IDENT,1)
|
|
eventually(lambda:item()['focused'],'single window focus')
|
|
fixture_call('two')
|
|
eventually(lambda:item()['running']==2,'group multiple windows')
|
|
assert ipc('dockTest','click',IDENT,1)
|
|
eventually(lambda:ipc('dock','status')['chooser'] and len(menu())==2,'window chooser')
|
|
time.sleep(.3)
|
|
first=menu()[0]['id'];assert ipc('dockTest','row',first)
|
|
eventually(lambda:any(w['address']==first[6:] and w['active'] for w in ipc('dockTest','snapshot')['windows']),'chooser focus')
|
|
assert ipc('dockTest','click',IDENT,2)
|
|
eventually(lambda:ipc('dock','status')['opened'] and any(r['id']=='unpin' for r in menu()),'app context')
|
|
time.sleep(.3)
|
|
close=next(r['id'] for r in menu() if r['id'].startswith('close:'))
|
|
assert ipc('dockTest','row',close)
|
|
eventually(lambda:item()['running']==1,'close requested window')
|
|
assert ipc('dockTest','click',IDENT,2)
|
|
eventually(lambda:ipc('dock','status')['opened'],'reopen menu')
|
|
time.sleep(.3);ipc('dockTest','pressEscape')
|
|
eventually(lambda:not ipc('dock','status')['opened'],'Escape dismiss')
|
|
ipc('shell','openSettings','dock')
|
|
eventually(lambda:ipc('shell','status')['settingsOpen'],'dock settings')
|
|
time.sleep(.4);ipc('shell','close')
|
|
pref('visibility','auto');ipc('dockTest','hover','false')
|
|
eventually(lambda:not ipc('dock','status')['docks'][0]['shown'],'auto hide')
|
|
assert ipc('dockTest','hover','true')
|
|
eventually(lambda:ipc('dock','status')['docks'][0]['shown'],'edge reveal')
|
|
ipc('dockTest','hover','false')
|
|
pref('monitor',ipc('dockTest','snapshot')['windows'][0]['monitor'])
|
|
fixture_call('hide')
|
|
pref('visibility','intelligent')
|
|
time.sleep(1)
|
|
baseline=ipc('dock','status')['docks'][0]['overlap']
|
|
fixture_call('fullscreen','true')
|
|
eventually(lambda:ipc('dock','status')['docks'][0]['overlap'] and not ipc('dock','status')['docks'][0]['shown'],'intelligent hide behind fullscreen window')
|
|
fixture_call('hide')
|
|
eventually(lambda:ipc('dock','status')['docks'][0]['overlap']==baseline and ipc('dock','status')['docks'][0]['shown']!=baseline,'intelligent visibility returns to existing-window baseline')
|
|
pref('visibility','always');pref('magnification',False)
|
|
screens=ipc('dockTest','screens')
|
|
for screen in screens:
|
|
pref('monitor',screen)
|
|
for edge in ['bottom','left','right']:
|
|
pref('position',edge)
|
|
eventually(lambda:ipc('dock','status')['docks'][0]['screen']==screen and ipc('dock','status')['docks'][0]['position']==edge,'monitor/edge placement')
|
|
time.sleep(.15)
|
|
pref('position','bottom');pref('monitor','primary')
|
|
assert ipc('dockTest','screenshot',str(ROOT/'.cache/dock-preview.png'))
|
|
pref('enabled',False)
|
|
eventually(lambda:not ipc('dock','status')['docks'],'disable dock')
|
|
pref('enabled',True)
|
|
eventually(lambda:len(ipc('dock','status')['docks'])==1,'enable dock')
|
|
assert ipc('dockTest','click',OTHER,2)
|
|
eventually(lambda:ipc('dock','status')['opened'],'unpin context menu')
|
|
time.sleep(.3)
|
|
assert ipc('dockTest','row','unpin')
|
|
eventually(lambda:len(ipc('dock','status')['items'])==1,'unpin')
|
|
finally:
|
|
for process in [fixture,shell]:
|
|
if process and process.poll() is None:
|
|
process.terminate();process.wait(timeout=5)
|
|
text=log.read_text()
|
|
assert 'WARN' not in text and 'ERROR' not in text,text
|
|
print('PASS: native desktop launch/actions, pin drag/persistence, real window matching/focus/chooser/close, Escape, settings, auto and intelligent hide/reveal, every output/edge, enable/disable, clean logs.')
|