Skip to content

Instantly share code, notes, and snippets.

@frostworx
Last active April 25, 2021 03:40
Show Gist options
  • Save frostworx/36bd76e705a0c87af523fa57cfeebaf8 to your computer and use it in GitHub Desktop.
Save frostworx/36bd76e705a0c87af523fa57cfeebaf8 to your computer and use it in GitHub Desktop.
little script to set stl as default starter for every steam game. works with a copy of the steam config
#!/bin/bash
YOURID=0
SUD="$HOME/.steam/steam/userdata/"
LCVDFO="$SUD/$YOURID/config/localconfig.vdf"
LCVDF="/tmp/localconfig.vdf"
LOPT="\\\t\t\t\t\t\t\"LaunchOptions\" \"stl %command%\""
if [ -n "$1" ]; then
if [ -f "$SUD/$1/config/localconfig.vdf" ]; then
echo "argument1 $1 seems to be your steamID"
YOURID="$1"
LCVDFO="$SUD/$YOURID/config/localconfig.vdf"
else
echo "argument1 $1 doesn't seem to be your steamID - $SUD/$1/config/localconfig.vdf does not exist!"
fi
fi
if [ "$YOURID" -eq 0 ]; then
echo "you have to edit YOURID first, to match the directory name of your steamID or provide it as commandline argument 1- exit"
echo "maybe:"
find "$SUD" -maxdepth 1 -type d -name "[1-9]*"
exit 1
fi
if [ ! -f "$LCVDF" ]; then
echo "$LCVDF doesn't exist - copying the original"
if [ ! -f "$LCVDFO" ]; then
echo "$LCVDFO doesn't exist as well - giving up"
exit 1
else
cp "$LCVDFO" "$LCVDF"
fi
fi
sed -i '/LaunchOptions/d' "$LCVDF"
sed -i '/"Play[Tt]ime"/i '"$LOPT"'' "$LCVDF"
echo "done - you might want to check if the file $LCVDF looks valid before using it!"
echo "make sure to close steam before copying the file!"
echo "create a backup of your unmodified $LCVDFO f.e. with this command:"
echo "cp $LCVDFO $LCVDFO.bak"
echo "if you dare update to the modified stl version with this command (you at your own risk!):"
echo "cp $LCVDF $LCVDFO"
@frostworx
Copy link
Author

There's no support for this script and I would generally recommend to not blindly execute any scripts when the basics are missing to read and understand the script.

Copy link

ghost commented Oct 17, 2020

So is there no other way,then go to add the launch options I want for every game individually?
Because that would take long.

@frostworx
Copy link
Author

Yes it would take long. AFAIK there's no other way to mass alter steams localconfig.vdf
A short description of what the script does:
It requires your steamID as argument1 to get the full path to the localconfig.vdf
The steamID can simply be found by following the path the script tries to glue together,
but it also suggests one if none is given as arg1.
When it finds the localconfig.vdf it creates a copy and only works with the copy,
so your original file is unmodified.
As echoed in the last lines it is up to you what you do with the modified file.

@Confetti-Camouflage
Copy link

@frostworx Steam seems to use playTime instead of Playtime now for line 38.

@frostworx
Copy link
Author

@Confetti-Camouflage Thanks, should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment