From 83ec5f1ec239f385e5b441492d4c5e7155802502 Mon Sep 17 00:00:00 2001
From: Jacob Babor <jacob@babor.tech>
Date: Mon, 23 Dec 2024 12:21:23 -0600
Subject: [PATCH] Sort out SuperTurtleIdle backups

---
 base/.config/systemd/user/autocategorize | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/base/.config/systemd/user/autocategorize b/base/.config/systemd/user/autocategorize
index ebd09607..1b3e70f8 100755
--- a/base/.config/systemd/user/autocategorize
+++ b/base/.config/systemd/user/autocategorize
@@ -10,6 +10,8 @@ downloaddir="${XDG_DOWNLOAD_DIR:-$HOME/Downloads}"
 documentsdir="${XDG_DOCUMENTS_DIR:-$HOME/Documents}"
 picturesdir="${XDG_PICTURES_DIR:-$HOME/Pictures}"
 videosdir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
+# If we have Nextcloud installed, this will be our backups dir
+backupsdir="${HOME}/Nextcloud/Backups"
 
 # Take loose crap out of the home folder
 echo "Sorting away videos from homedir..."
@@ -72,4 +74,16 @@ find "$HOME" \
 	find "$downloaddir" \
 		-mtime +30 -type f -iname "*.zip" \
 		-print -delete
+	# Sort out Super Turtle Idle automatic backups
+	[ -d "$backupsdir" ] && {
+		echo "Sorting out turtle backups..."
+		mkdir -p "$backupsdir/SuperTurtleIdle"
+		for file in "$downloaddir"/SuperSaveData-*.json; do
+			if [ -e "$file" ]; then
+				lastmod="$(stat -c %y -- "$file")"
+				echo "Moving backup from $lastmod"
+				mv "$file" "$backupsdir/SuperTurtleIdle/SuperSaveData-$lastmod.json"
+			fi
+		done
+	}
 }