16 Commits
main ... dev

Author SHA1 Message Date
wasabi
d3ca4c2539 Updated install.sh and webinstall.sh to use similar install scripts 2025-05-30 17:23:39 -05:00
wasabi
0c766576d4 Updated install.sh to actually do stuff 2025-05-30 17:21:51 -05:00
Elia Farin
5698e7108e Updated install.sh and webinstall.sh to not add extraneous copies of path and STEAMTRICKS_PREFIX 2025-05-30 16:36:22 -05:00
Elia Farin
0b617c9e27 Updated webinstall.sh and install.sh 2025-05-30 16:21:52 -05:00
Elia Farin
d972f36f67 Fixed steamtricks install 2025-05-30 16:16:58 -05:00
Elia Farin
5b44cb290a Updated readme.md, install.sh, and webinstall.sh 2025-05-30 15:49:58 -05:00
Elia Farin
09eb399f1e Updated README, install.sh, and steamtricks.conf.example 2025-05-30 15:31:08 -05:00
Elia Farin
fd210a0c34 Line width and permissions 2025-05-30 12:58:23 -05:00
Elia Farin
32d940ce8e Updated install.sh 2025-05-30 12:24:04 -05:00
Elia Farin
8917315b39 Updated install script 2025-05-30 11:55:55 -05:00
wasabi
5c792e6529 Semi-working version 2025-05-30 10:43:47 -05:00
wasabi
19b009f8ad Progress on the create-install main function logic: 2025-05-29 19:14:30 -05:00
wasabi
ad79e5cd98 Removed old useless files
added gitignore
2025-05-29 18:10:56 -05:00
wasabi
d7541cc843 Progress on the install script 2025-05-29 17:52:59 -05:00
wasabi
457351034b Progress on a perl version 2025-05-29 17:02:32 -05:00
wasabi
393ec31287 Progress 2025-05-29 15:14:38 -05:00
7 changed files with 322 additions and 156 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.tar.gz
*.tgz

View File

@@ -1,72 +1,50 @@
# steamtricks # steamtricks
This is a repository of my Steam hacks to allow things such as multiple installs of the same game This is a repository of my Steam hacks to allow things such as multiple installs of the same game
## Determining how you've installed Steam
The easiest way to find out if you've installed Steam as a flatpak or from your package manager is to run the following command:
$ flatpak list | grep Steam
Steam com.valvesoftware.Steam 1.0.0.81 stable system
If you get any output that does not look similar to the above, you have Steam installed through your package manager and can skip the next section.
## Installation ## Installation
Either git clone this repository and install using the install script, or run the following command in your shell: There are two methods of installing this project. The first requires git:
curl https://raw.githubusercontent.com/charwrangler404/steamtricks/refs/heads/main/webinstall.sh | $SHELL git clone https://github.com/charwrangler404/steamtricks.git && cd steamtricks && git checkout latest
./install.sh
## Notes on setup with a flatpak Steam And the single-command method requires curl:
NOTE: IF YOU DO NOT KNOW WHERE YOUR STEAM GAMES ARE INSTALLED, FIND THIS OUT FIRST curl https://raw.githubusercontent.com/charwrangler404/steamtricks/refs/heads/main/webinstall.sh | sh
You will need to know where your steam games live on your system for any of this to work. ## steamtricks.conf
If you're using a flatpak (the recommended method) you will need to ensure your games are installed OUTSIDE of the flatpak container. The steamtricks.conf file has some specific requirements. If you have not created a steamtricks.conf file when you run steamtricks for the first time, the
This can be done by installing the flatseal flatpak and modifying the permissions of your flatpak to allow it to access files outside of the container. main script will create one for you with sane defaults. The default assumption when creating the steamtricks.conf file is that you are running a flatpak
version of Steam with all your games installed inside the container. If this is not the case, you will need to change the `steam_prefix` variable in the
`[general]` section of the config file to match the absolute path of your `steamapps/common` directory.
ALLOWING STEAM TO ACCESS ANY FOLDER UNDER `/home` WILL BREAK YOUR STEAM INSTALL AND THAT PERMISSION WILL NEED TO BE REMOVED TO START STEAM ### `[general]` Section header
The default that I use is to put my Steam library under `/var/games`. If you do not know what you are doing, this is probably the best option. The `[general]` section header currently has one required variable, `steam_prefix`. This variable tells steamtricks where to look for your steam games.
Whatever you do, make sure that your install has enough space in `/var` to install all the games you wish to play. You can use the `df -h` command to The default value is listed below. If this is not where your Steam games are installed, you will need to change this variable in order for steamtricks to
let you know how much space you have free on your system, and where it is. Some Linux install defaults include VERY SMALL `/var` partitions work correctly.
and filling it up with files as you try to install games is a sure-fire way to CRASH YOUR SYSTEM. I mount a 4TB ssd to /var/games in my setup to prevent this.
If you do not know how to set this up, I recommend you read about `/etc/fstab` for automouting it on boot. If it's encrypted (not recommended for a games-only steam_prefix=/home/<username>/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common
drive) you will also need to read about `/etc/crypttab`. Setting up encrypted game installs is outside of the scope of this article.
If you're willing to mess around a bit until I get some proper variable management set up, you can install your games somewhere else. Other good options The `steamtricks` executable will evaluate the $HOME environment variable when creating the config file. Due to limitations of the path evaluation of the script,
include somewhere under `/opt`. That's probably about it as far as good places to put your games. If you want to know more about which files you will need shortcuts (such as ~) will not function as expected and will cause steamtricks to be unable to find your steam files.
to edit to change the path to something other than `/var/games`, read the below section as well.
### `[install_manager]` Section Header
## Notes on setup with a system package Steam The `[install_manager]` section header has one required variable, `managed_games[]` which may be added as many times as necessary and may be empty. It is
required to have at minimum one instance of this variable that may be blank. The `managed_games[]` variable is managed by the config generation section of the
steamtricks script and does not require any manual intervention. It keeps track of managed installs of games to support future features that are on the roadmap
but has no use at this time. You should not set the variable directly, rather let it be auto-populated by prompts in the script.
If you installed Steam with a system pacakage manager (apt, yum, dnf, etc) and NOT flatpak, you can ignore the above section, but will need to edit the STEAMPREFIX ## Roadmap
variable in your shell profile after install. As far as to where this variable is located, it depends on your shell. You can find out the name of your shell with the
following command:
echo $SHELL | awk -F "/" '{print $NF}' - [ ] Add a version selection dialog
- [ ] Add a game selection dialog
- [ ] Add prompts to tell user when to restart Steam and any other actions required of them to maintain the installs
- [ ] Transition to Perl implementation
The most common shells include `bash`, `sh`, and `zsh`. If you do not have one of these shells, you should do some googling to find out where your shell profile is located. ## Miscellaneous Resources
The `sh` shell is unsupported. If you have this as your main shell, either something is very wrong with your system or you know enough to figure out what I'm doing in the script
and can engineer your own solution. `bash` and `zsh` shell profiles are located in `~/.bashrc` and `~/.zshrc`, respectively. As they are "dotfiles" they are hidden from commands and the file
viewer by default, so if you want to list them in the shell or your file browser, you will need to either use `ls -la` or find out how to show hidden files in your graphical file browser.
## multiple_install_manager.sh If you wish to see what other resources I've bookmarked as good reading for those who game with Steam on linux, here's a page of [resources](resources.md) that
you may consult for further reading.
This is the script that will be added to your profile in your shell, allowing you access to the following commands
setup_install
change_install
The `setup_install` command essentially renames an existing install in your STEAMPREFIX path.
the `change_install` command creates symbolic links to that new install location at the location where Steam expects that game to be installed. Please note the prompts in this command,
you will need to heed the prompts if you don't want to be reinstalling your games all the time. I use this for Project Zomboid, which is a fairly small game, but if you are using this
for a game much larger than that, it will get annoying to accidentally update your game to a version you do not want it to be. In order to maintain the different versions of the game
as different versions, there are some clicks you will have to make in Steam itself to prevent it from updating the game to a version you do not want that install to be at. Some of these
clicks will be needed to be made EVERY TIME you run the change_install script.
Most notably, you will want to ensure that your update settings for the game are set up so that steam does not update the game automatically. If you change them to "Only update on launch"
it will not mean reinstalling the game to ensure you keep the versions that you want separate separate when you launch Steam.

63
install.sh Normal file → Executable file
View File

@@ -1,23 +1,52 @@
#!/usr/bin/env bash #!/usr/bin/env sh
install_manager () { unsupported_shell () {
case "$1" in echo "Your shell $SHELL is not supported by this install script"
sh) echo "Shell not supported"; exit 1 echo "You will need to manually install by extracting a tarball from"
;; echo "https://github.com/charwrangler404/steamtricks/releases to your home folder"
bash | zsh) cat multiple_install_manager.sh >> "${HOME}/.${1}rc" echo "and setting the STEAMTRICKS_PREFIX to your shell's environment, as well as"
;; echo "$HOME/.steamtricks/bin to your PATH"
*) echo "You will need to install this by manually adding it to either your /etc/profile for system-wide installation or to your shell's profile"
;;
esac
} }
echo "Would you like to install the multiple-install game manager?" install () {
echo -n "[y/N]: " export SHELLPROFILE="$1"
read ANS if [ ! -d "$HOME/.steamtricks" ]; then
mkdir $HOME/.steamtricks
fi
cp -r steamtricks/* $HOME/.steamtricks/
chmod 755 $HOME/.steamtricks/bin/steamtricks
if [ -z "$STEAMTRICKS_PREFIX" ]; then
echo "export STEAMTRICKS_PREFIX=\"$HOME/.steamtricks\"">>"${SHELLPROFILE}"
fi
if [ -z "$(echo $PATH | grep 'steamtricks')" ]; then
echo 'export PATH="$PATH:~/.steamtricks/bin"'>>${SHELLPROFILE}
fi
echo "Install completed! Please source your profile $SHELLPROFILE to load the changes!"
}
install_manager () {
case "$1" in
bash | zsh | yash) install "$HOME/.${1}rc"
;;
sh ) install "$HOME/.profile"
;;
*) unsupported_shell
;;
esac
}
if [ "$EUID" -eq 0 ]; then
echo "Please do not run this script as root"
exit 1
fi
read -r -p "Would you like to install the multiple-install game manager? [y/N]" ANS
case "$ANS" in case "$ANS" in
y* | Y* ) install_manager $(echo $SHELL | awk -F "/" '{print $NF}') [yY]* ) install_manager "$(echo $SHELL | awk -F "/" '{print $NF}')"
;; ;;
*) echo "Aborting with no change"; exit 1 *) echo "Aborting with no change"; exit 1
;; ;;
esac esac

View File

@@ -1,78 +0,0 @@
# STEAMPREFIX is simply the path to where your steam games are installed. My library is in /var/games, but you may change it to your liking
export STEAMPREFIX="/var/games/SteamLibrary/steamapps/common"
# This function will change symbolic links from your steamapps/common folder to the install location of whichever game you wish. I use this
# for managing stable and beta versions of Project Zomboid, but you can use them for any game
change_install () {
if [ "$#" -lt 2 ]; then
echo "Usage: change_install <GameFolder> <InstallLocation>"
echo "Where GameFolder is the location of your game files"
echo "and InstallLocation is where you'd like to link them."
echo "GameFolder should be a renamed game folder in your steamapps/common folder"
exit 1
fi
export GAMEFOLDER=${1}
export INSTALLLOCATION=${2}
echo "Please exit Steam now to prevent updating over a different version"
echo "It's also recommended to add ${INSTALLLOCATION} to your exceptions"
echo "in Steam to only update the game when you launch it"
echo "(Enter to continue, CTRL+C to exit)"
read
unlink "${STEAMPREFIX}/${INSTALLLOCATION}"
if [ "$?" -ne 0 ]; then
echo "Unlink failed, have you followed the setup process?"
exit 1
fi
ln -s "${STEAMPREFIX}/${GAMEFOLDER}" "${STEAMPREFIX}/${INSTALLLOCATION}"
echo "You may start Steam now. Please remember to change your beta settings for ${GAMEFOLDER}"
echo "to prevent from updating to a version you do not want in this location"
}
setup_install () {
if [ "$#" -lt 2 ]; then
export SHELLNAME=$(echo $SHELL | awk -F "/" '{print $NF}')
echo "Usage: setup_install <GameFolder> <NewLocation>"
echo "Where GameFolder is the install location in your steam prefix"
echo "Please make sure to update your Steam Prefix to your library location"
echo "if you are not using ${STEAMPREFIX} as your library location"
echo "This variable can be found in your profile, also known as .${SHELLNAME}rc"
exit 1
fi
export GAMEFOLDER=${1}
export NEWLOCATION=${2}
echo "Please quit Steam at this time"
echo "(Enter to continue, CTRL+C to exit)"
read
echo "Moving ${STEAMPREFIX}/${GAMEFOLDER} to ${STEAMPREFIX}/${NEWLOCATION}"
echo -n "Continue? [y/N]: "
read ANS
case "${ANS}" in
y* | Y*) mv "${STEAMPREFIX}/${GAMEFOLDER}" "${STEAMPREFIX}/${NEWLOCATION}"
;;
*) echo "Cancelling with no change"; exit 1
;;
esac
if [ "$?" -eq 0 ]; then
echo "Game moved successfully!"
echo "You may now start Steam and install a different version of the game."
echo "To make the game playable, please run:"
echo "change_install ${NEWLOCATION} ${GAMEFOLDER}"
else
echo "Game could not be moved. Please check your command and try again."
echo "Remember that file paths are case-sensitive on Linux"
exit 1
fi
}

188
steamtricks/bin/steamtricks Executable file
View File

@@ -0,0 +1,188 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Config::Tiny;
use File::Basename;
use Data::Dumper;
use File::Copy;
sub print_help;
sub main;
sub parse_config;
sub setup_config;
sub create_config;
sub update_config;
sub create_install;
sub change_install;
use constant {
VERSION => "v0.1.0",
};
my $steamtricks_prefix = $ENV{'STEAMTRICKS_PREFIX'};
my $home = $ENV{'HOME'};
if ( ! $steamtricks_prefix ) {
die "Error! Please set your STEAMTRICKS_PREFIX environment variable.";
}
if (! $home ) {
die "Error! HOME environment variable not set, don't know where to look!"
}
my $config_location = "${steamtricks_prefix}/steamtricks.conf";
my $change_install = '';
my $create_install = '';
my $new_config = '';
my $game = '';
my $game_version = '';
my $new_steam_prefix = "${home}/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common";
my $help = '';
my $version = '';
my $print_version = '';
GetOptions (
'create-managed-install' => \$create_install,
'change-managed-install' => \$change_install,
'game=s' => \$game,
'game-version=s' => \$game_version,
'setup-config' => \$new_config,
'steam-prefix=s' => \$new_steam_prefix,
'help' => \$help,
'version' => \$print_version);
main();
sub main {
if ($help) {
print_help;
return 0;
} elsif ($print_version) {
print basename($0),' ', VERSION, "\n";
return 0;
} elsif ($new_config) {
setup_config($new_steam_prefix);
return 0;
} else {
my ($steam_prefix, @managed_games) = parse_config;
if ($change_install && $game_version && ! $create_install) {
change_install($steam_prefix, @managed_games);
return 0;
} elsif ($create_install && $game_version && ! $change_install ) {
create_install($steam_prefix, @managed_games);
return 0;
}
}
}
sub parse_config {
my $Config;
if (-s "$config_location" ) {
$Config = Config::Tiny->read( "$config_location" );
} else {
warn "config file ${config_location} not found. Creating new config with flatpak defaults\n";
$Config = setup_config;
}
my $steam_prefix = Dumper($Config->{general}->{steam_prefix});
my @managed_games = Dumper($Config->{install_manager}->{managed_games});
return $steam_prefix, @managed_games;
}
sub setup_config {
my $Config;
print "Creating config with steam_prefix=${new_steam_prefix}\n";
if (-s "${config_location}") {
warn "$config_location already exists, do you wish to overwrite this file? [y/N]";
my $ans = <STDIN>;
chomp $ans;
if ( $ans =~ /^[yY].?$/ ) {
$Config = create_config;
} else {
die "Error! Config not created.";
}
} else {
$Config = create_config;
}
return $Config;
}
sub create_config {
my $Config = Config::Tiny->new({
general => { "steam_prefix" => $new_steam_prefix },
install_manager => { "managed_games[]" => ""}
});
$Config->write( ${config_location} ) or die "Error! Config file $config_location could not be written: $!";
return $Config;
}
sub update_config {
my ($section, $key, $value) = @_;
my $Config = Config::Tiny->read($config_location);
if ($section) {
$Config->{$section}->{$key}= $value;
} else {
$Config->{_}->{$key} = $value;
}
$Config->write($config_location) or die "Error! Config file $config_location could not be written: $!";
}
sub create_install {
my ($steam_prefix, @managed_games) = @_;
if (-d "${steam_prefix}/${game}" ) {
move("${steam_prefix}/${game}", "${steam_prefix}/${game}_${game_version}");
symlink("${steam_prefix}/${game}_${game_version}", "${steam_prefix}/${game}");
print "You may now restart Steam to apply effects\n";
} elsif ( -l "${steam_prefix}/${game}") {
if ( grep( /^$game$/, @managed_games) ){
warn "This game is already managed, are you looking for --change-managed-install ?";
exit 1;
} else {
warn "This game is symlinked but not in the managed_games[] field in the config";
print "Would you like to add it to the config? [Y/n]: ";
my $ans = <STDIN>;
chomp $ans;
if ($ans =~ /^[nN].?$/ ) {
die "Config not upddated.";
} else {
update_config("install_manager", "managed_games[]", $game);
}
}
} else {
die "Error! Game not found at ${steam_prefix}/${game} please check your steam_prefix and your game name.";
}
}
sub change_install {
my ($steam_prefix, $managed_games) = @_;
if ( -l "${steam_prefix}/${game}" && grep /^$game$/, $managed_games) {
unlink "${steam_prefix}/${game}" or die "Could not unlink $steam_prefix/$game: $!";
symlink "${steam_prefix}/${$game}_${game_version}", "${steam_prefix}/${game}"
or die "Could not create symlink ${steam_prefix}/${game}: $!";
print "You may now change any beta settings and restart Steam to apply your changes\n";
} elsif ( -l "${steam_prefix}/${game}" && ! grep /^$game$/, $managed_games) {
warn "$game not in config as a managed_game[], adding to config";
update_config("install_manager", "managed_games[]", $game);
unlink "${steam_prefix}/${game}" or die "Could not unlink $steam_prefix/$game: $!";
symlink "${steam_prefix}/${$game}_${game_version}", "${steam_prefix}/${game}"
or die "Could not create symlink ${steam_prefix}/${game}: $!";
print "You may now change any beta settings and restart Steam to apply your changes\n";
} else {
die "Error! ${steam_prefix}/${game} is not a symlink, please run with --create-managed-install";
}
}
sub print_help {
print basename($0), "\n";
return 0;
}

View File

@@ -0,0 +1,12 @@
# For the time being, this config file is very picky. You cannot leave trailing
# slashes on any paths in this folder
[general]
steam_prefix=~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common
# You may add any number of managed games you'd like, just note that the value
# is case sensitive and should match the original folder name in steamapps/common
# you must also have a separate managed_games[] entry for each game
# the brackets are necessary. Quotes are unnecessary
[install_manager]
managed_games[]=ProjectZomboid
managed_games[]=ELDEN RING
managed_games[]=Baldurs Gate 3

53
webinstall.sh Normal file → Executable file
View File

@@ -1,11 +1,46 @@
#!/usr/bin/env bash #!/usr/bin/env sh
export DOWNLOADURL=""
unsupported_shell () {
echo "Your shell $SHELL is not supported by this install script"
echo "You will need to manually install by extracting a tarball from"
echo "https://github.com/charwrangler404/steamtricks/releases to your home folder"
echo "and setting the STEAMTRICKS_PREFIX to your shell's environment, as well as"
echo "$HOME/.steamtricks/bin to your PATH"
}
install () {
export SHELLPROFILE="$1"
curl "$DOWNLOADURL" | tar -xvC $HOME/ || echo "Could not install steamtricks" && exit 1
chmod 755 $HOME/.steamtricks/bin/steamtricks
if [ -z "$STEAMTRICKS_PREFIX" ]; then
echo "export STEAMTRICKS_PREFIX=\"$HOME/.steamtricks\"">>"${SHELLPROFILE}"
fi
if [ -z "$(echo $PATH | grep 'steamtricks')" ]; then
echo 'export PATH="$PATH:~/.steamtricks/bin"'>>${SHELLPROFILE}
fi
echo "Install completed! Please source your profile $SHELLPROFILE to load the changes!"
}
install_manager () {
case "$1" in
bash | zsh | yash) install "$HOME/.${1}rc"
;;
sh ) install "$HOME/.profile"
;;
*) unsupported_shell
;;
esac
}
if [ "$EUID" -eq 0 ]; then
echo "Please do not run this script as root"
exit 1
fi
SHELLNAME=$(echo $SHELL | awk -F '/' '{print $NF}') SHELLNAME=$(echo $SHELL | awk -F '/' '{print $NF}')
case "$SHELLNAME" in
sh) echo "Shell not supported"; exit 1 install_manager $SHELLNAME
;;
bash | zsh) curl https://raw.githubusercontent.com/charwrangler404/steamtricks/refs/heads/main/multiple_install_manager.sh >> "${HOME}/.${SHELLNAME}rc"; echo "Installed to ${HOME}/.${SHELLNAME}rc"
;;
*) echo "You will need to install this by manually adding it to either your /etc/profile for system-wide installation or to your shell's profile"
;;
esac