wineblox/Wineblox.sh
2022-08-05 00:27:17 -06:00

158 lines
4.3 KiB
Bash
Executable file

#!/bin/bash
mkdir -p $HOME/.local/share/wineblox-prefix
WINEPREFIXX=$HOME/.local/share/wineblox-prefix
# To change what WINE that is used, specify the path. An example would be wine-tkg/bin/wine
WINEBIN=Default
# Variables for known Polygon install locations
BLOXSTRAPPATH=$WINEPREFIXX/drive_c/users/$USER/AppData/Local/Bloxstrap
if [[ ($WINEBIN == Default) ]]; then
WINEBIN=$(which wine)
else
echo "Warning: using custom wine binary"
fi
#Dependencies
fedora_install () {
sudo dnf install wine winetricks
}
ubuntu_install () {
sudo apt install wine winetricks
}
debian_install () {
sudo apt install wine-development winetricks
}
arch_install () {
sudo pacman -S --needed wine winetricks
}
check_dependencies () {
if [[ $(cat /etc/*-release | grep "Fedora") ]]; then
echo "Detected Fedora!"
fedora_install
else
if [[ $(cat /etc/*-release | grep "Ubuntu") ]] || [[ $(cat /etc/*-release | grep "LinuxMint") ]] || [[ $(cat /etc/*-release | grep "Pop") ]]; then
echo "Detected Ubuntu or derivative!"
ubuntu_install
else
if [[ $(cat /etc/*-release | grep "Debian") ]]; then
echo "Detected Debian!"
debian_install
else
if [[ $(cat /etc/*-release | grep "Arch Linux") ]] || [[ $(cat /etc/*-release | grep "SteamOS") ]]; then
echo "Detected Arch Linux or derivative!"
arch_install
else
echo "You're on an unsupported distro. Please manually install the required dependencies from the README.md or make a pull request adding support for your distro"
exit
fi
fi
fi
fi
}
#Downloads Roblox
download_game_base () {
if [ $WINEPREFIXX ]; then
echo "Prefix already exists, removing"
rm -rf $WINEPREFIXX
mkdir -p $WINEPREFIXX
else
echo "No prefix exists, creating one"
mkdir -p $WINEPREFIXX
fi
}
download_game () {
env WINEPREFIX=$WINEPREFIXX $WINEBIN bloxstrap/Bloxstrap.exe
echo "Bloxstrap installed!"
cp -rT bloxstrap $BLOXSTRAPPATH
}
#Creates .desktop files
desktop_file () {
DESKTOPFILE=$HOME/.local/share/applications/wineblox.desktop
MIMETYPE=x-scheme-handler/roblox-player
echo "[Desktop Entry]" > $DESKTOPFILE
echo "Version=1.0" >> $DESKTOPFILE
echo "Type=Application" >> $DESKTOPFILE
echo "Name=Bloxstrap URL Handler" >> $DESKTOPFILE
echo "Comment=Play Roblox games!" >> $DESKTOPFILE
echo "Exec=env WINEPREFIX=$WINEPREFIXX $WINEBIN '$BLOXSTRAPPATH/Bloxstrap.exe' %u" >> $DESKTOPFILE
echo "Categories=Game;" >> $DESKTOPFILE
echo "MimeType=$MIMETYPE;" >> $DESKTOPFILE
echo "Created desktop file!"
}
url_handler_base () {
#Add entries for URL handlers
MIMEAPPS=$HOME/.local/share/applications/mimeapps.list
MIMEAPPSBAK=$HOME/.local/share/applications/mimeapps.list.bak
if [ -f "$MIMEAPPS" ]; then
echo "$MIMEAPPS already exists"
echo "Making a backup as mimeapps.list.bak"
echo "In case the script messes it up"
cp $MIMEAPPS $MIMEAPPSBAK
else
echo "[Default Applications]" > $MIMEAPPS
fi
}
url_handler () {
MIMEENTRY="$MIMETYPE=$(basename "$DESKTOPFILE")"
if grep -Fxq "$MIMEENTRY" "$MIMEAPPS"
then
echo "URL handler for Bloxstrap is already created! Skipping..."
else
echo $MIMEENTRY >> $MIMEAPPS
echo "Created URL handler for Bloxstrap!"
fi
}
resync_databases () {
update-desktop-database "$HOME/.local/share/applications"
update-mime-database "$HOME/.local/share/mime"
echo "Synced desktop and mime databases"
}
kill_processes () {
env WINEPREFIX=$WINEPREFIXX "$WINEBIN"server -k
}
echo "Welcome to Wineblox! (for Roblox)"
echo "type 1 to install Roblox"
echo "type 2 to open studio"
echo "type 3 to kill processes in prefix"
echo "then press enter"
read what
if [[ $what == 1 ]]; then
echo "Selected to install Roblox"
check_dependencies
download_game_base
download_game
desktop_file
url_handler_base
url_handler
resync_databases
#install_winetricks_dependencies
else
if [[ $what == 2 ]]; then
echo "Selected to open Studio (NOT IMPLEMENTED YET)"
exit
else
if [[ $what == 3 ]]; then
echo "Selected kill all wine processes in prefix"
kill_processes
else
echo "No valid option specified"
exit
fi
fi
fi