From 38a82bc7e3569b7502a652c9f3fea37a017c0ccb Mon Sep 17 00:00:00 2001 From: auric Date: Thu, 11 Sep 2025 18:00:59 -0500 Subject: Remove browsers --- browsers/README.md | 40 -------------------------------- browsers/build.sh | 4 ---- browsers/firefox/accent_host.py | 36 ---------------------------- browsers/firefox/extension/background.js | 34 --------------------------- browsers/firefox/extension/content.js | 15 ------------ browsers/firefox/extension/manifest.json | 22 ------------------ browsers/firefox/install-native-host.sh | 15 ------------ browsers/firefox/update-userchrome.sh | 10 -------- browsers/firefox/userChrome.template.css | 7 ------ browsers/getaccent.c | 13 ----------- 10 files changed, 196 deletions(-) delete mode 100644 browsers/README.md delete mode 100755 browsers/build.sh delete mode 100755 browsers/firefox/accent_host.py delete mode 100644 browsers/firefox/extension/background.js delete mode 100644 browsers/firefox/extension/content.js delete mode 100644 browsers/firefox/extension/manifest.json delete mode 100755 browsers/firefox/install-native-host.sh delete mode 100755 browsers/firefox/update-userchrome.sh delete mode 100644 browsers/firefox/userChrome.template.css delete mode 100644 browsers/getaccent.c diff --git a/browsers/README.md b/browsers/README.md deleted file mode 100644 index 96ddfc3..0000000 --- a/browsers/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Browser Accent Color Experiments - -This directory contains experiments for applying the dynamic accent color -provided by `core/accent.h` to web browsers. - -## Ungoogled-Chromium - -Ungoogled Chromium exposes limited theming hooks and does not support -changing its UI colors at runtime. Applying a dynamic accent color would -require maintaining a custom patch set or an extension that continually -re-themes the browser, which is outside the scope of this repository. - -## Firefox - -Firefox can be themed programmatically. The files here demonstrate two -approaches: - -1. `firefox/update-userchrome.sh` writes a minimal `userChrome.css` using the - current accent color. Run it whenever the accent color changes. -2. `firefox/extension/` contains a small WebExtension and native messaging host - that continuously updates a `--accent-color` CSS variable across all pages. - -To use the extension: - -1. Build the helper program: - - ```sh - ./build.sh - ``` - -2. Register the native messaging host: - - ```sh - firefox/install-native-host.sh - ``` - -3. Load `firefox/extension` as a temporary extension from `about:debugging`. - -These scripts are meant as a starting point for proper browser ricing and can -be adapted to other workflows. diff --git a/browsers/build.sh b/browsers/build.sh deleted file mode 100755 index a57cc54..0000000 --- a/browsers/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -eu -cd "$(dirname "$0")" -cc -Wall -Wextra -std=c99 getaccent.c -o getaccent diff --git a/browsers/firefox/accent_host.py b/browsers/firefox/accent_host.py deleted file mode 100755 index ec0a166..0000000 --- a/browsers/firefox/accent_host.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/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()}) diff --git a/browsers/firefox/extension/background.js b/browsers/firefox/extension/background.js deleted file mode 100644 index df0ee80..0000000 --- a/browsers/firefox/extension/background.js +++ /dev/null @@ -1,34 +0,0 @@ -let port = browser.runtime.connectNative("accent_color"); -let current = null; - -function broadcast(color) { - browser.tabs.query({}).then(tabs => { - for (let tab of tabs) { - browser.tabs.sendMessage(tab.id, {color}).catch(() => {}); - } - }); - browser.theme.update({colors: {toolbar: color}}); -} - -port.onMessage.addListener(msg => { - if (msg.color && msg.color !== current) { - current = msg.color; - broadcast(current); - } -}); - -function poll() { - try { - port.postMessage({query: "color"}); - } catch (e) { - // ignore - } -} -setInterval(poll, 1000); -poll(); - -browser.runtime.onMessage.addListener((msg, sender) => { - if (msg.request === "color") { - return Promise.resolve({color: current}); - } -}); diff --git a/browsers/firefox/extension/content.js b/browsers/firefox/extension/content.js deleted file mode 100644 index 118c7ee..0000000 --- a/browsers/firefox/extension/content.js +++ /dev/null @@ -1,15 +0,0 @@ -function apply(color) { - document.documentElement.style.setProperty("--accent-color", color); -} - -browser.runtime.onMessage.addListener(msg => { - if (msg.color) { - apply(msg.color); - } -}); - -browser.runtime.sendMessage({request: "color"}).then(msg => { - if (msg && msg.color) { - apply(msg.color); - } -}); diff --git a/browsers/firefox/extension/manifest.json b/browsers/firefox/extension/manifest.json deleted file mode 100644 index abcbe08..0000000 --- a/browsers/firefox/extension/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "manifest_version": 2, - "name": "Accent Color Updater", - "version": "0.1", - "description": "Updates CSS variable --accent-color using a native host", - "applications": { - "gecko": { - "id": "accent-color@example.com" - } - }, - "background": { - "scripts": ["background.js"] - }, - "permissions": ["nativeMessaging", "tabs", ""], - "content_scripts": [ - { - "matches": [""], - "js": ["content.js"], - "run_at": "document_start" - } - ] -} diff --git a/browsers/firefox/install-native-host.sh b/browsers/firefox/install-native-host.sh deleted file mode 100755 index 33a6c88..0000000 --- a/browsers/firefox/install-native-host.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -set -eu -cd "$(dirname "$0")" -HOST_DIR="${HOME}/.mozilla/native-messaging-hosts" -mkdir -p "$HOST_DIR" -cat >"$HOST_DIR/accent_color.json" <&2; exit 1; } -PROFILE="$PROFILE_DIR/$PROFILE" -mkdir -p "$PROFILE/chrome" -sed "s/ACCENT/$ACCENT/" userChrome.template.css > "$PROFILE/chrome/userChrome.css" diff --git a/browsers/firefox/userChrome.template.css b/browsers/firefox/userChrome.template.css deleted file mode 100644 index 509ed81..0000000 --- a/browsers/firefox/userChrome.template.css +++ /dev/null @@ -1,7 +0,0 @@ -:root{ - --accent-color: ACCENT; -} - -#navigator-toolbox { - background-color: var(--accent-color) !important; -} diff --git a/browsers/getaccent.c b/browsers/getaccent.c deleted file mode 100644 index a7f81d4..0000000 --- a/browsers/getaccent.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include "../core/accent.h" - -int main(void) { - ColorShm *blk = NULL; - char col[8]; - if (readaccent(&blk, col)) { - printf("%s\n", col); - return 0; - } - return 1; -} -- cgit v1.2.3