diff --git a/.github/workflows/create-beta.yml b/.github/workflows/create-beta.yml index 130d3e456..398653aa7 100644 --- a/.github/workflows/create-beta.yml +++ b/.github/workflows/create-beta.yml @@ -3,9 +3,17 @@ name: Create Beta Release on: workflow_dispatch: inputs: + action_type: + description: 'Action to perform' + required: true + type: choice + options: + - create + - delete + default: 'create' target_branch: description: 'Branch to create beta from' - required: true + required: false default: 'Development' type: string @@ -14,6 +22,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + if: github.event.inputs.action_type == 'create' steps: - uses: actions/checkout@v4 with: @@ -46,10 +55,10 @@ jobs: - name: Check for commits id: check_commits run: | - # Get all commits - COMMITS=$(git log --pretty=format:'- %s (%an)%n') + # Get commits from last 24 hours + COMMITS=$(git log --since="24 hours ago" --pretty=format:'- %s (%an)%n') if [ -z "$COMMITS" ]; then - echo "No commits found" + echo "No commits found in the last 24 hours" exit 1 fi { @@ -83,7 +92,9 @@ jobs: -x!.gitattributes \ -x!create_spruce_release.bat \ -x!create_spruce_release.sh \ - -x!commits_beta.txt + -x!commits_beta.txt \ + -x!spruce/flags/developer_mode \ + -x!spruce/flags/developer_mode.lock # Add the commits file separately to place it at the root 7z u "spruceV${{ steps.get_version.outputs.version }}.7z" commits_beta.txt @@ -151,14 +162,68 @@ jobs: env: GH_TOKEN: ${{ secrets.PAT_TOKEN }} run: | - # Get all releases sorted by created date (newest first) - RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[].id') + # Get all beta releases + BETA_RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[] | select(.tag_name | contains("-beta")) | .id') - # Convert to array and keep only releases after the first 3 + # Convert to array and keep only the newest beta COUNT=0 - for RELEASE_ID in $RELEASES; do + for RELEASE_ID in $BETA_RELEASES; do COUNT=$((COUNT + 1)) - if [ $COUNT -gt 3 ]; then + if [ $COUNT -gt 1 ]; then gh api repos/spruceUI/spruceOSNightlies/releases/$RELEASE_ID -X DELETE fi - done \ No newline at end of file + done + + delete-beta: + runs-on: ubuntu-latest + permissions: + contents: write + if: github.event.inputs.action_type == 'delete' + steps: + - name: Delete beta releases + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN }} + run: | + # Get and delete all beta releases + BETA_RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[] | select(.tag_name | contains("-Beta")) | .id') + for RELEASE_ID in $BETA_RELEASES; do + gh api repos/spruceUI/spruceOSNightlies/releases/$RELEASE_ID -X DELETE + done + + - name: Clone and update OTA repos + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN }} + run: | + # Clone both repositories + git clone https://github.com/spruceUI/spruceui.github.io.git ota_repo + git clone https://github.com/spruceUI/spruceSource.git source_repo + + # Function to update OTA file + update_ota_file() { + local file="$1" + local content + content=$(cat "$file") + + # Remove BETA_ lines while preserving others + echo "$content" | grep -v "^BETA_" > "$file" + } + + # Update both OTA files + update_ota_file "ota_repo/OTA/spruce" + update_ota_file "source_repo/OTA/spruce" + + # Update primary OTA repo + cd ota_repo + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git add OTA/spruce + git commit -m "Remove beta release information" + git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/spruceUI/spruceui.github.io.git main + + # Update backup OTA repo + cd ../source_repo + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git add OTA/spruce + git commit -m "Remove beta release information" + git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/spruceUI/spruceSource.git main diff --git a/.github/workflows/create-nightly.yml b/.github/workflows/create-nightly.yml index a5cde7a95..124fd9eb4 100644 --- a/.github/workflows/create-nightly.yml +++ b/.github/workflows/create-nightly.yml @@ -149,8 +149,9 @@ jobs: env: GH_TOKEN: ${{ secrets.PAT_TOKEN }} run: | - # Get all releases sorted by created date (newest first) - RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[].id') + # Get all releases and filter out beta releases + RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | \ + jq -r '.[] | select(.tag_name | contains("-Beta") | not) | .id') # Convert to array and keep only releases after the first 3 COUNT=0 diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 86ff7a13e..46c97afa3 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -103,24 +103,25 @@ jobs: - Fixed some bugs ****** - - ## Updating + ## Downloads: ***** + [Fresh Install click here](https://github.com/spruceUI/spruceOS/releases/download/v${{ steps.get_version.outputs.version }}/spruceV${{ steps.get_version.outputs.version }}.zip) - [Fresh Install instructions](https://github.com/spruceUI/spruceOS/wiki/Installation-Instructions) + [Wiki instructions](https://github.com/spruceUI/spruceOS/wiki/01.-Installation-Instructions) ***** + [Update from 3.0.0 or newer click here](https://github.com/spruceUI/spruceOS/releases/download/v${{ steps.get_version.outputs.version }}/spruceV${{ steps.get_version.outputs.version }}.7z) - [Update from 3.0.0 or newer instructions](https://github.com/spruceUI/spruceOS/wiki/Updating-to-the-Latest-Release#ez-updater-for-spruce-vversions-300-and-above) + [Wiki instructions](https://github.com/spruceUI/spruceOS/wiki/02.-Updating-to-the-Latest-Release#ez-updater-for-spruce-versions-300-and-above) ***** + [Update from pre-3.0.0 click here](https://github.com/spruceUI/spruceOS/releases/download/v${{ steps.get_version.outputs.version }}/EZ.Updater.spruceV${{ steps.get_version.outputs.version }}.zip) - [Update from pre-3.0.0 instructions](https://github.com/spruceUI/spruceOS/wiki/Updating-to-the-Latest-Release#ez-updater-for-spruce--versions-230-and-below) + [Wiki instructions](https://github.com/spruceUI/spruceOS/wiki/02.-Updating-to-the-Latest-Release#ez-updater-for-spruce--versions-230-and-below) ***** - Credits/Thanks repository: spruceUI/spruceOS token: ${{ secrets.PAT_TOKEN }} diff --git a/App/-OTA/downloader.sh b/App/-OTA/downloader.sh index 0ac4cb4e8..26976106c 100644 --- a/App/-OTA/downloader.sh +++ b/App/-OTA/downloader.sh @@ -76,6 +76,21 @@ BETA_LINK=$(sed -n 's/BETA_LINK=//p' "$TMP_DIR/spruce" | tr -d '\n\r') BETA_SIZE=$(sed -n 's/BETA_SIZE_IN_MB=//p' "$TMP_DIR/spruce" | tr -d '\n\r') BETA_INFO=$(sed -n 's/BETA_INFO=//p' "$TMP_DIR/spruce" | tr -d '\n\r') +# Function to offer version choice +offer_version() { + local prompt="$1" + local version1="$2" + local version1_name="$3" + local version2="$4" + local version2_name="$5" + + display --icon "$IMAGE_PATH" -t "$prompt +$version1_name: $version1 +$version2_name: $version2" -p 220 --confirm + confirm + return $? +} + # Set default target to release TARGET_VERSION="$RELEASE_VERSION" TARGET_CHECKSUM="$RELEASE_CHECKSUM" @@ -83,73 +98,56 @@ TARGET_LINK="$RELEASE_LINK" TARGET_SIZE="$RELEASE_SIZE" TARGET_INFO="$RELEASE_INFO" -# Handle developer and tester mode selections +# Function to set target version +set_target() { + local version="$1" + local checksum="$2" + local link="$3" + local size="$4" + local info="$5" + + TARGET_VERSION="$version" + TARGET_CHECKSUM="$checksum" + TARGET_LINK="$link" + TARGET_SIZE="$size" + TARGET_INFO="$info" +} + +# Handle version selection based on flags if flag_check "developer_mode"; then # Developer mode: offer nightly -> beta -> release - display --icon "$IMAGE_PATH" -t "Developer mode detected. Would you like to use the latest nightly build? -Latest nightly: $NIGHTLY_VERSION -$([ -n "$BETA_VERSION" ] && echo "Beta release: $BETA_VERSION") -Public release: $RELEASE_VERSION" -p 220 --confirm - if confirm; then - TARGET_VERSION="$NIGHTLY_VERSION" - TARGET_CHECKSUM="$NIGHTLY_CHECKSUM" - TARGET_LINK="$NIGHTLY_LINK" - TARGET_SIZE="$NIGHTLY_SIZE" - TARGET_INFO="$NIGHTLY_INFO" + if offer_version "Developer mode detected. Would you like to use the latest nightly build?" "$NIGHTLY_VERSION" "Latest nightly" "$RELEASE_VERSION" "Public release"; then + set_target "$NIGHTLY_VERSION" "$NIGHTLY_CHECKSUM" "$NIGHTLY_LINK" "$NIGHTLY_SIZE" "$NIGHTLY_INFO" elif [ -n "$BETA_VERSION" ]; then - display --icon "$IMAGE_PATH" -t "Would you like to use the beta build instead? -Beta version: $BETA_VERSION -Public release: $RELEASE_VERSION" -p 220 --confirm - if confirm; then - TARGET_VERSION="$BETA_VERSION" - TARGET_CHECKSUM="$BETA_CHECKSUM" - TARGET_LINK="$BETA_LINK" - TARGET_SIZE="$BETA_SIZE" - TARGET_INFO="$BETA_INFO" + if offer_version "Would you like to use the beta build instead?" "$BETA_VERSION" "Beta version" "$RELEASE_VERSION" "Public release"; then + set_target "$BETA_VERSION" "$BETA_CHECKSUM" "$BETA_LINK" "$BETA_SIZE" "$BETA_INFO" + fi + fi +elif flag_check "beta"; then + # Beta mode: offer beta (if exists) -> release + if [ -n "$BETA_VERSION" ]; then + if offer_version "Beta mode detected. Would you like to use the beta build?" "$BETA_VERSION" "Beta version" "$RELEASE_VERSION" "Public release"; then + set_target "$BETA_VERSION" "$BETA_CHECKSUM" "$BETA_LINK" "$BETA_SIZE" "$BETA_INFO" fi fi elif flag_check "tester_mode"; then # Tester mode: offer beta (if exists) -> nightly -> release if [ -n "$BETA_VERSION" ]; then - display --icon "$IMAGE_PATH" -t "Tester mode detected. Would you like to use the beta build? -Beta version: $BETA_VERSION -Public release: $RELEASE_VERSION" -p 220 --confirm - if confirm; then - TARGET_VERSION="$BETA_VERSION" - TARGET_CHECKSUM="$BETA_CHECKSUM" - TARGET_LINK="$BETA_LINK" - TARGET_SIZE="$BETA_SIZE" - TARGET_INFO="$BETA_INFO" - else - display --icon "$IMAGE_PATH" -t "Would you like to use the latest nightly instead? -Latest nightly: $NIGHTLY_VERSION -Public release: $RELEASE_VERSION" -p 220 --confirm - if confirm; then - TARGET_VERSION="$NIGHTLY_VERSION" - TARGET_CHECKSUM="$NIGHTLY_CHECKSUM" - TARGET_LINK="$NIGHTLY_LINK" - TARGET_SIZE="$NIGHTLY_SIZE" - TARGET_INFO="$NIGHTLY_INFO" - fi + if offer_version "Tester mode detected. Would you like to use the beta build?" "$BETA_VERSION" "Beta version" "$RELEASE_VERSION" "Public release"; then + set_target "$BETA_VERSION" "$BETA_CHECKSUM" "$BETA_LINK" "$BETA_SIZE" "$BETA_INFO" + elif offer_version "Would you like to use the latest nightly instead?" "$NIGHTLY_VERSION" "Latest nightly" "$RELEASE_VERSION" "Public release"; then + set_target "$NIGHTLY_VERSION" "$NIGHTLY_CHECKSUM" "$NIGHTLY_LINK" "$NIGHTLY_SIZE" "$NIGHTLY_INFO" fi else - # No beta available, offer nightly - display --icon "$IMAGE_PATH" -t "Tester mode detected. Would you like to use the latest nightly build? -Latest nightly: $NIGHTLY_VERSION -Public release: $RELEASE_VERSION" -p 220 --confirm - if confirm; then - TARGET_VERSION="$NIGHTLY_VERSION" - TARGET_CHECKSUM="$NIGHTLY_CHECKSUM" - TARGET_LINK="$NIGHTLY_LINK" - TARGET_SIZE="$NIGHTLY_SIZE" - TARGET_INFO="$NIGHTLY_INFO" + if offer_version "Tester mode detected. Would you like to use the latest nightly build?" "$NIGHTLY_VERSION" "Latest nightly" "$RELEASE_VERSION" "Public release"; then + set_target "$NIGHTLY_VERSION" "$NIGHTLY_CHECKSUM" "$NIGHTLY_LINK" "$NIGHTLY_SIZE" "$NIGHTLY_INFO" fi fi fi SKIP_VERSION_CHECK=false # Set SKIP_VERSION_CHECK to true if developer mode or tester mode is enabled -if flag_check "developer_mode" || flag_check "tester_mode"; then +if flag_check "developer_mode" || flag_check "tester_mode" || flag_check "beta"; then SKIP_VERSION_CHECK=true fi diff --git a/App/-OTA/downloaderFunctions.sh b/App/-OTA/downloaderFunctions.sh index 7e9d4bc0e..3af206eaf 100644 --- a/App/-OTA/downloaderFunctions.sh +++ b/App/-OTA/downloaderFunctions.sh @@ -61,8 +61,8 @@ check_for_update() { done # Get current version based on mode - if flag_check "developer_mode" || flag_check "tester_mode"; then - CURRENT_VERSION=$(get_version_nightly) + if flag_check "developer_mode" || flag_check "tester_mode" || flag_check "beta"; then + CURRENT_VERSION=$(get_version_complex) else CURRENT_VERSION=$(get_version) fi @@ -90,26 +90,62 @@ check_for_update() { NIGHTLY_LINK=$(sed -n 's/NIGHTLY_LINK=//p' "$TMP_DIR/spruce" | tr -d '\n\r') NIGHTLY_SIZE=$(sed -n 's/NIGHTLY_SIZE_IN_MB=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + # Extract beta info + BETA_VERSION=$(sed -n 's/BETA_VERSION=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + BETA_CHECKSUM=$(sed -n 's/BETA_CHECKSUM=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + BETA_LINK=$(sed -n 's/BETA_LINK=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + BETA_SIZE=$(sed -n 's/BETA_SIZE_IN_MB=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + BETA_INFO=$(sed -n 's/BETA_INFO=//p' "$TMP_DIR/spruce" | tr -d '\n\r') + # Set target version based on developer/tester mode TARGET_VERSION="$RELEASE_VERSION" + if flag_check "beta"; then + TARGET_VERSION="$BETA_VERSION" + fi + if flag_check "developer_mode" || flag_check "tester_mode"; then TARGET_VERSION="$NIGHTLY_VERSION" fi - # Compare versions, handling nightly date format + # Compare versions, handling nightly date format and beta versions log_message "Update Check: Comparing versions: $TARGET_VERSION vs $CURRENT_VERSION" - # Extract base version and date for nightly builds + # Extract base version, date, and beta status current_base_version=$(echo "$CURRENT_VERSION" | cut -d'-' -f1) - current_date=$(echo "$CURRENT_VERSION" | cut -d'-' -f2 -s) + current_suffix=$(echo "$CURRENT_VERSION" | cut -d'-' -f2 -s) + current_is_beta=$(echo "$current_suffix" | grep -q "Beta" && echo "1" || echo "0") + current_date=$(echo "$current_suffix" | grep -qE "^[0-9]{8}$" && echo "$current_suffix" || echo "") + target_base_version=$(echo "$TARGET_VERSION" | cut -d'-' -f1) - target_date=$(echo "$TARGET_VERSION" | cut -d'-' -f2 -s) + target_suffix=$(echo "$TARGET_VERSION" | cut -d'-' -f2 -s) + target_is_beta=$(echo "$target_suffix" | grep -q "Beta" && echo "1" || echo "0") + target_date=$(echo "$target_suffix" | grep -qE "^[0-9]{8}$" && echo "$target_suffix" || echo "") update_available=0 - if [ "$(echo "$target_base_version $current_base_version" | awk '{split($1,a,"."); split($2,b,"."); for (i=1; i<=3; i++) {if (a[i]b[i]) {print $1; exit}} print $2}')" != "$current_base_version" ]; then - update_available=1 - elif [ -n "$current_date" ] && [ -n "$target_date" ] && [ "$target_date" -gt "$current_date" ]; then + + # Compare base versions first + version_higher=$(echo "$target_base_version $current_base_version" | awk '{split($1,a,"."); split($2,b,"."); for (i=1; i<=3; i++) {if (a[i]b[i]) {print "1"; exit}} print "0"}') + + if [ "$version_higher" = "1" ]; then + # Target version is higher, always consider it an update update_available=1 + elif [ "$version_higher" = "0" ] && [ "$target_base_version" = "$current_base_version" ]; then + # Same base version, check suffixes + if flag_check "developer_mode" || flag_check "tester_mode"; then + # For testers/developers, nightlies are updates + if [ -n "$target_date" ] && [ -n "$current_date" ] && [ "$target_date" -gt "$current_date" ]; then + update_available=1 + fi + elif flag_check "beta"; then + # Beta mode logic + if [ "$current_is_beta" = "1" ]; then + # Currently on beta, only higher base versions are updates + update_available=0 + elif [ "$target_is_beta" = "1" ]; then + # Not on beta, but target is beta - consider it an update + update_available=1 + fi + fi fi if [ $update_available -eq 1 ]; then diff --git a/App/BootLogo/logos/RA Shortcuts splash2/bootlogo.png b/App/BootLogo/logos/RA Shortcuts splash2/bootlogo.png new file mode 100644 index 000000000..ac8bd22bf Binary files /dev/null and b/App/BootLogo/logos/RA Shortcuts splash2/bootlogo.png differ diff --git a/App/BoxartScraper/scraper.sh b/App/BoxartScraper/scraper.sh index 733f48305..487212271 100644 --- a/App/BoxartScraper/scraper.sh +++ b/App/BoxartScraper/scraper.sh @@ -236,9 +236,6 @@ if ! ping -c 2 thumbnails.libretro.com > /dev/null 2>&1; then fi fi -# Set CPU governor to performance mode -echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - # Process each system directory for sys_dir in "$roms_dir"/*/; do if [ ! -d "$sys_dir" ]; then @@ -261,7 +258,7 @@ for sys_dir in "$roms_dir"/*/; do sys_label="$(jq ".label" "/mnt/SDCARD/Emu/$sys_name/config.json")" icon_path="$(jq ".iconsel" "/mnt/SDCARD/Emu/$sys_name/config.json")" - display --icon "\"$icon_path\"" -t "System: $sys_label + display -d 1 --icon "\"$icon_path\"" -t "System: $sys_label Scraping boxart for $amount_games games..." --add-image "$IMAGE_EXIT" 1.15 195 middle if [ -z "$extensions" ]; then log_message "BoxartScraper: No supported extensions found for directory $sys_name, skipping" @@ -328,7 +325,4 @@ for sys_dir in "$roms_dir"/*/; do log_message "BoxartScraper: $sys_name: Scraped: $scraped_count, Skipped: $skip_count, Not Found: $non_found_count" done -# Reset CPU governor to ondemand mode -echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - auto_regen_tmp_update diff --git a/App/ThemeGarden/config.json b/App/ThemeGarden/config.json index e4ffe745d..f9a764804 100644 --- a/App/ThemeGarden/config.json +++ b/App/ThemeGarden/config.json @@ -1,6 +1,6 @@ { "label": "Theme Garden", - "icon": "/mnt/SDCARD/Themes/SPRUCE/icons/App/expertappswitch.png", + "icon": "/mnt/SDCARD/Themes/SPRUCE/icons/App/themegallery.png", "launch": "launch.sh", "description": "Check out the latest themes for your device!" } diff --git a/App/ThemeGarden/themeGarden.sh b/App/ThemeGarden/themeGarden.sh index 6e5258390..85192357e 100644 --- a/App/ThemeGarden/themeGarden.sh +++ b/App/ThemeGarden/themeGarden.sh @@ -1,9 +1,10 @@ #!/bin/sh -APP_DIR=/mnt/SDCARD/App/ThemeNursery -CACHE_DIR=/mnt/SDCARD/spruce/cache/themenursery +APP_DIR=/mnt/SDCARD/App/ThemeGarden +ICON_PATH="/mnt/SDCARD/spruce/imgs/themegallery.png" +CACHE_DIR=/mnt/SDCARD/spruce/cache/themegarden UNPACKER=/mnt/SDCARD/spruce/scripts/archiveUnpacker.sh -ARCHIVE_DIR=/mnt/SDCARD/spruce/archives/preMenu +ARCHIVE_DIR=/mnt/SDCARD/spruce/archives IMAGE_CONFIRM_EXIT="/mnt/SDCARD/miyoo/res/imgs/displayConfirmExit.png" IMAGE_EXIT="/mnt/SDCARD/miyoo/res/imgs/displayExit.png" DIRECTION_PROMPTS="/mnt/SDCARD/miyoo/res/imgs/displayLeftRight.png" @@ -12,8 +13,6 @@ THEME_BASE_URL="https://raw.githubusercontent.com/spruceUI/Themes/main/PackedThe . /mnt/SDCARD/spruce/scripts/helperFunctions.sh -log_verbose - # Create necessary directories mkdir -p "$CACHE_DIR" mkdir -p "$ARCHIVE_DIR" @@ -25,7 +24,7 @@ touch "$SEEN_THEMES_FILE" # Modified setup_previews to handle first-time downloads setup_previews() { local timestamp_file="$CACHE_DIR/last_update" - local max_age=1200 # 20 minutes in seconds + local max_age=1200 # 20 minutes in seconds local current_time=$(date +%s) local should_update=1 @@ -40,51 +39,51 @@ setup_previews() { # Update previews if needed if [ $should_update -eq 1 ] || [ ! -d "$CACHE_DIR/previews" ] || [ -z "$(find "$CACHE_DIR/previews" -name "*.png" 2>/dev/null)" ]; then - display -t "Downloading theme previews..." -p 240 + display --icon "$ICON_PATH" -t "Downloading theme previews..." rm -rf "$CACHE_DIR/previews" mkdir -p "$CACHE_DIR/previews" - + if ! curl -s -k -L -o "$CACHE_DIR/theme_previews.7z" "$PREVIEW_PACK_URL"; then - display -t "Failed to download theme previews!" -p 240 -d 2 + display --icon "$ICON_PATH" -t "Failed to download theme previews!" -d 2 exit 1 fi - + if ! 7zr x "$CACHE_DIR/theme_previews.7z" -o"$CACHE_DIR/previews" 2>&1; then - display -t "Failed to extract theme previews!" -p 240 -d 2 + display --icon "$ICON_PATH" -t "Failed to extract theme previews!" -d 2 log_message "Theme Nursery: 7z extraction error output: $?" rm -f "$CACHE_DIR/theme_previews.7z" exit 1 fi rm -f "$CACHE_DIR/theme_previews.7z" - + # Update timestamp - echo "$current_time" > "$timestamp_file" + echo "$current_time" >"$timestamp_file" fi - + # Final check if we have any preview files if [ -z "$(find "$CACHE_DIR/previews" -name "*.png" 2>/dev/null)" ]; then - display -t "No theme previews found!" -p 240 -d 2 + display --icon "$ICON_PATH" -t "No theme previews found!" -d 2 exit 1 fi # After successful preview extraction, mark new themes if [ $should_update -eq 1 ]; then # Create temporary file of current themes - find "$CACHE_DIR/previews" -name "*.png" -exec basename {} .png \; > "$CACHE_DIR/current_themes.txt" - + find "$CACHE_DIR/previews" -name "*.png" -exec basename {} .png \; >"$CACHE_DIR/current_themes.txt" + # Only mark new themes if this isn't first run (seen_themes file has content) if [ -s "$SEEN_THEMES_FILE" ]; then while read -r theme; do if ! grep -q "^${theme}$" "$SEEN_THEMES_FILE"; then mv "$CACHE_DIR/previews/${theme}.png" "$CACHE_DIR/previews/${theme}.new.png" - echo "$theme" >> "$SEEN_THEMES_FILE" + echo "$theme" >>"$SEEN_THEMES_FILE" fi - done < "$CACHE_DIR/current_themes.txt" + done <"$CACHE_DIR/current_themes.txt" else # First time run - just populate seen_themes file without marking as new - cat "$CACHE_DIR/current_themes.txt" > "$SEEN_THEMES_FILE" + cat "$CACHE_DIR/current_themes.txt" >"$SEEN_THEMES_FILE" fi - + rm -f "$CACHE_DIR/current_themes.txt" fi } @@ -92,9 +91,9 @@ setup_previews() { # Modified get_theme_list to prioritize new themes get_theme_list() { # First list new themes - find "$CACHE_DIR/previews" -name "*.new.png" -exec basename {} .new.png \; | sort > "$CACHE_DIR/theme_list.txt" + find "$CACHE_DIR/previews" -name "*.new.png" -exec basename {} .new.png \; | sort >"$CACHE_DIR/theme_list.txt" # Then list regular themes - find "$CACHE_DIR/previews" -name "*.png" ! -name "*.new.png" -exec basename {} .png \; | sort >> "$CACHE_DIR/theme_list.txt" + find "$CACHE_DIR/previews" -name "*.png" ! -name "*.new.png" -exec basename {} .png \; | sort >>"$CACHE_DIR/theme_list.txt" cat "$CACHE_DIR/theme_list.txt" rm -f "$CACHE_DIR/theme_list.txt" } @@ -104,7 +103,7 @@ show_theme_preview() { local theme_name="$1" local preview_path local display_name="$theme_name" - + # Check if it's a new theme if [ -f "$CACHE_DIR/previews/${theme_name}.new.png" ]; then preview_path="$CACHE_DIR/previews/${theme_name}.new.png" @@ -112,22 +111,19 @@ show_theme_preview() { else preview_path="$CACHE_DIR/previews/${theme_name}.png" fi - + # Check if theme is installed if [ -d "/mnt/SDCARD/Themes/${theme_name}" ]; then display_name="${display_name} - Installed" fi - + # Check if file exists and log details if [ ! -f "$preview_path" ]; then log_message "Theme Nursery: Preview file not found!" - display -t "Preview image not found!" -p 240 + display --icon "$ICON_PATH" -t "Preview image not found!" return 1 fi - - # Log file permissions and size - ls -l "$preview_path" | log_message - + display_kill display -t "$display_name @@ -149,35 +145,95 @@ download_theme() { local theme_name="$1" local encoded_name=$(echo "$theme_name" | sed 's/ /%20/g' | sed "s/'/%27/g") local theme_url="${THEME_BASE_URL}/${encoded_name}.7z" - local output_path="$ARCHIVE_DIR/${theme_name}.7z" - - display -t "Downloading ${theme_name}..." -p 240 - + local temp_path="$ARCHIVE_DIR/temp_${theme_name}.7z" + local final_path="$ARCHIVE_DIR/preMenu/${theme_name}.7z" + + display --icon "$ICON_PATH" -t "Downloading ${theme_name}..." + # Get file size for progress tracking TARGET_SIZE_BYTES="$(curl -k -I -L "$theme_url" 2>/dev/null | grep -i "Content-Length" | tail -n1 | cut -d' ' -f 2)" TARGET_SIZE_KILO=$((TARGET_SIZE_BYTES / 1024)) TARGET_SIZE_MEGA=$((TARGET_SIZE_KILO / 1024)) - + . /mnt/SDCARD/App/-OTA/downloaderFunctions.sh - download_progress "$output_path" "$TARGET_SIZE_MEGA" "Now downloading ${theme_name}!" & + download_progress "$temp_path" "$TARGET_SIZE_MEGA" "Now downloading ${theme_name}!" & download_pid=$! - - if ! curl -s -k -L -o "$output_path" "$theme_url"; then + + if ! curl -s -k -L -o "$temp_path" "$theme_url"; then kill $download_pid - display -t "Download failed for ${theme_name}!" -p 240 -d 2 + rm -f "$temp_path" + display --icon "$ICON_PATH" -t "Download failed for ${theme_name}! Please try again." -o return 1 fi kill $download_pid - - if [ -f "$output_path" ]; then - display -t "Download complete!" -p 240 + + if [ -f "$temp_path" ]; then + # Create preMenu directory if it doesn't exist + mkdir -p "$ARCHIVE_DIR/preMenu" + # Move the completed download to the final location + mv "$temp_path" "$final_path" + display --icon "$ICON_PATH" -t "Download complete!" + return 0 + else + display --icon "$ICON_PATH" -t "Download failed! Please try again." -o + return 1 + fi +} + +# Add this new function before the main loop +redownload_installed_themes() { + # Get list of installed themes that have matching previews + local installed_count=0 + local temp_list="" + + # Iterate through installed themes and check for preview existence + for theme_dir in /mnt/SDCARD/Themes/*/; do + [ -d "$theme_dir" ] || continue + theme_name=$(basename "$theme_dir") + + # Check if preview exists (either normal or .new) + if [ -f "$CACHE_DIR/previews/${theme_name}.png" ] || [ -f "$CACHE_DIR/previews/${theme_name}.new.png" ]; then + temp_list="${temp_list}${theme_name}\n" + installed_count=$((installed_count + 1)) + fi + done + + if [ $installed_count -eq 0 ]; then + display --icon "$ICON_PATH" -t "No downloadable themes installed!" -d 2 + return 1 + fi + + # Show confirmation dialog + display --icon "$ICON_PATH" -t "Re-download all ${installed_count} available themes?" --confirm + + if confirm; then + # Process each theme from our filtered list + printf "%b" "$temp_list" | while IFS= read -r theme_name; do + [ -z "$theme_name" ] && continue + display --icon "$ICON_PATH" -t "Updating: ${theme_name}" + download_theme "$theme_name" + done + + # Run unpacker silently after all downloads + sh "$UNPACKER" --silent & return 0 else - display -t "Download failed!" -p 240 -d 2 return 1 fi } +update_theme_order() { + if flag_check "pre_menu_unpacking"; then + display -t "Finishing up unpacking archives.........." -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" + flag_remove "silentUnpacker" + while [ -f "$FLAGS_DIR/pre_menu_unpacking.lock" ]; do + : # null operation (no sleep needed) + done + fi + display --icon "$ICON_PATH" -t "Sorting themes..." + sh /mnt/SDCARD/spruce/scripts/tasks/sortThemes.sh +} + # Initial setup setup_previews @@ -193,30 +249,39 @@ show_theme_preview "$current_theme_name" # Main loop while true; do action=$(get_button_press) + log_message "Theme Garden: Button press: $action" case $action in - "RIGHT") - if [ $current_theme -lt $total_themes ]; then - current_theme=$((current_theme + 1)) - current_theme_name=$(echo "$THEME_LIST" | sed -n "${current_theme}p") - show_theme_preview "$current_theme_name" - fi - ;; - "LEFT") - if [ $current_theme -gt 1 ]; then - current_theme=$((current_theme - 1)) - current_theme_name=$(echo "$THEME_LIST" | sed -n "${current_theme}p") - show_theme_preview "$current_theme_name" - fi - ;; - "A") + "RIGHT") + if [ $current_theme -lt $total_themes ]; then + current_theme=$((current_theme + 1)) current_theme_name=$(echo "$THEME_LIST" | sed -n "${current_theme}p") - download_theme "$current_theme_name" show_theme_preview "$current_theme_name" - ;; - "B"|"START") - display_kill - sh "$UNPACKER" - exit 0 - ;; + fi + ;; + "LEFT") + if [ $current_theme -gt 1 ]; then + current_theme=$((current_theme - 1)) + current_theme_name=$(echo "$THEME_LIST" | sed -n "${current_theme}p") + show_theme_preview "$current_theme_name" + fi + ;; + "A") + current_theme_name=$(echo "$THEME_LIST" | sed -n "${current_theme}p") + download_theme "$current_theme_name" + sh "$UNPACKER" --silent & + show_theme_preview "$current_theme_name" + ;; + "B") + display_kill + sh "$UNPACKER" + flag_remove "silentUnpacker" + update_theme_order + exit 0 + ;; + "START") + redownload_installed_themes + # After bulk update, show current theme preview again + show_theme_preview "$current_theme_name" + ;; esac done diff --git a/Emu/.emu_setup/standard_launch.sh b/Emu/.emu_setup/standard_launch.sh index 9b0df7612..1b703ca78 100644 --- a/Emu/.emu_setup/standard_launch.sh +++ b/Emu/.emu_setup/standard_launch.sh @@ -104,9 +104,6 @@ flag_add 'emulator_launched' ##### LAUNCH STUFF ##### -# Pause simple mode watchdog so in-game Konami code doesn't break it -kill -19 $(pgrep -f simple_mode_watchdog.sh) 2>/dev/null - # we sanitise the rom path ROM_FILE="$(readlink -f "$1")" @@ -302,8 +299,6 @@ case $EMU_NAME in esac - -kill -18 $(pgrep -f simple_mode_watchdog.sh) 2>/dev/null # unpause kill -9 $(pgrep -f enforceSmartCPU.sh) log_message "-----Closing Emulator-----" -v diff --git a/Icons/Default/App/themegallery.png b/Icons/Default/App/themegallery.png new file mode 100644 index 000000000..06fcdc552 Binary files /dev/null and b/Icons/Default/App/themegallery.png differ diff --git a/Themes/Avocado.7z b/Themes/Avocado.7z index 27e1ddd0c..be9440da4 100644 Binary files a/Themes/Avocado.7z and b/Themes/Avocado.7z differ diff --git a/Themes/Cosy by KyleBing.7z b/Themes/Cosy by KyleBing.7z index 24428cbb3..1976ca81c 100644 Binary files a/Themes/Cosy by KyleBing.7z and b/Themes/Cosy by KyleBing.7z differ diff --git a/Themes/Glamoruce.7z b/Themes/Glamoruce.7z index 34934c3b2..7b63d66ac 100644 Binary files a/Themes/Glamoruce.7z and b/Themes/Glamoruce.7z differ diff --git a/Themes/HeyDW's Blue.7z b/Themes/HeyDW's Blue.7z index 2b810ec32..34710a689 100644 Binary files a/Themes/HeyDW's Blue.7z and b/Themes/HeyDW's Blue.7z differ diff --git a/Themes/KantOS.7z b/Themes/KantOS.7z index c1bfaa1a4..0bc8b2a4b 100644 Binary files a/Themes/KantOS.7z and b/Themes/KantOS.7z differ diff --git a/Themes/M.7z b/Themes/M.7z index e2b33f9b7..7d92ae91e 100644 Binary files a/Themes/M.7z and b/Themes/M.7z differ diff --git a/Themes/MinUInspired (Grey).7z b/Themes/MinUInspired (Grey).7z index e1bc2c6d8..ebab816ae 100644 Binary files a/Themes/MinUInspired (Grey).7z and b/Themes/MinUInspired (Grey).7z differ diff --git a/Themes/Pico-8.7z b/Themes/Pico-8.7z index 78c2a7f4a..ecb3a1cda 100755 Binary files a/Themes/Pico-8.7z and b/Themes/Pico-8.7z differ diff --git a/Themes/SPRUCE (simple).7z b/Themes/SPRUCE (simple).7z index 8be72cae2..e2c601c58 100644 Binary files a/Themes/SPRUCE (simple).7z and b/Themes/SPRUCE (simple).7z differ diff --git a/Themes/SPRUCE/icons/App/themegallery.png b/Themes/SPRUCE/icons/App/themegallery.png new file mode 100644 index 000000000..1f55572f4 Binary files /dev/null and b/Themes/SPRUCE/icons/App/themegallery.png differ diff --git a/Themes/SPRUCE/preview.gif b/Themes/SPRUCE/preview.gif new file mode 100644 index 000000000..c7942d256 Binary files /dev/null and b/Themes/SPRUCE/preview.gif differ diff --git a/Updater/updater.sh b/Updater/updater.sh index a634f9385..755937ad8 100644 --- a/Updater/updater.sh +++ b/Updater/updater.sh @@ -160,24 +160,46 @@ fi # Compare versions using awk SKIP_VERSION_CHECK=false +BETA_UPDATE=false if [ "$DEVELOPER_MODE" -eq 1 ] || [ "$TESTER_MODE" -eq 1 ]; then SKIP_VERSION_CHECK=true log_update_message "Version check skipped due to developer/tester mode" fi +# Check if update file contains '-beta' flag +if echo "$UPDATE_FILE" | grep -q -- "-beta"; then + BETA_UPDATE=true + log_update_message "Beta update detected" +fi + log_update_message "Comparing versions: $UPDATE_VERSION vs $CURRENT_VERSION" -if [ "$SKIP_VERSION_CHECK" = true ] || [ "$(echo "$UPDATE_VERSION $CURRENT_VERSION" | awk '{split($1,a,"."); split($2,b,"."); for (i=1; i<=3; i++) {if (a[i]b[i]) {print $1; exit}} print $2}')" != "$CURRENT_VERSION" ]; then - log_update_message "Proceeding with update" +if [ "$SKIP_VERSION_CHECK" = true ]; then + log_update_message "Proceeding with update (version check skipped)" +elif [ "$BETA_UPDATE" = true ]; then + # For beta updates, only proceed if version is same or greater + VERSION_COMPARE=$(echo "$UPDATE_VERSION $CURRENT_VERSION" | awk '{split($1,a,"."); split($2,b,"."); for (i=1; i<=3; i++) {if (a[i]b[i]) {print "higher"; exit}} print "same"}') + if [ "$VERSION_COMPARE" = "lower" ]; then + log_update_message "Beta version is lower than current version, update declined" + display "Current version is up to date" + exit 0 + else + log_update_message "Proceeding with beta update" + fi else - log_update_message "Current version is up to date" - if ! check_installation_validity; then - log_update_message "Bad installation detected" - display "Detected current installation is invalid. + # Regular update - only proceed if version is higher + if [ "$(echo "$UPDATE_VERSION $CURRENT_VERSION" | awk '{split($1,a,"."); split($2,b,"."); for (i=1; i<=3; i++) {if (a[i]b[i]) {print $1; exit}} print $2}')" = "$CURRENT_VERSION" ]; then + log_update_message "Current version is up to date" + if ! check_installation_validity; then + log_update_message "Bad installation detected" + display "Detected current installation is invalid. Allowing reinstall." 5 + else + display "Current version is up to date" + exit 0 + fi else - display "Current version is up to date" - exit 0 + log_update_message "Proceeding with update" fi fi @@ -304,6 +326,11 @@ if [ "$TESTER_MODE" -eq 1 ]; then log_update_message "Restored tester mode flag" fi +if [ "$BETA_UPDATE" -eq 1 ]; then + touch "$FLAG_DIR/beta" + log_update_message "Restored beta update flag" +fi + display "Update complete. Shutting down... You'll need to manually power back on" 3 echo 100 >/sys/devices/virtual/timed_output/vibrator/enable diff --git a/spruce/imgs/themegallery.png b/spruce/imgs/themegallery.png new file mode 100644 index 000000000..3bcabe94d Binary files /dev/null and b/spruce/imgs/themegallery.png differ diff --git a/spruce/scripts/archiveUnpacker.sh b/spruce/scripts/archiveUnpacker.sh index b3821f7ae..8c8da239e 100644 --- a/spruce/scripts/archiveUnpacker.sh +++ b/spruce/scripts/archiveUnpacker.sh @@ -10,13 +10,28 @@ ICON="/mnt/SDCARD/spruce/imgs/iconfresh.png" # Since some files need to be available before the menu is displayed, we need to unpack them before the menu is displayed so that's one mode. # The other mode is to unpack archives needed before the command_to_run, this is used for the preCmd folder. -# This can be called with a pre_cmd to run a check and unpack over the preCmd folder. +# This can be called with a "pre_cmd" argument to run a check and unpack over the preCmd folder only. +# Typically you'd use that for any unpacking process since we don't want extraction to happen in the background. +# It's rather resource heavy and we don't want leave it running in the background. + +# If a silentUnpacker flag is present another script is running and we don't want to run this one. +if flag_check "silentUnpacker"; then + log_message "Unpacker: Another silent unpacker is running, exiting" -v + exit 0 +fi + + +cleanup() { + flag_remove "silentUnpacker" +} + +# Set trap for script exit +trap cleanup EXIT # Process command line arguments -SILENT_MODE=0 RUN_MODE="all" if [ "$1" = "--silent" ]; then - SILENT_MODE=1 + flag_add "silentUnpacker" [ -n "$2" ] && RUN_MODE="$2" elif [ -n "$1" ]; then RUN_MODE="$1" @@ -24,7 +39,7 @@ fi # Function to display text if not in silent mode display_if_not_silent() { - [ $SILENT_MODE -eq 0 ] && display "$@" + flag_check "silentUnpacker" || display "$@" } # Function to unpack archives from a specified directory @@ -75,7 +90,7 @@ case "$RUN_MODE" in if flag_check "save_active"; then unpack_archives "$ARCHIVE_DIR/preCmd" "pre_cmd_unpacking" else - SILENT_MODE=1 + flag_add "silentUnpacker" unpack_archives "$ARCHIVE_DIR/preCmd" "pre_cmd_unpacking" & fi ;; diff --git a/spruce/scripts/firstboot.sh b/spruce/scripts/firstboot.sh index a2173bd0f..e843737f3 100644 --- a/spruce/scripts/firstboot.sh +++ b/spruce/scripts/firstboot.sh @@ -65,6 +65,9 @@ if [ -d "/mnt/SDCARD/Themes/DONTTOUCH" ]; then rm -rf /mnt/SDCARD/Themes/DONTTOUCH fi +log_message "Sorting themes" +sh /mnt/SDCARD/spruce/scripts/tasks/sortThemes.sh + sleep 3 # make sure installing spruce logo stays up longer; gives more time for XMB to unpack too log_message "Displaying wiki image" @@ -78,7 +81,8 @@ if [ "$VERSION" -lt 20240713100458 ]; then fi if flag_check "pre_menu_unpacking"; then - display --icon "/mnt/SDCARD/spruce/imgs/iconfresh.png" -t "Finishing up unpacking themes.........." + display --icon "/mnt/SDCARD/spruce/imgs/iconfresh.png" -t "Finishing up unpacking themes and files.........." + flag_remove "silentUnpacker" while flag_check "pre_menu_unpacking"; do sleep 0.3 done diff --git a/spruce/scripts/helperFunctions.sh b/spruce/scripts/helperFunctions.sh index 974ab9267..9c207c600 100644 --- a/spruce/scripts/helperFunctions.sh +++ b/spruce/scripts/helperFunctions.sh @@ -560,7 +560,9 @@ get_button_press() { *"$B_LEFT"*) button_pressed="LEFT" ;; *"$B_RIGHT"*) button_pressed="RIGHT" ;; *"$B_START"*) button_pressed="START" ;; + *"$B_START_2"*) button_pressed="START" ;; *"$B_SELECT"*) button_pressed="SELECT" ;; + *"$B_SELECT_2"*) button_pressed="SELECT" ;; esac if [ -n "$button_pressed" ]; then @@ -732,7 +734,7 @@ get_version() { fi } -get_version_nightly() { +get_version_complex() { local base_version=$(get_version) # Ensure we got a valid base version @@ -741,17 +743,14 @@ get_version_nightly() { return 1 fi - local nightly_pattern="/mnt/SDCARD/${base_version}-*" + local version_pattern="/mnt/SDCARD/${base_version}-*" + + # Find any matching version file (beta or nightly) + local test_file=$(ls $version_pattern 2>/dev/null | head -n 1) - # List all matching files and log them - local matching_files=$(ls $nightly_pattern 2>/dev/null) - - # Find any matching nightly version file - local nightly_file=$(ls $nightly_pattern 2>/dev/null | head -n 1) - - if [ -n "$nightly_file" ]; then - local nightly_version=$(basename "$nightly_file") - echo "$nightly_version" + if [ -n "$test_file" ]; then + local test_version=$(basename "$test_file") + echo "$test_version" else echo "$base_version" fi diff --git a/spruce/scripts/low_power_warning.sh b/spruce/scripts/low_power_warning.sh index 83b1d7fa0..711979206 100644 --- a/spruce/scripts/low_power_warning.sh +++ b/spruce/scripts/low_power_warning.sh @@ -64,6 +64,15 @@ log_battery() { fi } +hard_shutdown() { + CAPACITY=$1 + if [ "$CAPACITY" -le 1 ]; then + flag_add "forced_shutdown" + /mnt/SDCARD/spruce/scripts/save_poweroff.sh + exit + fi +} + # Log boot entry CAPACITY=$(cat /sys/class/power_supply/battery/capacity) CURRENT_TIME=$(date "+%Y-%m-%d %H:%M:%S") @@ -80,10 +89,9 @@ while true; do # Add battery logging CURRENT_TIME=$(date +%s) - log_message "Current time: $CURRENT_TIME, Last log: $LAST_LOG, Interval: $LOG_INTERVAL" -v if [ $((CURRENT_TIME - LAST_LOG)) -gt $LOG_INTERVAL ]; then log_battery - LAST_LOG=$(date +%s) # Keep this as Unix timestamp + LAST_LOG=$(date +%s) # Keep this as Unix timestamp fi # Set default value if PERCENT is empty or non-numeric @@ -92,15 +100,7 @@ while true; do esac # force a safe shutdown at 1% regardless of settings - if [ "$CAPACITY" -le 1 ]; then - if ! setting_get "skip_shutdown_confirm"; then - setting_update "skip_shutdown_confirm" on - flag_add "forced_shutdown" - fi - display -d 2 --icon "/mnt/SDCARD/spruce/imgs/notfound.png" -t "Battery level is below 1%. Shutting down to prevent progress loss." - /mnt/SDCARD/spruce/scripts/save_poweroff.sh - exit - fi + hard_shutdown $CAPACITY # disable script if turned off in spruce.cfg [ "$PERCENT" = "Off" ] && sleep $SLEEP && continue @@ -128,16 +128,7 @@ while true; do CAPACITY=$(cat /sys/class/power_supply/battery/capacity) PERCENT="$(setting_get "low_power_warning_percent")" - # force a safe shutdown at 1% regardless of settings - if [ "$CAPACITY" -le 1 ]; then - if ! setting_get "skip_shutdown_confirm"; then - setting_update "skip_shutdown_confirm" on - flag_add "forced_shutdown" - fi - display -d 2 --icon "/mnt/SDCARD/spruce/imgs/notfound.png" -t "Battery level is below 1%. Shutting down to prevent progress loss." - /mnt/SDCARD/spruce/scripts/save_poweroff.sh - exit - fi + hard_shutdown $CAPACITY # disable script if turned off in spruce.cfg [ "$PERCENT" = "Off" ] && sleep $SLEEP && continue diff --git a/spruce/scripts/principal.sh b/spruce/scripts/principal.sh index 248ea43be..80ea70022 100644 --- a/spruce/scripts/principal.sh +++ b/spruce/scripts/principal.sh @@ -1,9 +1,9 @@ #!/bin/sh # Principal Script for Miyoo A30 -# +# # This script serves as the main control loop for the system. It operates as follows: -# +# # Initializes by ensuring keymon is running # Enters an infinite loop that: # a. Checks for and handles game switching if necessary @@ -13,7 +13,7 @@ # - Or executes a custom command # Then the loop repeats, returning to the main UI # -# Throughout this process, it monitors various system flags and +# Throughout this process, it monitors various system flags and # responds accordingly, managing the overall system state. # Source the helper functions @@ -24,20 +24,20 @@ BOOT_ACTION="$(setting_get "boot_to")" # only go ahead with boot actions if not resuming from a quicksave if ! flag_check "save_active"; then case "$BOOT_ACTION" in - "Random") - echo "\"/mnt/SDCARD/App/RandomGame/random.sh\"" > /tmp/cmd_to_run.sh - ;; - "Switcher") - touch /mnt/SDCARD/spruce/flags/gs.lock - ;; - "Splore") - if ( [ -f "/mnt/SDCARD/Emu/PICO8/bin/pico8.dat" ] && [ -f "/mnt/SDCARD/Emu/PICO8/bin/pico8_dyn" ] ) || \ - ( [ -f "/mnt/SDCARD/BIOS/pico8.dat" ] && [ -f "/mnt/SDCARD/BIOS/pico8_dyn" ] ); then - echo "\"/mnt/SDCARD/Emu/.emu_setup/standard_launch.sh\" \"/mnt/SDCARD/Roms/PICO8/-=☆ Launch Splore ☆=-.splore\"" > /tmp/cmd_to_run.sh - else - log_message "Pico-8 binaries not found, booting to MainUI instead" - fi - ;; + "Random") + echo "\"/mnt/SDCARD/App/RandomGame/random.sh\"" >/tmp/cmd_to_run.sh + ;; + "Switcher") + touch /mnt/SDCARD/spruce/flags/gs.lock + ;; + "Splore") + if ([ -f "/mnt/SDCARD/Emu/PICO8/bin/pico8.dat" ] && [ -f "/mnt/SDCARD/Emu/PICO8/bin/pico8_dyn" ]) || + ([ -f "/mnt/SDCARD/BIOS/pico8.dat" ] && [ -f "/mnt/SDCARD/BIOS/pico8_dyn" ]); then + echo "\"/mnt/SDCARD/Emu/.emu_setup/standard_launch.sh\" \"/mnt/SDCARD/Roms/PICO8/-=☆ Launch Splore ☆=-.splore\"" >/tmp/cmd_to_run.sh + else + log_message "Pico-8 binaries not found, booting to MainUI instead" + fi + ;; esac fi @@ -45,12 +45,12 @@ flag_remove "save_active" while [ 1 ]; do - if [ -f /mnt/SDCARD/spruce/flags/gs.lock ] ; then + if [ -f /mnt/SDCARD/spruce/flags/gs.lock ]; then log_message "***** GAME SWITCHER: GS enabled and flag file detected! Launching! *****" /mnt/SDCARD/spruce/scripts/gameswitcher.sh fi - if [ ! -f /tmp/cmd_to_run.sh ] ; then + if [ ! -f /tmp/cmd_to_run.sh ]; then # create in menu flag and remove last played game flag flag_remove "lastgame" @@ -72,6 +72,14 @@ while [ 1 ]; do /mnt/SDCARD/spruce/scripts/powerdisplay.sh & + if flag_check "pre_menu_unpacking"; then + display -t "Finishing up unpacking archives.........." -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" + flag_remove "silentUnpacker" + while [ -f "$FLAGS_DIR/pre_menu_unpacking.lock" ]; do + : # null operation (no sleep needed) + done + fi + # This is to kill leftover display processes that may be running display_kill & @@ -94,6 +102,7 @@ while [ 1 ]; do if flag_check "pre_cmd_unpacking"; then display -t "Finishing up unpacking archives.........." -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" + flag_remove "silentUnpacker" while [ -f "$FLAGS_DIR/pre_cmd_unpacking.lock" ]; do : # null operation (no sleep needed) done @@ -104,6 +113,7 @@ while [ 1 ]; do if [ -f /tmp/cmd_to_run.sh ]; then set_performance + kill -9 $(pgrep -f simple_mode_watchdog.sh) 2>/dev/null # Kill simple mode watchdog chmod a+x /tmp/cmd_to_run.sh cp /tmp/cmd_to_run.sh "$FLAGS_DIR/lastgame.lock" /tmp/cmd_to_run.sh &>/dev/null @@ -112,6 +122,7 @@ while [ 1 ]; do # reset CPU settings to defaults in case an emulator changes anything scaling_min_freq=1008000 ### default value, may be overridden in specific script set_smart + /mnt/SDCARD/spruce/scripts/simple_mode_watchdog.sh & fi # set gs.lock flag if last loaded program is real game and gs.fix flag is set @@ -119,8 +130,8 @@ while [ 1 ]; do grep -q /mnt/SDCARD/Emu/*/../.emu_setup/standard_launch.sh "$FLAGS_DIR/lastgame.lock" ; then touch /mnt/SDCARD/spruce/flags/gs.lock fi - - if [ -f /mnt/SDCARD/spruce/flags/credits.lock ] ; then + + if [ -f /mnt/SDCARD/spruce/flags/credits.lock ]; then /mnt/SDCARD/App/Credits/launch.sh rm /mnt/SDCARD/spruce/flags/credits.lock fi diff --git a/spruce/scripts/runtime.sh b/spruce/scripts/runtime.sh index 26b7322b2..14033f546 100644 --- a/spruce/scripts/runtime.sh +++ b/spruce/scripts/runtime.sh @@ -56,11 +56,6 @@ flag_remove "low_battery" flag_remove "in_menu" flag_remove "emufresh" -if flag_check "forced_shutdown"; then - flag_remove "forced_shutdown" - setting_update "skip_shutdown_confirm" off -fi - log_message " " -v log_message "---------Starting up---------" log_message " " -v diff --git a/spruce/scripts/save_poweroff.sh b/spruce/scripts/save_poweroff.sh index b34bf859a..904435f8b 100644 --- a/spruce/scripts/save_poweroff.sh +++ b/spruce/scripts/save_poweroff.sh @@ -24,10 +24,10 @@ vibrate if flag_check "sleep.powerdown"; then cp /mnt/SDCARD/spruce/settings/tmp_sys_brightness_level /mnt/SDCARD/spruce/settings/sys_brightness_level else - cat /sys/devices/virtual/disp/disp/attr/lcdbl > /mnt/SDCARD/spruce/settings/sys_brightness_level + cat /sys/devices/virtual/disp/disp/attr/lcdbl >/mnt/SDCARD/spruce/settings/sys_brightness_level fi -if pgrep -f gameswitcher.sh > /dev/null ; then +if pgrep -f gameswitcher.sh >/dev/null; then # pause game switcher killall -q -19 switcher # remove lastgame flag to prevent loading any App after next boot @@ -41,10 +41,15 @@ fi # Check if MainUI or PICO8 is running and skip_shutdown_confirm is not set if flag_check "in_menu" || pgrep "pico8_dyn" >/dev/null; then - if setting_get "skip_shutdown_confirm"; then + if setting_get "skip_shutdown_confirm" || flag_check "forced_shutdown"; then # If skip_shutdown_confirm is set, proceed directly with shutdown rm "${FLAGS_DIR}/lastgame.lock" - display -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" + if flag_check "forced_shutdown"; then + display -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" -t "Battery level is below 1%. Shutting down to prevent progress loss." + flag_remove "forced_shutdown" + else + display -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" + fi dim_screen & else # Pause MainUI or pico8_dyn @@ -133,7 +138,11 @@ while killall -q -0 ra32.miyoo || done # show saving screen -if ! pgrep "display_text.elf" >/dev/null && ! flag_check "sleep.powerdown"; then +if flag_check "forced_shutdown"; then + display -i "/mnt/SDCARD/spruce/imgs/bg_tree.png" -t "Battery level is below 1%. Shutting down to prevent progress loss." + flag_remove "forced_shutdown" + dim_screen & +elif ! pgrep "display_text.elf" >/dev/null && ! flag_check "sleep.powerdown"; then display --icon "/mnt/SDCARD/spruce/imgs/save.png" -t "Saving and shutting down... Please wait a moment." dim_screen & fi @@ -150,15 +159,16 @@ if setting_get "syncthing" && flag_check "emulator_launched"; then # Restore brightness and sound if sleep->powerdown for syncthing if flag_check "sleep.powerdown"; then - cat /mnt/SDCARD/spruce/settings/tmp_sys_brightness_level > /sys/devices/virtual/disp/disp/attr/lcdbl + cat /mnt/SDCARD/spruce/settings/tmp_sys_brightness_level >/sys/devices/virtual/disp/disp/attr/lcdbl amixer set 'Soft Volume Master' $(cat /mnt/SDCARD/spruce/settings/tmp_sys_volume_level) fi - if check_and_connect_wifi; then - start_syncthing_process - # Dimming screen before syncthing sync check - dim_screen & - /mnt/SDCARD/spruce/bin/Syncthing/syncthing_sync_check.sh --shutdown - fi + + if check_and_connect_wifi; then + start_syncthing_process + # Dimming screen before syncthing sync check + dim_screen & + /mnt/SDCARD/spruce/bin/Syncthing/syncthing_sync_check.sh --shutdown + fi flag_remove "syncthing_startup_synced" fi diff --git a/spruce/scripts/tasks/sortThemes.sh b/spruce/scripts/tasks/sortThemes.sh new file mode 100644 index 000000000..f11addb06 --- /dev/null +++ b/spruce/scripts/tasks/sortThemes.sh @@ -0,0 +1,49 @@ +#!/bin/sh +if [ "$1" == "0" ]; then + echo -n "Themes will be alphabetized on save and exit." + return 0 +fi + +if [ "$1" == "1" ]; then + echo -n "Use this to re-sort themes alphabetically." + return 0 +fi + +. /mnt/SDCARD/spruce/scripts/helperFunctions.sh + + + +# Add this new function before the main loop +update_theme_dates() { + log_message "Theme Garden: Attempt to alphabetize themes" + + # Create temporary directory + mkdir -p "/mnt/SDCARD/temp_themes" + + # First move all themes to temp directory + for theme_dir in /mnt/SDCARD/Themes/*/; do + [ -d "$theme_dir" ] || continue + theme_name="$(basename "$theme_dir")" + log_message "Theme Garden: Moving to temp: $theme_name" + mv "$theme_dir" "/mnt/SDCARD/temp_themes/$theme_name" + done + + # First move SPRUCE back if it exists + if [ -d "/mnt/SDCARD/temp_themes/SPRUCE" ]; then + log_message "Theme Garden: Moving SPRUCE back first" + mv "/mnt/SDCARD/temp_themes/SPRUCE" "/mnt/SDCARD/Themes/SPRUCE" + fi + + # Move the rest back in alphabetical order + for theme_dir in /mnt/SDCARD/temp_themes/*/; do + [ -d "$theme_dir" ] || continue + theme_name="$(basename "$theme_dir")" + log_message "Theme Garden: Moving back: $theme_name" + mv "$theme_dir" "/mnt/SDCARD/Themes/$theme_name" + done + + # Clean up + rmdir "/mnt/SDCARD/temp_themes" +} + +update_theme_dates \ No newline at end of file diff --git a/spruce/settings/settings_config b/spruce/settings/settings_config index 3de55db25..c6b6afebd 100644 --- a/spruce/settings/settings_config +++ b/spruce/settings/settings_config @@ -27,14 +27,14 @@ $BLFILTER=/mnt/SDCARD/spruce/scripts/applySetting/blfilter.sh$ # Task Scripts $CLEAR_WIFI=/mnt/SDCARD/spruce/scripts/tasks/clearwifi.sh$ +$DELETE_MAC_FILES=/mnt/SDCARD/spruce/scripts/tasks/deleteMacFiles.sh$ $RESET_EMUFRESH=/mnt/SDCARD/spruce/scripts/tasks/resetEmufresh.sh$ $RESET_RA=/mnt/SDCARD/spruce/scripts/tasks/resetRA.sh$ $RESET_RAHOTKEY=/mnt/SDCARD/spruce/scripts/tasks/resetRAHotkeys.sh$ $RESET_PPSSPP=/mnt/SDCARD/spruce/scripts/tasks/resetPPSSPP.sh$ $SIMPLE_MODE=/mnt/SDCARD/spruce/scripts/applySetting/simple_mode.sh$ $SKIP_VERSION=/mnt/SDCARD/spruce/scripts/tasks/skipVersion.sh$ -$DELETE_MAC_FILES=/mnt/SDCARD/spruce/scripts/tasks/deleteMacFiles.sh$ - +$SORT_THEMES=/mnt/SDCARD/spruce/scripts/tasks/sortThemes.sh$ [System] @@ -82,6 +82,10 @@ $DELETE_MAC_FILES=/mnt/SDCARD/spruce/scripts/tasks/deleteMacFiles.sh$ "" "Disable joystick" "|" "on|off" "$HELP$ check disableJoystick" "$JOYSTICK$ _VALUE_" "" + +"" "Sort Themes" "|" "run|off" "echo -n off" "$SORT_THEMES$|" "$SORT_THEMES$ _INDEX_" +@"Use this to re-sort themes alphabetically." + "" "Automatically check for updates" "|" "on|off" "$HELP$ check checkForUpdates" "$HELP$ update checkForUpdates _VALUE_" "" @"Spruce will check periodically on startup" @@ -274,3 +278,7 @@ $DELETE_MAC_FILES=/mnt/SDCARD/spruce/scripts/tasks/deleteMacFiles.sh$ "" "Spruce Restore" "|" "on|off" "$SHOW_HIDE$ check /mnt/SDCARD/App/spruceRestore/config.json" "$SHOW_HIDE$ show /mnt/SDCARD/App/spruceRestore/config.json|$SHOW_HIDE$ hide /mnt/SDCARD/App/spruceRestore/config.json" "" @"Restore spruce from a backup file" + + +"" "Theme Garden" "|" "on|off" "$SHOW_HIDE$ check /mnt/SDCARD/App/ThemeGarden/config.json" "$SHOW_HIDE$ show /mnt/SDCARD/App/ThemeGarden/config.json|$SHOW_HIDE$ hide /mnt/SDCARD/App/ThemeGarden/config.json" "" +@"Download and install themes from our theme repo" \ No newline at end of file