|
#!/usr/bin/env bash |
|
|
|
echo "Checking dependencies..." |
|
|
|
function run_grapejuice { |
|
if command -v grapejuice>/dev/null |
|
then |
|
grapejuice gui |
|
elif command -v flatpak>/dev/null |
|
then |
|
flatpak run net.brinkervii.grapejuice gui |
|
else |
|
echo "Grapejuice doesn't seem to be installed. Please install it via flatpak, or add it to your path if you've installed it from sources." |
|
exit |
|
fi |
|
} |
|
|
|
winetricks_url="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" |
|
function prompt_download_winetricks { |
|
if command -v wget>/dev/null |
|
then |
|
read -n 1 -r -p "Download 'winetricks' from GitHub ($winetricks_url)? (y/N)" REPLY |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]] |
|
then |
|
echo "Downloading winetricks from GitHub ($winetricks_url)..." |
|
mkdir -p "/tmp/studio64_workaround" |
|
cd /tmp/studio64_workaround |
|
wget $winetricks_url |
|
chmod +x winetricks |
|
fi |
|
else |
|
echo "Install 'wget' to download 'winetricks' automatically." |
|
fi |
|
} |
|
|
|
function run_winetricks { |
|
if command -v ./winetricks>/dev/null |
|
then |
|
WINEDEBUG=-all ./winetricks "$@" |
|
elif command -v /tmp/studio64_workaround/winetricks>/dev/null |
|
then |
|
WINEDEBUG=-all /tmp/studio64_workaround/winetricks "$@" |
|
else |
|
WINEDEBUG=-all winetricks "$@" |
|
fi |
|
wineserver -k |
|
} |
|
|
|
function run_wine64 { |
|
if command -v ./wine64>/dev/null |
|
then |
|
WINEDEBUG=-all ./wine64 "$@" |
|
else |
|
WINEDEBUG=-all wine64 "$@" |
|
fi |
|
wineserver -k |
|
} |
|
|
|
# Check dependencies |
|
if ! command -v wine64>/dev/null |
|
then |
|
echo "'wine64' wasn't found. Please install wine by following https://wiki.winehq.org/Download in your Linux environment. 'winehq-devel' is suggested at the time of creating this script." |
|
exit |
|
fi |
|
if ! command -v wineserver>/dev/null |
|
then |
|
echo "'wineserver' wasn't found. Please install wine by following https://wiki.winehq.org/Download in your Linux environment. 'winehq-devel' is suggested at the time of creating this script." |
|
exit |
|
fi |
|
if ! command -v winetricks>/dev/null |
|
then |
|
if ! command -v ./winetricks>/dev/null |
|
then |
|
if ! command -v /tmp/studio64_workaround/winetricks>/dev/null |
|
then |
|
prompt_download_winetricks |
|
if ! command -v /tmp/studio64_workaround/winetricks>/dev/null |
|
then |
|
echo "'winetricks' wasn't found. Please install winetricks by following https://wiki.winehq.org/Winetricks in your Linux environment." |
|
exit |
|
fi |
|
fi |
|
fi |
|
fi |
|
|
|
# dpkg/winetricks |
|
if command -v dpkg>/dev/null |
|
then |
|
if dpkg -s winetricks 2>/dev/null |
|
then |
|
echo |
|
echo "NOTE: You have installed 'winetricks' via your package manager. If you are on Debian, Ubuntu, or using a Linux environment on ChromeOS (Crostini), the version provided by your system may be out of date." |
|
echo "See https://wiki.winehq.org/Winetricks" |
|
if command -v apt>/dev/null |
|
then |
|
read -n 1 -r -p "(Optional, press n if you aren't sure) Do you want to replace 'winetricks' from apt with the one from GitHub ($winetricks_url) instead? This will download and place the winetricks command into '/usr/local/bin'. (y/N)" REPLY |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]] |
|
then |
|
echo "Uninstalling winetricks from apt..." |
|
sudo apt purge winetricks |
|
cd /tmp |
|
echo "Downloading winetricks from GitHub ($winetricks_url)..." |
|
wget $winetricks_url |
|
chmod +x winetricks |
|
echo "Moving winetricks to '/usr/local/bin'..." |
|
sudo mv winetricks /usr/local/bin |
|
echo "winetricks was installed from GitHub for you in '/usr/local/bin'. You can run 'winetricks --self-update' to update it, or remove it with 'sudo rm /usr/local/bin/winetricks'." |
|
cd ->/dev/null |
|
fi |
|
fi |
|
fi |
|
fi |
|
|
|
# killall |
|
if ! command -v killall > /dev/null |
|
then |
|
echo "'killall' wasn't found. If you are on Debian, Ubuntu, or using a Linux environment on ChromeOS (Crostini) you can install it via 'sudo apt install killall'." |
|
exit |
|
fi |
|
|
|
# Check for prefixes folder |
|
prefix_folder=$(pwd) |
|
if [ -d "$HOME/.local/share/grapejuice/prefixes" ] |
|
then |
|
echo "Found Grapejuice prefixes folder." |
|
prefix_folder="$HOME/.local/share/grapejuice/prefixes" |
|
fi |
|
|
|
# Wine prefix path |
|
read -p "Paste the path to your 64 bit studio prefix: " prefix_to_use |
|
echo |
|
|
|
cd $prefix_folder |
|
prefix_to_use=$(realpath "$prefix_to_use") |
|
cd ->/dev/null |
|
|
|
# drive_c check |
|
if [ ! -d "$prefix_to_use/drive_c" ] |
|
then |
|
if [ "$(basename "$prefix_to_use")" == "drive_c" ] |
|
then |
|
echo "You included 'drive_c' in your path and it wasn't a valid prefix. You might've passed the path to the prefix's 'drive_c' subfolder by mistake. Selecting the parent directory instead." |
|
prefix_to_use="$(dirname "$prefix_to_use")" |
|
fi |
|
fi |
|
|
|
# If the directory is not a valid prefix, try the one in the grapejuice folder with the name specified by the first argument |
|
function try_prefix { |
|
if [ ! -d "$prefix_to_use/drive_c" ] |
|
then |
|
try_grapejuice_prefix="$prefix_folder/$1" |
|
if [ -d "$try_grapejuice_prefix/drive_c" ] |
|
then |
|
read -n 1 -r -p "The prefix you specified doesn't seem to exist, but one was found at \"$try_grapejuice_prefix\". Do you want to use that one instead? Make sure it's the Studio prefix. (y/N)" REPLY |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]] |
|
then |
|
prefix_to_use="$try_grapejuice_prefix" |
|
fi |
|
fi |
|
fi |
|
} |
|
|
|
# If the prefix isn't valid, try some alternatives |
|
try_prefix $(basename "$prefix_to_use") # Basename of the inputted path but inside Grapejuice's prefixes folder |
|
cd $prefix_folder |
|
try_prefix $(ls -td -- */ | head -n 1) # Most recent prefix folder in Grapejuice's prefixes folder |
|
cd ->/dev/null |
|
|
|
# Check if the prefix is valid |
|
if [ ! -d "$prefix_to_use/drive_c" ] |
|
then |
|
read -n 1 -r -p "The path you entered wasn't a valid wine prefix. Do you want to create one via Grapejuice? (y/N)" REPLY |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]] |
|
then |
|
echo "Grapejuice will be opened. You will need to follow the steps below." |
|
echo " 1. If it exists, find your current studio prefix, and click it." |
|
echo " 2. Either delete the prefix, or scroll to the very bottom under 'Application Hints' and disable the 'Studio' hint if you want to keep the prefix folder around as a backup." |
|
echo " 3. Create a new prefix, and click 'Initialize'." |
|
echo " 4. Scroll to the very bottom under 'Application Hints' and enable the 'Studio' hint." |
|
echo "Press any key to continue." |
|
read -n 1 -s |
|
run_grapejuice |
|
cd $prefix_folder |
|
try_grapejuice_prefix="$prefix_folder/$(ls -td -- */ | head -n 1)" |
|
cd ->/dev/null |
|
echo |
|
read -n 1 -r -p "\"$try_grapejuice_prefix\" is the most recently created prefix. Is this the prefix you want to use? (y/N)" REPLY |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]] |
|
then |
|
prefix_to_use="$try_grapejuice_prefix" |
|
fi |
|
fi |
|
fi |
|
|
|
# Confirm with the user the prefix is correct |
|
read -n 1 -r -p "Will use WINEPREFIX=\"$prefix_to_use\". Is this the 64 bit Studio prefix you want to use? (y/N)" REPLY |
|
echo |
|
if [[ ! $REPLY =~ ^[Yy]$ ]] |
|
then |
|
echo "Cancelled." |
|
exit |
|
fi |
|
export WINEPREFIX=$prefix_to_use |
|
|
|
# Kill MicrosoftEdgeUpdate.exe & wait for wine server to exit |
|
echo "Making sure MicrosoftEdgeUpdate.exe isn't running." |
|
killall MicrosoftEdgeUpdate.exe 2> /dev/null |
|
wineserver -k > /dev/null |
|
|
|
# Prevent MicrosoftEdgeUpdate.exe from running again, so that wine won't get eternally stuck (held hostage by Microsoft) |
|
echo "Preventing MicrosoftEdgeUpdate.exe from autostarting, otherwise wine will hang." |
|
edge_update_path="$WINEPREFIX/drive_c/Program Files (x86)/Microsoft/EdgeUpdate/MicrosoftEdgeUpdate.exe" |
|
if [ ! -f "$edge_update_path" ]; then |
|
mkdir -p "$(dirname "$edge_update_path")" |
|
echo "" > "$edge_update_path" # Create empty MicrosoftEdgeUpdate.exe file |
|
fi |
|
chmod 0 "$edge_update_path" > /dev/null # Revoke all permissions to the file so it won't run at auto start |
|
|
|
# Winetricks |
|
echo |
|
echo "Will install 'vcrun2015', and 'videomemorysize' will be set to its maximum (2048). You will be prompted with a vcruntime installer GUI twice, you will need to accept both." |
|
echo "Press any key to continue. This will take a while." |
|
read -n 1 -s |
|
echo "Proceeding, please wait..." |
|
run_winetricks vcrun2015 videomemorysize=2048 |
|
|
|
echo "Done." |
|
echo |
|
|
|
# Output screen resolution |
|
screen_resolution="your screen resolution" |
|
if command -v xdpyinfo>/dev/null |
|
then |
|
screen_resolution=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') # https://superuser.com/a/196545 |
|
echo "Your screen resolution is $screen_resolution." |
|
else |
|
echo "Can't automatically determine your screen resolution." |
|
fi |
|
|
|
# Open Wine Config |
|
echo |
|
echo "winecfg will be opened in your prefix. You will need to follow the steps below for the Graphics and Libraries tabs. These steps are required for Studio to be functional. Once you are finished, hit 'Ok'." |
|
echo " 1. In 'Graphics', enable 'Emulate a Virtual Desktop'. Set the 'Desktop size' to $screen_resolution. This option will use Wine's integrated window manager instead of your system's window manager." |
|
echo " 2. In 'Libraries', select '*vcruntime140'. Then click 'Edit' and set it to 'Builtin then Native'. Do the same for '*vcruntime140_1'." |
|
echo "Press any key to continue." |
|
read -n 1 -s |
|
echo "Proceeding..." |
|
run_wine64 winecfg |
|
|
|
echo "Grapejuice will be opened. You will need to follow the steps below for your prefix. These steps will eliminate some forms of crashing." |
|
echo "NOTE: If any other Studio prefixes other than the one that you want to use have the Roblox Studio icon, make sure to disable the 'Studio' hint for them under 'Application Hints'. If you don't do this, Grapejuice may run them instead." |
|
echo " 1. Turn on 'Enable Wine debugging' and set your WINEDEBUG string to '+synchronous'." |
|
echo " 2. Launch Roblox Studio. You will still always see a page fault. Just click 'Close', and then Studio should open all the way to the start page." |
|
echo " 3. (Optional, not recommended to use OpenGL) With D3d11, which will generally be selected by default, Studio may quit sometimes when the state of any window changes. If this is a problem you can use OpenGL at the cost of a lot of GUIs being non functional. In Studio, navigate to 'File > Studio Settings > Rendering'. Change 'Graphics Mode' to OpenGL. Vulkan doesn't work, so do not set it to Vulkan, or you will need to start over, or manually edit the Roblox settings file to fix it." |
|
echo " 4. Close out of both Studio and Grapejuice." |
|
echo "Press any key to continue." |
|
read -n 1 -s |
|
echo "Proceeding..." |
|
run_grapejuice |
|
|
|
echo |
|
echo "Done. If you followed the steps above, you can now open Studio." |