Skip to content

Commit

Permalink
Merge pull request #13 from jcnils/no_compiler
Browse files Browse the repository at this point in the history
Removes need for compiler—(#11 #12)
  • Loading branch information
jcnils authored Apr 10, 2024
2 parents cc185d6 + da31f7c commit d6c67a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 80 deletions.
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,57 @@
# protonhax

Tool to help running other programs (i.e. Cheat Engine) inside Steam's proton.

## Usage
In Steam set the launch options for the desired game to `protonhax init %COMMAND%`
Set the steam game launch options to `protonhax init %COMMAND%`

On your Steam Library:
- Right-click the game > Properties > General.
- Set Launch Options as `protonhax init %COMMAND%`.

To list all running appids use\
Now, you can use your terminal to run the following commands:

- To list all running appids use\
`protonhax ls`

To run a program with proton use\
- To run a program with proton use\
`protonhax run <appid> <path/to/program> [args...]`\
NOTE: The PATH variable is ignored

To run cmd.exe use\
- To run cmd.exe use\
`protonhax cmd <appid>`

To run a program natively with the environment variables that were used to launch the game originally use\
- To run a program natively with the environment variables that were used to launch the game originally use\
`protonhax exec <appid> <path/to/program> [args...]`\
NOTE: The PATH variable is ignored

## Installing

For it to work, you need to be able to access both `protonhax` and `envload` from the terminal. You can use one of the available packages or build it yourself.

### Build it yourself
**protonhax** is currently a single bash script, you just need to add it to your $PATH.

*Current Makefile uses `tcc`, you can update it to use any c compiler you have (e.g. gcc)*

1. Clone our repo `https://github.com/jcnils/protonhax.git`, or download the source from our [release page](https://github.com/jcnils/protonhax/releases)
2. Open the directory in a terminal.
3. Run `make`. It will build the `envload.c` using the `Makefile` into a file called `envload`.
4. Copy both `envload` and `protonhax` files to where you want to call them from and give proper permissions, Example `/usr/bin/protonhax` and `usr/bin/envload` with permission `755`.

Try to call `envload` and `protonhax` if a usage guide appears, it means they are working.
1. Either clone our repo `https://github.com/jcnils/protonhax.git`, or download the source from our [release page](https://github.com/jcnils/protonhax/releases)
2. Copy the **protonhax** file to where you preffer and give it permission to execute:
- Example of locations `$HOME/.local/bin/protonhax`, `/usr/bin/protonhax`. They need to be on your $PATH
- Permission `chmod 755 protonhax`.

### Arch Linux
- https://aur.archlinux.org/packages/protonhax
- https://aur.archlinux.org/packages/protonhax-git/

## Debugging

Open the `protonhax` file and add to the second line
```sh
set -x
exec >/tmp/protonhax.$$.log 2>&1
```
It will save protonhax debug log into `/tmp/protonhax.*.log`

## Contributing
Contributions are always welcome! Especially if they are packages for other distributions.

## TODO

- [ ] Flatpak version for Steam Flatpak
- [ ] Nix Packages
- [ ] Packages for other Linux distributions.
49 changes: 0 additions & 49 deletions envload.c

This file was deleted.

10 changes: 6 additions & 4 deletions protonhax
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [[ "$c" == "init" ]]; then
mkdir -p $phd/$SteamAppId
printf "%s\n" "${@}" | grep -m 1 "/proton" > $phd/$SteamAppId/exe
printf "%s" "$STEAM_COMPAT_DATA_PATH/pfx" > $phd/$SteamAppId/pfx
env -0 > $phd/$SteamAppId/env
declare -px > $phd/$SteamAppId/env
"$@"
ec=$?
rm -r $phd/$SteamAppId
Expand All @@ -53,20 +53,22 @@ elif [[ "$c" == "run" ]] || [[ "$c" == "cmd" ]] || [[ "$c" == "exec" ]]; then
SteamAppId=$1
shift

source $phd/$SteamAppId/env

if [[ "$c" == "run" ]]; then
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
$(dirname $0)/envload $phd/$SteamAppId/env "$(cat $phd/$SteamAppId/exe)" run "$@"
exec "$(cat $phd/$SteamAppId/exe)" run "$@"
elif [[ "$c" == "cmd" ]]; then
$(dirname $0)/envload $phd/$SteamAppId/env "$(cat $phd/$SteamAppId/exe)" run "$(cat $phd/$SteamAppId/pfx)/drive_c/windows/system32/cmd.exe"
exec "$(cat $phd/$SteamAppId/exe)" run "$(cat $phd/$SteamAppId/pfx)/drive_c/windows/system32/cmd.exe"
elif [[ "$c" == "exec" ]]; then
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
$(dirname $0)/envload $phd/$SteamAppId/env "$@"
exec "$@"
fi
else
printf "Unknown command %s\n" "$c"
Expand Down

0 comments on commit d6c67a4

Please sign in to comment.