diff --git a/AGENTS.md b/AGENTS.md index 50c3983..63d2afd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,8 +29,9 @@ gamescope and the Plasma desktop. Primary target: the Valve Steam Machine `_available` is checked via `component_available` (e.g. `machine` only on Fremont). Turn-on order is `COMPONENTS` order, turn-off reverse; `gaming` must stay first. Dependencies live in `toggle_component`. -- **Feature versions.** Bump `FEATURE_VERSION[]` (`lib/menu.sh`) whenever - what `_enable` sets up changes: installs recorded with an older number +- **Feature versions.** Set `FEATURE_VERSION[]` (`lib/menu.sh`) to the new + `VERSION` whenever what `_enable` sets up changes (a new component gets + one too): installs recorded with an older version are ticked and re-applied ("update" in the plan and the app). New default sub-options are ticked for installs whose parent is on (`feature_new`). Status still comes from the system; don't add ad-hoc `_repair` checks diff --git a/TECHNICAL.md b/TECHNICAL.md index 3e2d66b..2bb7b10 100644 --- a/TECHNICAL.md +++ b/TECHNICAL.md @@ -238,20 +238,24 @@ normal run adds it. ## Feature versions (updates) -Each component has a feature version (`FEATURE_VERSION` in `lib/menu.sh`, -1 when not listed). After a component is turned on successfully, the version -is recorded in `~/.local/state/cachyos-gamescope-boot/features.state` +Each component has a feature version (`FEATURE_VERSION` in `lib/menu.sh`): +the Steamify version in which what it sets up last changed (2.1.0 for +everything that hasn't changed since). After a component is turned on +successfully, that version is recorded in `~/.local/state/cachyos-gamescope-boot/features.state` (turning it off records `off`). Whether a component is on is always checked on the system itself; the version only decides about updates: - **On, recorded version older** than the current one: ticked and re-applied by a normal run; the plan (and the app's review) says - "update". A setup from before versions were recorded counts as 1. + "update". A setup from before versions were recorded counts as 2.1.0, + so on a machine set up with 2.1.0, Steam Machine support (2.2.0) is + updated. - **A new default sub-option** (not in `NO_PRESELECT`) whose parent is on and that was never turned on or off: ticked, so a normal run adds it. Turning it off once records `off`, so it isn't ticked again. -Bump a component's number whenever what its `_enable` sets up changes. +Set a component's entry to the new `VERSION` whenever what its +`_enable` sets up changes. ## BIOS updates (Steam Machine) diff --git a/lib/menu.sh b/lib/menu.sh index 6e1742f..6f64ecd 100644 --- a/lib/menu.sh +++ b/lib/menu.sh @@ -17,12 +17,18 @@ declare -A PARENT=([boot]=gaming [poweroff]=machine [kpin]=machine [hdmi]=machin # which has CEC like on SteamOS. HDMI refresh boost needs someone at the # screen to confirm each step. NO_PRESELECT=(boot cec kpin hdmi) -# Feature versions: bump a component's number whenever what its enable sets -# up changes. Each successful run records the number (state "features"); a -# component that's on with an older number is ticked and re-applied by a -# normal run, and the app shows it as an update. Unlisted = 1, and so is a -# setup from before these were recorded. -declare -A FEATURE_VERSION=() +# Feature versions: the Steamify version in which what a component's enable +# sets up last changed; set it to the new VERSION whenever you change one. +# Each successful run records it (state "features"); a component that's on +# with an older one is ticked and re-applied by a normal run, and the app +# shows it as an update. A setup from before these were recorded counts as +# FEATURE_BASELINE. +FEATURE_BASELINE=2.1.0 +declare -A FEATURE_VERSION=( + [gaming]=2.1.0 [boot]=2.1.0 [theme]=2.1.0 [glyphs]=2.1.0 [single]=2.1.0 + [launcher]=2.1.0 [cec]=2.1.0 [machine]=2.2.0 [poweroff]=2.2.0 + [kpin]=2.1.0 [hdmi]=2.1.0 +) declare -A LABEL=( [gaming]="SteamOS conversion: boot into gaming mode, Steam on the desktop" @@ -66,16 +72,19 @@ menu_visible() { feature_record() { # feature_record : after a successful run. - if [[ "$2" == enable ]]; then state_set features "$1" "${FEATURE_VERSION[$1]:-1}" + if [[ "$2" == enable ]]; then state_set features "$1" "${FEATURE_VERSION[$1]:-$FEATURE_BASELINE}" else state_set features "$1" off; fi } feature_outdated() { - # On, but set up by an older version of that feature. - local have + # On, but set up by an older version of that feature (compared as + # versions: 2.10.0 is newer than 2.9.0). + local have want [[ "${CURRENT[$1]:-0}" == 1 ]] || return 1 - have="$(state_get features "$1" 1)" - [[ "$have" =~ ^[0-9]+$ ]] && (( have < ${FEATURE_VERSION[$1]:-1} )) + have="$(state_get features "$1" "$FEATURE_BASELINE")" + [[ "$have" == off ]] && have="$FEATURE_BASELINE" + want="${FEATURE_VERSION[$1]:-$FEATURE_BASELINE}" + [[ "$have" != "$want" && "$(printf '%s\n' "$have" "$want" | sort -V | head -n 1)" == "$have" ]] } feature_new() {