#!/usr/bin/env python3 """Opt-in live launcher test. Temporary desktop entries/preferences; no real apps launched.""" 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'] ESC,DOWN,UP,ENTER=0x01000000,0x01000015,0x01000013,0x01000004 def ipc(target,method,*args): p=subprocess.run(BASE+[target,method,*map(str,args)],capture_output=True,text=True) return json.loads(p.stdout) if p.returncode==0 and p.stdout.strip() else None def eventually(check,label,timeout=8): end=time.monotonic()+timeout while time.monotonic()') eventually(lambda:{r['id'] for r in snapshot()['results']}=={'about','appearance','audio','bar','tray','bluetooth','controlcenter','display','dock','launcher','media','metrics','network','notifications','power','wallpaper','widgets','osd','lock','dashboard','plugins'},'all commands registered') time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png')) for text,page in [('>metrics','metrics'),('>wall','wallpaper'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]: query(text) ipc('launcherTest','key',ENTER) eventually(lambda:ipc('shell','status')['settingsOpen'] and ipc('shell','status')['settingsPage']==page,'command destination '+page) assert not snapshot()['opened'] open_launcher() assert not ipc('shell','status')['settingsOpen'] query('>command-that-does-not-exist') assert not snapshot()['results'] ipc('launcherTest','key',ENTER);assert snapshot()['opened'] assert ipc('launcherTest','extension','true') assert not ipc('launcherTest','extension','true'),'Duplicate command accepted' query('>fixture');ipc('launcherTest','key',ENTER) eventually(lambda:ipc('shell','status')['settingsPage']=='about','extension execution') ipc('launcherTest','extension','false');ipc('shell','close') # Reduced motion and rapid reversals must settle without hidden keyboard grabs. assert ipc('shell','setPreference','animation.reducedMotion','true') for _ in range(6):ipc('launcher','toggle') eventually(lambda:not snapshot()['opened'] and not snapshot()['visible'],'rapid toggle settles') open_launcher();assert centered() ipc('shell','close') eventually(lambda:not snapshot()['opened'],'shared close IPC') finally: if shell and shell.poll() is None: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: centered active-monitor placement, keyboard/text/mouse input, fuzzy/keyword search, NoDisplay filtering, native launch/errors, all commands and extension lifecycle, settings routes, outside/Escape, reduced motion, rapid toggles, clean logs.')