diff options
| author | auric <104602845+ihateamongus@users.noreply.github.com> | 2025-09-11 15:14:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-11 15:14:27 -0500 |
| commit | 8245aa3b9fbd8a2bf271133f9fbdc2ca45b221c9 (patch) | |
| tree | 0ab78ec4155721ae8571fdcac435c9b84e232ca9 /browsers/firefox/accent_host.py | |
| parent | 2d10fcf6bb85732819385f20a9bc13c50036c0f7 (diff) | |
| parent | 6207d8a75e40aa76008edaffbbe138bbc9f6baa4 (diff) | |
Merge pull request #33 from ihateamongus/codex/explore-dynamic-accent-color-support
Add dynamic browser accent color experiment
Diffstat (limited to 'browsers/firefox/accent_host.py')
| -rwxr-xr-x | browsers/firefox/accent_host.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/browsers/firefox/accent_host.py b/browsers/firefox/accent_host.py new file mode 100755 index 0000000..ec0a166 --- /dev/null +++ b/browsers/firefox/accent_host.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +import json +import os +import struct +import subprocess +import sys + +def send(msg): + data = json.dumps(msg).encode('utf-8') + sys.stdout.buffer.write(struct.pack('I', len(data))) + sys.stdout.buffer.write(data) + sys.stdout.buffer.flush() + +def read(): + raw = sys.stdin.buffer.read(4) + if len(raw) == 0: + return None + length = struct.unpack('I', raw)[0] + return json.loads(sys.stdin.buffer.read(length).decode('utf-8')) + +def get_accent(): + try: + helper = os.path.join(os.path.dirname(__file__), '..', 'getaccent') + color = subprocess.check_output([helper], stderr=subprocess.DEVNULL).decode().strip() + if color: + return color + except Exception: + pass + return '#000000' + +while True: + msg = read() + if msg is None: + break + if msg.get('query') == 'color': + send({'color': get_accent()}) |
