Wine-based Game Launcher for FreeBSD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

619 lines
18 KiB

#!/usr/local/bin/bash
printf %b '\e]11;#000000\a'
export NAME=Homura
export VER="5.6"
export ALH=500
export WTH=500
export FBSDVER=$(uname -r | cut -c -2)
GPU=$(glxinfo | grep "OpenGL vendor string")
OSN=$(uname)
export ARCH=$(uname -m)
if [ -f "/etc/pkg/GhostBSD.conf" ]; then
OSN=GhostBSD
fi
# Directorys
if [ -n "$NDIR" ]; then
echo "Custom $NAME path in use!"
else
export NDIR=$HOME/.local/share/$NAME
fi
if [ -n "$DDIR" ]; then
echo "Custom Data path in use!"
else
export DDIR=$NDIR/Data
fi
if [ -n "$LDIR" ]; then
echo "Custom Library path in use!"
else
export LDIR=$NDIR/Library
fi
if [ -n "$GDIR" ]; then
echo "Custom Games path in use!"
else
export GDIR=$NDIR/Games
fi
if [ -n "$PDIR" ]; then
echo "Custom Programs path in use!"
else
export PDIR=$NDIR/Programs
fi
# Misc
DATE=$(date)
DATEY=$(date +%Y)
DATEDM=$(date +%d-%m)
COPYRIGHT=$(echo 2019-$DATEY, Alexander Vereeken)
export WINEDLLOVERRIDES=winemenubuilder.exe=d
# Use curl if installed.
SDBIN=$(which curl 2>/dev/null)
if [[ $SDBIN == *"/usr/local/bin/curl"* ]]; then
export DBIN="curl -O -L"
else
export DBIN="fetch"
fi
# Functions :)
function download {
zenity --notification --window-icon=$ICO --text "Downloading $INST $UPDE"
cd $DDIR
$DBIN $1
}
function prefix-message {
zenity --notification --window-icon=$ICO --text "Setup prefix"
}
function installer-message {
zenity --notification --window-icon=$ICO --text "Starting installation"
}
function warn {
zenity --warning --width=400 --window-icon=$ICO --title "$NAME $VER - $TODO" --text "$1"
}
function info {
zenity --info --width=400 --window-icon=$ICO --title "$NAME $VER - $TODO" --text "$1"
}
function question {
zenity --question --width=400 --window-icon=$ICO --title "$NAME $VER" --text "$1"; echo $?
}
function notify {
zenity --notification --window-icon=$ICO --text "$1"
}
function remove {
rm -d -r -f "$1"
}
export -f download
export -f prefix-message
export -f installer-message
export -f warn
export -f info
export -f question
export -f notify
export -f remove
# Running Homura as root is not recommended. If you still want to run Homura as root, please overwrite the USER variable with an existing user.
if [[ $USER == *"root"* ]]; then
info "$NAME can (and should) not be executed as root."
exit
fi
# When Homura is first started.
if [ ! -d "$NDIR" ]; then
TODO="Setting up $NAME"
mkdir -p $NDIR
info "Welcome to $NAME. If you have a problem, suggestion, questions or similar, do not hesitate to open an issue on Codeberg. Have Fun!"
if [[ $OSN != "FreeBSD" ]]; then
info "You are about to use $NAME on an unsupported system ($OSN). Please be aware that unexpected errors may occur and that your bug reports can be marked as invaild."
fi
SC=$(question "Do you want a shortcut of $NAME in your application menu?")
if [[ $SC == *"0"* ]]; then
if [ ! -d "/usr/home/$USER/.local/share/applications" ]; then
mkdir /usr/home/$USER/.local/share/applications
fi
echo "[Desktop Entry]
Comment=Windows Games Launcher for FreeBSD
Exec=bash /usr/local/bin/$NAME
Icon=$DDIR/$NAME.png
Categories=Game;
Name=$NAME
StartupNotify=false
Terminal=false
TerminalOptions=
Type=Application
" >> /usr/home/$USER/.local/share/applications/$NAME.desktop
if [[ $SC == *"1"* ]]; then
echo "Shortcut will be not created"
fi
fi
fi
# Creating the subdirectories
if [ ! -d "$GDIR" ]; then
mkdir $GDIR
fi
if [ ! -d "$PDIR" ]; then
mkdir $PDIR
fi
if [ ! -d "$DDIR" ]; then
mkdir $DDIR
fi
if [ ! -d "$DDIR/WineVerLib" ]; then
mkdir $DDIR/WineVerLib
fi
# Icon
export ICO=$DDIR/$NAME.png
if [ ! -f "$ICO" ]; then
download http://alt.magzu.net/damn/dl/Homura.png
fi
TODO="Library"
if [ ! -d "$LDIR" ]; then
mkdir -p $LDIR
cd $LDIR
fetch https://codeberg.org/Alexander88207/Homura/archive/library-5.6+.zip
unzip library-5.6+.zip
mv $LDIR/homura/* $LDIR
cd $LDIR/
chmod +x *
rm -r -d $LDIR/homura
rm library-5.6+.zip
rm LICENSE
if [ "$(ls -A $LDIR)" ]; then
echo -e "\e[3;5;0;32mLibrary successfully loaded.\e[30;48;5;82m\e[0m"
else
warn "The library could not be loaded successfully, maybe no internet connection? Use update library under other to try a reload."
exec $NAME
fi
fi
if [ "$(ls -A $LDIR)" ]; then
echo -e "\e[3;5;0;32mHomura library is not empty, nice!.\e[30;48;5;82m\e[0m"
else
warn "The Homura library is empty. Please use update library under other to try a reload."
fi
# The Applists
export APPLIST=$(cd $LDIR && ls | grep -v fixes | grep -v Scripts )
export APPEXISTCHECK=$(cd "$GDIR" && ls && cd "$PDIR" && ls )
# Small checks to ensure that the user knows that no correct drivers are running.
if [[ $GPU == *"VMware, Inc."* ]]; then
info "$NAME have detected that you are using the fallback drivers, please check your gpu driver installation. If you should run $NAME in a virtual machine or you have enabled software rendering then you can ignore this message."
fi
if [[ $GPU == *"Mesa/X.org"* ]]; then
info "$NAME have detected that you are using the fallback drivers, please check your gpu driver installation. If you should run $NAME in a virtual machine or you have enabled software rendering then you can ignore this message."
fi
# CLI
Install() {
CLI=1
export APPNAME=$1
export TODO=Installation
}
Launch() {
CLI=1
export APPNAME=$1
export TODO=Launcher
}
Uninstall() {
CLI=1
export APPNAME=$1
export TODO=Uninstallation
}
"$@"
# Set to use wine-proton and wow64
export WINEBIN="/usr/local/wine-proton/bin/wine"
if [[ $ARCH == *"amd64"* ]]; then
if [ ! -d "$HOME/.i386-wine-pkg/usr/local/wine-proton" ]; then
echo -e "\e[3;5;0;96mSetting up lib32 for wine-proton\e[30;48;5;82m\e[0m"
/usr/local/wine-proton/bin/pkg32.sh install -y wine-proton mesa-dri
info "$NAME uses wine-proton as default but you can change it anytime for any application under the 'Manage Wine' menu"
fi
fi
export WINEVER=$(/usr/local/wine-proton/bin/wine --version | cut -b 6-)
# Small informations in the terminal
echo -e "\e[0;33mCopyright (c) $COPYRIGHT All rights reserved."
echo -e "\e[0;35mWelcome to $NAME $VER Have Fun!"
echo -e "\e[3;5;0;92mRunning on $OSN $(uname -r)"
echo -e "\e[3;5;0;36mWine-Proton Version: $WINEVER\e[30;48;5;82m\e[0m"
echo -e "\e[3;5;0;31mGPU Info OpenGL:\e[30;48;5;82m\e[0m" && glxinfo | grep OpenGL
echo -e "\e[3;5;0;31mGPU Info Vulkan:\e[30;48;5;82m\e[0m" && vulkaninfo | grep -m 1 "GPU id"
# Greetings on certain holidays
if [[ $DATEDM == *"01-01"* ]]; then
notify "Happy new year :)"
fi
if [[ $DATEDM == *"14-02"* ]]; then
notify "Happy Valentine's Day <3"
fi
if [[ $DATEDM == *"17-03"* ]]; then
notify "Happy St. Patrick's Day :)"
fi
if [[ $DATEDM == *"12-04"* ]] || [[ $DATEDM == *"13-04"* ]]; then
notify "Happy Easter :)"
fi
if [[ $DATEDM == *"31-10"* ]]; then
notify "Happy Halloween ;)"
fi
if [[ $DATEDM == *"25-12"* ]] || [[ $DATEDM == *"26-12"* ]]; then
notify "We wish you merry christmas to you, your family and friends :)"
fi
# Initial menu
if [ -z "$CLI" ]
then
export TODO=$(zenity --list --radiolist --window-icon=$ICO --height=450 --width 300 --title="$NAME $VER" --text " Welcome $USER! - What do you want to do?" --hide-header --column "$NAME" --column "Item" FALSE "Installation" FALSE "Launcher" FALSE "Uninstallation" FALSE "Winetricks" FALSE "Run a executable in a selected prefix" FALSE "Kill wine in a selected prefix" FALSE "Update" FALSE "Manage Wine" FALSE "Applying a fix" FALSE "Open Homura folder" FALSE "Enable logging" FALSE "Other" FALSE "About" FALSE "Exit")
fi
if [[ $LOG == *"1"* ]]; then
export WINEDEBUG=warn+trace+fixme+err
else
if [ -z "$CLI" ]
then
export WINEDEBUG=-all
else
export WINEDEBUG=warn+trace+fixme+err
fi
fi
if [[ $TODO == *"Installation"* ]]; then
# Checking the internet connection.
nc -z 1.1.1.1 80 >/dev/null 2>&1
online=$?
if [ $online -eq 0 ]; then
echo -e "\e[3;5;0;32mConnection to the internet exists.\e[30;48;5;82m\e[0m"
else
IQ=$(question "Hm.. it looks like you have no internet connection, do you want to continue?")
if [[ $IQ == *"0"* ]]; then
echo -e "\e[3;5;0;31m$USER is going to the applist even $NAME have no internet connection apparently?\e[30;48;5;82m\e[0m"
fi
if [[ $IQ == *"1"* ]]; then
notify "Action was canceled."
exec $NAME
fi
fi
if [ -z "$CLI" ]
then
export APPNAME=$(zenity --list --title="$NAME $VER - $TODO" --window-icon=$ICO --text "What do you want to install?" --height=$ALH --width=$WTH --column="Application" $APPLIST)
fi
# Check if an application was selected.
if [[ -z "$APPNAME" ]]; then
notify "Nothing was selected for installation"
unset INST
exec $NAME
else
cd $DDIR
# Checks if $APPNAME was already installed, needs to be improved.
CIAI1=$(cd "$GDIR" && ls | grep "$APPNAME")
if [ -z "$CIAI1" ]
then
echo -e "\e[3;5;0;32mApplication was not installed as a Game before.\e[30;48;5;82m\e[0m"
else
QT=$(question "Hm.. it looks like $APPNAME is already installed, do you want to continue?")
if [[ $QT == *"0"* ]]; then
notify "Installation continues"
fi
if [[ $QT == *"1"* ]]; then
notify "Installation have been canceled"
exec $NAME
fi
fi
CIAI2=$(cd "$PDIR" && ls | grep "$APPNAME")
if [ -z "$CIAI2" ]
then
echo -e "\e[3;5;0;32mApplication was not installed as a Program before.\e[30;48;5;82m\e[0m"
else
QT=$(question "Hm.. it looks like $INST is already installed, do you want to continue?")
if [[ $QT == *"0"* ]]; then
notify "Installation continues"
fi
if [[ $QT == *"1"* ]]; then
notify "Installation have been canceled"
exec $NAME
fi
fi
QT=$(question "Do you really want to install $APPNAME?")
if [[ $QT == *"0"* ]]; then
notify "Starting Installation"
fi
if [[ $QT == *"1"* ]]; then
notify "Installation have been canceled"
exec $NAME
fi
if [ -f "$DDIR/WineVerLib/$APPNAME" ]; then
WINEVERLIBFILE=$(cat $DDIR/WineVerLib/$APPNAME)
echo -e "\e[3;5;0;34m$WINEVERLIBFILE will be used\e[30;48;5;82m\e[0m"
else
echo -e "\e[3;5;0;34mWine version have been not set for this application yet, taking recommended wine version.\e[30;48;5;82m\e[0m"
echo "$WINEBIN" > $DDIR/WineVerLib/$APPNAME
fi
WINEVERLIBFILE=$(cat $DDIR/WineVerLib/$APPNAME)
export WINEBIN="$WINEVERLIBFILE"
export WINE=$WINEBIN
bash /usr/local/share/Homura/Data/Framework
notify "Task completed!"
unset APPNAME
fi
fi
if [[ $TODO == *"Launcher"* ]]; then
# Check if something was installed
if [ -z "$(ls -A $GDIR && ls -A $PDIR && ls -A $CPDIR )" ]; then
notify "Nothing is installed"
exec $NAME
fi
# Application menu
if [ -z "$CLI" ]
then
export APPNAME=$(zenity --list --title="$NAME $VER - $TODO" --window-icon=$ICO --text "What do you want to launch?" --height=$ALH --width=$WTH --column="Application" $APPEXISTCHECK)
fi
# Check if an application was selected
if [[ -z "$APPNAME" ]]; then
notify "Nothing was selected to launch"
unset LNCH
exec $NAME
else
WINEVERLIBFILE=$(cat $DDIR/WineVerLib/$APPNAME)
if [ -f "$DDIR/WineVerLib/$APPNAME" ]; then
echo -e "\e[3;5;0;34m$WINEVERLIBFILE will be used\e[30;48;5;82m\e[0m"
else
echo -e "\e[3;5;0;34mWine version have been not set for this application yet, taking recommended wine version.\e[30;48;5;82m\e[0m"
echo "$WINEBIN" > $DDIR/WineVerLib/$APPNAME
fi
WINEVERLIBFILE=$(cat $DDIR/WineVerLib/$APPNAME)
export WINEBIN="$WINEVERLIBFILE"
bash /usr/local/share/Homura/Data/Framework
notify "Task completed!"
unset APPNAME
fi
fi
if [[ $TODO == *"Uninstallation"* ]]; then
# Check if something was installed
if [ -z "$(ls -A $GDIR && ls -A $PDIR && ls -A $CPDIR )" ]; then
notify "Nothing is installed"
exec $NAME
fi
# Application menu
if [ -z "$CLI" ]
then
export APPNAME=$(zenity --list --title="$NAME $VER - $TODO" --window-icon=$ICO --text "What do you want to uninstall?" --height=$ALH --width=$WTH --column="Application" $APPEXISTCHECK)
fi
# Check if an application was selected
if [[ -z "$APPNAME" ]]; then
notify "Nothing was selected for uninstallation"
unset UNST
exec $NAME
else
QT=$(question "Do you really want to uninstall $APPNAME?")
if [[ $QT == *"0"* ]]; then
notify "Starting Uninstallation"
fi
if [[ $QT == *"1"* ]]; then
notify "Uninstall have been canceled"
exec $NAME
fi
bash /usr/local/share/Homura/Data/Framework
notify "Task completed!"
unset APPNAME
fi
fi
if [[ $TODO == *"Winetricks"* ]]; then
cd $NDIR
PREFIX=$(zenity --file-selection --directory --title="Choose your prefix" --filename="/usr/home/$USER/.local/share/$NAME/")
if [ -z "$PREFIX" ]
then
info "No prefix was selected, action was aborted."
exec $NAME
else
echo -e "\e[3;5;0;32m$PREFIX have been selected.\e[30;48;5;82m\e[0m"
SAWVFWX=$(zenity --list --title="$NAME $VER - $MW" --window-icon=$ICO --text "What Wine verson do you like to use?" --height=300 --width=50 --column="Application" "Default (wine-proton)" "Using an other wine")
if [[ $SAWVFWX == *"Default (wine-proton)"* ]]; then
WINE=$WINEBIN
fi
if [[ $SAWVFWX == *"Using an other wine"* ]]; then
WINEBIN=$(zenity --file-selection --title="Choose your prefix" --filename="/usr/local")
fi
fi
WINEPREFIX=$PREFIX WINE="$WINEBIN" winetricks
fi
if [[ $TODO == *"Run a executable in a selected prefix"* ]]; then
cd $NDIR
PREFIX=$(zenity --file-selection --directory --title="Choose your prefix" --filename="/usr/home/$USER/.local/share/$NAME/")
if [ -z "$PREFIX" ]
then
info "No prefix was selected, action was aborted."
exec $NAME
else
echo -e "\e[3;5;0;32m$PREFIX have been selected.\e[30;48;5;82m\e[0m"
fi
EXECUTABLE="$(zenity --file-selection --title="Choose your executable")"
if [ -z "$EXECUTABLE" ]
then
info "No executable was selected, action was aborted."
exec $NAME
else
echo -e "\e[3;5;0;32m$EXECUTABLE have been selected.\e[30;48;5;82m\e[0m"
SAFWVESP=$(zenity --list --title="$NAME $VER - $MW" --window-icon=$ICO --text "What Wine verson do you like to use?" --height=300 --width=50 --column="Application" "Default (wine-proton)" "Using an other wine")
if [[ $SAFWVESP == *"Default (wine-proton)"* ]]; then
WINE=$WINEBIN
fi
if [[ $SAFWVESP == *"Using an other wine"* ]]; then
WINEBIN=$(zenity --file-selection --title="Choose your prefix" --filename="/usr/local")
fi
fi
WINEPREFIX=$PREFIX $WINEBIN "$EXECUTABLE"
fi
if [[ $TODO == *"Kill wine in a selected prefix"* ]]; then
cd $NDIR
PREFIX=$(zenity --file-selection --directory --title="Choose your prefix" --filename="/usr/home/$USER/.local/share/$NAME/")
if [ -z "$PREFIX" ]
then
info "No prefix was selected, action was aborted."
exec $NAME
else
echo -e "\e[3;5;0;32m$PREFIX have been selected.\e[30;48;5;82m\e[0m"
fi
WINEPREFIX=$PREFIX /usr/local/wine-proton/bin/wineserver -k
exit
fi
if [[ $TODO == *"Update"* ]]; then
if [ -z "$(ls -A $GDIR && ls -A $PDIR && ls -A $CPDIR )" ]; then
notify "Nothing is installed"
exec $NAME
fi
export APPNAME=$(zenity --list --title="$NAME $VER - $TODO" --window-icon=$ICO --text "What do you want to update?" --height=$ALH --width=$WTH --column="Application" $APPEXISTCHECK)
bash /usr/local/share/Homura/Data/Framework
fi
if [[ $TODO == *"Manage Wine"* ]]; then
MW=$(zenity --list --radiolist --window-icon=$ICO --height=250 --width 500 --title="$NAME $VER - $TODO" --text "What do you want to do?" --hide-header --column "$NAME" --column "Item" FALSE "Change Wine version for an application")
if [[ $MW == *"Change Wine version for an application"* ]]; then
SAFWVC=$(zenity --list --title="$NAME $VER - $MW" --window-icon=$ICO --text "For what application do you like to change the Wine version?" --height=$ALH --width=$WTH --column="Application" $APPLIST)
SAFWVCWV=$(zenity --list --title="$NAME $VER - $MW" --window-icon=$ICO --text "What Wine verson do you like to use?" --height=300 --width=50 --column="Application" "Default (wine-proton)" "Using an other wine")
if [[ $SAFWVCWV == *"Default (wine-proton)"* ]]; then
WINE=$WINEBIN
fi
if [[ $SAFWVCWV == *"Using an other wine"* ]]; then
WINEBIN=$(zenity --file-selection --title="Choose your prefix" --filename="/usr/local")
fi
echo "$WINEBIN" > "$DDIR/WineVerLib/$SAFWVC"
fi
fi
if [[ $TODO == *"Applying a fix"* ]]; then
bash $LDIR/fixes
fi
if [[ $TODO == *"Open Homura folder"* ]]; then
xdg-open $NDIR
fi
if [[ $TODO == *"Enable logging"* ]]; then
mkdir -p $NDIR/Logs
cd $NDIR/Logs
info "Logging for this session has been enabled, you will later find the log file in the log folder."
export LOG=1
bash $NAME >> "$LNCH-$DATE.log" 2>&1
notify "The logging have been quit."
fi
if [[ $TODO == *"Other"* ]]; then
OTR=$(zenity --list --radiolist --window-icon=$ICO --height=250 --width 250 --title="$NAME $VER - $TODO" --text "What do you want to do?" --hide-header --column "$NAME" --column "Item" FALSE "Use Software Rendering" False "Use mesa_glthread" False "Use Gallium HUD" FALSE "Delete & reset everything" FALSE "Codeberg page" FALSE "Update library")
if [[ $OTR == *"Use Software Rendering"* ]]; then
notify "Software Rendering have been enabled, this will stay until this session of $NAME have been closed."
LIBGL_ALWAYS_SOFTWARE=1 $NAME
notify "Software Rendering have been disabled."
fi
if [[ $OTR == *"Use Gallium HUD"* ]]; then
notify "Gallium HUD have been enabled, this will stay until this session of $NAME have been closed."
GALLIUM_HUD="fps,GPU-load" $NAME
notify "Gallium HUD have been disabled."
fi
if [[ $OTR == *"Use mesa_glthread"* ]]; then
notify "mesa_glthread have been enabled, this will stay until this session of $NAME have been closed."
mesa_glthread=true $NAME
notify "mesa_glthread have been disabled."
fi
if [[ $OTR == *"Delete & reset everything"* ]]; then
DRQ=$(zenity --question --window-icon=$ICO --width 300 --title "$NAME $VER - $OTR" --text "Do you really want to delete and reset everything?"; echo $?)
if [[ $DRQ == *"0"* ]]; then
rm -r -d $NDIR
if [ -f "/usr/home/$USER/.local/share/applications/$NAME.desktop" ]; then
rm "/usr/home/$USER/.local/share/applications/$NAME.desktop"
else
echo -e "\e[40;38;5;32mNo shortcut was created\e[30;48;5;82m\e[0m"
fi
zenity --info --window-icon=$ICO --width=200 --title="$NAME $VER - $OTR" --text="All files of $NAME have been deleted, we hope you had a good time."
exit
fi
fi
fi
if [[ $OTR == *"Codeberg page"* ]]; then
xdg-open https://codeberg.org/Alexander88207/$NAME
fi
if [[ $OTR == *"Update library"* ]]; then
rm -r -d $LDIR
fi
if [[ $TODO == *"About"* ]]; then
info "Inspired by Lutris.
$NAME is a launcher that makes it easy to run Windows games/launcher easily on FreeBSD by providing the required fixes and workarounds.
The Windows emulation is provided by Wine.
$NAME is licensed under the BSD 2-Clause License.
Copyright (c) $COPYRIGHT
All rights reserved."
fi
if [[ $TODO == *"Exit"* ]]; then
notify "Thanks $USER for using $NAME!"
exit
fi
if [ -z "$CLI" ]
then
exec $NAME
fi
notify "Task completed!"