install.sh: rebind ALT+SHIFT+V in bindings.lua (the live Quattro config), not just legacy bindings.conf

This commit is contained in:
2026-09-05 23:16:20 +01:00
parent 6da0c42847
commit c48c10b3ec
6 changed files with 156 additions and 9 deletions
+29
View File
@@ -16,6 +16,7 @@ binary payloads are skipped silently.
import hashlib
import json
import os
import shutil
import subprocess
import sys
import tempfile
@@ -119,6 +120,10 @@ def capture_image(types, app):
if qr:
entry["qr"] = qr
ocr = decode_ocr(path, os.environ.get("CLIPBOARD_OCR_LANG", "eng"))
if ocr:
entry["ocr"] = ocr
emit(entry)
return True
@@ -143,6 +148,30 @@ def decode_text(data):
return text
def decode_ocr(path, lang):
"""Recognize text in an image with tesseract; None when unavailable/binary."""
if os.environ.get("CLIPBOARD_OCR", "1") == "0":
return None
# Tesseract is optional — degrade to no-OCR when missing.
if shutil.which("tesseract") is None:
return None
try:
r = subprocess.run(
["tesseract", path, "stdout", "-l", lang, "--quiet"],
capture_output=True, timeout=30
)
if r.returncode != 0:
return None
text = r.stdout.decode("utf-8", "replace")
# Collapse tesseract's whitespace so the stored haystack stays dense.
text = "\n".join(line.strip() for line in text.splitlines()
if line.strip())
text = text.strip()
return text[:4000] or None
except Exception:
return None
def capture_uri_list(types, app):
if "text/uri-list" not in types:
return False