#!/usr/bin/env bash set -euo pipefail # POS: entertainment config — Show or edit the entertainment config (ENABLED auto-trigger list, weather location) source "$(dirname "$0")/../lib/common.sh" 2>/dev/null || source "$(dirname "$0")/common.sh" source "$(dirname "$0")/../lib/entertainment-lib.sh" 2>/dev/null || source "$(dirname "$0")/entertainment-lib.sh" keys_section() { # Renders the Keys reference: ENABLED + every key declared by installed # plugins (via their # POS_KEYS: headers), aligned by key name. local d="$1" maxw=8 line key plugin desc req while IFS= read -r line; do IFS='|' read -r _plugin key _desc _req <<<"$line" [ ${#key} -gt "$maxw" ] && maxw=${#key} done <<< "$(config_keys "$d")" printf ' %-*s %s\n' "$maxw" "ENABLED" "Auto-trigger list: comma-separated 'plugin, interval' pairs," printf ' %-*s %s\n' "$maxw" "" "e.g. ENABLED=\"weather, 5m gold, 1h\"" while IFS= read -r line; do [ -n "$line" ] || continue IFS='|' read -r plugin key desc req <<<"$line" printf ' %-*s %s (%s) [%s]\n' "$maxw" "$key" "$desc" "$req" "$plugin" done <<< "$(config_keys "$d")" printf ' %-*s %s\n' "$maxw" "" "UPPER_SNAKE key settable freely; a warning is shown if no installed plugin declares it" } usage() { cat < [interval]' or 'pos entertainment config set ...')" fi echo echo "ENABLED: $(config_value ENABLED)" echo "Intervals: 5m 10m 15m 30m 45m hourly 2h 6h 12h daily weekly, or OnCalendar=..." echo echo "Plugin keys (declared in each plugin's # POS_KEYS: header):" keys_section "$(plugin_dir)" ;; esac