Write the eight accents down once
They were written down five times: ThemeProfileModel.js for QML, looks.lua for the compositor, and again in panama-theme-apps and panama-lock. The GNOME accent-name mapping was a sixth list. Adding a ninth accent meant editing all of them, and the file most likely to be missed was the lock screen, which fails silently -- the machine locks in last season's colour and nothing says why. panama-theme-apps admitted it in a comment: "there is no shared source between QML and a shell script". config/palette.json is that source now. looks.lua reads it through a new prefs.readJson, which uses the same never-raise parser the settings store uses, so an unreadable palette costs the accent colours and never the compositor config. The two shell generators read it through scripts/panama-palette, which also carries the hex-to-rgb conversion hyprlock needs and the GNOME member lookup. QML keeps its table, because a .js module imported into QML cannot read a file. That is still a copy, so the palette contract compares the two value by value -- every accent, every field -- and fails on any disagreement. Verified by planting a wrong hex and watching it name the exact field. The adwaita contract used to check the shell's own copy of the GNOME mapping. It now checks that the shell resolves through the palette, and fails if that copy ever grows back.
This commit is contained in:
@@ -24,11 +24,16 @@
|
||||
# nothing until you open a new window.
|
||||
#
|
||||
# kitty's active_border_color and hyprlock's focus ring are also the accent
|
||||
# role, not just the scheme -- see accent_hex() below, which mirrors the same
|
||||
# lookup hypr/looks.lua and scripts/panama-lock carry for the same reason.
|
||||
# role, not just the scheme. The lookup lives in scripts/panama-palette,
|
||||
# which reads config/palette.json -- the one place the eight accents are
|
||||
# written down for everything outside QML.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# The accents, from the one file that holds them.
|
||||
# shellcheck source=./panama-palette
|
||||
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/panama-palette"
|
||||
|
||||
scheme="${1:-dark}"
|
||||
case "$scheme" in
|
||||
dark|light) ;;
|
||||
@@ -49,25 +54,8 @@ esac
|
||||
# hand -- there is no shared source between QML and a shell script), primary
|
||||
# hue per scheme only: both consumers below draw a flat color, not the
|
||||
# two-stop gradient the window border does.
|
||||
accent_hex() {
|
||||
local name="$1" scheme="$2"
|
||||
case "$name" in
|
||||
orchid) [[ "$scheme" == light ]] && printf '7847bd' || printf 'c099ff' ;;
|
||||
teal) [[ "$scheme" == light ]] && printf '007197' || printf '86e1fc' ;;
|
||||
green) [[ "$scheme" == light ]] && printf '587539' || printf 'c3e88d' ;;
|
||||
amber) [[ "$scheme" == light ]] && printf '8c6c3e' || printf 'ffc777' ;;
|
||||
orange) [[ "$scheme" == light ]] && printf 'b15c00' || printf 'ff966c' ;;
|
||||
rose) [[ "$scheme" == light ]] && printf 'f52a65' || printf 'ff757f' ;;
|
||||
slate) [[ "$scheme" == light ]] && printf '6172b0' || printf '828bb8' ;;
|
||||
*) [[ "$scheme" == light ]] && printf '2e7de9' || printf '82aaff' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hyprlock wants "R, G, B" decimal, not hex.
|
||||
hex_to_rgb() {
|
||||
local hex="$1"
|
||||
printf '%d, %d, %d' "0x${hex:0:2}" "0x${hex:2:2}" "0x${hex:4:2}"
|
||||
}
|
||||
|
||||
accent_border_hex="$(accent_hex "$accent" "$scheme")"
|
||||
|
||||
@@ -210,29 +198,19 @@ done
|
||||
# render in GNOME blue no matter which accent the desktop is set to.
|
||||
#
|
||||
# GNOME's accent-color is a FIXED enum of nine names -- there is no hex here to
|
||||
# match, only a nearest member to pick -- so this maps our eight to theirs. Kept
|
||||
# in sync by hand with config/Theme.qml's `gnome` field, for the same reason
|
||||
# accent_hex() above is: there is no shared source between QML and shell.
|
||||
# match, only a nearest member to pick. Which one each Panama accent maps to is
|
||||
# recorded in config/palette.json alongside its colours, for the same reason
|
||||
# accent lookup once was: there was no shared source between QML and shell.
|
||||
# There is now -- config/palette.json -- and palette-contract fails when the
|
||||
# QML table and it disagree.
|
||||
#
|
||||
# The portal must route Settings to the gnome backend for this to reach
|
||||
# anything; xdg-desktop-portal-gtk cannot serve accent-color at all. See
|
||||
# config/dot/xdg-desktop-portal/hyprland-portals.conf.
|
||||
gnome_accent() {
|
||||
case "$1" in
|
||||
orchid) printf 'purple' ;;
|
||||
teal) printf 'teal' ;;
|
||||
green) printf 'green' ;;
|
||||
amber) printf 'yellow' ;;
|
||||
orange) printf 'orange' ;;
|
||||
rose) printf 'red' ;;
|
||||
slate) printf 'slate' ;;
|
||||
*) printf 'blue' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
status_adwaita="skipped"
|
||||
if command -v gsettings >/dev/null 2>&1; then
|
||||
adwaita_accent="$(gnome_accent "$accent")"
|
||||
adwaita_accent="$(accent_gnome "$accent")"
|
||||
# Writing the same value emits no change signal, so applications already
|
||||
# showing this accent are not asked to restyle for nothing.
|
||||
if [[ "$(gsettings get org.gnome.desktop.interface accent-color 2>/dev/null)" == "'$adwaita_accent'" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user