Skip to content

Instantly share code, notes, and snippets.

@terrabruder
Created February 15, 2023 06:04
Show Gist options
  • Save terrabruder/5ee3df184b8e56b081a39253d2ecfbc7 to your computer and use it in GitHub Desktop.
Save terrabruder/5ee3df184b8e56b081a39253d2ecfbc7 to your computer and use it in GitHub Desktop.
Steam Deck Stardew Valley Mod Profile switcher
#! /usr/bin/bash
#####################################
# STARDEW VALLEY MOD PROFILE SWITCHER
#
# This is the approach I use to
# manage collections of
# Stardew Valley mods on Steam Deck
# without fighting with Vortex.
#
# - backs up SMAPI logs
# - commits any changes to the current profile
# - logs git output to a file (~/.config/StardewValley/ErrorLogs/git-latest.txt)
# - checks out the requested profile
# - starts the game
#
# SETUP - Default profile:
#
# Setup is straightforward. With
# your default mods installed:
#
# cd /home/deck/.steam/steam/steamapps/common/Stardew\ Valley/Mods;
# git init .
# git checkout -b profiles/default
#
# SETUP - New profile:
#
# For a new profile called profile-name,
#
# cd /home/deck/.steam/steam/steamapps/common/Stardew\ Valley/Mods
# git add -A # add any changed files to the current profile
# git commit -m "Updating before new branch" # commit the current state
# git checkout -b profiles/profile-name # make a new branch
#
# Then, update your Mods for the new profile, and add and commit them:
# git add -A # add any changed files to the new profile
# git commit -m "First commit for this profile" # commit the current state
#
# TODO: automate the new profile process
#
# SCRIPT USAGE:
#
# . ~/Path/To/Script/stardew-profile.sh my-profile
#
# GAMING MODE:
#
# Set this as the command in a
# desktop application to add it as a non-steam game for a
# specific profile.
#
####################################
###### Set paths ######
LOGPATH=~/.config/StardewValley/ErrorLogs/
LOGSTAMP=$(grep -Po '(?<=Log started at )[^ ]+' ${LOGPATH}SMAPI-latest.txt | sed 's/[T\:\-]//g')
###### Manage log files ######
#overkill? tar -czvf ${LOGPATH}/older/smapi-${LOGSTAMP}.tar.gz ${LOGPATH}SMAPI-latest.txt
if [ ! -d "${LOGPATH}/older" ]; then
mkdir -p "${LOGPATH}/older"
fi
cp ${LOGPATH}SMAPI-latest.txt ${LOGPATH}/older/smapi-${LOGSTAMP}.txt 2> /dev/null #we don't care if SMAPI isn't present
cd /home/deck/.steam/steam/steamapps/common/Stardew\ Valley/Mods;
rm ${LOGPATH}/git-latest.txt 2> /dev/null
touch ${LOGPATH}/git-latest.txt
###### Execute git operations & log ######
printf "Updating repo with changes from ${LOGSTAMP} or later:\n\n" >> ${LOGPATH}/git-latest.txt 2>&1
git add -A >> ${LOGPATH}/git-latest.txt 2>&1
git commit -m "Updating with changes from ${LOGSTAMP} or later." >> ${LOGPATH}/git-latest.txt 2>&1
git checkout profiles/$1 >> ${LOGPATH}/git-latest.txt 2>&1
cp ${LOGPATH}/git-latest.txt ${LOGPATH}/older/git-${LOGSTAMP}.txt
###### Start game ######
cd ..;
steam steam://rungameid/413150;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment