forked from CastroFidel/PortWINE
		
	
		
			
				
	
	
		
			1014 lines
		
	
	
		
			45 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1014 lines
		
	
	
		
			45 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| # Author: Castro-Fidel (PortWINE-Linux.ru)
 | |
| ########################################################################
 | |
| pw_ping_test () {
 | |
|     ping -w3 -c1 github.com &> /dev/null
 | |
|     [ "$?" == "0" ] && return 0 || return 1
 | |
| }
 | |
| 
 | |
| print_error () {
 | |
|     echo "ERROR: $@"
 | |
| }
 | |
| export -f print_error
 | |
| 
 | |
| zenity_error () {
 | |
|     echo "ERROR: $@"
 | |
|     zenity --error --no-wrap --text "$@" 2> /dev/null
 | |
| }
 | |
| export -f zenity_error
 | |
| 
 | |
| print_info () {
 | |
|     echo "INFO: $@"
 | |
| }
 | |
| export -f print_info
 | |
| 
 | |
| zenity_info () {
 | |
|     echo "INFO: $@"
 | |
|     zenity --info --no-wrap --text "$@" 2> /dev/null
 | |
| }
 | |
| export -f zenity_info
 | |
| 
 | |
| print_var () {
 | |
|     for vp in $@ ; do echo "${vp}=${!vp}" ; done
 | |
| }
 | |
| export -f print_var
 | |
| 
 | |
| try_copy_file () {
 | |
|     if [ ! -f "$1" ] ; then	print_info "file $1 not found for copy" && return 1
 | |
|     elif [ -z "$2" ] ; then	print_error "no way to copy file $1" && return 1
 | |
|     else
 | |
|         cp -f "$1" "$2"
 | |
|         if [ "$?" != 0 ]
 | |
|         then print_error "failed to copy file $1 to $2" || return 1
 | |
|         else return 0
 | |
|         fi
 | |
|     fi
 | |
| }
 | |
| export -f try_copy_file
 | |
| 
 | |
| try_copy_dir () {
 | |
|     if [ ! -d "$1" ] ; then	print_info "directory $1 not found for copy"
 | |
|     elif [ -z "$2" ] ; then	print_error "no way to copy directory $1"
 | |
|     else
 | |
|         cp -fr "$1" "$2"
 | |
|         [ "$?" != 0 ] && print_error "failed to copy directory $1 to $2" || return 0
 | |
|     fi
 | |
|     return 1
 | |
| }
 | |
| export -f try_copy_dir
 | |
| 
 | |
| try_remove_file () {
 | |
|     if [ -f "$1" ] ; then
 | |
|         rm -f "$1"
 | |
|         [ "$?" != 0 ] && print_error "failed to remove file $1" || return 0
 | |
|     fi
 | |
|     return 1
 | |
| }
 | |
| export -f try_remove_file
 | |
| 
 | |
| try_remove_dir () {
 | |
|     if [ -d "$1" ] ; then
 | |
|         rm -fr "$1"
 | |
|         [ "$?" != 0 ] && print_error "failed to remove directory $1" || return 0
 | |
|     fi
 | |
|     return 1
 | |
| }
 | |
| export -f try_remove_dir
 | |
| 
 | |
| try_force_link_file () {
 | |
|     if [ -z "$2" ] ; then
 | |
|         print_error "no way to link file $1"
 | |
|     else
 | |
|         ln -sf "$1" "$2"
 | |
|         [ "$?" != 0 ] && print_error "failed to link file $1 to $2" || return 0
 | |
|     fi
 | |
|     return 1
 | |
| }
 | |
| export -f try_force_link_file
 | |
| 
 | |
| check_symlink () {
 | |
|     CHK_SYMLINK_FILE=`file "$1"`
 | |
|     if [ ! -z `echo "$CHK_SYMLINK_FILE" | grep -v "broken" | grep "symbolic link to" | awk '{print $1}'` ] ; then
 | |
|         return 0
 | |
|     elif [ ! -z `echo "$CHK_SYMLINK_FILE" | grep "broken symbolic link to" | awk '{print $1}'` ] ; then
 | |
|         print_error "remove broken symlink: $CHK_SYMLINK_FILE"
 | |
|         rm -fr "$CHK_SYMLINK_FILE"
 | |
|         return 1
 | |
|     else
 | |
|         return 1
 | |
|     fi
 | |
| }
 | |
| export -f check_symlink
 | |
| 
 | |
| try_force_link_dir () {
 | |
|     if [ ! -d "$1" ] ; then	print_info "directory $1 not found for link"
 | |
|     elif [ -z "$2" ] ; then	print_error "no way to link directory $1"
 | |
|     else
 | |
|         ln -sf "$1" "$2"
 | |
|         [ "$?" != 0 ] && print_error "failed to link directory $1 to $2" || return 0
 | |
|     fi
 | |
|     return 1
 | |
| }
 | |
| export -f try_force_link_dir
 | |
| 
 | |
| check_process () {
 | |
|     [ ! -n "`ps cax | grep "$1" | awk '{print $1}'`" ] && return 0 || return 1 
 | |
| }
 | |
| export -f check_process
 | |
| 
 | |
| try_download () {
 | |
|     set -o pipefail
 | |
|     wget -O "$2" --read-timeout 300 --retry-connrefused --timeout 15 --tries 3 \
 | |
|     --user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1" 2>&1 | \
 | |
|     tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
 | |
|     zenity --progress --percentage=0 --title="Download $(basename $1)" --text=Starting... --auto-close --width=500 --height=90
 | |
|     if [ "${PIPESTATUS[0]}" != 0 ] ; then
 | |
|         print_error "failed to download $1. Skipping."
 | |
|         try_remove_file "$2"
 | |
|         return 1 
 | |
|     else
 | |
|         return 0
 | |
|     fi
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/download_log"
 | |
| }
 | |
| 
 | |
| try_download_to_path () {
 | |
|     set -o pipefail
 | |
|     wget --directory-prefix="$2" --read-timeout 300 --retry-connrefused --timeout 15 --tries 3 \
 | |
|     --user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1" 2>&1 | \
 | |
|     tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
 | |
|     zenity --progress --percentage=0 --title="Download $(basename $1)" --text=Starting... --auto-close --width=500 --height=90
 | |
|     if [ "${PIPESTATUS[0]}" != 0 ] ; then
 | |
|         print_error "failed to download $1. Skipping."
 | |
|         return 1 
 | |
|     else 
 | |
|         return 0
 | |
|     fi
 | |
| }
 | |
| 
 | |
| try_download_silent () {
 | |
|     wget -O "$2" --read-timeout 300 --retry-connrefused --timeout 15 --tries 3 \
 | |
|     --user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1"
 | |
|     if [ "${PIPESTATUS[0]}" != 0 ] ; then
 | |
|         print_error "failed to download $1. Skipping."
 | |
|         try_remove_file "$2"
 | |
|         return 1 
 | |
|     else 
 | |
|         return 0
 | |
|     fi
 | |
| }
 | |
| 
 | |
| zenity_error_download () {
 | |
|     `zenity --error --title "Error..." --text "You will need to check internet connection,\nand press OK for repeat download" --no-wrap `
 | |
|     if [[ "$?" != 0 ]] ; then
 | |
|         stop_portwine
 | |
|     else
 | |
|         return 0
 | |
|     fi
 | |
| }
 | |
| 
 | |
| create_new_dir () {
 | |
|     if [ ! -d "$1" ] ; then
 | |
|         mkdir -p "$1"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| var_winedlloverride_update () {
 | |
|     if [ ! -z "${WINEDLLOVERRIDES}" ]
 | |
|     then export WINEDLLOVERRIDES="${1};${WINEDLLOVERRIDES}"
 | |
|     else export WINEDLLOVERRIDES="${1}"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| var_vkd3d_config_update () {
 | |
|     if [ ! -z "${VKD3D_CONFIG}" ]
 | |
|     then export VKD3D_CONFIG="${1};${VKD3D_CONFIG}"
 | |
|     else export VKD3D_CONFIG="${1}"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| unpack_tar_xz () {
 | |
|     set -o pipefail
 | |
|     tar -Jxvf "$1" -C "$2" | sszen
 | |
|     [ "${PIPESTATUS[0]}" != 0 ] && print_error "File unpacking error." && return 1 || return 0
 | |
| }
 | |
| 
 | |
| unpack_tar_gz () {
 | |
|     set -o pipefail
 | |
|     tar -xzvf "$1" -C "$2" | sszen
 | |
|     [ "${PIPESTATUS[0]}" != 0 ] && print_error "File unpacking error." && return 1 || return 0
 | |
| }
 | |
| 
 | |
| unpack_tar () {
 | |
|     set -o pipefail
 | |
|     tar -xvf "$1" -C "$2" | sszen
 | |
|     [ "${PIPESTATUS[0]}" != 0 ] && print_error "File unpacking error." && return 1 || return 0
 | |
| }
 | |
| 
 | |
| pw_mangohud_check () {
 | |
|     export RUN_MANGOHUD=""
 | |
|     if [ "${PW_MANGOHUD}" == "1" ] ; then
 | |
|         if [ "${PW_VULKAN_USE}" = "0" ] ; then 
 | |
|             export RUN_MANGOHUD="${PW_WINELIB}/portable/bin/mangohud --dlsym"
 | |
|         else 
 | |
|             export RUN_MANGOHUD="${PW_WINELIB}/portable/bin/mangohud"
 | |
|         fi
 | |
|     else
 | |
|         export DISABLE_MANGOHUD=1
 | |
|     fi
 | |
| }
 | |
| export -f pw_mangohud_check
 | |
| 
 | |
| pw_vkbasalt_check () {
 | |
|     if [[ ! -z "${ENABLE_VKBASALT}" && "${ENABLE_VKBASALT}" == 1 ]] ; then
 | |
|         if [ -z "${PW_VKBASALT_EFFECTS}" ] ; then
 | |
|             export PW_VKBASALT_EFFECTS="cas:FilmGrain2" 
 | |
|         fi
 | |
|         sed -ri "s/effects = .*/effects = ${PW_VKBASALT_EFFECTS}/g" "${PORT_WINE_PATH}/data/vkBasalt.conf"
 | |
|         if [ -z "${PW_VKBASALT_FFX_CAS}" ] ; then
 | |
|             export PW_VKBASALT_FFX_CAS="0.7" 
 | |
|         fi
 | |
|         sed -ri "s/casSharpness .*/casSharpness = ${PW_VKBASALT_FFX_CAS}/g" "${PORT_WINE_PATH}/data/vkBasalt.conf"
 | |
|         export VKBASALT_CONFIG_FILE="${PORT_WINE_PATH}/data/vkBasalt.conf"
 | |
|         sed -i s/'> = 0.05;'/'> = 0.035;'/ "${PW_WINELIB}/pressure-vessel/reshade/shaders/FilmGrain2.fx"
 | |
|         sed -i s/'> = 0.65;'/'> = 0.4;'/ "${PW_WINELIB}/pressure-vessel/reshade/shaders/Curves.fx"
 | |
|         sed -i s/'> = 0.8;'/'> = 0.9;'/ "${PW_WINELIB}/pressure-vessel/reshade/shaders/Bloom.fx"
 | |
|         if [ ! -z "${VK_INSTANCE_LAYERS}" ]
 | |
|         then export VK_INSTANCE_LAYERS="VK_LAYER_VKBASALT_post_processing:${VK_INSTANCE_LAYERS}"
 | |
|         else export VK_INSTANCE_LAYERS="VK_LAYER_VKBASALT_post_processing"
 | |
|         fi
 | |
|     else
 | |
|         export DISABLE_VKBASALT=1
 | |
|     fi
 | |
| 
 | |
| }
 | |
| 
 | |
| gui_question () {
 | |
|     `zenity --question --title "${inst_set}." --text "$1" --no-wrap ` &> /dev/null
 | |
|      [ $? -eq "0" ] && return 0 || return 1
 | |
| }
 | |
| 
 | |
| pw_clear_pfx () {
 | |
|     try_remove_file "${WINEPREFIX}/system.reg"
 | |
|     try_remove_file "${WINEPREFIX}/user.reg"
 | |
|     try_remove_file "${WINEPREFIX}/userdef.reg"
 | |
|     try_remove_file "${WINEPREFIX}/winetricks.log"
 | |
|     try_remove_file "${WINEPREFIX}/.update-timestamp"
 | |
|     try_remove_file "${WINEPREFIX}/drive_c/.windows-serial"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/windows/"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/ProgramData/Setup"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/ProgramData/Windows"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/ProgramData/WindowsTask"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/ProgramData/Package Cache"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Local Settings/Application Data/Microsoft"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Local Settings/Application Data/Temp"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Local Settings/Temporary Internet Files"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Application Data/Microsoft"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Application Data/wine_gecko"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/Public/Temp"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Local Settings/Application Data/Microsoft"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Local Settings/Application Data/Temp"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Local Settings/Temporary Internet Files"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Application Data/Microsoft"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Application Data/wine_gecko"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/users/steamuser/Temp"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files/Internet Explorer"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files/Windows Media Player"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files/Windows NT"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files/Common Files"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files (x86)/Internet Explorer"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files (x86)/Common Files"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files (x86)/Windows Media Player"
 | |
|     try_remove_dir "${WINEPREFIX}/drive_c/Program Files (x86)/Windows NT"
 | |
|     try_remove_dir "${PORT_WINE_TMP_PATH}/mesa_shader_cache"
 | |
|     rm -f "${PORT_WINE_TMP_PATH}"/*.bin
 | |
|     rm -f "${PORT_WINE_TMP_PATH}"/*.foz
 | |
| }
 | |
| 
 | |
| check_user_conf () {
 | |
|     if [ ! -f "${USER_CONF}" ]; then
 | |
|         echo "#!/bin/bash" > "${USER_CONF}"
 | |
|         echo "# User overides db and var settings..." >> "${USER_CONF}"
 | |
|         chmod u+x "${USER_CONF}"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| init_wine_ver () {
 | |
|     if [[ -z `ls "${PORT_WINE_PATH}/data/dist/" | grep "${PW_WINE_USE}"` ]] ; then
 | |
|         if [[ ! -z `echo "${PW_WINE_USE}" | grep "PROTON_STEAM"` ]] ; then
 | |
|             export PW_WINE_USE=PROTON_STEAM
 | |
|         else
 | |
|             export PW_WINE_USE=PROTON_GE
 | |
|         fi
 | |
|     fi
 | |
|     if [[ ! -z `echo "${PW_WINE_USE}" | grep "^PROTON_STEAM$"` ]] 
 | |
|     then export PW_WINE_USE="${PW_PROTON_STEAM_VER}"
 | |
|     elif [[ ! -z `echo "${PW_WINE_USE}" | grep "^PROTON_GE$"` ]]
 | |
|     then export PW_WINE_USE="${PW_PROTON_GE_VER}"
 | |
|     fi
 | |
|     [ ! -z "${PW_WINE_VER}" ] && export PW_WINE_USE=`echo "${PW_WINE_VER}" | tr [[:lower:]] [[:upper:]]`
 | |
|     [ ! -z "${PW_WINE_USE}" ] && export PW_WINE_USE=`echo "${PW_WINE_USE}" | tr [[:lower:]] [[:upper:]]`
 | |
|     unset PW_WINE_VER
 | |
|     export WINEDIR="${PORT_WINE_PATH}/data/dist/${PW_WINE_USE}"
 | |
|     export WINE="${WINEDIR}/bin/wine"
 | |
|     export WINELOADER="${WINEDIR}/bin/wine"
 | |
|     export WINESERVER="${WINEDIR}/bin/wineserver"
 | |
|     export WINEDLLPATH="${WINEDIR}/lib64/wine:${WINEDIR}/lib/wine"
 | |
| 
 | |
|     if [[ -d "${WINEDIR}/files" && ! -d "${WINEDIR}/dist" ]] ; then
 | |
|         chmod -R 755 "${WINEDIR}"
 | |
|         for clear_dist_files in `ls "${WINEDIR}" | sed -e "s/^files$//g" | sed -e "s/^version$//g"` ; do 
 | |
|             rm -fr "${WINEDIR}/$clear_dist_files"
 | |
|         done
 | |
|         mv -f "${WINEDIR}/files"/* "${WINEDIR}/"
 | |
|         rm -fr "${WINEDIR}/files"
 | |
|     elif [[ ! -d "${WINEDIR}/files" && -d "${WINEDIR}/dist" ]] ; then
 | |
|             chmod -R 755 "${WINEDIR}"
 | |
|         for clear_dist_files in `ls "${WINEDIR}" | sed -e "s/^dist$//g" | sed -e "s/^version$//g"` ; do 
 | |
|             rm -fr "${WINEDIR}/$clear_dist_files"
 | |
|         done
 | |
|         mv -f "${WINEDIR}/dist"/* "${WINEDIR}/"
 | |
|         rm -fr "${WINEDIR}/dist"
 | |
|     elif [ -f "${WINEDIR}/proton_dist.tar" ] ; then
 | |
|         unpack_tar "${WINEDIR}/proton_dist.tar" "${WINEDIR}/"
 | |
|         for clear_dist_files in `ls "${WINEDIR}" | sed -e "s/^bin$//g" | sed -e "s/^lib$//g" | sed -e "s/^lib64$//g" | sed -e "s/^share$//g" | sed -e "s/^version$//g"` ; do 
 | |
|             rm -fr "${WINEDIR}/$clear_dist_files"
 | |
|         done
 | |
|     fi
 | |
|     if [[ -d "${WINEDIR}" ]] ; then
 | |
|         [[ ! -f "${WINEDIR}/version" ]] && echo "${PW_WINE_USE}" > "${WINEDIR}/version"
 | |
| 
 | |
|         if [[ ! -d "${WINEDIR}/lib64/" && -d "${WINEDIR}/lib/wine/x86_64-unix" ]] ; then
 | |
|             create_new_dir "${WINEDIR}/lib64/wine"
 | |
|             mv -f "${WINEDIR}/lib/wine/x86_64-unix" "${WINEDIR}/lib64/wine/"
 | |
|             mv -f "${WINEDIR}/lib/wine/x86_64-windows" "${WINEDIR}/lib64/wine/"
 | |
|         fi
 | |
| 
 | |
|         for copy_proton_dll in "dxvk" "vkd3d-proton" ; do
 | |
|             if [[ ! -d "${WINEDIR}/lib/wine/${copy_proton_dll}/" || ! -d "${WINEDIR}/lib64/wine/${copy_proton_dll}/" ]] ; then
 | |
|                 try_copy_dir "${PORT_WINE_PATH}/data/dist/${PW_PROTON_GE_VER}/lib/wine/${copy_proton_dll}" "${WINEDIR}/lib/wine/"
 | |
|                 try_copy_dir "${PORT_WINE_PATH}/data/dist/${PW_PROTON_GE_VER}/lib64/wine/${copy_proton_dll}" "${WINEDIR}/lib64/wine/"
 | |
|             fi
 | |
|         done
 | |
|         
 | |
|         for mono_gecko_chk in "mono" "gecko" ; do
 | |
|             if [ ! -d "${WINEDIR}/share/wine/${mono_gecko_chk}" ] ; then
 | |
|                 try_remove_dir "${WINEDIR}/share/wine/${mono_gecko_chk}"
 | |
|                 try_force_link_dir "${PORT_WINE_TMP_PATH}/${mono_gecko_chk}" "${WINEDIR}"/share/wine/
 | |
|             elif ! check_symlink "${WINEDIR}/share/wine/${mono_gecko_chk}" && [[ -d "${WINEDIR}/share/wine/${mono_gecko_chk}" ]]  ; then  
 | |
|                 cp -fr "${WINEDIR}/share/wine/${mono_gecko_chk}" "${PORT_WINE_TMP_PATH}"
 | |
|                 rm -fr "${WINEDIR}/share/wine/${mono_gecko_chk}"
 | |
|                 try_force_link_dir "${PORT_WINE_TMP_PATH}/${mono_gecko_chk}" "${WINEDIR}"/share/wine/
 | |
|             fi
 | |
|         done
 | |
|     fi
 | |
| }
 | |
| 
 | |
| sszen() {
 | |
|     zenity --progress --title="Settings..." --text="Updating parameters" --pulsate --auto-close --width=500 --height=90 --no-cancel
 | |
| }
 | |
| 
 | |
| pw_start_progress_bar_cover () {
 | |
|     PW_GIF_FILE="$1"
 | |
|     PW_GIF_SIZE_X=`file "${PW_GIF_FILE}" | awk '{print $7 + 20}'`
 | |
|     PW_GIF_SIZE_Y=`file "${PW_GIF_FILE}" | awk '{print $9 + 20}'`
 | |
|     "${pw_yad}" --picture --filename="${PW_GIF_FILE}" --close-on-unfocus --no-buttons --undecorated --center \
 | |
|     --skip-taskbar --width=$PW_GIF_SIZE_X --height=$PW_GIF_SIZE_Y > /dev/null 2>&1 &
 | |
|     export PW_YAD_PID_PROGRESS_BAR_COVER="$!"
 | |
| }
 | |
| 
 | |
| pw_update_pfx_cover_gui () {
 | |
|         PW_KEY_PROGRESS_BAR=$RANDOM
 | |
|         PW_GIF_FILE="${PW_GUI_ICON_PATH}/covers/pw_update_pfx_cover.gif"
 | |
|         PW_GIF_SIZE_X=`file "${PW_GIF_FILE}" | awk '{print $7 + 40}'`
 | |
|         PW_GIF_SIZE_Y=`file "${PW_GIF_FILE}" | awk '{print $9 + 80}'`
 | |
|         echo "UPDATE PREFIX..." > "${PORT_WINE_TMP_PATH}/update_pfx_log"
 | |
|         while [[ -f "${PORT_WINE_TMP_PATH}/update_pfx_log" ]] ; do
 | |
|             sleep 1
 | |
|             while read -r gui_line  ; do
 | |
|                 echo "# ${gui_line}"
 | |
|             done
 | |
|         done < "${PORT_WINE_TMP_PATH}/update_pfx_log" | "${pw_yad_new}" --plug=$PW_KEY_PROGRESS_BAR  --tabnum="2" --text-info --tail &
 | |
|         "${pw_yad_new}" --plug=$PW_KEY_PROGRESS_BAR --tabnum="1" --picture --filename="${PW_GIF_FILE}" --image-on-top &
 | |
| 
 | |
|         "${pw_yad_new}" --notebook --key="$PW_KEY_PROGRESS_BAR" --tab=LOGO --tab=TERMINAL --no-buttons --undecorated \
 | |
|         --center --auto-close --skip-taskbar --width=$PW_GIF_SIZE_X --height=$PW_GIF_SIZE_Y --tab-pos=bottom &
 | |
|         export PW_YAD_PID_PFX_COVER_UI="$!"
 | |
| }
 | |
| 
 | |
| pw_start_progress_bar_cs () {
 | |
|     "${pw_yad}" --progress --progress-text="$@" --pulsate --close-on-unfocus \
 | |
|     --no-buttons --undecorated --center --skip-taskbar --width=500 --wrap-width=500 > /dev/null 2>&1 &
 | |
|     export PW_YAD_PID_PROGRESS_BAR_CS="$!"
 | |
| }
 | |
| 
 | |
| pw_start_progress_bar_block () {
 | |
|     "${pw_yad}" --progress --progress-text="$@" --pulsate \
 | |
|     --no-buttons --undecorated --center --skip-taskbar --width=500 --wrap-width=500 > /dev/null 2>&1 &
 | |
|     export PW_YAD_PID_PROGRESS_BAR_BLOCK="$!"
 | |
| }
 | |
| 
 | |
| pw_stop_progress_bar () {
 | |
|     kill -s SIGUSR1 "$PW_YAD_PID_PROGRESS_BAR_BLOCK" "$PW_YAD_PID_PROGRESS_BAR_CS" "$PW_YAD_PID_PFX_COVER_UI" \
 | |
|     "$PW_YAD_PID_PROGRESS_BAR_COVER" > /dev/null 2>&1
 | |
|     return 0
 | |
| }
 | |
| export -f pw_stop_progress_bar
 | |
| 
 | |
| wait_wineserver () {
 | |
|     while [ ! -z "$(ls -l /proc/*/exe 2>/dev/null | grep -ie ${portname} | grep -E 'wine(64)?-preloader|wineserver' | awk -F/ '{print $3}')" ] ; do
 | |
|         sleep 1
 | |
|     done
 | |
| }
 | |
| export -f wait_wineserver
 | |
| 
 | |
| kill_portwine () {
 | |
|     wine_pids="`ls -l /proc/*/exe 2>/dev/null | grep -ie ${portname} | grep -E 'wine(64)?-preloader|wineserver' | awk -F/ '{print $3}'`"
 | |
|     if  [ ! -z "${wine_pids}" ] ; then
 | |
|         for pw_kill_pids in ${wine_pids} ; do
 | |
|             if [ "`ps cax | grep ${pw_kill_pids}`" ] ; then
 | |
|                 kill -n 9 ${pw_kill_pids} > /dev/null 2>&1  
 | |
|             fi
 | |
|         done
 | |
|     fi
 | |
|     bwrap_pids="`pgrep -a wrap | grep ${portname} | head -n 1 | awk '{print $1}'`"
 | |
|     if  [ ! -z "${bwrap_pids}" ] ; then
 | |
|         for pw_kill_pids in ${bwrap_pids} ; do
 | |
|             if [ "`ps cax | grep ${pw_kill_pids}`" ] ; then
 | |
|                 kill -n 9 ${pw_kill_pids} > /dev/null 2>&1
 | |
|             fi
 | |
|         done
 | |
|     fi
 | |
| }
 | |
| export -f kill_portwine
 | |
| 
 | |
| pw_kill_autostart () {
 | |
|     if [ "$PW_USE_RUNTIME" != 1 ]
 | |
|     then print_info "PW_USE_RUNTIME=$PW_USE_RUNTIME"
 | |
|     else
 | |
|         sleep 5
 | |
|         while true ; do
 | |
|             if  [[ -z "`ps aux | grep -m 1 "$1" | grep -v grep | awk '{print $2}'`" ]] && [[ ! -z "`ps aux | grep wrap | grep -v grep | grep -i ${portname} | head -n 1`" ]] ; then
 | |
|                 echo -e "PID "$1" not found"
 | |
|                 sleep 5
 | |
|             else
 | |
|                 sleep 5
 | |
|                 kill_portwine 
 | |
|                 break
 | |
|             fi
 | |
|         done
 | |
|     fi
 | |
|     if [[ ! -z "`ls "${WINEPREFIX}"/drive_c/ | grep -m 1 ".tmp"`" ]] ; then
 | |
|         rm -f "${WINEPREFIX}"/drive_c/*.tmp
 | |
|     fi
 | |
| }
 | |
| export -f pw_kill_autostart
 | |
| 
 | |
| stop_portwine () { 
 | |
|     if [ "$int_xneur" = "1"  ]; then
 | |
|         xneur &
 | |
|     fi
 | |
|     if [ ! -z ${PW_XKBD} ]; then
 | |
|         setxkbmap ${PW_XKBD}
 | |
|     fi
 | |
|     pw_stop_progress_bar
 | |
|     try_remove_file "${PORT_SCRIPTS_PATH}/0"
 | |
|     try_remove_file "${PORT_SCRIPTS_PATH}/1"
 | |
|     kill_portwine &&
 | |
|     if [  ! -z "`ls "${WINEPREFIX}"/drive_c/users/steamuser/Temp/ | head -n 1`" ] ; then
 | |
|         chmod -R 755 "${WINEPREFIX}"/drive_c/users/steamuser/Temp/
 | |
|         rm -fr "${WINEPREFIX}"/drive_c/users/steamuser/Temp/*
 | |
|     fi
 | |
|     try_remove_dir "${PW_WINELIB}/var"
 | |
|     find "${WINEPREFIX}/drive_c/" -maxdepth 1 -type f -name "*.tmp" -delete
 | |
|     if [ ! -z "`pgrep -a yad_new | grep "\-\-notification" | awk '{print $1}'`" ] ; then
 | |
|         kill -s SIGUSR1 "`pgrep -a yad_new | grep "\-\-notification" | awk '{print $1}'`"
 | |
|     fi
 | |
|     add_in_stop_portwine > /dev/null 2>&1
 | |
|     kill -n 9 `pgrep -a start.sh | grep -i '/PortProton/' | awk '{print $1}'` > /dev/null 2>&1
 | |
|     exit 0
 | |
| }
 | |
| export -f stop_portwine
 | |
| 
 | |
| pw_download_libs () {
 | |
|     if [ ! -z "`ls ${PORT_WINE_TMP_PATH} | grep libs_v | grep -v libs${PW_LIBS_VER}`" ] ; then
 | |
|         for RM_LIBS in `ls ${PORT_WINE_TMP_PATH} | grep libs_v | grep -v libs${PW_LIBS_VER}`
 | |
|         do try_remove_dir "${PORT_WINE_TMP_PATH}/${RM_LIBS}"
 | |
|         done
 | |
|     fi
 | |
|     if [[ ! -e "${PW_WINELIB}/portable/bin/yad" || ! -e "${PW_WINELIB}/portable/lib/p7zip/7z" \
 | |
|     || ! -e "${PW_WINELIB}/runtime/files/bin/vkcube" || -e "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz" ]] ;
 | |
|     then
 | |
|         print_info "Download and install libraries..."
 | |
|         if try_download "https://github.com/Castro-Fidel/PortWINE/releases/download/libs${PW_LIBS_VER}/libs${PW_LIBS_VER}.tar.xz" "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz" ; then
 | |
|             if unpack_tar_xz "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz" "${PORT_WINE_TMP_PATH}/" ; then
 | |
|                 try_remove_file "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz"
 | |
|             else
 | |
|                 try_remove_dir "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}"
 | |
|                 try_remove_file "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}.tar.xz"
 | |
|                 zenity_error_download && pw_download_libs
 | |
|             fi
 | |
|         else
 | |
|             zenity_error_download && pw_download_libs
 | |
|         fi
 | |
|     fi
 | |
|     export pw_yad="${PW_WINELIB}/portable/bin/yad"
 | |
|     export pw_yad_new="${PW_WINELIB}/portable/bin/yad_new"
 | |
|     export pw_zstd="${PW_WINELIB}/portable/bin/zstd"
 | |
|     export pw_7z="${PW_WINELIB}/portable/lib/p7zip/7z"
 | |
|     if [ -x "`which xterm 2>/dev/null`" ]; then
 | |
|         export SYS_XTERM=`which xterm`
 | |
|         export PW_XTERM="${SYS_XTERM} -geometry 159x37 -e"
 | |
|     else
 | |
|         export PW_XTERM="${PW_WINELIB}/runtime/files/bin/xterm -geometry 159x37 -e"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| pw_check_and_download_wine () {
 | |
|     [ ! -d "${PORT_WINE_PATH}/data/dist/" ] && create_new_dir "${PORT_WINE_PATH}/data/dist"
 | |
|     if [[ "${PW_WINE_USE}" == "GET-OTHER-WINE" ]] ; then
 | |
|         gui_proton_downloader
 | |
|     fi
 | |
|     if [[ ! -z `echo "${PW_WINE_USE}" | grep "^PROTON_STEAM$"` ]] 
 | |
|     then export PW_WINE_USE="${PW_PROTON_STEAM_VER}"
 | |
|     elif [[ ! -z `echo "${PW_WINE_USE}" | grep "^PROTON_GE$"` ]]
 | |
|     then export PW_WINE_USE="${PW_PROTON_GE_VER}"
 | |
|     fi
 | |
|     if [ ! -d "${PORT_WINE_PATH}/data/dist/${PW_WINE_USE}" ] ; then
 | |
|         print_info "Download and install ${PW_WINE_USE}..."
 | |
|         if try_download "https://github.com/Castro-Fidel/wine_builds/releases/download/${PW_WINE_USE}/${PW_WINE_USE}.tar.xz" "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}.tar.xz" ; then
 | |
|             if unpack_tar_xz "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}.tar.xz" "${PORT_WINE_PATH}/data/dist/" ; then
 | |
|                 echo "${PW_WINE_USE}" > "${PORT_WINE_PATH}/data/dist/${PW_WINE_USE}/version"
 | |
|                 try_remove_file "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}.tar.xz"
 | |
|                 try_remove_dir "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}"
 | |
|             else
 | |
|                 try_remove_file "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}.tar.xz"
 | |
|                 try_remove_dir "${PORT_WINE_PATH}/data/tmp/${PW_WINE_USE}"
 | |
|                 try_remove_dir "${PORT_WINE_PATH}/data/dist/${PW_WINE_USE}"
 | |
| 
 | |
|                 zenity_error_download && pw_check_and_download_wine
 | |
|             fi
 | |
|         else
 | |
|             zenity_error_download && pw_check_and_download_wine
 | |
|         fi
 | |
|     fi
 | |
| }
 | |
| 
 | |
| pw_check_and_download_plugins () {
 | |
|     if [ ! -z "`ls ${PORT_WINE_TMP_PATH} | grep plugins_v | grep -v plugins${PW_PLUGINS_VER}`" ] ; then
 | |
|         for RM_PLUGINS in `ls ${PORT_WINE_TMP_PATH} | grep plugins_v | grep -v plugins${PW_PLUGINS_VER}`
 | |
|         do try_remove_dir "${PORT_WINE_TMP_PATH}/${RM_PLUGINS}"
 | |
|         done
 | |
|     fi
 | |
|     if [[ ! -d "${PW_PLUGINS_PATH}/BattlEye_Runtime" || ! -d "${PW_PLUGINS_PATH}/d3d_extras" \
 | |
|     || ! -d "${PW_PLUGINS_PATH}/nvapi" || ! -d "${PW_PLUGINS_PATH}/nvml" ]]
 | |
|     then
 | |
|         print_info "Download and install plugins${PW_PLUGINS_VER}..."
 | |
|         if try_download "https://github.com/Castro-Fidel/wine_builds/releases/download/plugins${PW_PLUGINS_VER}/plugins${PW_PLUGINS_VER}.tar.xz" "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz" ; then
 | |
|             if unpack_tar_xz "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz" "${PORT_WINE_TMP_PATH}" ; then
 | |
|                 try_remove_file "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz" 
 | |
|             else
 | |
|                 try_remove_file "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}.tar.xz"
 | |
|                 try_remove_dir "${PORT_WINE_TMP_PATH}/plugins${PW_PLUGINS_VER}"
 | |
| 
 | |
|                 zenity_error_download && pw_check_and_download_wine
 | |
|             fi
 | |
|         else
 | |
|             zenity_error_download && pw_check_and_download_wine
 | |
|         fi
 | |
|     fi
 | |
| }
 | |
| 
 | |
| open_changelog () {
 | |
|     "${pw_yad}" --title="Changelog" --borders=10 --no-buttons --text-align=center \
 | |
|     --text-info --show-uri --wrap --center --width=1200 --height=550 --uri-color=red \
 | |
|     --filename="${PORT_WINE_PATH}/data/${PW_CHANGELOG_FILE}"
 | |
| }
 | |
| export -f open_changelog
 | |
| 
 | |
| pw_tray_icon () {
 | |
|     if [ ! -z "`pgrep -a yad_new | grep "\-\-notification" | awk '{print $1}'`" ] ; then
 | |
|         kill -s SIGUSR1 "`pgrep -a yad_new | grep "\-\-notification" | awk '{print $1}'`"
 | |
|     fi
 | |
|     tray_icon_click () {
 | |
|         echo ""
 | |
|     }
 | |
|     export -f tray_icon_click
 | |
|     pw_tray_winefile () {
 | |
|         pw_run explorer
 | |
|     }
 | |
|     export -f pw_tray_winefile
 | |
|     tray_icon_click_exit () {
 | |
|         pw_stop_progress_bar
 | |
|         stop_portwine
 | |
|     }
 | |
|     export -f tray_icon_click_exit
 | |
| 
 | |
|     "${pw_yad_new}" --notification --no-middle --text="PortProton" \
 | |
|     --window-icon="$PW_GUI_ICON_PATH/port_proton.png" \
 | |
|     --image="$PW_GUI_ICON_PATH/port_proton.png" \
 | |
|     --command="bash -c tray_icon_click" \
 | |
|     --tooltip="PortProton" \
 | |
|     --menu="| \
 | |
| <<<     WINEFILE     >>>!bash -c pw_tray_winefile!"$PW_GUI_ICON_PATH/port_winefile.png"| \
 | |
| <<< CHANGE  LOG >>>!bash -c open_changelog!"$PW_GUI_ICON_PATH/port_changelog.png"| \
 | |
| <<<   FORCE  EXIT   >>>!bash -c tray_icon_click_exit!"$PW_GUI_ICON_PATH/port_exit.png"|" &
 | |
| }
 | |
| 
 | |
| pw_init_db () {
 | |
|     if [ ! -z "${portwine_exe}" ]; then
 | |
|         export PORTWINE_DB=`echo "${portwine_exe}" | awk -F '/' 'NF>1{print $NF}' | sed s/".exe"/""/gi`
 | |
|         orig_IFS="$IFS"
 | |
|         IFS=$'\n'
 | |
|         PW_FIND_DB_FILE=`grep -ilw "#${PORTWINE_DB}" "${PORT_SCRIPTS_PATH}/portwine_db"/* | sed s/".exe"/""/gi`
 | |
|         if [[ `echo "$PW_FIND_DB_FILE" | wc -l` -gt 1 ]] ; then
 | |
|             unset ADD_CB_DBFILE
 | |
|             for PW_CHECK_DB_FILE in $PW_FIND_DB_FILE ; do
 | |
|                 if [[ -z "${ADD_CB_DBFILE}" ]] ; then
 | |
|                     export ADD_CB_DBFILE="${PW_CHECK_DB_FILE}"
 | |
|                 else
 | |
|                     export ADD_CB_DBFILE="${PW_CHECK_DB_FILE}!${ADD_CB_DBFILE}"
 | |
|                 fi
 | |
|             done
 | |
|             PORTWINE_DB_FILE=`"${pw_yad_new}" --text-align=center --text "${PW_SELECTION_DB_LOC}" --borders=15 --form --center  \
 | |
|             --title "Database file selection..." --window-icon="$PW_GUI_ICON_PATH/port_proton.png"  --form --separator="" \
 | |
|             --field="DB FILE: :CB" "${ADD_CB_DBFILE}"`
 | |
|             if [[ "$?" == "1" || "$?" == "252" ]] ; then exit 0 ; fi
 | |
|         elif [[ `echo "$PW_FIND_DB_FILE" | wc -l` -eq 1 ]] ; then
 | |
|             PORTWINE_DB_FILE="${PW_FIND_DB_FILE}"
 | |
|         fi
 | |
|         IFS="$orig_IFS"
 | |
|         if [ ! -z "${PORTWINE_DB_FILE}" ]; then
 | |
|             . "${PORTWINE_DB_FILE}"
 | |
|             init_wine_ver &&
 | |
|             print_info "Use ${PORTWINE_DB_FILE} db file."
 | |
|         fi
 | |
|         if [ -z "$PATH_TO_GAME" ] ; then
 | |
|             export PATH_TO_GAME="$( cd "$( dirname "${portwine_exe}" )" >/dev/null 2>&1 && pwd )"
 | |
|         fi
 | |
|     fi
 | |
| #        export WIN_PATH_TO_GAME=`echo "C:${PATH_TO_GAME}" | sed "s%$WINEPREFIX%%g" | sed "s/drive_c//g" | sed 's#/#\\\#g'`
 | |
| }
 | |
| 
 | |
| pw_port_update () {
 | |
|     ###PORT UPDATE###
 | |
|     if [ ! -f "${PORT_WINE_TMP_PATH}/scripts_ver" ] ; then
 | |
|         echo "2000" > "${PORT_WINE_TMP_PATH}/scripts_ver"
 | |
|     fi
 | |
|     export scripts_install_ver=`cat "${PORT_WINE_TMP_PATH}/scripts_ver" | head -n 1`
 | |
|     curl -s --list-only https://raw.githubusercontent.com/Castro-Fidel/PortWINE/master/data_from_portwine/scripts/var > "${PORT_WINE_TMP_PATH}/curent_var_ver"
 | |
|     if [[ "$?" == 0 ]] ; then
 | |
|         if [ ! -f "${PORT_WINE_TMP_PATH}/${portname}_ver" ] ; then
 | |
|             echo "10" > "${PORT_WINE_TMP_PATH}/${portname}_ver"
 | |
|         fi
 | |
|         export port_install_ver=`cat "${PORT_WINE_TMP_PATH}/${portname}_ver" | head -n 1`
 | |
|         if [ ! -f "${PORT_WINE_TMP_PATH}/update_notifier" ] ; then
 | |
|             echo "1" > "${PORT_WINE_TMP_PATH}/update_notifier"
 | |
|         fi
 | |
|         read "update_not" < "${PORT_WINE_TMP_PATH}/update_notifier"
 | |
|         if [ "${update_not}" = "1" ] ; then
 | |
|             export port_current_ver=`cat "${PORT_WINE_TMP_PATH}/curent_var_ver" | grep PORT_NEXT_VERSION | awk -F "=" '{print $2}'`
 | |
|             print_info "Port version in github = ${port_current_ver}"
 | |
|             print_info "Port version local = ${port_install_ver}"
 | |
|             if  [[ ! -z "${port_current_ver}" && "${port_current_ver}" -gt "${port_install_ver}" ]] ; then
 | |
|                 xsd=`zenity --title  "${port_upd1}" --text "${port_upd2}" --list --radiolist --height=240 --column="${inst_set}" --column "${port_upd3}" \
 | |
|                 TRUE "${port_upd4}" \
 | |
|                 FALSE "${port_upd5}" \
 | |
|                 FALSE "${port_upd6}" `
 | |
|                 case $xsd in
 | |
|                     "${port_upd4}")
 | |
|                         kill_portwine &&
 | |
|                         xdg-open $PORTWINE_URL
 | |
|                         exit 0 ;;
 | |
|                     "${port_upd5}")
 | |
|                         echo " " ;;
 | |
|                     "${port_upd6}")
 | |
|                     echo "0" > "${PORT_WINE_TMP_PATH}/update_notifier" ;;
 | |
|                 esac
 | |
|             fi
 | |
|         fi
 | |
|         ###SCRIPTS UPDATE###
 | |
|         if [ ! -f "${PORT_WINE_TMP_PATH}/scripts_update_notifier" ] ; then
 | |
|                 echo "1" > "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
 | |
|         fi
 | |
|         read "scripts_update_not" < "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
 | |
|         if [ "${scripts_update_not}" = "1" ] ; then
 | |
|             export scripts_current_ver=`cat "${PORT_WINE_TMP_PATH}/curent_var_ver" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}'`
 | |
|             print_info "Scripts version in github = ${scripts_current_ver}"
 | |
|             print_info "Scripts version local = ${scripts_install_ver}"
 | |
|             if [[ ! -z "${scripts_current_ver}" && "${scripts_current_ver}" -gt "${scripts_install_ver}" ]] ; then
 | |
|                 xcsd=`zenity --title  "${scripts_upd1}" --text "${scripts_upd2}" --list --radiolist --height=240 --column="${inst_set}" --column "${scripts_upd3}" \
 | |
|                 TRUE "${scripts_upd4}" \
 | |
|                 FALSE "${scripts_upd5}" \
 | |
|                 FALSE "${scripts_upd6}"`
 | |
|                 case $xcsd in
 | |
|                     "${scripts_upd4}")
 | |
|                         echo "######################################################"
 | |
|                         print_info "Update scripts..."
 | |
|                         try_remove_file "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
 | |
|                         if try_download "https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz" "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" ; then
 | |
|                             if unpack_tar_gz "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" "${PORT_WINE_TMP_PATH}" ; then
 | |
|                                 cp -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/data_from_portwine/"* "${PORT_WINE_PATH}/data/"
 | |
|                                 try_remove_file "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
 | |
|                                 try_remove_dir "${PORT_WINE_TMP_PATH}/PortWINE-master/"
 | |
|                                 echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
 | |
|                                 zenity --title="Changelog" --text-info --width=1200 --height=550 \
 | |
|                                 --filename="${PORT_WINE_PATH}/data/${PW_CHANGELOG_FILE}"
 | |
|                                 [ "$?" == 0 ] && /bin/bash -c ${pw_full_command_line[*]} &
 | |
|                                 exit 0
 | |
|                             fi
 | |
|                         else
 | |
|                             zenity_error_download && pw_scripts_update
 | |
|                         fi ;;
 | |
|                     "${scripts_upd5}")
 | |
|                         echo " " ;;
 | |
|                     "${scripts_upd6}")
 | |
|                     echo "0" > "${PORT_WINE_TMP_PATH}/scripts_update_notifier" ;;
 | |
|                 esac
 | |
|             fi
 | |
|         fi
 | |
|         try_remove_file "${PORT_WINE_TMP_PATH}/curent_var_ver"
 | |
|     fi
 | |
| }
 | |
| 
 | |
| 
 | |
| update_winetricks () {
 | |
|     W_TRX_URL="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
 | |
|     W_TRX_EXT_VER="$(curl -s --list-only ${W_TRX_URL} | grep -i 'WINETRICKS_VERSION=' | sed 's/WINETRICKS_VERSION=//')"
 | |
|     print_info "Version winetricks on server: ${W_TRX_EXT_VER}"
 | |
|     W_TRX_INT_VER="$(cat "${PORT_WINE_TMP_PATH}/winetricks" | grep -i 'WINETRICKS_VERSION=' | sed 's/WINETRICKS_VERSION=//')"
 | |
|     print_info "Version winetricks in port: ${W_TRX_INT_VER}"
 | |
|     if [[ ! -f "${PORT_WINE_TMP_PATH}/winetricks" && ! -z "$W_TRX_EXT_VER" ]] || [[ "$W_TRX_INT_VER" != "$W_TRX_EXT_VER" && ! -z "$W_TRX_EXT_VER" ]]; then
 | |
|         if try_download "${W_TRX_URL}" "${PORT_WINE_TMP_PATH}/winetricks_new" ; then
 | |
|             mv -f "${PORT_WINE_TMP_PATH}/winetricks_new" "${PORT_WINE_TMP_PATH}/winetricks"
 | |
|             W_TRX_INT_VER="$(cat "${PORT_WINE_TMP_PATH}/winetricks" | grep -i 'WINETRICKS_VERSION=' | sed 's/WINETRICKS_VERSION=//')" && print_info "Winetricks version in port has been updated (${W_TRX_INT_VER})" 
 | |
|             chmod u+x "${PORT_WINE_TMP_PATH}/winetricks"
 | |
|         fi
 | |
|     fi
 | |
|     if  [ -f "${PORT_WINE_TMP_PATH}/winetricks" ] ; then
 | |
|         sed -i 's/w_metadata vcrun2015 dlls \\/w_metadata !dont_use_2015! dlls \\/' "${PORT_WINE_TMP_PATH}/winetricks"
 | |
|         sed -i 's/w_metadata vcrun2017 dlls \\/w_metadata !dont_use_2017! dlls \\/' "${PORT_WINE_TMP_PATH}/winetricks"
 | |
|         #HOTFIX SHA256SUM FOR VC_RUN2019
 | |
|         sed -i 's/vc_redist.x86.exe 1acd8d5ea1cdc3eb2eb4c87be3ab28722d0825c15449e5c9ceef95d897de52fa/vc_redist.x86.exe 80c7969f4e05002a0cd820b746e0acb7406d4b85e52ef096707315b390927824/g' "${PORT_WINE_TMP_PATH}/winetricks"
 | |
|         sed -i 's/vc_redist.x64.exe 003063723b2131da23f40e2063fb79867bae275f7b5c099dbd1792e25845872b/vc_redist.x64.exe 9b9dd72c27ab1db081de56bb7b73bee9a00f60d14ed8e6fde45dab3e619b5f04/g' "${PORT_WINE_TMP_PATH}/winetricks"
 | |
| 
 | |
|     fi
 | |
| }
 | |
| 
 | |
| edit_db_from_gui () {
 | |
|     for mod_db in $@ ; do
 | |
|         echo "${mod_db}=${!mod_db}"
 | |
|         if [ -z "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" ] ; then
 | |
|             echo "export ${mod_db}=${!mod_db}" >> "${PORTWINE_DB_FILE}"
 | |
|         elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" ] ; then
 | |
|             if [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}=" | grep -v "#"`" != "export ${mod_db}=${!mod_db}" ] ; then
 | |
|                 sed -ri "s/^export ${mod_db}=.*/export ${mod_db}=${!mod_db}/" "${PORTWINE_DB_FILE}"
 | |
|             fi
 | |
|         elif [ "`cat "${PORTWINE_DB_FILE}" | grep "export ${mod_db}="`" != "export ${mod_db}=${!mod_db}" ] ; then
 | |
|             sed -ri "s/.*export ${mod_db}=.*/export ${mod_db}=${!mod_db}/g" "${PORTWINE_DB_FILE}"
 | |
|         fi
 | |
|     done
 | |
| }
 | |
| 
 | |
| pw_gui_for_edit_db () {
 | |
|     KEY_EDIT_DB_GUI=$RANDOM
 | |
|     if [[ -n "`echo "${MANGOHUD_CONFIG}" | grep "fps_limit"`" ]] ; then
 | |
|         FPS_LIMIT_VAR="`echo ${MANGOHUD_CONFIG} | sed 's/.*fps_limit=//g' | awk -F, '{print $1}'`"
 | |
|     else
 | |
|         FPS_LIMIT_VAR=0
 | |
|     fi
 | |
|     echo "FPS_LIMIT_VAR=$FPS_LIMIT_VAR"
 | |
|     unset ADD_CHK_BOX_EDIT_DB
 | |
|     edit_db_field_add () {
 | |
|         for int_to_boole in $@ ; do
 | |
|             if [ "${!int_to_boole}" == "1" ]
 | |
|             then export ${int_to_boole}="TRUE"
 | |
|             else export ${int_to_boole}="FALSE"
 | |
|             fi
 | |
|             TMP_HELP_FOR_GUI="${int_to_boole}_INFO"
 | |
|             int_to_boole_non_pw="`echo ${int_to_boole} | sed 's/^PW_//'`"
 | |
|             ADD_CHK_BOX_EDIT_DB+="--field=  ${int_to_boole_non_pw}    !${!TMP_HELP_FOR_GUI}:CHK%${!int_to_boole}%"
 | |
|         done
 | |
|     }
 | |
|     edit_db_field_add $@
 | |
|     old_IFS=$IFS
 | |
|     IFS="%" 
 | |
|     "${pw_yad_new}" --plug=$KEY_EDIT_DB_GUI --tabnum="1" --form --separator=" " --columns=4 ${ADD_CHK_BOX_EDIT_DB} \
 | |
|     1> "${PORT_WINE_TMP_PATH}/tmp_output_yad_edit_db" & 
 | |
|     IFS=$old_IFS
 | |
| 
 | |
|     "${pw_yad_new}" --plug=$KEY_EDIT_DB_GUI --tabnum="2" --form --separator=" " --columns=1 \
 | |
|     --field="MANGOHUD FPS LIMIT (0-disabled):SCL" ${FPS_LIMIT_VAR} 1> "${PORT_WINE_TMP_PATH}/tmp_output_yad_fps_limit" & 
 | |
| 
 | |
|     "${pw_yad_new}" --paned --key="$KEY_EDIT_DB_GUI" --title "EDIT_DB" --text-align=center --height="400" \
 | |
|     --text "Change settings in database file for ${PORTWINE_DB}\n" --separator=" " --borders=10 --center \
 | |
|     --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --button="CANCEL":1 --button="OPEN DB FILE":150 --button="SAVE CHANGES":0
 | |
|     YAD_STATUS="$?"
 | |
|     if [[ "$YAD_STATUS" == "1" ]] ; then
 | |
|         /bin/bash -c ${pw_full_command_line[*]} &
 | |
|         exit 0
 | |
|     elif [[ "$YAD_STATUS" == "252" ]] ; then 
 | |
|         exit 0
 | |
|     elif [ "$YAD_STATUS" == "150" ] ; then
 | |
|         xdg-open "${PORTWINE_DB_FILE}" &
 | |
|         exit 0
 | |
|     fi
 | |
|     output_yad_edit_db=(`cat "${PORT_WINE_TMP_PATH}/tmp_output_yad_edit_db"`)
 | |
|     bool_from_yad=0
 | |
|     edit_db_field_read () {
 | |
|         for boole_to_int in $@ ; do
 | |
|             export ${boole_to_int}=${output_yad_edit_db[$bool_from_yad]}
 | |
|             if [ "${!boole_to_int}" == "TRUE" ]
 | |
|             then export ${boole_to_int}="1"
 | |
|             else export ${boole_to_int}="0"
 | |
|             fi
 | |
|             export bool_from_yad=$(( ${bool_from_yad} + 1 ))
 | |
|         done
 | |
|     }
 | |
|     edit_db_field_read $@
 | |
|     FPS_LIMIT="`cat "${PORT_WINE_TMP_PATH}/tmp_output_yad_fps_limit"`"
 | |
|     if [ "${FPS_LIMIT}" == 0 ] ; then
 | |
|         export MANGOHUD_CONFIG=font_size=24,position=top-left,toggle_hud=Shift_R+F12,no_display,resolution,wine,gpu_name,vulkan_driver,gpu_stats,vkbasalt
 | |
|     else
 | |
|         export MANGOHUD_CONFIG=font_size=24,position=top-left,toggle_hud=Shift_R+F12,no_display,resolution,wine,gpu_name,vulkan_driver,gpu_stats,vkbasalt,fps_limit=${FPS_LIMIT}
 | |
|     fi
 | |
|     edit_db_from_gui $@ MANGOHUD_CONFIG
 | |
| 
 | |
|     # PW_DB_TMP=`cat "${PORTWINE_DB_FILE}"`
 | |
|     # echo "${PW_DB_TMP}" | awk '! a[$0]++' > "${PORTWINE_DB_FILE}"
 | |
|     # unset PW_DB_TMP
 | |
| }
 | |
| 
 | |
| gui_proton_downloader () {
 | |
|     pw_start_progress_bar_block "Check new version WINE from GitHub"
 | |
|     #PROTON_GE
 | |
|     export PROTON_GE_GIT=($(curl -s "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases" | grep "browser_download_url.*\.tar\.gz" | cut -d \" -f 4))
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|     if [[ ! -z "${PROTON_GE_GIT}" ]] ; then
 | |
|         for PGEGIT in ${PROTON_GE_GIT[@]} ; do
 | |
|             echo ${PGEGIT} | awk -F/ '{print $NF}' | sed 's/.tar.gz//' >> "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|         done
 | |
|         sed -i '/Proton-6.5-GE-2/,$d' "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|         sed -i '/github-action/d' "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|     fi
 | |
| 
 | |
|     #PROTON_PW
 | |
|     export PROTON_PW_GIT=($(curl -s "https://api.github.com/repos/Castro-Fidel/wine_builds/releases" | grep "browser_download_url.*\.tar\.xz" | cut -d \" -f 4))
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|     if [[ ! -z "${PROTON_PW_GIT}" ]] ; then
 | |
|         for PPWGIT in ${PROTON_PW_GIT[@]} ; do
 | |
|             echo ${PPWGIT} | awk -F/ '{print $NF}' | sed 's/.tar.xz//' >> "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|         done
 | |
|         sed -i /${PW_PROTON_GE_VER}/d "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|         sed -i '/plugins/d' "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|     fi
 | |
|     pw_stop_progress_bar
 | |
|     if [[ -z "${PROTON_GE_GIT}" ]] || [[ -z "${PROTON_PW_GIT}" ]] ; then
 | |
|         zenity_error "Error: check wine from github."
 | |
|         /bin/bash -c ${pw_full_command_line[*]} &
 | |
|         exit 0
 | |
|     fi
 | |
|     for INSTALLING_VERSION_IN_DIST in `ls "${PORT_WINE_PATH}/data/dist/"` ; do
 | |
|         sed -i "/${INSTALLING_VERSION_IN_DIST}$/Id" "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|         sed -i "/${INSTALLING_VERSION_IN_DIST}$/Id" "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|     done
 | |
| 	#Installed wine
 | |
| 	ls -l ${PORT_WINE_PATH}/data/dist | awk '{print $9}' | sed '/^$/d' > ${PORT_WINE_TMP_PATH}/tmp_installed_wine	
 | |
|     #GUI
 | |
|     export KEY_WINE=$RANDOM
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_pw_set"
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_set"
 | |
| 	try_remove_file "${PORT_WINE_TMP_PATH}/tmp_installed_wine_set"
 | |
|     `"${pw_yad}" --plug=$KEY_WINE --tabnum=2 --list --separator="" --listen \
 | |
|     --column "Select WINE for download:" < "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git" 1> "${PORT_WINE_TMP_PATH}/tmp_proton_pw_set"` &
 | |
|     `"${pw_yad}" --plug=$KEY_WINE --tabnum=1 --list --separator="" --listen \
 | |
|     --column "Select WINE for download:" < "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git" 1> "${PORT_WINE_TMP_PATH}/tmp_proton_set"` &
 | |
| 	`"${pw_yad}" --plug=$KEY_WINE --tabnum=3 --list --separator="" --listen \
 | |
|     --column "Select installed WINE for delete:" < "${PORT_WINE_TMP_PATH}/tmp_installed_wine" 1> "${PORT_WINE_TMP_PATH}/tmp_installed_wine_set"` &
 | |
|     `"${pw_yad}" --key=$KEY_WINE --notebook --width=500 --height=600 --text-align=center --center \
 | |
|     --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "Download..." --separator="" \
 | |
|     --tab-pos=top --tab="PROTON-GE" --tab="PROTON-PW" --tab="INSTALLED"`
 | |
|     YAD_WINE_STATUS="$?"
 | |
|     if [[ "$YAD_WINE_STATUS" == "1" || "$YAD_WINE_STATUS" == "252" ]] ; then
 | |
|         /bin/bash -c ${pw_full_command_line[*]} &
 | |
|         exit 0
 | |
|     fi
 | |
| 
 | |
|     if [ ! -z `cat "${PORT_WINE_TMP_PATH}/tmp_proton_set" | awk '{print $1}'` ] ; then
 | |
|         export VERSION_WINE_GIT="`cat "${PORT_WINE_TMP_PATH}/tmp_proton_set"`"
 | |
|     elif [ ! -z `cat "${PORT_WINE_TMP_PATH}/tmp_proton_pw_set" | awk '{print $1}'` ] ; then
 | |
|         export VERSION_WINE_GIT="`cat "${PORT_WINE_TMP_PATH}/tmp_proton_pw_set"`"
 | |
| 	elif [ ! -z `cat "${PORT_WINE_TMP_PATH}/tmp_installed_wine_set" | awk '{print $1}'` ] ; then
 | |
| 	    export VERSION_INSTALLED_WINE="`cat "${PORT_WINE_TMP_PATH}/tmp_installed_wine_set"`"
 | |
|     fi
 | |
| 
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_ge_git"
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_pw_git"
 | |
|     try_remove_file "${PORT_WINE_TMP_PATH}/tmp_proton_set"
 | |
| 	try_remove_file "${PORT_WINE_TMP_PATH}/tmp_installed_wine"
 | |
| 
 | |
|     for GIVE_WINE_URL in ${PROTON_GE_GIT[@]} ${PROTON_PW_GIT[@]} ; do
 | |
|         if [ ! -z `echo ${GIVE_WINE_URL} | grep "$VERSION_WINE_GIT"` ] ; then
 | |
|             export URL_VERSION_PROTON_GIT="${GIVE_WINE_URL}"
 | |
|         fi
 | |
|     done
 | |
| 	
 | |
| 	if [[ ! -z "${VERSION_INSTALLED_WINE}" ]]; then
 | |
| 		try_remove_dir "${PORT_WINE_PATH}/data/dist/${VERSION_INSTALLED_WINE}"
 | |
| 		unset VERSION_INSTALLED_WINE
 | |
|         /bin/bash -c ${pw_full_command_line[*]} &
 | |
|         exit 0
 | |
| 	fi
 | |
| 	
 | |
|     print_info "Download and install ${VERSION_WINE_GIT}..."
 | |
|     if try_download_to_path "${URL_VERSION_PROTON_GIT}" "${PORT_WINE_PATH}/data/tmp/" ; then
 | |
|         for archive_type in "gz" "xz" ; do
 | |
|             if [ -f "${PORT_WINE_PATH}/data/tmp/${VERSION_WINE_GIT}.tar.${archive_type}" ] ; then
 | |
|                 if unpack_tar_${archive_type} "${PORT_WINE_PATH}/data/tmp/${VERSION_WINE_GIT}.tar.${archive_type}" "${PORT_WINE_PATH}/data/dist/" ; then
 | |
|                     try_remove_file "${PORT_WINE_PATH}/data/tmp/${VERSION_WINE_GIT}.tar.${archive_type}"
 | |
|                     if [ ! -z "${portwine_exe}" ]; then
 | |
|                         PW_WINE_USE=${VERSION_WINE_GIT}
 | |
|                         edit_db_from_gui PW_WINE_USE
 | |
|                     fi
 | |
|                 else
 | |
|                     try_remove_file "${PORT_WINE_PATH}/data/tmp/${VERSION_WINE_GIT}.tar.${archive_type}"
 | |
|                     try_remove_dir "${PORT_WINE_PATH}/data/dist/${VERSION_WINE_GIT}"
 | |
|                     zenity_error_download && gui_proton_downloader
 | |
|                 fi
 | |
|             fi
 | |
|         done
 | |
|     else
 | |
|         zenity_error_download && gui_proton_downloader
 | |
|     fi
 | |
|     /bin/bash -c ${pw_full_command_line[*]} &
 | |
|     exit 0
 | |
| }
 | |
| export -f gui_proton_downloader
 | |
| 
 | |
| gui_vkBasalt () {
 | |
|     KEY_FX_GUI=$RANDOM
 | |
|     FILE_VKBASALT_CONF="${PORT_WINE_PATH}/data/vkBasalt.conf"
 | |
|     LIST_FX=(`grep ".fx$" "${FILE_VKBASALT_CONF}" | awk '{print $1}'`)
 | |
|     GET_FX_IN_FILE=(`echo ${PW_VKBASALT_EFFECTS} | sed s/"cas:"// | sed s/":"/" "/g`)
 | |
|     unset ADD_GUI_FX GUI_FX_RESULT
 | |
|     for add_list_fx in ${LIST_FX[@]} ; do
 | |
|         PW_VKBASALT_GUI_HELP="PW_${add_list_fx}_INFO"
 | |
|         if [[ ! -z `echo " ${GET_FX_IN_FILE[@]} " | grep " ${add_list_fx} "` ]] ; then
 | |
|             ADD_GUI_FX+="--field=$add_list_fx!${!PW_VKBASALT_GUI_HELP}:CHK%TRUE%"
 | |
|         else
 | |
|             ADD_GUI_FX+="--field=$add_list_fx!${!PW_VKBASALT_GUI_HELP}:CHK%FALSE%"
 | |
|         fi
 | |
|     done
 | |
|     if [[ ! -z "${PW_VKBASALT_FFX_CAS}" ]] ; then
 | |
|         VKBASALT_FFX_CAS_GUI=`bc -s <<< "${PW_VKBASALT_FFX_CAS}*100" | sed 's/\..*//'`
 | |
|     else
 | |
|         VKBASALT_FFX_CAS_GUI=75
 | |
|     fi
 | |
|     export old_IFS=$IFS
 | |
|     export IFS="%" 
 | |
|     "${pw_yad_new}" --plug=$KEY_FX_GUI --tabnum="1" --form --columns=5 --separator=" " \
 | |
|     ${ADD_GUI_FX} 1> "${PORT_WINE_TMP_PATH}/tmp_yad_basalt_set" &
 | |
|     export IFS="${old_IFS}" 
 | |
| 
 | |
|     "${pw_yad_new}" --plug=$KEY_FX_GUI --tabnum="2" --separator=" " --form \
 | |
|     --field="AMD FidelityFX - Contrast Adaptive Sharpening":SCL "${VKBASALT_FFX_CAS_GUI}" \
 | |
|     1> "${PORT_WINE_TMP_PATH}/tmp_yad_cas_set" &
 | |
| 
 | |
|     "${pw_yad_new}" --paned --key="$KEY_FX_GUI" --height="500" --title="vkBasalt" --center --borders=10 \
 | |
|     --separator=" " --window-icon="$PW_GUI_ICON_PATH/port_proton.png" \
 | |
|     --button="CANCEL":1 --button="DISABLE  VKBASALT":180 --button="ENABLE  VKBASALT":182
 | |
|     YAD_VKBASALT_STATUS="$?"
 | |
|     case "${YAD_VKBASALT_STATUS}" in
 | |
|         1|252)
 | |
|             /bin/bash -c ${pw_full_command_line[*]} &
 | |
|             exit 0 ;;
 | |
|         180)
 | |
|             export ENABLE_VKBASALT=0 ;;
 | |
|         182)
 | |
|             export ENABLE_VKBASALT=1 ;;
 | |
|     esac
 | |
|     YAD_BASALT_SET=`cat "${PORT_WINE_TMP_PATH}/tmp_yad_basalt_set"`
 | |
|     YAD_CAS_SET=`cat "${PORT_WINE_TMP_PATH}/tmp_yad_cas_set" | sed s/" "//g`
 | |
| 
 | |
|     INT_COUNT_FX=0
 | |
|     for read_list_fx in ${YAD_BASALT_SET} ; do
 | |
|         if [[ "$read_list_fx" == "TRUE" ]] ; then
 | |
|             export GUI_FX_RESULT+=":${LIST_FX[$INT_COUNT_FX]}"
 | |
|         fi
 | |
|         export INT_COUNT_FX=$(( ${INT_COUNT_FX} + 1 ))
 | |
|     done
 | |
|     GUI_FX_RESULT="cas${GUI_FX_RESULT}"
 | |
|     export PW_VKBASALT_EFFECTS="${GUI_FX_RESULT}"       
 | |
| 
 | |
|     if [[ "$YAD_CAS_SET" == "0" ]] ; then
 | |
|         export PW_VKBASALT_FFX_CAS="0"
 | |
|     elif [[ "$YAD_CAS_SET" == "100" ]] ; then
 | |
|         export PW_VKBASALT_FFX_CAS="1"
 | |
|     else
 | |
|         export PW_VKBASALT_FFX_CAS="0`bc -s <<< "scale=2; $YAD_CAS_SET/100"`"
 | |
|     fi
 | |
|     edit_db_from_gui PW_VKBASALT_EFFECTS PW_VKBASALT_FFX_CAS ENABLE_VKBASALT
 | |
|     /bin/bash -c ${pw_full_command_line[*]} &
 | |
|     exit 0
 | |
| }
 |