Skip to content

Commit

Permalink
Improved MC screenshots symlinking
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlendea committed Jan 15, 2025
1 parent f40e784 commit 6b36887
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions scripts/configure-directories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ if ${HAS_GUI} && [ "${OS}" = 'Linux' ]; then

create_directory "${MINECRAFT_SCREENSHOTS_DIR}"

for MINECRAFT_INSTANCE in "${HOME_VAR_APP}/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances/"*"/"; do
MINECRAFT_INSTANCE_SCREENSHOTS_DIR="${MINECRAFT_INSTANCE}/.minecraft/screenshots"
if [ -d "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}" ] && \
[ ! -L "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}" ]; then
MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES=$(ls -A "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}")
if [ "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES}" ]; then
echo "Moving contents of '${MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES}' to '${MINECRAFT_SCREENSHOTS_DIR}'..."
mv "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"/* "${MINECRAFT_SCREENSHOTS_DIR}"
for MINECRAFT_INSTANCE in "${HOME_VAR_APP}/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances/"*; do
[ -d "${MINECRAFT_INSTANCE}" ] || continue

MINECRAFT_INSTANCE_GAME_DIR="${MINECRAFT_INSTANCE}/.minecraft"
[ -d "${MINECRAFT_INSTANCE}/minecraft" ] && MINECRAFT_INSTANCE_GAME_DIR="${MINECRAFT_INSTANCE}/minecraft"

if [ -d "${MINECRAFT_INSTANCE_GAME_DIR}" ]; then
MINECRAFT_INSTANCE_SCREENSHOTS_DIR="${MINECRAFT_INSTANCE_GAME_DIR}/screenshots"

if [ -d "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}" ] && \
[ ! -L "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}" ]; then
MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES=$(ls -A "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}")
if [ "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES}" ]; then
echo "Moving contents of '${MINECRAFT_INSTANCE_SCREENSHOTS_DIR_FILES}' to '${MINECRAFT_SCREENSHOTS_DIR}'..."
mv "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"/* "${MINECRAFT_SCREENSHOTS_DIR}"
fi

rm -rf "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"
fi

rm -rf "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"
create_symlink "${MINECRAFT_SCREENSHOTS_DIR}" "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"
fi

create_symlink "${MINECRAFT_SCREENSHOTS_DIR}" "${MINECRAFT_INSTANCE_SCREENSHOTS_DIR}"
done
fi
fi
Expand Down

0 comments on commit 6b36887

Please sign in to comment.