Add an Emoji Picker as a launcher mode with a searchable grid

The launcher gains an emoji mode like Clipboard History: >emoji switches in
place without closing or animating, and glassmxrph emoji toggles it. Emoji
show as a grid instead of named rows; the selected or hovered emoji's name is
the section label. Search requires every term and ranks name matches before
keyword matches; Enter copies with wl-copy.

assets/emoji.tsv comes from Unicode 17 emoji-test.txt without skin-tone
variants, with keywords from the rofi emopicker list (scripts/emoji-data).
The test driver caps snapshot results, since IPC replies have a size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-15 23:47:14 +02:00
1 parent 29dd64572a
commit b3076a4cde
13 files changed
+2220 -29

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""Real Wayland Emoji Picker test on a private session bus.
Copying is global on Wayland, so the user's clipboard is saved and restored.
Run: dbus-run-session -- python3 tests/emoji_runtime.py [screenshot-dir]"""
import json,os,subprocess,sys,tempfile,time
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
BASE=['quickshell','ipc','--path',str(ROOT/'quickshell'),'call']
SHOTS=Path(sys.argv[1]) if len(sys.argv)>1 else None
Key={'Return':0x01000004,'Right':0x01000014,'Down':0x01000015,'Escape':0x01000000}
def ipc(target,method,*args):
r=subprocess.run(BASE+[target,method,*map(str,args)],capture_output=True,text=True)
out=r.stdout.strip()
if r.returncode or not out:return None
try:return json.loads(out)
except ValueError:return out
def snap():return ipc('launcherTest','snapshot') or {}
def wait(check,label,timeout=10):
end=time.monotonic()+timeout
while time.monotonic()<end:
try:
if check():return
except (TypeError,KeyError,ValueError,IndexError):pass
time.sleep(.08)
raise AssertionError(label+': '+json.dumps(snap(),ensure_ascii=False)[:600])
def shot(name):
if SHOTS:
time.sleep(.5);SHOTS.mkdir(parents=True,exist_ok=True)
subprocess.run(['grim','-o',snap()['screen'],str(SHOTS/(name+'.png'))],check=False)
def pasted():return subprocess.run(['wl-paste','--no-newline'],capture_output=True,text=True,timeout=5).stdout
if 'DBUS_SESSION_BUS_ADDRESS' not in os.environ or ipc('shell','status'):raise SystemExit('Run in a private dbus-run-session with no instance from this path.')
saved=subprocess.run(['wl-paste','--no-newline'],capture_output=True,timeout=5)
log=ROOT/'.cache/emoji-runtime.log';log.parent.mkdir(exist_ok=True)
total=sum(1 for _ in open(ROOT/'quickshell/assets/emoji.tsv',encoding='utf-8'))
with tempfile.TemporaryDirectory(prefix='glassmxrph-emoji-') as tmp:
env=dict(os.environ,XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state',XDG_CACHE_HOME=tmp+'/cache',GLASSMXRPH_LAUNCHER_TESTING='1',QT_NO_XDG_DESKTOP_PORTAL='1')
Path(tmp,'config/glassMxrph').mkdir(parents=True)
Path(tmp,'config/glassMxrph/config.json').write_text(json.dumps({'schemaVersion':3,'dock':{'enabled':False}}))
with log.open('w') as output:
shell=subprocess.Popen([str(ROOT/'scripts/glassmxrph'),'run'],env=env,stdout=output,stderr=subprocess.STDOUT)
try:
wait(lambda:ipc('shell','status')['ready'],'ready')
ipc('launcher','open');wait(lambda:snap()['opened'] and snap()['focused'],'launcher opens')
time.sleep(.4);before=snap()
ipc('launcherTest','query','>emoji')
wait(lambda:snap()['results'][0]['id']=='emoji','emoji command listed')
ipc('launcherTest','key',Key['Return'])
wait(lambda:snap()['mode']=='emoji' and snap()['resultCount']==total,'command switches to the emoji grid')
s=snap();assert s['opened'] and s['query']=='' and s['focused'],s
assert (s['x'],s['y'],s['width'])==(before['x'],before['y'],before['width']),(before,s)
assert s['results'][0]['id']=='😀' and s['results'][0]['title']=='grinning face',s['results'][0]
time.sleep(.3);shot('1-emoji')
# Six rows visible: the body stops growing past them.
assert abs(s['height']-(60+6*52+42))<=2,s['height']
ipc('launcherTest','key',Key['Right']);ipc('launcherTest','key',Key['Down'])
cols=snap()['selected']-1;assert cols>4,snap()['selected']
ipc('launcherTest','query','heart red')
wait(lambda:snap()['results'][0]['title']=='red heart','search ranks names first')
ipc('launcherTest','query','pizza')
wait(lambda:[r['id'] for r in snap()['results']]==['🍕'],'search filters')
shot('2-search')
ipc('launcherTest','key',Key['Return'])
wait(lambda:not snap()['opened'],'copying closes')
wait(lambda:pasted()=='🍕','emoji copied')
ipc('launcherTest','query','')
ipc('launcher','emoji');wait(lambda:snap()['opened'] and snap()['mode']=='emoji','IPC opens the emoji picker')
ipc('launcherTest','query','flag germany')
wait(lambda:[r['id'] for r in snap()['results']]==['🇩🇪'],'keyword search')
ipc('launcher','emoji');wait(lambda:not snap()['opened'],'IPC toggles it closed')
ipc('launcher','open');wait(lambda:snap()['opened'] and snap()['mode']=='apps','launcher reopens in app mode')
ipc('launcher','close')
print('Emoji picker: >emoji switches in place, grid of six rows, search, copy, IPC toggle passed.')
finally:
shell.terminate()
try:shell.wait(5)
except subprocess.TimeoutExpired:shell.kill()
if saved.returncode==0:
restore=subprocess.Popen(['wl-copy'],stdin=subprocess.PIPE,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True)
restore.stdin.write(saved.stdout);restore.stdin.close()
+1 -1
View File
@@ -112,7 +112,7 @@ Terminal={'true' if suffix=='Terminal' else 'false'}
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')
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','emoji'},'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)