#!/usr/bin/env python3 """Real Wayland notification test on a private session bus (the user's daemon is untouched). Run inside one: dbus-run-session -- python3 tests/notifications_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 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 status():return ipc('notifications','status') or {} def wait(check,label,timeout=15): end=time.monotonic()+timeout while time.monotonic()noon? The usual place.') wait(lambda:status()['count']==1 and status()['popups']==1,'banner shown') shot('1-banner') notify('-a','Chat','Ada','Did you see the build?') notify('-a','Chat','Grace','Ship it 🚀') notify('-a','Chat','Linus','One more thing…') notify('-u','critical','-a','Battery','Battery low','5% remaining') wait(lambda:status()['count']==5,'history keeps everything') wait(lambda:status()['popups']==3,'banner stack capped at maxPopups') shot('2-stack') # Non-critical banners time out into history; the critical one stays. wait(lambda:status()['popups']==1,'banners expire',timeout=10) assert status()['count']==5 groups={g['app']:g['count'] for g in status()['groups']} assert groups=={'Mail':1,'Chat':3,'Battery':1},groups ipc('controlcenter','open') wait(lambda:ipc('controlcenter','status')['opened'],'control center opens') wait(lambda:status()['popups']==0,'opening Control Center clears banners') shot('3-controlcenter') ipc('controlcenter','close') assert ipc('notifications','setDnd','true') wait(lambda:status()['dnd'],'dnd on') notify('-a','Mail','Quiet','Should not pop up') wait(lambda:status()['count']==6,'dnd still records') time.sleep(.5);assert status()['popups']==0,'dnd suppresses banners' notify('-u','critical','-a','Alarm','Wake up','Critical breaks through') wait(lambda:status()['popups']==1,'critical alerts break through dnd') ipc('notifications','setDnd','false');ipc('notifications','dismiss') wait(lambda:status()['popups']==0 and status()['count']==7,'dismiss hides banners but keeps history') ipc('notifications','clear') wait(lambda:status()['count']==0,'clear empties history') wait(lambda:json.loads(cfg.read_text())['notifications']['doNotDisturb'] is False,'dnd persisted') print('Notification server, banners, stacking, expiry, DND, Control Center grouping and clearing passed.') finally: shell.terminate() try:shell.wait(5) except subprocess.TimeoutExpired:shell.kill()