#!/usr/bin/env python3
"""Stub for qdbus6: records Klipper setClipboardContents calls, the way
Frame Control sends text to the headset desktop's clipboard (server.PASTE,
verified 2026-09-25)."""
import os
import sys

sys.path.insert(0, '/usr/local/lib/fakeframe')
import fakeframe_state as fs  # noqa: E402

args = sys.argv[1:]
fs.log('qdbus6', args=args[:3], bus=os.environ.get('DBUS_SESSION_BUS_ADDRESS'))
if args[:3] == ['org.kde.klipper', '/klipper', 'org.kde.klipper.klipper.setClipboardContents'] and len(args) == 4:
    if not os.environ.get('DBUS_SESSION_BUS_ADDRESS'):
        sys.exit('Could not connect to D-Bus server')
    with fs.update() as s:
        s['clipboard'].append(args[3])
else:
    sys.exit(f'qdbus6 stub: unsupported {args}')
