From 3b72e6d01f5d34d5936e87487bae73f9e8eabfbe Mon Sep 17 00:00:00 2001 From: Ragnarok <260221049+librerob@users.noreply.github.com> Date: Mon, 19 Oct 2026 14:29:17 +0000 Subject: [PATCH] Fix live Cinnamon accent updates and separate folder colors --- .github/workflows/theme-checks.yml | 5 +- ACCENT_COLORS.md | 6 +- COMPATIBILITY.md | 15 ++++ INSTALLING.md | 40 ++++++++- README.md | 7 +- icon-accent | 1 + install.sh | 93 +++++++++++++++++++- runtime-files.txt | 1 + setup-menu.sh | 49 +++++++++-- tests/README.md | 22 +++++ tests/cinnamon_accent_update.py | 102 ++++++++++++++++++++++ tests/test_color_updates.py | 132 +++++++++++++++++++++++++++++ tests/test_guided_installer.py | 72 +++++++++++++++- tests/test_icons.py | 4 +- tests/test_system_installer.py | 20 +++++ 15 files changed, 544 insertions(+), 25 deletions(-) create mode 100644 icon-accent create mode 100644 tests/cinnamon_accent_update.py create mode 100644 tests/test_color_updates.py diff --git a/.github/workflows/theme-checks.yml b/.github/workflows/theme-checks.yml index 96ee79c..477851d 100644 --- a/.github/workflows/theme-checks.yml +++ b/.github/workflows/theme-checks.yml @@ -39,6 +39,7 @@ jobs: python3 tests/test_installer_failures.py python3 tests/test_installer_preservation.py python3 tests/test_icons.py + python3 tests/test_color_updates.py python3 tests/test_flatpak_installer.py python3 tests/test_manual_installation.py python3 tests/test_theme.py @@ -202,7 +203,7 @@ jobs: DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git ca-certificates cinnamon cinnamon-session dbus-x11 \ python3-gi python3-cairo python3-gi-cairo gir1.2-gtk-3.0 \ - xvfb xauth libgl1-mesa-dri + xvfb xauth xdotool libgl1-mesa-dri - uses: actions/checkout@v7 - name: Check Cinnamon preference activation run: python3 tests/test_install_settings.py DesktopSettingTests.test_cinnamon_activation @@ -215,6 +216,8 @@ jobs: python3 tests/report.py xvfb-run -a -s '-screen 0 1600x1200x24 +extension GLX +render -noreset' \ dbus-run-session -- python3 tests/cinnamon_colors.py . /tmp/cinnamon-color-evidence python3 tests/report.py python3 tests/accent_native.py cinnamon /tmp/cinnamon-color-evidence/accents + python3 tests/report.py xvfb-run -a -s '-screen 0 1600x1200x24 +extension GLX +render -noreset' \ + dbus-run-session -- python3 tests/cinnamon_accent_update.py . /tmp/cinnamon-color-evidence/live-updates - name: Upload Cinnamon color evidence if: always() uses: actions/upload-artifact@v7 diff --git a/ACCENT_COLORS.md b/ACCENT_COLORS.md index ab7dd21..3302767 100644 --- a/ACCENT_COLORS.md +++ b/ACCENT_COLORS.md @@ -86,8 +86,10 @@ semantic mode/status colors and user-defined ANSI slots stay separate. The Bash installer combines the base runtime with one verified overlay. It installs no palette sources, compiler or other presets. Rerunning retains the -installed color unless another is chosen. Rerun with the same optional extras -to refresh copied app snippets; existing GTK4/Flatpak links follow the installed +installed color unless another is chosen. **Change installed colors** (or +`--recolor`) refreshes existing copied app snippets and installed folder icons. +Folder icons default to matching but can use an independently selected preset. +Existing GTK4/Flatpak links follow the installed theme. App themes still need selection in their own applications. Shell 46 and 51 use the selected theme preset for all eight colors, including diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index c45f76b..8bb54c2 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -175,6 +175,21 @@ by the environment's namespace restrictions. Budgie's built-in-theme-disabled configuration, native Wayland Cinnamon/Xfce sessions, and a full GNOME/MATE login session were not verified. +## Cinnamon accent updates (2026-10-19) + +A same-session blue-to-pink reinstall reproduced stale menu focus, calendar +and taskbar CSS on Cinnamon 6.0.4 and 6.6.9. The selected theme name did not +change, so Cinnamon retained its old stylesheet while newly loaded assets +could already use the new accent. The installer now calls Cinnamon's public +`ReloadTheme` D-Bus method when Adwaita-AMOLED is selected. + +Disposable non-root X11 sessions on both versions passed all eight accents, +including a return to blue: 16 update transitions, 126 resolved style assertions +and 36 menu/calendar screenshots in total. Tests cover both search-entry IDs, +today's calendar date, grouped/classic taskbar states and popup hover, plus +actual painted menus and the mapped calendar widget. This does not establish +coverage of every third-party applet, extension or Wayland session. + ## Official references - [GNOME 51 build manifest](https://github.com/GNOME/gnome-build-meta/tree/51.0) diff --git a/INSTALLING.md b/INSTALLING.md index 7020d35..befa2b2 100644 --- a/INSTALLING.md +++ b/INSTALLING.md @@ -30,6 +30,11 @@ In a terminal this opens guided setup: and selected-app Flatpak configuration. 4. **Accent color** chooses blue (default), yellow, gold, purple, green, red, orange or pink, then returns to the main menu. Continue with Install/update. +5. **Folder icon color** independently chooses a folder preset; **Match theme** + is the default. Installation also offers these color choices directly. +6. **Change installed colors** updates the installed theme and existing copied + app/icon themes without selecting all components again. It does not install + missing optional components or replace custom GTK4 CSS. Numbered choices need only Enter or a number. Setup shows destinations and existing GTK4 override paths before its final **Apply / Cancel / Preview** @@ -110,9 +115,27 @@ and on the staged theme. The full collection of overlays is not installed. Rerunning from a newer download retains the valid installed `accent-name` marker unless `--accent` selects another color. Older installations without a marker use blue. To return to blue, run `./install.sh --accent blue`. -Rerun with the same optional extras to refresh their copied app snippets; +Use **Change installed colors** to refresh existing copied app snippets and +installed folder icons together, or run: + +```bash +./install.sh --recolor --accent pink +./install.sh --recolor --accent purple --icon-accent green +./install.sh --recolor --icon-accent match +``` + +For ordinary installation/update, select the optional extras again to update them; GTK4/Flatpak links already referencing this theme follow the changed theme files. -Restart apps and reload Shell/Cinnamon as appropriate. Separate user and system +Restart affected apps; GNOME Shell may need a session restart. Cinnamon's selected +Adwaita-AMOLED theme reloads automatically through its public D-Bus API, including +when its theme name stays unchanged. If the session bus or `gdbus` is unavailable, +setup prints a manual reload/reselection hint. From the Cinnamon session, run: + +```bash +gdbus call --session --dest org.Cinnamon --object-path /org/Cinnamon --method org.Cinnamon.ReloadTheme +``` + +Separate user and system installations each retain their own color. Shared-system guided setup also has an Accent color choice. @@ -347,9 +370,16 @@ icon theme: our folder artwork uses the selected accent, while application, symbolic and other icons fall back to **Adwaita**, then **hicolor**. Your current application icons may therefore change too. +Folders default to **Match theme accent**. Choose another folder color in the +main menu or when selecting the icon component. This is independent of GTK, +Qt and other app accents. The installed `icon-accent` marker remembers `match` +or the explicit color; `accent-name` remembers the theme accent. No installer +database is needed. Older installations default to matching. + ```bash ./install.sh --icons # Copy without selecting ./install.sh --activate-icons --accent green # Copy and select explicitly +./install.sh --icons --accent pink --icon-accent gold # Pink UI, gold folders ./install.sh --icons --remove # Remove the optional icon component and GTK theme ``` @@ -373,8 +403,10 @@ If qt5ct/qt6ct manages your Qt appearance, select **Adwaita-AMOLED** in its GNOME/Budgie, Cinnamon, MATE and Xfce support explicit automatic selection. On other desktops, use Appearance settings. Copying icons alone never changes -the selected icon theme. Rerun with **--icons** (or select the component again -in the menus) to update its files and match a changed accent. Existing icon +the selected icon theme. **Change installed colors** or `--recolor` refreshes +installed icons, retaining an independent color or following the theme when +set to **Match theme**. Normal updates use **--icons** or select the component +again. Restart file managers if they cache old icons. Existing icon checkouts, symlink destinations and unlisted local files are preserved and reported as conflicts. A separate legacy `~/.icons/Adwaita-AMOLED` is reported if it could shadow the new installation. diff --git a/README.md b/README.md index 29f1ca6..73c68d0 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,14 @@ extract it, and open a terminal inside the **Adwaita-AMOLED** folder: Run user setup **without sudo**. The installer uses Bash; no Python, compiler or additional menu package is required. -Choose **Accent color** if you want a different preset, then **Install/update -for this user**. Guided setup offers GTK4/libadwaita styling, desktop selection, +Choose **Install/update for this user**. Setup asks for a theme accent and offers GTK4/libadwaita styling, desktop selection, matching supported GNOME Shell styling, optional app themes and folder icons. Review the changes, then choose **Apply**, **Cancel** or **Preview**. +Folder icons default to **Match theme**, or you can choose their color separately. +Later, **Change installed colors** refreshes the theme and existing app/icon +themes together. Cinnamon reloads its selected theme automatically. + Selecting GTK4/libadwaita setup replaces existing CSS/assets overrides **without backups**; guided setup defaults to keeping existing overrides. App extras still need selection or inclusion in each application. diff --git a/icon-accent b/icon-accent new file mode 100644 index 0000000..02b1d1a --- /dev/null +++ b/icon-accent @@ -0,0 +1 @@ +match diff --git a/install.sh b/install.sh index 15f7874..4d3e133 100755 --- a/install.sh +++ b/install.sh @@ -5,6 +5,8 @@ set -euo pipefail ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) THEME=Adwaita-AMOLED ACCENT=auto +ICON_ACCENT=auto +RECOLOR=false DATA=${XDG_DATA_HOME:-$HOME/.local/share} CONFIG=${XDG_CONFIG_HOME:-$HOME/.config} DESKTOP=${XDG_CURRENT_DESKTOP:-} @@ -20,6 +22,7 @@ EXTRAS=() FLATPAKS=() TARGETS=() PAYLOAD=() ACCENT_PAYLOAD=() declare -A ACCENT_OVERRIDES=() +declare -A ICON_OVERRIDES=() REQUIRED=(accent-name index.theme gtk-2.0/gtkrc gtk-3.0/gtk.css gtk-3.0/gtk.gresource gtk-4.0/gtk.css gtk-4.0/gtk.gresource cinnamon/cinnamon.css metacity-1/metacity-theme-3.xml openbox-3/themerc @@ -40,6 +43,9 @@ Default destination: ${XDG_DATA_HOME:-$HOME/.local/share}/themes/Adwaita-AMOLED -a, --activate Select the theme for the current desktop --accent COLOR blue, yellow, gold, purple, green, red, orange, pink Default: keep installed color, or blue for a new install + --icon-accent COLOR Independent folder color, or match (default) + Used with --icons; keeps the installed choice on updates + --recolor Refresh installed colors and existing app/icon themes --shell Require a matching GNOME Shell theme (46 or 51) --icons Install the optional palette-matched folder icon theme --activate-icons Also select the icon theme for this desktop (implies --icons) @@ -81,6 +87,12 @@ installed_accent() { case $name in blue|yellow|gold|purple|green|red|orange|pink) printf '%s\n' "$name" ;; *) printf 'blue\n' ;; esac } +installed_icon_accent() { + local name=match + if [[ -f $1/icon-accent && ! -L $1/icon-accent ]]; then IFS= read -r name < "$1/icon-accent" || :; fi + case $name in match|blue|yellow|gold|purple|green|red|orange|pink) printf '%s\n' "$name" ;; *) printf 'match\n' ;; esac +} + # GTK theme selection and the portal's app appearance preference are separate. # Non-GNOME sessions may use either the GTK or XApp settings portal. Configure # their available keys together; the guided review lists each one explicitly. @@ -143,6 +155,8 @@ while (($#)); do -l|--libadwaita) LIBADWAITA=true ;; -a|--activate) ACTIVATE=true ;; --accent) value "$@"; ACCENT=$2; shift ;; + --icon-accent) value "$@"; ICON_ACCENT=$2; shift ;; + --recolor) RECOLOR=true ;; --prefer-dark) ;; # Accepted for v1.6.0 command compatibility; now the user-install default. --shell) SHELL_THEME=true ;; --icons) ICONS=true ;; @@ -180,6 +194,8 @@ done [[ $GTK_MODE =~ ^(auto|legacy|modern)$ ]] || die 'GTK4 mode must be auto, legacy or modern.' [[ $SHELL_VERSION =~ ^(auto|46|51)$ ]] || die 'Shell version must be auto, 46 or 51.' case $ACCENT in auto|blue|yellow|gold|purple|green|red|orange|pink) ;; *) die 'Unknown accent color. Use blue, yellow, gold, purple, green, red, orange or pink.' ;; esac +case $ICON_ACCENT in auto|match|blue|yellow|gold|purple|green|red|orange|pink) ;; *) die 'Unknown folder icon color. Use match, blue, yellow, gold, purple, green, red, orange or pink.' ;; esac +$RECOLOR && { $REMOVE || $LIBADWAITA || ((${#FLATPAKS[@]})); } && die '--recolor changes existing themes; use installation/removal separately for GTK4 overrides or Flatpak permissions.' if $SYSTEM; then ((EUID == 0)) || die 'Use sudo with --system.' $CUSTOM_DEST || DEST=/usr/local/share/themes @@ -192,7 +208,7 @@ elif [[ -n ${SUDO_USER:-} ]]; then die 'Run user setup without sudo, or use --system for shared theme files.' fi $ACTIVATE_ICONS && $REMOVE && die 'Use --icons --remove without --activate-icons; choose another icon theme in Appearance settings first.' -$CUSTOM_ICON_DEST && ! $ICONS && die '--icon-dest requires --icons.' +$CUSTOM_ICON_DEST && ! $ICONS && ! $RECOLOR && die '--icon-dest requires --icons.' [[ -z $LINK_PARENT ]] || $SYSTEM || die '--link requires --system; it must point to a root-owned copy, not a user theme.' for path in "$HOME" "$DATA" "$CONFIG" "$DEST" "$ICON_DEST" ${LINK_PARENT:+"$LINK_PARENT"}; do [[ $path == /* && $path != / && $path != *$'\n'* ]] || die "Expected an absolute directory other than /: $path" @@ -202,6 +218,27 @@ TARGET=$DEST/$THEME ICON_DEST=$(realpath -m -- "$ICON_DEST") ICON_TARGET=$ICON_DEST/$THEME [[ $ACCENT != auto ]] || ACCENT=$(installed_accent "$TARGET") +[[ $ICON_ACCENT != auto ]] || ICON_ACCENT=$(installed_icon_accent "$TARGET") +ICON_COLOR=$ICON_ACCENT +[[ $ICON_COLOR != match ]] || ICON_COLOR=$ACCENT +if $RECOLOR; then + [[ -d $TARGET ]] || die 'Install the theme first, then use Change installed colors.' + [[ ! -d $ICON_TARGET ]] || ICONS=true + if ! $SYSTEM; then + [[ ! -f $CONFIG/qt5ct/colors/$THEME.conf && ! -f $CONFIG/qt6ct/colors/$THEME.conf && ! -f $CONFIG/qt5ct/qss/fusion-simple-scrollbar.qss && ! -f $CONFIG/qt6ct/qss/fusion-simple-scrollbar.qss ]] || EXTRAS+=(qt) + [[ ! -f ${KITTY_CONFIG_DIRECTORY:-$CONFIG/kitty}/themes/adwaita-amoled.conf ]] || EXTRAS+=(kitty) + [[ ! -f $CONFIG/alacritty/themes/adwaita-amoled.toml ]] || EXTRAS+=(alacritty) + bat_parent=${BAT_CONFIG_PATH:+$(dirname -- "$BAT_CONFIG_PATH")}; bat_parent=${bat_parent:-$CONFIG/bat} + bat_executable=$(command -v bat || command -v batcat || :) + if [[ -n $bat_executable && -z ${BAT_CONFIG_PATH:-} ]]; then bat_parent=$("$bat_executable" --config-dir); fi + [[ ! -f $bat_parent/themes/adwaita-amoled.tmTheme ]] || EXTRAS+=(bat) + if [[ ${NVIM_APPNAME:-nvim} != */* && ${NVIM_APPNAME:-nvim} != . && ${NVIM_APPNAME:-nvim} != .. ]]; then + [[ ! -f $CONFIG/${NVIM_APPNAME:-nvim}/colors/adwaita-amoled.vim && ! -f $CONFIG/${NVIM_APPNAME:-nvim}/autoload/airline/themes/adwaita_amoled.vim ]] || EXTRAS+=(nvim) + fi + [[ ! -f $CONFIG/rofi/themes/adwaita-amoled.rasi ]] || EXTRAS+=(rofi) + [[ ! -f $CONFIG/zsh/adwaita-amoled.zsh ]] || EXTRAS+=(zsh) + fi +fi LINK_PATH='' GTK2_LINK='' if [[ -n $LINK_PARENT ]]; then @@ -359,7 +396,7 @@ read_runtime_files() { PAYLOAD+=("$name") done < "$ROOT/runtime-files.txt" [[ ${seen[runtime-files.txt]+present} ]] || die 'Runtime list must include runtime-files.txt.' - for name in "${REQUIRED[@]}" install.sh setup-menu.sh INSTALLING.md; do + for name in "${REQUIRED[@]}" install.sh setup-menu.sh INSTALLING.md icon-accent; do [[ ${seen[$name]+present} ]] || die "Incomplete runtime file list: $name" done } @@ -391,6 +428,24 @@ accent_source() { else printf '%s\n' "$ROOT/$1"; fi } +icon_source() { + local path=extra/icons/$THEME/$1 + if [[ $ICON_COLOR != blue && ${ICON_OVERRIDES[$path]+yes} ]]; then + printf '%s\n' "$ROOT/accents/$ICON_COLOR/$path" + else printf '%s\n' "$ROOT/$path"; fi +} + +validate_icon_accent() { + # Dynamic locals keep validation of the independent icon preset from + # changing the selected GTK/app preset or its overlay tables. + local ACCENT=$ICON_COLOR + local -a ACCENT_PAYLOAD=() + local -A ACCENT_OVERRIDES=() + read_accent_files + local name + for name in "${!ACCENT_OVERRIDES[@]}"; do ICON_OVERRIDES[$name]=1; done +} + # Build the new copy first. Keep the previous directory only during the rename # so an ordinary copy/promotion error or catchable signal can restore it. replace_theme() ( @@ -422,7 +477,10 @@ replace_theme() ( stage=$(mktemp -d "${target%/*}/.Adwaita-AMOLED-install.XXXXXX") mkdir -- "$stage/new" if $icon_copy; then - cp -a --no-preserve=ownership -- "$TARGET/extra/icons/$THEME/." "$stage/new/" + for name in "${ICON_FILES[@]}"; do + mkdir -p -- "$(dirname -- "$stage/new/$name")" + cp -a --no-preserve=ownership -- "$(icon_source "$name")" "$stage/new/$name" + done (cd -- "$stage/new" && sha256sum --check --status SHA256SUMS) || die 'Staged icon checksum verification failed.' else (cd -- "$ROOT" && cp -a --no-preserve=ownership --parents -- "${PAYLOAD[@]}" "$stage/new/") @@ -432,6 +490,7 @@ replace_theme() ( (cd -- "$stage/new" && sha256sum --check --status "$ROOT/accents/$ACCENT/SHA256SUMS") || die 'Staged accent checksum verification failed.' fi cp --remove-destination -T -- "$stage/new/gnome-shell/gnome-shell-$SHELL_VERSION.css" "$stage/new/gnome-shell/gnome-shell.css" + printf '%s\n' "$ICON_ACCENT" > "$stage/new/icon-accent" fi chmod -R a+rX,go-w -- "$stage/new" if [[ -e $target ]]; then mv -T -- "$target" "$stage/previous"; fi @@ -515,6 +574,15 @@ if $ICONS; then if ! $REMOVE; then command -v sha256sum >/dev/null || die 'sha256sum is required to verify folder icons.' (cd -- "$ROOT/extra/icons/$THEME" && sha256sum --check --status SHA256SUMS) || die 'Folder icon checksum verification failed.' + if [[ $ICON_COLOR != blue && $ICON_COLOR != "$ACCENT" ]]; then + validate_icon_accent + elif [[ $ICON_COLOR != blue ]]; then + for name in "${!ACCENT_OVERRIDES[@]}"; do ICON_OVERRIDES[$name]=1; done + fi + mapfile -t ICON_FILES < "$ROOT/extra/icons/$THEME/runtime-files.txt" + for name in "${ICON_FILES[@]}"; do + [[ $name =~ ^[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)*$ && /$name/ != *'/../'* && /$name/ != *'/./'* ]] || die 'Invalid folder icon runtime path.' + done icon_bases=() if ! $SYSTEM; then icon_bases+=("$DATA/icons" "$HOME/.icons"); fi IFS=: read -r -a data_dirs <<< "${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" @@ -622,6 +690,7 @@ if ! $REMOVE || ((${#FLATPAKS[@]} == 0)); then fi if $ICONS; then printf 'Folder icon theme: %s\n' "$ICON_TARGET" + if ! $REMOVE; then printf 'Folder icon color: %s (choice: %s)\n' "$ICON_COLOR" "$ICON_ACCENT"; fi if $REMOVE; then run rm -rf -- "$ICON_TARGET" printf 'Select another icon theme in Appearance settings if Adwaita-AMOLED is currently selected.\n' @@ -646,6 +715,7 @@ fi if $LIBADWAITA || { $REMOVE && ! $SYSTEM && ((${#FLATPAKS[@]} == 0)); }; then gtk_links "$CONFIG/gtk-4.0" "$GTK_MODE"; fi extra_file() { + if $RECOLOR && [[ ! -f $2 ]]; then return; fi if $REMOVE; then run rm -f -- "$2"; else copy_file "$(accent_source "extra/$1")" "$2"; fi } for extra in "${EXTRAS[@]}"; do @@ -702,6 +772,23 @@ if $ACTIVATE_ICONS; then run gsettings set "$ICON_SETTING" icon-theme "$THEME" fi fi +# The selected name stays the same across accent updates. Cinnamon does not +# reload CSS merely because those files changed, even after setting that name +# again. Use its public reload method; never change an unrelated selected theme. +if ! $SYSTEM && ! $REMOVE && [[ ${DESKTOP^^} == *CINNAMON* ]] && command -v gsettings >/dev/null; then + cinnamon_theme=$(gsettings get org.cinnamon.theme name 2>/dev/null) || cinnamon_theme='' + if [[ $cinnamon_theme == "'$THEME'" ]] || { $DRY_RUN && $ACTIVATE; }; then + if $DRY_RUN; then + printf ' Reload the selected Cinnamon desktop theme after updating its colors.\n' + elif [[ -n ${DBUS_SESSION_BUS_ADDRESS:-} ]] && command -v gdbus >/dev/null && + gdbus call --session --dest org.Cinnamon --object-path /org/Cinnamon \ + --method org.Cinnamon.ReloadTheme --timeout 10 >/dev/null 2>&1; then + printf 'Cinnamon desktop theme reloaded with the installed accent.\n' + else + printf 'Cinnamon theme files updated. Reselect the desktop theme in Themes, or log out/in, to refresh its colors.\n' >&2 + fi + fi +fi if $DRY_RUN; then printf 'Dry run: nothing changed.\n'; else printf 'Done. Restart affected applications; reload GNOME Shell themes by logging out/in.\n'; fi if ! $DRY_RUN && ! $REMOVE; then printf 'File locations and app setup: %s/INSTALLING.md (Every extra and destination).\n' "$TARGET" diff --git a/runtime-files.txt b/runtime-files.txt index a829c6f..c59ac90 100644 --- a/runtime-files.txt +++ b/runtime-files.txt @@ -114,6 +114,7 @@ gtk-4.0/assets/devel-symbolic.svg gtk-4.0/gtk-dark.css gtk-4.0/gtk.css gtk-4.0/gtk.gresource +icon-accent index.theme install.sh metacity-1/metacity-theme-3.xml diff --git a/setup-menu.sh b/setup-menu.sh index ff36b87..be4181f 100644 --- a/setup-menu.sh +++ b/setup-menu.sh @@ -68,6 +68,8 @@ guided_extras() { fi printf 'Extras copy theme snippets; select/include them in each app afterward.\n' if [[ ${selected[icons]+yes} && ${MENU_ARGS[0]} != --remove ]]; then + if ! $MENU_ICON_PICKED; then guided_icon_accent; fi + MENU_ARGS+=(--icon-accent "$MENU_ICON_ACCENT") printf 'Selecting the icon theme also uses Adwaita application icons, with our colored folders.\n' local can_select_icons=false case ${DESKTOP^^} in @@ -128,12 +130,15 @@ guided_system() { printf '\nShared system theme (administrator)\n' printf 'Copies theme files for all users; personal GTK4/app settings stay separate.\n' MENU_ACCENT=auto + MENU_ICON_ACCENT=auto + MENU_ICON_PICKED=false while true; do - printf ' 1. Install/update\n 2. Remove\n 3. Accent color (%s)\n 0. Exit\n' "$MENU_ACCENT" - menu_number 3 0 + printf ' 1. Install/update\n 2. Remove\n 3. Accent color (%s)\n 4. Folder icon color (%s)\n 0. Exit\n' "$MENU_ACCENT" "$MENU_ICON_ACCENT" + menu_number 4 0 case $MENU_NUMBER in 0) printf 'Cancelled; no changes made.\n'; exit 0 ;; 3) guided_accent ;; + 4) guided_icon_accent ;; *) MENU_ARGS=(--system --accent "$MENU_ACCENT"); [[ $MENU_NUMBER != 2 ]] || MENU_ARGS+=(--remove); break ;; esac done @@ -148,7 +153,10 @@ guided_system() { MENU_ARGS+=(--link /usr/share/themes) fi ;; esac - if menu_yes 'Also manage the accent-colored folder icon theme for all users?' n; then MENU_ARGS+=(--icons); fi + if menu_yes 'Also manage the accent-colored folder icon theme for all users?' n; then + if ! $MENU_ICON_PICKED; then guided_icon_accent; fi + MENU_ARGS+=(--icons --icon-accent "$MENU_ICON_ACCENT") + fi } guided_advanced() { @@ -182,21 +190,41 @@ guided_accent() { local i printf '\nAccent color (AMOLED backgrounds are unchanged):\n' for i in "${!names[@]}"; do printf ' %s. %s\n' "$((i+1))" "${names[$i]}"; done - printf ' 0. Back\n' + printf ' 0. Keep current choice (%s)\n' "$MENU_ACCENT" menu_number 8 0 ((MENU_NUMBER == 0)) || MENU_ACCENT=${names[$((MENU_NUMBER-1))]} + MENU_ACCENT_PICKED=true return 0 } +guided_icon_accent() { + local -a names=(blue yellow gold purple green red orange pink) + local i + printf '\nFolder icon color (independent of the theme accent):\n' + printf ' 1. Match theme accent (recommended)\n' + for i in "${!names[@]}"; do printf ' %s. %s\n' "$((i+2))" "${names[$i]}"; done + printf ' 0. Keep current choice (%s)\n' "$MENU_ICON_ACCENT" + menu_number 9 0 + case $MENU_NUMBER in + 0) ;; + 1) MENU_ICON_ACCENT=match ;; + *) MENU_ICON_ACCENT=${names[$((MENU_NUMBER-2))]} ;; + esac + MENU_ICON_PICKED=true +} + guided_setup() { MENU_ARGS=() if [[ -n ${SUDO_USER:-} ]] && ((EUID == 0)); then guided_system; return; fi local existing=false default=y version='' output name select_desktop=false gnome_desktop=false MENU_ACCENT=$(installed_accent "$DEST/$THEME") + MENU_ICON_ACCENT=$(installed_icon_accent "$DEST/$THEME") + MENU_ACCENT_PICKED=false + MENU_ICON_PICKED=false while true; do printf '\nAdwaita-AMOLED setup\n\n 1. Install/update for this user (recommended)\n' - printf ' 2. Remove for this user\n 3. Help\n 4. Advanced options\n 5. Accent color (%s)\n 0. Exit\n' "$MENU_ACCENT" - menu_number 5 1 + printf ' 2. Remove for this user\n 3. Help\n 4. Advanced options\n 5. Accent color (%s)\n 6. Folder icon color (%s)\n 7. Change installed colors (refresh existing app themes and icons)\n 0. Exit\n' "$MENU_ACCENT" "$MENU_ICON_ACCENT" + menu_number 7 1 case $MENU_NUMBER in 0) printf 'Cancelled; no changes made.\n'; exit 0 ;; 1) MENU_ARGS=(install); break ;; @@ -204,8 +232,15 @@ guided_setup() { 3) printf '\nSetup shows a review before changing anything. Choose Preview to print operations only.\nGTK4/libadwaita styles modern GNOME apps through user CSS. Existing overrides are replaced only if selected.\nExtras need selection in each app. Root/shared and selected-app Flatpak setup are under Advanced options.\nFor command-line options, run ./install.sh --help.\n' ;; 4) if guided_advanced; then return; fi ;; 5) guided_accent ;; + 6) guided_icon_accent ;; + 7) + if ! $MENU_ACCENT_PICKED; then guided_accent; fi + if [[ -d $ICON_DEST/$THEME ]] && ! $MENU_ICON_PICKED; then guided_icon_accent; fi + MENU_ARGS=(--recolor --accent "$MENU_ACCENT" --icon-accent "$MENU_ICON_ACCENT") + return ;; esac done + if [[ ${MENU_ARGS[0]} != --remove ]] && ! $MENU_ACCENT_PICKED; then guided_accent; fi MENU_ARGS+=(--accent "$MENU_ACCENT") printf '\nDesktop: %s\nTheme files: %s/%s\n' "${DESKTOP:-not detected}" "$DEST" "$THEME" if [[ ${MENU_ARGS[0]} == --remove ]]; then @@ -302,7 +337,7 @@ guided_review() { [[ -z $LINK_PATH ]] || printf 'Shared link: %s -> %s\n' "$LINK_PATH" "$TARGET" [[ -z $GTK2_LINK ]] || printf 'GTK2 compatibility link: %s -> %s\n' "$GTK2_LINK" "$TARGET" if $ICONS; then - printf 'Folder icon theme (%s): %s (inherits Adwaita; other application icons may change)\n' "$ACCENT" "$ICON_TARGET" + printf 'Folder icon theme (%s; choice: %s): %s (inherits Adwaita; other application icons may change)\n' "$ICON_COLOR" "$ICON_ACCENT" "$ICON_TARGET" if $ACTIVATE_ICONS; then printf 'Select the icon theme for: %s\n' "$DESKTOP"; fi fi if $LIBADWAITA || { $REMOVE && ! $SYSTEM && ((${#FLATPAKS[@]} == 0)); }; then diff --git a/tests/README.md b/tests/README.md index 5d22e69..2527e92 100644 --- a/tests/README.md +++ b/tests/README.md @@ -24,6 +24,7 @@ python3 tests/test_guided_installer.py GuidedInstallerTests python3 tests/test_installer.py python3 tests/test_installer_failures.py python3 tests/test_installer_preservation.py +python3 tests/test_color_updates.py python3 tests/test_flatpak_installer.py python3 tests/test_manual_installation.py sudo xvfb-run -a python3 tests/test_system_installer.py @@ -392,3 +393,24 @@ Other supported application arguments are `thunar`, `caja`, `nautilus` and `pcmanfm-qt`. Repeat with each of the eight accent names for the full matrix. These are isolated X11 application checks, not complete desktop login sessions or a guarantee about other applications, extensions or Wayland compositors. + +## Updating colors in a live Cinnamon session + +`test_color_updates.py` checks all 64 independent theme/icon combinations, +remembered matching/independent icon modes, refreshing only existing app themes, +custom settings preservation, corrupt-overlay rejection and safe reload behavior. +The guided suite exercises the independent pickers and preview/cancel/apply flows. + +With Cinnamon, cinnamon-session, xdotool, GTK3 introspection, Xvfb and system +D-Bus available, run in a disposable environment: + +```bash +xvfb-run -a -s '-screen 0 1600x1200x24 +extension GLX +render -noreset' \ + dbus-run-session -- python3 tests/cinnamon_accent_update.py . /tmp/cinnamon-updates +``` + +The driver requires fresh wrappers and uses its own temporary HOME. It starts +a real Cinnamon session, updates the selected theme without changing its name, +checks seven resolved properties per state and saves actual menu/calendar +screenshots. Its test-only inspection uses Cinnamon Eval; the installer uses +only the public ReloadTheme API. Verified locally on Cinnamon 6.0.4 and 6.6.9. diff --git a/tests/cinnamon_accent_update.py b/tests/cinnamon_accent_update.py new file mode 100644 index 0000000..aee78c0 --- /dev/null +++ b/tests/cinnamon_accent_update.py @@ -0,0 +1,102 @@ +"""Live Cinnamon recoloring: run under fresh dbus-run-session and xvfb-run. + +Requires Cinnamon/session, a system D-Bus service, GTK3 introspection and xdotool. +Uses a disposable HOME and the real installer; saves menu/calendar screenshots. +""" +import json,os,signal,subprocess,sys,tempfile,time +from pathlib import Path +import gi +gi.require_version('Gtk','3.0');from gi.repository import Gtk,Gdk,Gio,GLib +Gtk.init([]) +ancestors=set();pid=os.getppid() +for _ in range(20): + if pid<=1:break + proc=Path('/proc')/str(pid);args=(proc/'cmdline').read_bytes().split(b'\0') + ancestors.update(Path(os.fsdecode(arg)).name for arg in args[:3] if arg) + pid=int(next(line.split()[1] for line in (proc/'status').read_text().splitlines() if line.startswith('PPid:'))) +assert {'dbus-run-session','xvfb-run'}.issubset(ancestors), 'Use fresh D-Bus and Xvfb wrappers, not a desktop session.' +root=Path(sys.argv[1]).resolve();out=Path(sys.argv[2]).resolve();out.mkdir(parents=True,exist_ok=True) +with tempfile.TemporaryDirectory(prefix='amoled-cinnamon-update-') as tmp: + home=Path(tmp);(home/'.config/autostart').mkdir(parents=True) + env={k:v for k,v in os.environ.items() if not k.startswith(('GH_','GITHUB_','ACTIONS_')) and 'TOKEN' not in k and 'SECRET' not in k} + env.update(HOME=str(home),GSETTINGS_BACKEND='keyfile',XDG_CURRENT_DESKTOP='X-Cinnamon',XDG_SESSION_TYPE='x11',CLUTTER_BACKEND='x11',GDK_BACKEND='x11',LIBGL_ALWAYS_SOFTWARE='1');env.pop('GTK_THEME',None) + for key,directory in [('XDG_DATA_HOME','data'),('XDG_CONFIG_HOME','config'),('XDG_CACHE_HOME','cache'),('XDG_RUNTIME_DIR','runtime')]: + p=home/directory;p.mkdir(mode=0o700);env[key]=str(p) + def run(*args): + p=subprocess.run(args,env=env,capture_output=True,text=True,timeout=60);assert p.returncode==0,p.stdout+p.stderr;return p.stdout + run('bash',str(root/'install.sh'),'--accent','blue','--activate') + run('dbus-update-activation-environment','HOME','XDG_CONFIG_HOME','XDG_DATA_HOME','XDG_CACHE_HOME','XDG_RUNTIME_DIR','GSETTINGS_BACKEND','DISPLAY','XAUTHORITY','XDG_CURRENT_DESKTOP','XDG_SESSION_TYPE') + with (out/'session.log').open('w') as log: + session=subprocess.Popen(['cinnamon-session','--session','cinnamon','--debug'],env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True);app=None + try: + proxy=Gio.DBusProxy.new_for_bus_sync(Gio.BusType.SESSION,Gio.DBusProxyFlags.NONE,None,'org.Cinnamon','/org/Cinnamon','org.Cinnamon',None) + def evaluate(js): + ok,data=proxy.call_sync('Eval',GLib.Variant('(s)',(js,)),Gio.DBusCallFlags.NONE,10000,None).unpack();assert ok,data;return json.loads(data) + for _ in range(900): + assert session.poll() is None,'Cinnamon exited' + try: + if evaluate('imports.ui.main.runState === imports.ui.main.RunState.RUNNING'):break + except GLib.Error:pass + time.sleep(.1) + else:raise AssertionError('Cinnamon not ready') + app=subprocess.Popen(['python3','-c',"import gi;gi.require_version('Gtk','3.0');from gi.repository import Gtk;w=Gtk.Window(title='Accent update');w.set_default_size(500,300);w.show_all();Gtk.main()"],env=env,stdout=log,stderr=log) + time.sleep(1) + sample=r"""(() => { + const St=imports.gi.St,c=St.ThemeContext.get_for_stage(global.stage),t=c.get_theme(),r=c.get_root_node(); + const node=(id,cls,state,parent=r,type=St.Widget.$gtype)=>St.ThemeNode.new(c,parent,t,type,id,cls,state,'',false); + const result={}; + for(const id of ['menu-search-entry','appmenu-search-entry']) + result[id]=node(id,null,'focus',r,St.Entry.$gtype).get_border_color(St.Side.TOP).to_string(); + const calendar=node(null,'calendar',null); + result.calendar=node(null,'calendar-day-base calendar-day calendar-today',null,calendar).get_background_color().to_string(); + const panel=node('panel','panel-bottom',null); + result.grouped=node(null,'grouped-window-list-item-box','active',panel).get_background_color().to_string(); + result.window=node(null,'window-list-item-box','active',panel).get_box_shadow().color.to_string(); + result.hover=node(null,'grouped-window-list-item-box','hover',panel).get_box_shadow().color.to_string(); + result.popup=node(null,'popup-menu-item','hover').get_background_color().to_string(); + result.theme=imports.ui.main.themeManager.themeDirectory; + return result; + })()""" + sys.path.insert(0,str(root/'tools'));import generate_palette as palette + records=[] + def screenshot(name): + time.sleep(.4) + window=Gdk.get_default_root_window();pix=Gdk.pixbuf_get_from_window(window,0,0,window.get_width(),window.get_height()) + pix.savev(str(out/(name+'.png')),'png',[],[]) + return bytes(pix.get_pixels()) + def open_applet(uuid): + data=evaluate("imports.ui.appletManager.definitions.filter(d=>d.applet).map(d=>{let a=d.applet.actor,p=a.get_transformed_position(),s=a.get_transformed_size();return {uuid:d.real_uuid||d.uuid,x:p[0],y:p[1],w:s[0],h:s[1]};})") + target=next(a for a in data if a['uuid']==uuid and a['w']>0 and a['h']>0) + run('xdotool','mousemove',str(round(target['x']+target['w']/2)),str(round(target['y']+target['h']/2)),'click','1') + for index,color in enumerate(('blue','pink','green','yellow','gold','purple','red','orange','blue')): + if index: + # Alternate ordinary reinstalls and the new update-only entry point. Neither + # changes the selected theme name; both must refresh the live shell CSS. + options=('--recolor',) if index%2 else ('--activate',) + output=run('bash',str(root/'install.sh'),'--accent',color,*options) + assert 'Cinnamon desktop theme reloaded' in output,output + colors=palette.preset_colors(root,color) + expected={'menu-search-entry':colors['accent_text']+'ff','appmenu-search-entry':colors['accent_text']+'ff', + 'calendar':colors['accent_indicator']+'40','grouped':colors['accent_indicator']+'14', + 'window':colors['accent_text']+'ff','hover':colors['accent_text']+'ff','popup':colors['accent_fill']+'ff'} + time.sleep(.4);actual=evaluate(sample) + records.append({'accent':color,'expected':expected,'actual':actual}) + (out/'results.json').write_text(json.dumps(records,indent=2)+'\n') + for name,value in expected.items():assert actual[name]==value,(color,name,actual[name],value) + assert actual['theme'].endswith('/Adwaita-AMOLED/cinnamon'),actual + open_applet('menu@cinnamon.org');pixels=screenshot(f'{index}-{color}-menu') + # The real start menu must paint its pale accent, beyond synthetic nodes. + assert pixels.count(bytes.fromhex(colors['accent_text'][1:]))>100,(color,'menu accent not painted') + run('xdotool','key','Escape');time.sleep(.2) + open_applet('calendar@cinnamon.org');screenshot(f'{index}-{color}-calendar') + real_calendar=evaluate("(() => {let found=[];const walk=a=>{if(a.mapped&&a.get_style_class_name&&/(^| )calendar-today( |$)/.test(a.get_style_class_name()||''))found.push(a.get_theme_node().get_background_color().to_string());for(let ch of a.get_children())walk(ch);};walk(global.stage);return found;})()") + assert expected['calendar'] in real_calendar,(color,'actual calendar',real_calendar) + run('xdotool','key','Escape');time.sleep(.2) + print(color,'live accent passed',flush=True) + print(json.dumps({'transitions':len(records)-1,'color_states':len(records),'properties_per_state':7,'screenshots':len(records)*2})) + finally: + if app is not None:app.terminate();app.wait(timeout=10) + try:os.killpg(session.pid,signal.SIGTERM) + except ProcessLookupError:pass + try:session.wait(timeout=10) + except subprocess.TimeoutExpired:os.killpg(session.pid,signal.SIGKILL);session.wait() diff --git a/tests/test_color_updates.py b/tests/test_color_updates.py new file mode 100644 index 0000000..f911e2d --- /dev/null +++ b/tests/test_color_updates.py @@ -0,0 +1,132 @@ +"""Independent icon choices and recoloring existing installed components.""" +import hashlib +import os +from pathlib import Path +import shutil +import unittest + +import test_installer as base + +COLORS = ('blue', 'yellow', 'gold', 'purple', 'green', 'red', 'orange', 'pink') + + +class ColorUpdateTests(unittest.TestCase): + setUp = base.InstallerTests.setUp + run_cli = base.InstallerTests.run_cli + write = base.InstallerTests.write + fake_program = base.InstallerTests.fake_program + + def expected(self, accent, name): + overlay = base.ROOT / 'accents' / accent / name + return overlay if accent != 'blue' and overlay.is_file() else base.ROOT / name + + def icons(self): + return self.data / 'icons' / base.THEME + + def snapshot(self): + return {str(p.relative_to(self.home)): ('link', os.readlink(p)) if p.is_symlink() + else ('file', hashlib.sha256(p.read_bytes()).hexdigest()) if p.is_file() + else ('directory', p.stat().st_mode) + for p in self.home.rglob('*')} + + def test_all_64_theme_and_folder_color_combinations(self): + for accent in COLORS: + for icon in COLORS: + with self.subTest(accent=accent, icons=icon): + self.run_cli('--accent', accent, '--icons', '--icon-accent', icon) + self.assertEqual((self.theme / 'gtk-3.0/gtk.gresource').read_bytes(), + self.expected(accent, 'gtk-3.0/gtk.gresource').read_bytes()) + self.assertEqual((self.theme / 'icon-accent').read_text(), icon + '\n') + self.assertEqual((self.icons() / 'accent-name').read_text(), icon + '\n') + for name in (self.icons() / 'runtime-files.txt').read_text().splitlines(): + self.assertEqual((self.icons() / name).read_bytes(), + self.expected(icon, 'extra/icons/Adwaita-AMOLED/' + name).read_bytes()) + + def test_recolor_preserves_independent_choice_then_can_restore_matching(self): + self.run_cli('--accent', 'pink', '--icons', '--icon-accent', 'yellow', '--extras', 'qt,kitty,nvim') + # A single Qt installation and custom GTK4/app configuration must stay so. + shutil.rmtree(self.config / 'qt6ct') + self.write(self.config / 'gtk-4.0/gtk.css', '/* private override */\n') + self.write(self.config / 'kitty/kitty.conf', 'font_size 15\n') + self.write(self.config / 'nvim/init.lua', '-- personal settings\n') + self.write(self.config / 'zsh/adwaita-amoled.zsh', 'old installed snippet\n') + self.run_cli('--recolor', '--accent', 'green') + self.assertEqual((self.theme / 'accent-name').read_text(), 'green\n') + self.assertEqual((self.icons() / 'accent-name').read_text(), 'yellow\n') + self.assertEqual((self.theme / 'icon-accent').read_text(), 'yellow\n') + for installed, source in [ + ('qt5ct/colors/Adwaita-AMOLED.conf', 'qt5ct/colors/Adwaita-AMOLED.conf'), + ('kitty/themes/adwaita-amoled.conf', 'kitty/adwaita-amoled.conf'), + ('nvim/colors/adwaita-amoled.vim', 'nvim/colors/adwaita-amoled.vim'), + ('zsh/adwaita-amoled.zsh', 'zsh/.zshrc'), + ]: + self.assertEqual((self.config / installed).read_bytes(), self.expected('green', 'extra/' + source).read_bytes()) + self.assertFalse((self.config / 'qt6ct').exists()) + self.assertFalse((self.config / 'alacritty').exists()) + self.assertEqual((self.config / 'gtk-4.0/gtk.css').read_text(), '/* private override */\n') + self.assertEqual((self.config / 'kitty/kitty.conf').read_text(), 'font_size 15\n') + self.assertEqual((self.config / 'nvim/init.lua').read_text(), '-- personal settings\n') + before = self.snapshot() + self.run_cli('--recolor', '--accent', 'blue', '--icon-accent', 'match', '--dry-run') + self.assertEqual(self.snapshot(), before) + self.run_cli('--recolor', '--icon-accent', 'match') + self.assertEqual((self.icons() / 'accent-name').read_text(), 'green\n') + self.run_cli('--recolor', '--accent', 'purple') + self.assertEqual((self.icons() / 'accent-name').read_text(), 'purple\n') + self.assertEqual((self.theme / 'icon-accent').read_text(), 'match\n') + + def test_recolor_does_not_install_missing_optional_components(self): + result = self.run_cli('--recolor', success=False) + self.assertIn('Install the theme first', result.stderr) + self.assertFalse(self.theme.exists()) + self.run_cli() + self.run_cli('--recolor', '--accent', 'gold') + self.assertFalse(self.icons().exists()) + self.assertFalse(self.config.exists()) + self.assertEqual((self.theme / 'accent-name').read_text(), 'gold\n') + self.run_cli('--recolor', '--remove', success=False) + self.run_cli('--recolor', '-l', success=False) + + def test_corrupt_independent_icon_variant_stops_before_theme_changes(self): + self.run_cli('--icons') + before = self.snapshot() + source = self.base / 'damaged-source' + shutil.copytree(base.ROOT, source, ignore=shutil.ignore_patterns('.git', '__pycache__')) + (source / 'accents/pink/extra/icons/Adwaita-AMOLED/scalable/places/folder.svg').write_text('damaged') + self.run_cli('--accent', 'green', '--icons', '--icon-accent', 'pink', root=source, success=False) + self.assertEqual(self.snapshot(), before) + self.run_cli('--icon-accent', 'not-a-preset', success=False) + self.assertEqual(self.snapshot(), before) + + def test_cinnamon_reload_only_for_the_selected_live_user_theme(self): + log = self.base / 'reload.log' + self.env.update(XDG_CURRENT_DESKTOP='X-Cinnamon', DBUS_SESSION_BUS_ADDRESS='fixture-bus', + RELOAD_LOG=str(log), RELOAD_THEME=str(self.theme), SELECTED_THEME=base.THEME) + self.fake_program('gsettings', '''case "$1:$2:$3" in +get:org.cinnamon.theme:name) printf "'%s'\\n" "$SELECTED_THEME" ;; +range:*) exit 1 ;; +*) exit 0 ;; +esac''') + self.fake_program('gdbus', '''[[ -f $RELOAD_THEME/accent-name ]] || exit 9 +printf '%s\\n' "$*" >> "$RELOAD_LOG" +[[ ${RELOAD_FAIL:-no} != yes ]]''') + self.run_cli('--accent', 'pink') + self.assertIn('org.Cinnamon.ReloadTheme --timeout 10', log.read_text()) + self.assertNotIn('Eval', log.read_text()) + before = log.read_text() + self.run_cli('--recolor', '--accent', 'green', '--dry-run') + self.assertEqual(log.read_text(), before) + self.env['SELECTED_THEME'] = 'Other theme' + self.run_cli('--recolor', '--accent', 'yellow') + self.assertEqual(log.read_text(), before) + self.env.update(SELECTED_THEME=base.THEME, RELOAD_FAIL='yes') + result = self.run_cli('--recolor', '--accent', 'purple') + self.assertIn('Reselect the desktop theme', result.stderr) + self.assertEqual((self.theme / 'accent-name').read_text(), 'purple\n') + before = log.read_text() + self.run_cli('--remove') + self.assertEqual(log.read_text(), before) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/tests/test_guided_installer.py b/tests/test_guided_installer.py index 00b78a7..bdcc2b6 100644 --- a/tests/test_guided_installer.py +++ b/tests/test_guided_installer.py @@ -121,9 +121,60 @@ def terminal(self, args=(), source=base.ROOT): def install_choices(self, terminal, gtk="n", extras="n"): terminal.answer("Choose [1]:", "1") + terminal.answer("Choose [0]:", "0") # Keep the current theme accent. terminal.answer("Apply the theme to native GTK4/libadwaita apps too?", gtk) terminal.answer("Copy optional application themes or wallpaper?", extras) + def test_install_directly_offers_independent_theme_and_icon_colors(self): + t = self.terminal() + t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "8") # Pink theme. + t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") + t.answer("Copy optional application themes or wallpaper?", "y") + t.answer("Choose [0]:", "9") # Icons component. + t.answer("Choose [0]:", "0") + t.answer("Choose [0]:", "4") # Gold icons. + t.expect("Folder icon theme (gold; choice: gold)") + t.answer("Apply these changes?", "y") + t.finish() + self.assertEqual((self.theme / "accent-name").read_text(), "pink\n") + self.assertEqual((self.theme / "icon-accent").read_text(), "gold\n") + self.assertEqual((self.data / "icons" / base.THEME / "accent-name").read_text(), "gold\n") + + def test_quick_color_menu_preview_cancel_and_apply(self): + base.InstallerTests.run_cli(self, "--icons", "--extras", "kitty") + files = [self.theme / "accent-name", self.theme / "icon-accent", + self.data / "icons" / base.THEME / "accent-name", + self.config / "kitty/themes/adwaita-amoled.conf"] + before = [p.read_bytes() for p in files] + for reply in ("p", "n", "y"): + t = self.terminal() + t.answer("Choose [1]:", "7") + t.answer("Choose [0]:", "5") # Green theme. + t.answer("Choose [0]:", "9") # Pink icons. + t.expect("Folder icon theme (pink; choice: pink)") + t.answer("Apply these changes?", reply) + t.finish() + if reply != "y": + self.assertEqual([p.read_bytes() for p in files], before) + self.assertEqual(files[0].read_text(), "green\n") + self.assertEqual(files[1].read_text(), "pink\n") + self.assertEqual(files[2].read_text(), "pink\n") + self.assertEqual(files[3].read_bytes(), (base.ROOT / "accents/green/extra/kitty/adwaita-amoled.conf").read_bytes()) + self.assertFalse((self.config / "qt5ct").exists()) + + def test_main_icon_picker_defaults_back_to_matching(self): + base.InstallerTests.run_cli(self, "--icons", "--accent", "pink", "--icon-accent", "gold") + t = self.terminal() + t.answer("Choose [1]:", "6") + t.answer("Choose [0]:", "1") + t.answer("Choose [1]:", "7") + t.answer("Choose [0]:", "0") + t.answer("Apply these changes?", "y") + t.finish() + self.assertEqual((self.theme / "icon-accent").read_text(), "match\n") + self.assertEqual((self.data / "icons" / base.THEME / "accent-name").read_text(), "pink\n") + def test_release_archive_contains_and_runs_guided_setup(self): archive = self.base / "runtime.tar.gz" subprocess.run( @@ -176,7 +227,7 @@ def test_cancel_and_preview_make_no_files_or_settings(self): def test_help_invalid_input_and_exit_do_not_install(self): t = self.terminal() t.answer("Choose [1]:", "bogus") - t.expect("Enter a number from 0 to 5.") + t.expect("Enter a number from 0 to 7.") t.answer("Choose [1]:", "3") t.expect("For command-line options") t.answer("Choose [1]:", "0") @@ -245,6 +296,7 @@ def test_optional_details_explain_selected_extras_without_applying(self): self.install_choices(t, extras="y") for choice in ["10", "0"]: t.answer("Choose [0]:", choice) + t.answer("Choose [0]:", "0") # Folder icons match the theme. t.answer("Apply these changes?", "d") t.expect("About the selected extras") t.expect("Apply these changes?") @@ -279,11 +331,13 @@ def test_icon_activation_is_offered_separately_and_preview_is_safe(self): for reply in ("p", "y"): t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "n") t.answer("Copy optional application themes or wallpaper?", "y") for choice in ("9", "0"): t.answer("Choose [0]:", choice) + t.answer("Choose [0]:", "0") # Folder icons match the theme. t.expect("also uses Adwaita application icons") t.answer("Select the Adwaita-AMOLED icon theme for this desktop now?", "y") t.answer("Apply these changes?", reply) @@ -340,6 +394,7 @@ def test_supported_shell_matches_and_unsupported_shell_is_not_offered(self): self.fake("gnome-shell", "echo 'GNOME Shell " + version + "'") t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "y") if version == "46.10": @@ -367,6 +422,7 @@ def test_missing_user_themes_does_not_block_gnome_gtk_installation(self): self.fake("gnome-shell", "echo 'GNOME Shell 46.10'") t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "y") t.expect("To apply them, install/allow User Themes") @@ -384,6 +440,7 @@ def test_budgie_gnome_session_does_not_offer_gnome_shell_activation(self): self.fake("gnome-shell", "echo 'GNOME Shell 46.10'") t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "y") t.answer("Copy optional application themes or wallpaper?", "n") @@ -403,6 +460,7 @@ def test_desktop_selection_happens_only_after_confirmation(self): for apply in ["n", "y"]: t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "y") t.answer("Copy optional application themes or wallpaper?", "n") @@ -437,6 +495,7 @@ def test_dark_preference_review_cancel_preview_and_apply(self): self.env["XDG_CURRENT_DESKTOP"] = desktop t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "n") t.answer("Copy optional application themes or wallpaper?", "n") @@ -505,6 +564,7 @@ def test_unavailable_dark_preference_does_not_add_question_or_block_installation ) t = self.terminal() t.answer("Choose [1]:", "1") + t.answer("Choose [0]:", "0") # Keep the current accent. t.answer("Apply the theme to native GTK4/libadwaita apps too?", "n") t.answer("Select Adwaita-AMOLED for this desktop now?", "n") t.answer("Copy optional application themes or wallpaper?", "n") @@ -634,13 +694,17 @@ def test_shared_color_choice_is_in_the_review_without_writing_system_paths(self) t = self.terminal(("--interactive",)) t.answer("Choose [0]:", "3") t.answer("Choose [0]:", "8") + t.answer("Choose [0]:", "4") + t.answer("Choose [0]:", "6") # Independent green icons. t.answer("Choose [0]:", "1") - t.answer("Choose [1]:", "2") - t.answer("Also manage the accent-colored folder icon theme for all users?", "n") + t.answer("Choose [1]:", "1") + t.answer("Also manage a link under /usr/share/themes", "n") + t.answer("Also manage the accent-colored folder icon theme for all users?", "y") t.answer("Apply these changes?", "p") text = t.finish() self.assertIn("Accent color: pink", text) - self.assertIn("/usr/share/themes/Adwaita-AMOLED", text) + self.assertIn("Folder icon theme (green; choice: green)", text) + self.assertIn("/usr/local/share/themes/Adwaita-AMOLED", text) self.assertEqual(list(self.home.iterdir()), []) def test_shared_setup_preview_and_cancel_never_write_system_paths(self): diff --git a/tests/test_icons.py b/tests/test_icons.py index c29528a..0b971f6 100644 --- a/tests/test_icons.py +++ b/tests/test_icons.py @@ -153,9 +153,9 @@ def test_icon_staging_failure_preserves_the_previous_icon_theme(self): self.run_cli("--icons") root = self.icon_root() previous = (root / "scalable/places/folder.svg").read_bytes() - self.env["ICON_SOURCE"] = str(self.theme / PREFIX) + self.env["ICON_PARENT"] = str(root.parent) self.fake_program("cp", '''for value in "$@"; do -[[ $value != "$ICON_SOURCE/." ]] || { echo 'simulated icon copy failure' >&2; exit 1; } +[[ $value != "$ICON_PARENT/".Adwaita-AMOLED-install.*/new/*.svg ]] || { echo 'simulated icon copy failure' >&2; exit 1; } done exec /usr/bin/cp "$@"''') self.run_cli("--icons", "--accent", "red", success=False) diff --git a/tests/test_system_installer.py b/tests/test_system_installer.py index 3b0b634..0e30e54 100644 --- a/tests/test_system_installer.py +++ b/tests/test_system_installer.py @@ -12,6 +12,26 @@ class SystemInstallerTests(unittest.TestCase): setUp = base.InstallerTests.setUp run_cli = base.InstallerTests.run_cli + def test_shared_recolor_retains_independent_icons_without_user_files(self): + self.assertEqual(os.geteuid(), 0) + dest = self.base / "shared/themes" + icon_dest = self.base / "shared/icons" + common = ("--system", "--dest", str(dest), "--icon-dest", str(icon_dest)) + self.run_cli(*common, "--icons", "--accent", "pink", "--icon-accent", "gold") + self.run_cli(*common, "--recolor", "--accent", "purple") + theme = dest / base.THEME + icons = icon_dest / base.THEME + self.assertEqual((theme / "accent-name").read_text(), "purple\n") + self.assertEqual((theme / "icon-accent").read_text(), "gold\n") + self.assertEqual((icons / "accent-name").read_text(), "gold\n") + self.run_cli(*common, "--recolor", "--icon-accent", "match") + self.assertEqual((icons / "accent-name").read_text(), "purple\n") + for root in (theme, icons): + for path in root.rglob("*"): + self.assertEqual(path.stat().st_uid, 0) + self.assertFalse(path.stat().st_mode & 0o022) + self.assertFalse(self.config.exists()) + def test_optional_shared_icons_are_root_owned_and_use_staged_paths(self): self.assertEqual(os.geteuid(), 0) dest = self.base / "shared/themes"