The launcher gains a clipboard mode with the same bar, position and size: the latest five entries show at once and the rest scroll, search filters in recency order, Enter copies, Shift+Delete removes an entry. >clipboard switches in place without closing or animating; glassmxrph clipboard toggles it directly. History stays with the user's cliphist watcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
149 lines
9.5 KiB
Python
149 lines
9.5 KiB
Python
#!/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()<end:
|
|
try:
|
|
if check():return
|
|
except (ValueError,KeyError,TypeError,AttributeError,IndexError,FileNotFoundError):pass
|
|
time.sleep(.06)
|
|
raise AssertionError(label+': '+str(ipc('launcherTest','snapshot')))
|
|
|
|
def snapshot():return ipc('launcherTest','snapshot') or {}
|
|
def open_launcher():
|
|
ipc('launcher','open')
|
|
eventually(lambda:snapshot()['opened'] and snapshot()['focused'],'launcher focused')
|
|
# Spotlight style: opens as the bare search bar, listing nothing until typing or browsing.
|
|
eventually(lambda:abs(snapshot()['width']-680)<1 and abs(snapshot()['height']-60)<1 and not snapshot()['results'],'animation complete')
|
|
|
|
def query(text):
|
|
ipc('launcherTest','query',text)
|
|
eventually(lambda:snapshot()['query']==text,'query')
|
|
|
|
def centered():
|
|
# Spotlight placement: horizontally centred, top edge in the upper third.
|
|
s=snapshot()
|
|
return abs(s['x']+s['width']/2-s['screenWidth']/2)<1 and abs(s['y']-round(s['screenHeight']*0.22))<1
|
|
|
|
if ipc('shell','status'):
|
|
raise SystemExit('This source path is already running. Use an isolated copy; do not replace the active shell.')
|
|
log=ROOT/'.cache/launcher-runtime.log';log.parent.mkdir(exist_ok=True)
|
|
monitors=json.loads(subprocess.check_output(['hyprctl','monitors','-j'],text=True))
|
|
original=next((m['name'] for m in monitors if m['focused']),None)
|
|
with tempfile.TemporaryDirectory(prefix='glassmxrph-launcher-') as tmp:
|
|
temp=Path(tmp);apps=temp/'data/applications';apps.mkdir(parents=True)
|
|
events=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 suffix in ['Alpha','Beta','Hidden','Terminal']:
|
|
(apps/f'org.glassMxrph.LauncherFixture{suffix}.desktop').write_text(f'''[Desktop Entry]
|
|
Type=Application
|
|
Name=GlassMxrph Fixture {suffix}
|
|
GenericName=Launcher test application
|
|
Keywords=gmxbrush;painting;
|
|
Exec=python3 {helper} {events} {suffix}
|
|
NoDisplay={'true' if suffix=='Hidden' else 'false'}
|
|
Terminal={'true' if suffix=='Terminal' else 'false'}
|
|
''')
|
|
cfg=temp/'config/glassMxrph/config.json';cfg.parent.mkdir(parents=True)
|
|
# Hermetic: never scan the user's wallpaper folders (and their image formats).
|
|
cfg.write_text(json.dumps({'schemaVersion':3,'dock':{'enabled':False},'wallpaper':{'directories':[str(temp)]}}))
|
|
env=dict(os.environ,XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state',XDG_DATA_HOME=tmp+'/data',GLASSMXRPH_LAUNCHER_TESTING='1',QT_QPA_PLATFORMTHEME='',QT_NO_XDG_DESKTOP_PORTAL='1')
|
|
shell=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')
|
|
for monitor in monitors:
|
|
subprocess.run(['hyprctl','dispatch','focusmonitor',monitor['name']],check=True,capture_output=True)
|
|
# With cursor:no_warps and follow_mouse, focus snaps back to the
|
|
# monitor under the pointer; such monitors cannot be reached here.
|
|
try:eventually(lambda:snapshot()['activeMonitor']==monitor['name'],'Hyprland focus event',timeout=3)
|
|
except AssertionError:
|
|
print('SKIP: cannot focus',monitor['name'],'(pointer-follow focus without cursor warps)');continue
|
|
open_launcher()
|
|
assert snapshot()['screen']==monitor['name'] and centered(),snapshot()
|
|
ipc('launcherTest','outside')
|
|
eventually(lambda:not snapshot()['visible'],'outside dismissal')
|
|
# Shell runner toggles the existing instance, never starts another process.
|
|
subprocess.run([str(ROOT/'scripts/glassmxrph'),'launcher'],env=env,check=True,capture_output=True)
|
|
eventually(lambda:snapshot()['opened'],'runner IPC toggle')
|
|
ipc('launcherTest','typeAscii','glass')
|
|
eventually(lambda:snapshot()['query']=='glass','real keyboard text input')
|
|
query('GlassMxrph Fixture')
|
|
eventually(lambda:len(snapshot()['results'])==3,'NoDisplay excluded')
|
|
assert all(not r['id'].endswith('Hidden') for r in snapshot()['results'])
|
|
assert ipc('launcherTest','hover',0)
|
|
ipc('launcherTest','key',DOWN)
|
|
time.sleep(.3) # Stationary pointer / opening layout must not override selection.
|
|
assert snapshot()['selected']==1, {k:snapshot()[k] for k in ['selected','focused','width','height','query']}
|
|
ipc('launcherTest','key',UP);assert snapshot()['selected']==0
|
|
query('GlassMxrph Fixture Alpha')
|
|
ipc('launcherTest','key',ENTER)
|
|
eventually(lambda:events.exists() and 'Alpha' in events.read_text(),'Enter launches native desktop entry')
|
|
eventually(lambda:not snapshot()['opened'],'launch closes')
|
|
open_launcher();query('gmfxbt')
|
|
eventually(lambda:snapshot()['results'][0]['id'].endswith('Beta'),'fuzzy app match')
|
|
ipc('launcherTest','click',0)
|
|
eventually(lambda:'Beta' in events.read_text(),'pointer launches result')
|
|
open_launcher();query('gmxbrush')
|
|
eventually(lambda:len(snapshot()['results'])==3,'keyword search')
|
|
query('GlassMxrph Fixture Terminal')
|
|
ipc('launcherTest','key',ENTER)
|
|
eventually(lambda:bool(snapshot()['error']) and snapshot()['opened'],'terminal requirement remains visible')
|
|
assert 'Terminal' not in events.read_text()
|
|
# Spotlight: the first Escape clears the query, the next one closes.
|
|
ipc('launcherTest','key',ESC)
|
|
eventually(lambda:snapshot()['query']=='' and snapshot()['opened'],'Escape clears query')
|
|
ipc('launcherTest','key',ESC)
|
|
eventually(lambda:not snapshot()['visible'],'Escape dismiss')
|
|
open_launcher();query('>')
|
|
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','clipboard'},'all commands registered')
|
|
time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png'))
|
|
for text,page in [('>metrics','metrics'),('>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']
|
|
# >wallpaper opens the picker, not its settings page.
|
|
query('>wall');ipc('launcherTest','key',ENTER)
|
|
eventually(lambda:ipc('shell','status')['wallpaperPickerOpen'] and not ipc('shell','status')['settingsOpen'],'wallpaper command opens picker')
|
|
ipc('shell','close');open_launcher()
|
|
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.')
|