diff --git a/lib/menu.sh b/lib/menu.sh index 8372868..9fcebde 100644 --- a/lib/menu.sh +++ b/lib/menu.sh @@ -236,6 +236,31 @@ defaults_options() { return 0 } +defaults_list() { + # --defaults --list: what --defaults can set up on this PC, as one JSON + # array, for an installer page (the Steam Machine ISO builds its Steamify + # page from it, so new items show up without a new ISO). Per item: id, + # label, hint, kind (toggle, or choice for boot: on = desktop), parent, + # on (preselected like a first run) and selectable. Actions, retired + # items and items this PC can't use (e.g. no Steam account yet) are + # left out. Read-only: no sudo, no state. + local c kind on sel items="" + for c in "${COMPONENTS[@]}"; do + component_available "$c" || continue + is_action "$c" && continue + [[ "$c" == kpin || "$c" == hdmi ]] && continue + kind=toggle; [[ "$c" == boot ]] && kind=choice + sel=false; component_selectable "$c" && sel=true + on=false + [[ "$sel" == true && " ${NO_PRESELECT[*]} " != *" $c "* ]] && on=true + [[ "$c" == cec ]] && machine_available && on=true + items+="${items:+,}{\"id\":$(json_str "$c"),\"label\":$(json_str "${LABEL[$c]%%:*}")" + items+=",\"hint\":$(json_str "$( [[ "${LABEL[$c]}" == *:* ]] && echo "${LABEL[$c]#*: }")")" + items+=",\"kind\":\"$kind\",\"parent\":$(json_str "${PARENT[$c]:-}"),\"on\":$on,\"selectable\":$sel}" + done + printf '[%s]\n' "$items" +} + toggle_component() { local c="$1" component_selectable "$c" || return 1 diff --git a/steamify.sh b/steamify.sh index 43d9b1a..f9662b4 100755 --- a/steamify.sh +++ b/steamify.sh @@ -33,12 +33,16 @@ BACKEND=false # prompt (the Steam Machine ISO's first login runs this; sudo must not ask). DEFAULTS=false [[ "${1:-}" == --defaults ]] && DEFAULTS=true +# --defaults --list: what --defaults can set up here, as JSON (an installer +# page is built from it); nothing else on stdout. +LIST=false +[[ "$DEFAULTS" == true && "${2:-}" == --list ]] && LIST=true # --boot gamescope|desktop: only change where an installed conversion # starts, everything else stays as it is (for scripts; no menu). BOOT_ONLY=false [[ "${1:-}" == --boot ]] && BOOT_ONLY=true -if [[ "$BACKEND" == false ]]; then +if [[ "$BACKEND" == false && "$LIST" == false ]]; then echo -e "${c_bold}Steamify CachyOS${c_reset} v$VERSION" echo "Turn the SteamOS-style parts on or off. The menu shows what is on now;" echo "anything you turn off is put back the way it was." @@ -128,6 +132,11 @@ if [[ "${1:-}" == --first-login ]]; then exit 0 fi +if [[ "$LIST" == true ]]; then + defaults_list + exit 0 +fi + if [[ "$DEFAULTS" == true ]]; then RESTART_FOR_LOGIN=false REAPPLY=false