start.sh 53 KB
Newer Older
castro-fidel's avatar
castro-fidel committed
1
#!/usr/bin/env bash
castro-fidel's avatar
castro-fidel committed
2
# Author: linux-gaming.ru
3

Mikhail Tergoev's avatar
Mikhail Tergoev committed
4
export PW_START_PID="$$"
5
export NO_AT_BRIDGE=1
castro-fidel's avatar
castro-fidel committed
6
export pw_full_command_line=("$0" $*)
7
export YAD_BORDERS=5
8 9 10
MISSING_DESKTOP_FILE=0

if [[ -f "$1" ]] ; then
11
    export portwine_exe="$1"
12 13 14
elif [[ "$1" == *.exe ]] ; then
    export portwine_exe="$1"
    MISSING_DESKTOP_FILE=1
castro-fidel's avatar
castro-fidel committed
15
fi
16 17 18 19 20 21 22 23 24

# HOTFIX - ModernWarships
if echo "$portwine_exe" | grep ModernWarships &>/dev/null \
&& [[ -f "$(dirname "${portwine_exe}")/Modern Warships.exe" ]]
then
    export portwine_exe="$(dirname "${portwine_exe}")/Modern Warships.exe"
    MISSING_DESKTOP_FILE=0
fi

castro-fidel's avatar
castro-fidel committed
25 26
. "$(dirname $(readlink -f "$0"))/runlib"
kill_portwine
27
killall -15 yad_v12_3 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
28
kill -TERM `pgrep -a yad | grep ${portname} | head -n 1 | awk '{print $1}'` 2>/dev/null
castro-fidel's avatar
castro-fidel committed
29

30 31 32
if [[ -f "/usr/bin/portproton" ]] \
&& [[ -f "${HOME}/.local/share/applications/PortProton.desktop" ]]
then
33
    rm -f "${HOME}/.local/share/applications/PortProton.desktop"
castro-fidel's avatar
castro-fidel committed
34 35
fi

36 37 38 39 40 41 42
if grep "SteamOS" "/etc/os-release" &>/dev/null \
&& [[ ! -f  "${HOME}/.local/share/applications/PortProton.desktop" ]]
then
	cp -f "${PORT_WINE_PATH}/PortProton.desktop" "${HOME}/.local/share/applications/"
	update-desktop-database -q "${HOME}/.local/share/applications"
fi

43 44
[[ "$MISSING_DESKTOP_FILE" == 1 ]] && portwine_missing_shortcut

45 46 47 48 49 50 51
# if [[ -f "$portwine_exe" ]] \
# && [[ "${WARN_CYRILLIC_IN_PATH}" != 1 ]] \
# && echo "${portwine_exe}" | grep -e $'[\u0430-\u044F\u0410-\u042F]' &>/dev/null
# then
#     yad_info "$loc_warn_cyrillic_in_path"
#     export WARN_CYRILLIC_IN_PATH="1"
# fi
Mikhail Tergoev's avatar
Mikhail Tergoev committed
52

53
if [[ -f "${PORT_WINE_TMP_PATH}/tmp_main_gui_size" ]] && [[ ! -z "$(cat ${PORT_WINE_TMP_PATH}/tmp_main_gui_size)" ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
54 55 56
    export PW_MAIN_SIZE_W="$(cat ${PORT_WINE_TMP_PATH}/tmp_main_gui_size | awk '{print $1}')"
    export PW_MAIN_SIZE_H="$(cat ${PORT_WINE_TMP_PATH}/tmp_main_gui_size | awk '{print $2}')"
else
57
    export PW_MAIN_SIZE_W="1100"
58
    export PW_MAIN_SIZE_H="350"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
59 60
fi    

61
if [[ ! -z $(basename "${portwine_exe}" | grep .ppack) ]] ; then
castro-fidel's avatar
castro-fidel committed
62 63 64 65
    export PW_ADD_TO_ARGS_IN_RUNTIME="--xterm"
    unset PW_SANDBOX_HOME_PATH
    pw_init_runtime
    export PW_PREFIX_NAME=$(basename "$1" | awk -F'.' '{print $1}')
Mikhail Tergoev's avatar
Mikhail Tergoev committed
66
    ${pw_runtime} "${PW_PLUGINS_PATH}/portable/bin/xterm" -e env PATH="${PATH}" LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" unsquashfs -f -d "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}" "$1" &
castro-fidel's avatar
castro-fidel committed
67 68
    sleep 10
    while true ; do
69
        if [[ ! -z $(pgrep -a xterm | grep ".ppack" | head -n 1 | awk '{print $1}') ]] ; then
castro-fidel's avatar
castro-fidel committed
70 71 72 73 74 75 76 77 78 79
            sleep 0.5
        else
            kill -TERM $(pgrep -a unsquashfs | grep ".ppack" | head -n 1 | awk '{print $1}')
            sleep 0.3
            if [[ -z "$(pgrep -a unsquashfs | grep ".ppack" | head -n 1 | awk '{print $1}')" ]]
            then break
            else sleep 0.3
            fi
        fi
    done
castro-fidel's avatar
castro-fidel committed
80
    if [[ -f "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/.create_shortcut" ]] ; then
castro-fidel's avatar
castro-fidel committed
81 82
        orig_IFS="$IFS"
        IFS=$'\n'
castro-fidel's avatar
castro-fidel committed
83 84 85
        for crfb in $(cat "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/.create_shortcut") ; do
            export portwine_exe="${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/${crfb}"
            portwine_create_shortcut "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/${crfb}"
castro-fidel's avatar
castro-fidel committed
86 87 88 89 90 91 92 93 94 95
        done
        IFS="$orig_IFS"
    fi
    exit 0
fi

portwine_launch () {
    start_portwine
    PORTWINE_MSI=$(basename "${portwine_exe}" | grep .msi)
    PORTWINE_BAT=$(basename "${portwine_exe}" | grep .bat)
96
    if [[ ! -z "${PW_VIRTUAL_DESKTOP}" && "${PW_VIRTUAL_DESKTOP}" == "1" ]] ; then
97
        pw_run explorer "/desktop=PortProton,${PW_SCREEN_RESOLUTION}" ${WINE_WIN_START} "$portwine_exe"
98
    elif [ ! -z "${PORTWINE_MSI}" ]; then
castro-fidel's avatar
castro-fidel committed
99
        pw_run msiexec /i "$portwine_exe"
100
    elif [[ ! -z "${PORTWINE_BAT}" || -n "${portwine_exe}" ]] ; then
castro-fidel's avatar
castro-fidel committed
101
        pw_run ${WINE_WIN_START} "$portwine_exe"
castro-fidel's avatar
castro-fidel committed
102
    else
castro-fidel's avatar
castro-fidel committed
103
        pw_run winefile
castro-fidel's avatar
castro-fidel committed
104 105 106 107 108
    fi
}

portwine_start_debug () {
    kill_portwine
castro-fidel's avatar
castro-fidel committed
109
    export PW_LOG=1
110
    if [[ -z "$VULKAN_DRIVER_NAME" ]] || [[ "$VULKAN_DRIVER_NAME" == "llvmpipe" ]] ; then
111
	yad_info "Attention working version of vulkan not detected!\nIt is recommended to run games in OpenGL (low performance possible)!"
112
    fi
castro-fidel's avatar
castro-fidel committed
113 114 115 116 117 118 119 120 121 122
    echo "${port_deb1}" > "${PORT_WINE_PATH}/${portname}.log"
    echo "${port_deb2}" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-------------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "PortWINE version:" >> "${PORT_WINE_PATH}/${portname}.log"
    read install_ver < "${PORT_WINE_TMP_PATH}/${portname}_ver"
    echo "${portname}-${install_ver}" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "------------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Scripts version:" >> "${PORT_WINE_PATH}/${portname}.log"
    cat "${PORT_WINE_TMP_PATH}/scripts_ver" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-----------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
123
    if [ "${PW_USE_RUNTIME}" = 0 ] ; then
castro-fidel's avatar
castro-fidel committed
124 125 126 127 128
        echo "RUNTIME is disabled" >> "${PORT_WINE_PATH}/${portname}.log"
    else
        echo "RUNTIME is enabled" >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "----------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
129
    if [ ! -z "${portwine_exe}" ] ; then
castro-fidel's avatar
castro-fidel committed
130 131 132 133 134 135 136
        echo "Debug for programm:" >> "${PORT_WINE_PATH}/${portname}.log"
        echo "${portwine_exe}" >> "${PORT_WINE_PATH}/${portname}.log"
        echo "---------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "GLIBC version:" >> "${PORT_WINE_PATH}/${portname}.log"
    echo $(ldd --version | grep -m1 ldd | awk '{print $NF}') >> "${PORT_WINE_PATH}/${portname}.log"
    echo "--------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
137
    if [[ "${PW_VULKAN_USE}" = "0" ]] ; then 
Mikhail Tergoev's avatar
Mikhail Tergoev committed
138
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - DX9-11 to ${loc_gui_open_gl}" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
139 140 141 142
    elif [[ "${PW_VULKAN_USE}" = "1" ]] ; then
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - DXVK v.${DXVK_STABLE_VER} and VKD3D-PROTON v.${VKD3D_STABLE_VER}" >> "${PORT_WINE_PATH}/${portname}.log"
    elif [[ "${PW_VULKAN_USE}" = "2" ]] ; then
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - DXVK v.${DXVK_GIT_VER} and VKD3D-PROTON v.${VKD3D_GIT_VER}" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
143 144
    elif [[ "${PW_VULKAN_USE}" = "3" ]] ; then 
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - native DX9 on MESA drivers" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
145 146
    elif [[ "${PW_VULKAN_USE}" = "4" ]] ; then
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - DirectX to wined3d vulkan" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
147
    else 
castro-fidel's avatar
castro-fidel committed
148
        echo "PW_VULKAN_USE=${PW_VULKAN_USE}" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
149 150
    fi
    echo "--------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
151
    echo "Version WINE in use:" >> "${PORT_WINE_PATH}/${portname}.log"
152
    echo "$PW_WINE_USE" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
153 154
    echo "-------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Program bit depth:" >> "${PORT_WINE_PATH}/${portname}.log"
155 156 157 158 159 160 161
    if [[ $(file "$portwine_exe") =~ x86-64 ]]; then
        echo "64 bit" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-----------------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    else
        echo "32 bit" >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "--------------------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
162 163 164 165 166
    echo "Date and time of start debug for ${portname}:" >> "${PORT_WINE_PATH}/${portname}.log"
    date >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-----------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "The installation path of the ${portname}:" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "$PORT_WINE_PATH" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
167
    echo "------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
168
    echo "Operating system:" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
169
    cat /etc/os-release | grep -oP 'PRETTY_NAME="\K[^"]+' >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
170 171 172 173 174
    echo "--------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Desktop environment:" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Desktop session: ${DESKTOP_SESSION}" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Current desktop: ${XDG_CURRENT_DESKTOP}" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Session type: ${XDG_SESSION_TYPE}" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
175
    echo "---------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
176
    echo "Kernel:" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
177 178
    uname -r >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
179
    echo "CPU:" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
180 181 182
    echo "CPU physical cores:$(cat /proc/cpuinfo | grep 'cpu cores' | sort -u | cut -d':' -f2)" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "CPU logical cores: $(cat /proc/cpuinfo | grep 'processor' | wc -l)" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "CPU model name:$(cat /proc/cpuinfo | grep 'model name' | sort -u | cut -d':' -f2)" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
183
    echo "------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
184
    echo "RAM:" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
185 186 187
    free -m >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-----------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Graphic cards and drivers:" >> "${PORT_WINE_PATH}/${portname}.log"
188 189
    echo 'lspci -k | grep -EA3 VGA|3D|Display :' >> "${PORT_WINE_PATH}/${portname}.log"
    echo "$(lspci -k | grep -EA3 'VGA|3D|Display')" >> "${PORT_WINE_PATH}/${portname}.log"
190
    echo "----" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
191
    [[ `command -v glxinfo` ]] && glxinfo -B >> "${PORT_WINE_PATH}/${portname}.log"
192
    echo "-----" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
193
    echo "inxi -G:" >> "${PORT_WINE_PATH}/${portname}.log"
194
    "${PW_PLUGINS_PATH}/portable/bin/inxi" -Gc0 >> "${PORT_WINE_PATH}/${portname}.log"
195 196 197 198 199 200 201
    if echo "$LSPCI_VGA" | grep -i nvidia &>/dev/null ; then 
        if command -v ldconfig &>/dev/null ; then
            echo "------" >> "${PORT_WINE_PATH}/${portname}.log"
            echo "ldconfig -p | grep libGLX_nvidia" >> "${PORT_WINE_PATH}/${portname}.log"
            ldconfig -p | grep libGLX_nvidia >> "${PORT_WINE_PATH}/${portname}.log"
        fi
    fi
castro-fidel's avatar
castro-fidel committed
202 203
    echo "----------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Vulkan info device name:" >> "${PORT_WINE_PATH}/${portname}.log"
204
    "$PW_VULKANINFO_PORTABLE" 2>/dev/null | grep -E '^GPU|deviceName|driverName' >> "${PORT_WINE_PATH}/${portname}.log"
205
    "${PW_PLUGINS_PATH}/portable/bin/vkcube" --c 50
castro-fidel's avatar
castro-fidel committed
206 207 208
    if [ $? -eq 0 ]; then
        echo "Vulkan cube test passed successfully" >> "${PORT_WINE_PATH}/${portname}.log"
    else
Boria138's avatar
Boria138 committed
209
        echo "Vulkan cube test completed with error" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
210
    fi
Boria138's avatar
Boria138 committed
211
    echo "----------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
212
    echo 'locale:' >> "${PORT_WINE_PATH}/${portname}.log"
213 214 215 216
    locale >> "${PORT_WINE_PATH}/${portname}.log"
    echo "---" >> "${PORT_WINE_PATH}/${portname}.log"
    echo 'locale -a | grep -i "$(locale | grep -e '^LANG=' | sed 's/LANG=//' | sed  's/\-8//')" :' >> "${PORT_WINE_PATH}/${portname}.log"
    locale -a | grep -i "$(locale | grep -e '^LANG=' | sed 's/LANG=//' | sed  's/\-8//')" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
217
    echo "-------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
218
    if [[ "${PW_USE_D3D_EXTRAS}" != 1 ]]
castro-fidel's avatar
castro-fidel committed
219 220 221 222 223
    then echo "D3D_EXTRAS - disabled" >> "${PORT_WINE_PATH}/${portname}.log"
    else echo "D3D_EXTRAS - enabled" >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "winetricks.log:" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
224
    cat "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" | sed -e /"^d3dcomp*"/d -e /"^d3dx*"/d >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
225
    echo "-----------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
226
    if [ ! -z "${PORTWINE_DB_FILE}" ]; then
castro-fidel's avatar
castro-fidel committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
        echo "Use ${PORTWINE_DB_FILE} db file:" >> "${PORT_WINE_PATH}/${portname}.log"
        cat "${PORTWINE_DB_FILE}" | sed '/##/d' >> "${PORT_WINE_PATH}/${portname}.log"
    else
        echo "Use ${PORT_SCRIPTS_PATH}/portwine_db/default db file:" >> "${PORT_WINE_PATH}/${portname}.log"
        cat "${PORT_SCRIPTS_PATH}/portwine_db/default" | sed '/##/d' >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "----------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    if [ -f "${USER_CONF}" ]; then
        cat "${USER_CONF}" | sed '/bash/d' >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "---------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"

    export DXVK_HUD="full"

    portwine_launch &
    sleep 3
castro-fidel's avatar
castro-fidel committed
243 244
    pw_stop_progress_bar_cover
    unset PW_TIMER
245
    while read -r line || [[ ! -z $(pgrep -a yad | grep "yad_v12_3 --text-info --tail --button="STOP":0 --title="DEBUG"" | awk '{print $1}') ]] ; do
castro-fidel's avatar
castro-fidel committed
246
            sleep 0.005
247
            if [[ ! -z "${line}" ]] && [[ -z "$(echo "${line}" | grep -i "kerberos")" ]] \
castro-fidel's avatar
castro-fidel committed
248 249 250 251
                                    && [[ -z "$(echo "${line}" | grep -i "ntlm")" ]]
            then
                echo "# ${line}"
            fi
castro-fidel's avatar
castro-fidel committed
252
            if [[ "${PW_TIMER}" != 1 ]] ; then
castro-fidel's avatar
castro-fidel committed
253
                sleep 3
castro-fidel's avatar
castro-fidel committed
254
                PW_TIMER=1
castro-fidel's avatar
castro-fidel committed
255
            fi
256
    done < "${PORT_WINE_PATH}/${portname}.log" | "${pw_yad_v12_3}" --text-info --tail --button="STOP":0 --title="DEBUG" \
257
    --skip-taskbar --width=800 --height=400 --text "${port_debug}" 2>/dev/null &&
castro-fidel's avatar
castro-fidel committed
258 259 260 261
    kill_portwine
    sed -i '/.fx$/d' "${PORT_WINE_PATH}/${portname}.log"
    sed -i '/HACK_does_openvr_work/d' "${PORT_WINE_PATH}/${portname}.log"
    sed -i '/Uploading is disabled/d' "${PORT_WINE_PATH}/${portname}.log"
262
    sed -i '/wine: RLIMIT_NICE is <= 20/d' "${PORT_WINE_PATH}/${portname}.log"
263 264
    sed -i '/ALT_2.24/d' "${PORT_WINE_PATH}/${portname}.log"
    sed -i '/UDEV monitor/d' "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
265 266
    deb_text=$(cat "${PORT_WINE_PATH}/${portname}.log"  | awk '! a[$0]++') 
    echo "$deb_text" > "${PORT_WINE_PATH}/${portname}.log"
267
    "$pw_yad" --title="${portname}.log" --borders=${YAD_BORDERS} --no-buttons --text-align=center \
268
    --text-info --show-uri --wrap --width=1200 --height=550  --uri-color=red \
castro-fidel's avatar
castro-fidel committed
269 270 271 272
    --filename="${PORT_WINE_PATH}/${portname}.log"
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
273
pw_winecfg () {
castro-fidel's avatar
castro-fidel committed
274
    start_portwine
275
    export GST_PLUGIN_SYSTEM_PATH_1_0=""
castro-fidel's avatar
castro-fidel committed
276
    pw_run winecfg
castro-fidel's avatar
castro-fidel committed
277 278
}

castro-fidel's avatar
castro-fidel committed
279
pw_winefile () {
castro-fidel's avatar
castro-fidel committed
280
    start_portwine
castro-fidel's avatar
castro-fidel committed
281
    pw_run winefile
castro-fidel's avatar
castro-fidel committed
282 283
}

castro-fidel's avatar
castro-fidel committed
284 285
pw_winecmd () {
    export PW_USE_TERMINAL=1
castro-fidel's avatar
castro-fidel committed
286
    start_portwine
castro-fidel's avatar
castro-fidel committed
287
    cd "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/drive_c"
288
    ${pw_runtime} env LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" "${PW_PLUGINS_PATH}/portable/bin/xterm" -e "${WINELOADER}" cmd
castro-fidel's avatar
castro-fidel committed
289 290 291
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
292
pw_winereg () {
castro-fidel's avatar
castro-fidel committed
293
    start_portwine
294
    export GST_PLUGIN_SYSTEM_PATH_1_0=""
castro-fidel's avatar
castro-fidel committed
295
    pw_run regedit
castro-fidel's avatar
castro-fidel committed
296 297
}

castro-fidel's avatar
castro-fidel committed
298
pw_prefix_manager () {
castro-fidel's avatar
castro-fidel committed
299 300
    update_winetricks
    start_portwine
castro-fidel's avatar
castro-fidel committed
301 302
    if [ ! -f "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" ] ; then
        touch "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log"
castro-fidel's avatar
castro-fidel committed
303 304
    fi

castro-fidel's avatar
castro-fidel committed
305
    pw_start_progress_bar_block "Starting prefix manager..."
castro-fidel's avatar
castro-fidel committed
306 307 308
    "${PORT_WINE_TMP_PATH}/winetricks" dlls list | awk -F'(' '{print $1}' 1> "${PORT_WINE_TMP_PATH}/dll_list"
    "${PORT_WINE_TMP_PATH}/winetricks" fonts list | awk -F'(' '{print $1}' 1> "${PORT_WINE_TMP_PATH}/fonts_list"
    "${PORT_WINE_TMP_PATH}/winetricks" settings list | awk -F'(' '{print $1}' 1> "${PORT_WINE_TMP_PATH}/settings_list"
castro-fidel's avatar
castro-fidel committed
309
    pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
310 311

    gui_prefix_manager () {
castro-fidel's avatar
castro-fidel committed
312
        pw_start_progress_bar_block "Starting prefix manager..."
castro-fidel's avatar
castro-fidel committed
313 314 315 316
        unset SET_FROM_PFX_MANAGER_TMP SET_FROM_PFX_MANAGER
        old_IFS=$IFS
        IFS=$'\n'
        try_remove_file  "${PORT_WINE_TMP_PATH}/dll_list_tmp"
castro-fidel's avatar
castro-fidel committed
317 318 319 320
        while read PW_BOOL_IN_DLL_LIST ; do
            if [[ -z $(echo "${PW_BOOL_IN_DLL_LIST}" | grep -E 'd3d|directx9|dont_use|dxvk|vkd3d|galliumnine|faudio1') ]] ; then
                if grep "^$(echo ${PW_BOOL_IN_DLL_LIST} | awk '{print $1}')$" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" ; then
                    echo -e "true\n$(echo ${PW_BOOL_IN_DLL_LIST} | awk '{print $1}')\n`echo ${PW_BOOL_IN_DLL_LIST} | awk '{ $1 = ""; print substr($0, 2) }'`" >> "${PORT_WINE_TMP_PATH}/dll_list_tmp"
castro-fidel's avatar
castro-fidel committed
321
                else
castro-fidel's avatar
castro-fidel committed
322
                    echo -e "false\n`echo "${PW_BOOL_IN_DLL_LIST}" | awk '{print $1}'`\n`echo ${PW_BOOL_IN_DLL_LIST} | awk '{ $1 = ""; print substr($0, 2) }'`" >> "${PORT_WINE_TMP_PATH}/dll_list_tmp"
castro-fidel's avatar
castro-fidel committed
323 324 325 326
                fi
            fi
        done < "${PORT_WINE_TMP_PATH}/dll_list"
        try_remove_file  "${PORT_WINE_TMP_PATH}/fonts_list_tmp"
castro-fidel's avatar
castro-fidel committed
327 328 329 330
        while read PW_BOOL_IN_FONTS_LIST ; do
            if [[ -z $(echo "${PW_BOOL_IN_FONTS_LIST}" | grep -E 'dont_use') ]] ; then
                if grep "^$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')$" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" ; then
                    echo -e "true\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{ $1 = ""; print substr($0, 2) }')" >> "${PORT_WINE_TMP_PATH}/fonts_list_tmp"
castro-fidel's avatar
castro-fidel committed
331
                else
castro-fidel's avatar
castro-fidel committed
332
                    echo -e "false\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{ $1 = ""; print substr($0, 2) }')" >> "${PORT_WINE_TMP_PATH}/fonts_list_tmp"
castro-fidel's avatar
castro-fidel committed
333 334 335 336
                fi
            fi
        done < "${PORT_WINE_TMP_PATH}/fonts_list"
        try_remove_file  "${PORT_WINE_TMP_PATH}/settings_list_tmp"
castro-fidel's avatar
castro-fidel committed
337 338 339 340
        while read PW_BOOL_IN_FONTS_LIST ; do
            if [[ -z $(echo "${PW_BOOL_IN_FONTS_LIST}" | grep -E 'vista|alldlls|autostart_|bad|good|win|videomemory|vd=|isolate_home') ]] ; then
                if grep "^$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')$" "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" ; then
                    echo -e "true\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{ $1 = ""; print substr($0, 2) }')" >> "${PORT_WINE_TMP_PATH}/settings_list_tmp"
castro-fidel's avatar
castro-fidel committed
341
                else
castro-fidel's avatar
castro-fidel committed
342
                    echo -e "false\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{print $1}')\n$(echo "${PW_BOOL_IN_FONTS_LIST}" | awk '{ $1 = ""; print substr($0, 2) }')" >> "${PORT_WINE_TMP_PATH}/settings_list_tmp"
castro-fidel's avatar
castro-fidel committed
343 344 345
                fi
            fi
        done < "${PORT_WINE_TMP_PATH}/settings_list"
castro-fidel's avatar
castro-fidel committed
346
        pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
347 348

        KEY_EDIT_MANAGER_GUI=$RANDOM
349
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=1 --list --checklist \
350
        --text="${loc_prefix_manager_comp} <b>\"${PW_PREFIX_NAME}\"</b>, ${loc_prefix_manager_wine} <b>\"${PW_WINE_USE}\"</b>" \
351
        --column=set --column=dll --column=info < "${PORT_WINE_TMP_PATH}/dll_list_tmp" 1>> "${PORT_WINE_TMP_PATH}/to_winetricks" 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
352

353
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=2 --list --checklist \
354
        --text="${loc_prefix_manager_font} <b>\"${PW_PREFIX_NAME}\"</b>, ${loc_prefix_manager_wine} <b>\"${PW_WINE_USE}\"</b>" \
355
        --column=set --column=dll --column=info < "${PORT_WINE_TMP_PATH}/fonts_list_tmp" 1>> "${PORT_WINE_TMP_PATH}/to_winetricks" 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
356

357
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=3 --list --checklist \
358
        --text="${loc_prefix_manager_conf} <b>\"${PW_PREFIX_NAME}\"</b>" \
359
        --column=set --column=dll --column=info < "${PORT_WINE_TMP_PATH}/settings_list_tmp" 1>> "${PORT_WINE_TMP_PATH}/to_winetricks" 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
360

361 362
        "${pw_yad_v12_3}" --key=$KEY_EDIT_MANAGER_GUI --notebook --borders=${YAD_BORDERS} --width=900 --height=800 \
        --window-icon="$PW_GUI_ICON_PATH/portproton.svg" --title "$loc_pm" --tab-pos=bottom --tab="$loc_pm_dlls" --tab="$loc_pm_fonts" --tab="$loc_pm_settings" 2>/dev/null
castro-fidel's avatar
castro-fidel committed
363 364 365 366 367 368 369 370 371 372
        YAD_STATUS="$?"
        if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then
            stop_portwine
            exit 0
        fi 
        try_remove_file  "${PORT_WINE_TMP_PATH}/dll_list_tmp"
        try_remove_file  "${PORT_WINE_TMP_PATH}/fonts_list_tmp"
        try_remove_file  "${PORT_WINE_TMP_PATH}/settings_list_tmp"

        for STPFXMNG in $(cat "${PORT_WINE_TMP_PATH}/to_winetricks") ; do
castro-fidel's avatar
castro-fidel committed
373
            grep $(echo ${STPFXMNG} | awk -F'|' '{print $2}') "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/winetricks.log" &>/dev/null
castro-fidel's avatar
castro-fidel committed
374
            if [ "$?" == "1" ] ; then
375
                [[ ! -z "${STPFXMNG}" ]] && SET_FROM_PFX_MANAGER+="$(echo "${STPFXMNG}" | awk -F'|' '{print $2}') "
castro-fidel's avatar
castro-fidel committed
376 377 378 379 380
            fi
        done
        IFS=${old_IFS}
        try_remove_file  "${PORT_WINE_TMP_PATH}/to_winetricks"

381
        if [[ ! -z ${SET_FROM_PFX_MANAGER} ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
382 383
            ${pw_runtime} "${PW_PLUGINS_PATH}/portable/bin/xterm" -e env PATH="${PATH}" LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \
            "${PORT_WINE_TMP_PATH}/winetricks" -q -r -f ${SET_FROM_PFX_MANAGER}
castro-fidel's avatar
castro-fidel committed
384 385 386 387
            gui_prefix_manager
        else
            print_info "Nothing to do. Restarting PortProton..."
            stop_portwine &
Mikhail Tergoev's avatar
Mikhail Tergoev committed
388 389
            /usr/bin/env bash -c ${pw_full_command_line[*]} &
            exit 0
castro-fidel's avatar
castro-fidel committed
390 391 392 393 394
        fi
    }
    gui_prefix_manager
}

castro-fidel's avatar
castro-fidel committed
395
pw_winetricks () {
castro-fidel's avatar
castro-fidel committed
396
    update_winetricks
castro-fidel's avatar
castro-fidel committed
397
    export PW_USE_TERMINAL=1
castro-fidel's avatar
castro-fidel committed
398
    start_portwine
castro-fidel's avatar
castro-fidel committed
399
    pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
400
    echo "WINETRICKS..." > "${PORT_WINE_TMP_PATH}/update_pfx_log"
castro-fidel's avatar
castro-fidel committed
401
    unset PW_TIMER
402
    while read -r line || [[ ! -z $(pgrep -a yad | grep "yad_v12_3 --text-info --tail --no-buttons --title="WINETRICKS"" | awk '{print $1}') ]] ; do
castro-fidel's avatar
castro-fidel committed
403
            sleep 0.005
404
            if [[ ! -z "${line}" ]] && [[ -z "$(echo "${line}" | grep -i "gstreamer")" ]] \
castro-fidel's avatar
castro-fidel committed
405 406 407 408 409
                                    && [[ -z "$(echo "${line}" | grep -i "kerberos")" ]] \
                                    && [[ -z "$(echo "${line}" | grep -i "ntlm")" ]]
            then
                echo "# ${line}"
            fi
castro-fidel's avatar
castro-fidel committed
410
            if [[ "${PW_TIMER}" != 1 ]] ; then
castro-fidel's avatar
castro-fidel committed
411
                sleep 3
castro-fidel's avatar
castro-fidel committed
412
                PW_TIMER=1
castro-fidel's avatar
castro-fidel committed
413
            fi
414
    done < "${PORT_WINE_TMP_PATH}/update_pfx_log" | "${pw_yad_v12_3}" --text-info --tail --no-buttons --title="WINETRICKS" \
415
    --auto-close --skip-taskbar --width=$PW_GIF_SIZE_X --height=$PW_GIF_SIZE_Y 2>/dev/null &
416 417
    ${pw_runtime} env PATH="${PATH}" LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" GST_PLUGIN_SYSTEM_PATH_1_0="" \
    "${PORT_WINE_TMP_PATH}/winetricks" -q -r -f ${PW_DLL_NEED_INSTALL} &>>"${PORT_WINE_TMP_PATH}/update_pfx_log"
castro-fidel's avatar
castro-fidel committed
418
    try_remove_file "${PORT_WINE_TMP_PATH}/update_pfx_log"
419
    kill -s SIGTERM "$(pgrep -a yad_v12_3 | grep "title=WINETRICKS" | awk '{print $1}')" > /dev/null 2>&1    
castro-fidel's avatar
castro-fidel committed
420 421 422
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
423
pw_start_cont_xterm () {
castro-fidel's avatar
castro-fidel committed
424
    cd "$HOME"
castro-fidel's avatar
castro-fidel committed
425 426
    unset PW_SANDBOX_HOME_PATH
    pw_init_runtime
427 428
    ${pw_runtime} \
    env PATH="${PATH}" \
429 430 431 432
    LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" \
    LD_PRELOAD="${PW_LD_PRELOAD}" \
    VK_LAYER_PATH="${PW_VK_LAYER_PATH}" \
    VK_INSTANCE_LAYERS="${PW_VK_INSTANCE_LAYERS}" \
433 434
    ${PW_GAMEMODERUN_SLR} \
    ${PW_MANGOHUD_SLR} \
435
    "${PW_PLUGINS_PATH}/portable/bin/xterm"
castro-fidel's avatar
castro-fidel committed
436 437
}

castro-fidel's avatar
castro-fidel committed
438
pw_create_prefix_backup () {
castro-fidel's avatar
castro-fidel committed
439
    cd "$HOME"
440 441
    PW_PREFIX_TO_BACKUP=$("${pw_yad_v12_3}" --file --directory --borders=${YAD_BORDERS} --width=650 --height=500 --auto-close \
    --window-icon="$PW_GUI_ICON_PATH/portproton.svg" --title "$loc_create_pfx_backup_path" 2>/dev/null )
castro-fidel's avatar
castro-fidel committed
442 443
    YAD_STATUS="$?"
    if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then exit 0 ; fi
444
    if [[ ! -z "$(grep "/${PW_PREFIX_NAME}/" "${PORT_WINE_PATH}"/*.desktop )" ]] ; then
castro-fidel's avatar
castro-fidel committed
445 446 447
        try_remove_file "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/.create_shortcut"
        grep "/${PW_PREFIX_NAME}/" "${PORT_WINE_PATH}"/*.desktop | awk -F"/${PW_PREFIX_NAME}/" '{print $2}' \
        | awk -F\" '{print $1}' > "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/.create_shortcut"
castro-fidel's avatar
castro-fidel committed
448
    fi
castro-fidel's avatar
castro-fidel committed
449 450 451 452 453
    unset PW_SANDBOX_HOME_PATH
    export PW_ADD_TO_ARGS_IN_RUNTIME="--xterm"
    pw_init_runtime
    chmod -R u+w "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}"
    ${pw_runtime} env PATH="${PATH}" LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" mksquashfs "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}" "${PW_PREFIX_TO_BACKUP}/${PW_PREFIX_NAME}.ppack.part" -comp zstd &
castro-fidel's avatar
castro-fidel committed
454 455
    sleep 10
    while true ; do
456
        if [[ ! -z $(pgrep -a xterm | grep ".ppack.part" | head -n 1 | awk '{print $1}') ]] ; then
castro-fidel's avatar
castro-fidel committed
457 458 459 460 461 462 463 464 465 466
            sleep 0.5
        else
            kill -TERM $(pgrep -a mksquashfs | grep ".ppack.part" | head -n 1 | awk '{print $1}')
            sleep 0.3
            if [[ -z "$(pgrep -a mksquashfs | grep ".ppack.part" | head -n 1 | awk '{print $1}')" ]]
            then break
            else sleep 0.3
            fi
        fi
    done
castro-fidel's avatar
castro-fidel committed
467 468
    if [[ -f "${PW_PREFIX_TO_BACKUP}/${PW_PREFIX_NAME}.ppack.part" ]] ; then
        mv -f "${PW_PREFIX_TO_BACKUP}/${PW_PREFIX_NAME}.ppack.part" "${PW_PREFIX_TO_BACKUP}/${PW_PREFIX_NAME}.ppack"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
469
        yad_info "$PW_PFX_BACKUP_SUCCESS $PW_PREFIX_NAME"
470
        if [[ ! -f "${PORT_WINE_TMP_PATH}/pfx_backup_info" ]] ; then
471
            yad_info "$PW_PFX_BACKUP_INFO"
472 473
            echo "1" > "${PORT_WINE_TMP_PATH}/pfx_backup_info"
        fi
castro-fidel's avatar
castro-fidel committed
474
    else 
Mikhail Tergoev's avatar
Mikhail Tergoev committed
475
        yad_error "$PW_PFX_BACKUP_ERROR $PW_PREFIX_NAME"
476
    fi
477

castro-fidel's avatar
castro-fidel committed
478 479 480
    return 0
}

castro-fidel's avatar
castro-fidel committed
481
pw_edit_db () {
482
    if [[ "${XDG_SESSION_TYPE}" == "wayland" ]] ; then
483
        pw_gui_for_edit_db \
484
        PW_MANGOHUD PW_MANGOHUD_USER_CONF ENABLE_VKBASALT PW_VKBASALT_USER_CONF PW_NO_ESYNC PW_NO_FSYNC PW_USE_RAY_TRACING \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
485 486 487 488
        PW_USE_NVAPI_AND_DLSS PW_USE_FAKE_DLSS PW_USE_FAKE_DLSS_3 PW_WINE_FULLSCREEN_FSR PW_HIDE_NVIDIA_GPU PW_VIRTUAL_DESKTOP \
        PW_USE_TERMINAL PW_GUI_DISABLED_CS PW_USE_GAMEMODE PW_USE_D3D_EXTRAS PW_FIX_VIDEO_IN_GAME PW_REDUCE_PULSE_LATENCY \
        PW_USE_GSTREAMER PW_FORCE_LARGE_ADDRESS_AWARE PW_USE_SHADER_CACHE PW_USE_WINE_DXGI PW_USE_EAC_AND_BE PW_USE_SYSTEM_VK_LAYERS \
        PW_USE_OBS_VKCAPTURE PW_USE_GALLIUM_ZINK PW_USE_GAMESCOPE PW_DISABLE_COMPOSITING PW_USE_RUNTIME
489 490
    else
        pw_gui_for_edit_db \
491
        PW_MANGOHUD PW_MANGOHUD_USER_CONF ENABLE_VKBASALT PW_VKBASALT_USER_CONF PW_NO_ESYNC PW_NO_FSYNC PW_USE_RAY_TRACING \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
492 493 494 495
        PW_USE_NVAPI_AND_DLSS PW_USE_FAKE_DLSS PW_USE_FAKE_DLSS_3 PW_WINE_FULLSCREEN_FSR PW_HIDE_NVIDIA_GPU PW_VIRTUAL_DESKTOP \
        PW_USE_TERMINAL PW_GUI_DISABLED_CS PW_USE_GAMEMODE PW_USE_D3D_EXTRAS PW_FIX_VIDEO_IN_GAME PW_REDUCE_PULSE_LATENCY\
        PW_USE_US_LAYOUT PW_USE_GSTREAMER PW_FORCE_LARGE_ADDRESS_AWARE PW_USE_SHADER_CACHE PW_USE_WINE_DXGI PW_USE_EAC_AND_BE \
        PW_USE_SYSTEM_VK_LAYERS PW_USE_OBS_VKCAPTURE PW_USE_GALLIUM_ZINK PW_USE_GAMESCOPE PW_DISABLE_COMPOSITING PW_USE_RUNTIME
496
    fi
497
    if [[ "$?" == 0 ]] ; then
498
        print_info "Restarting PP after update ppdb file..."
499
        export SKIP_CHECK_UPDATES=1
castro-fidel's avatar
castro-fidel committed
500
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
501 502
        exit 0
    fi
503
    # PW_FORCE_USE_VSYNC HEAP_DELAY_FREE
castro-fidel's avatar
castro-fidel committed
504 505
}

castro-fidel's avatar
castro-fidel committed
506 507
pw_autoinstall_from_db () {
    export PW_USER_TEMP="${PORT_WINE_TMP_PATH}"
508
    export PW_FORCE_LARGE_ADDRESS_AWARE=1
castro-fidel's avatar
castro-fidel committed
509 510 511 512
    export PW_USE_GAMEMODE=0
    export PW_CHECK_AUTOINSTAL=1
    export PW_GUI_DISABLED_CS=1
    export PW_NO_WRITE_WATCH=0
513
    export PW_VULKAN_USE=1
514
    export PW_USE_EAC_AND_BE=0
castro-fidel's avatar
castro-fidel committed
515 516
    export PW_NO_FSYNC=1
    export PW_NO_ESYNC=1
castro-fidel's avatar
castro-fidel committed
517
    unset PORTWINE_CREATE_SHORTCUT_NAME
castro-fidel's avatar
castro-fidel committed
518 519
    export PW_DISABLED_CREATE_DB=1
    export PW_MANGOHUD=0
castro-fidel's avatar
castro-fidel committed
520
    export ENABLE_VKBASALT=0
castro-fidel's avatar
castro-fidel committed
521 522
    export PW_USE_D3D_EXTRAS=1
    . "${PORT_SCRIPTS_PATH}/pw_autoinstall/${PW_YAD_SET}"
castro-fidel's avatar
castro-fidel committed
523 524 525 526 527 528 529 530
}

gui_credits () {
    . "${PORT_SCRIPTS_PATH}/credits"
}
export -f gui_credits

###MAIN###
castro-fidel's avatar
castro-fidel committed
531

fidel's avatar
fidel committed
532
# CLI
castro-fidel's avatar
castro-fidel committed
533 534
case "${1}" in
    '--help' )
fidel's avatar
fidel committed
535 536
        files_from_autoinstall=$(ls "${PORT_SCRIPTS_PATH}/pw_autoinstall") 
        echo -e "
Mikhail Tergoev's avatar
Mikhail Tergoev committed
537
use: [--reinstall] [--autoinstall]
fidel's avatar
fidel committed
538 539 540 541 542 543

--reinstall                                         reinstall files of the portproton to default settings
--autoinstall [script_frome_pw_autoinstall]         autoinstall from the list below:
"
        echo ${files_from_autoinstall}
        echo ""
castro-fidel's avatar
castro-fidel committed
544 545 546 547 548
        exit 0 ;;

    '--reinstall' )
        export PW_REINSTALL_FROM_TERMINAL=1
        pw_reinstall_pp ;;
fidel's avatar
fidel committed
549 550 551 552 553

    '--autoinstall' )
        export PW_YAD_SET="$2"
        pw_autoinstall_from_db 
        exit 0 ;;
castro-fidel's avatar
castro-fidel committed
554 555
esac

castro-fidel's avatar
castro-fidel committed
556 557 558
PW_PREFIX_NAME="$(echo "${PW_PREFIX_NAME}" | sed -e s/[[:blank:]]/_/g)"
PW_ALL_PREFIXES=$(ls "${PORT_WINE_PATH}/data/prefixes/" | sed -e s/"${PW_PREFIX_NAME}$"//g)
export PW_PREFIX_NAME PW_ALL_PREFIXES
castro-fidel's avatar
castro-fidel committed
559

560
# if [[ ! -z "${PORTWINE_DB}" ]] && [[ -z `echo "${PW_PREFIX_NAME}" | grep -i "$(echo "${PORTWINE_DB}" | sed -e s/[[:blank:]]/_/g)"` ]] ; then 
castro-fidel's avatar
castro-fidel committed
561
#     export PW_PREFIX_NAME="${PW_PREFIX_NAME}!`echo "${PORTWINE_DB}" | sed -e s/[[:blank:]]/_/g`"
castro-fidel's avatar
castro-fidel committed
562 563
# fi

castro-fidel's avatar
castro-fidel committed
564
unset PW_ADD_PREFIXES_TO_GUI
castro-fidel's avatar
castro-fidel committed
565 566
IFS_OLD=$IFS
IFS=$'\n'
castro-fidel's avatar
castro-fidel committed
567
for PAIG in ${PW_ALL_PREFIXES[*]} ; do 
castro-fidel's avatar
castro-fidel committed
568
    [[ "${PAIG}" != $(echo "${PORTWINE_DB^^}" | sed -e s/[[:blank:]]/_/g) ]] && \
castro-fidel's avatar
castro-fidel committed
569
    export PW_ADD_PREFIXES_TO_GUI="${PW_ADD_PREFIXES_TO_GUI}!${PAIG}"
castro-fidel's avatar
castro-fidel committed
570 571
done
IFS=$IFS_OLD
castro-fidel's avatar
castro-fidel committed
572
export PW_ADD_PREFIXES_TO_GUI="${PW_PREFIX_NAME^^}${PW_ADD_PREFIXES_TO_GUI}"
castro-fidel's avatar
castro-fidel committed
573

574
PW_ALL_DIST=$(ls "${PORT_WINE_PATH}/data/dist/" | sed -e s/"${PW_WINE_LG_VER}$//g" | sed -e s/"${PW_PROTON_LG_VER}$//g")
Mikhail Tergoev's avatar
Mikhail Tergoev committed
575 576 577 578
if command -v wine &>/dev/null
then DIST_ADD_TO_GUI="!USE_SYSTEM_WINE"
else unset DIST_ADD_TO_GUI
fi
castro-fidel's avatar
castro-fidel committed
579
for DAIG in ${PW_ALL_DIST}
castro-fidel's avatar
castro-fidel committed
580 581 582
do
    export DIST_ADD_TO_GUI="${DIST_ADD_TO_GUI}!${DAIG}"
done
583

Boria138's avatar
Boria138 committed
584 585 586 587
# if [[ $VULKAN_API_DRIVER_VERSION == 1.[1-2].* ]]
# then check_variables PW_VULKAN_USE "1"
# else check_variables PW_VULKAN_USE "2"
# fi
588 589 590 591 592 593 594 595 596
check_nvidia_rtx && check_variables PW_VULKAN_USE "2"

case "${PW_VULKAN_USE}" in
    0) export PW_DEFAULT_VULKAN_USE="${loc_gui_open_gl}!${loc_gui_vulkan_stable}!${loc_gui_vulkan_git}!${loc_gui_gallium_nine}" ;;
    1) export PW_DEFAULT_VULKAN_USE="${loc_gui_vulkan_stable}!${loc_gui_vulkan_git}!${loc_gui_open_gl}!${loc_gui_gallium_nine}" ;;
    3) export PW_DEFAULT_VULKAN_USE="${loc_gui_gallium_nine}!${loc_gui_vulkan_stable}!${loc_gui_vulkan_git}!${loc_gui_open_gl}" ;;
    *) export PW_DEFAULT_VULKAN_USE="${loc_gui_vulkan_git}!${loc_gui_vulkan_stable}!${loc_gui_open_gl}!${loc_gui_gallium_nine}" ;;
esac

597
if [[ ! -z "${PORTWINE_DB_FILE}" ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
598
    [[ -z "${PW_COMMENT_DB}" ]] && PW_COMMENT_DB="${loc_gui_db_comments} <b>${PORTWINE_DB}</b>."
599
    if [[ ! -z $(echo "${PW_WINE_USE}" | grep "^PROTON_LG$") ]] ; then
600
        export PW_DEFAULT_WINE_USE="${PW_PROTON_LG_VER}!${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
601
    elif [[ ! -z $(echo "${PW_WINE_USE}" | grep "^PROTON_GE$") ]] ; then
602
        export PW_DEFAULT_WINE_USE="${PW_WINE_LG_VER}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
castro-fidel's avatar
castro-fidel committed
603
    else
castro-fidel's avatar
castro-fidel committed
604
        if [[ "${PW_WINE_USE}" == "${PW_PROTON_LG_VER}" ]] ; then
605 606
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE" 
        elif [[ "${PW_WINE_USE}" == "${PW_WINE_LG_VER}" ]] ; then
castro-fidel's avatar
castro-fidel committed
607
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE" 
castro-fidel's avatar
castro-fidel committed
608
        else
castro-fidel's avatar
castro-fidel committed
609
            export DIST_ADD_TO_GUI=$(echo "${DIST_ADD_TO_GUI}" | sed -e s/"\!${PW_WINE_USE}$//g")
610
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_WINE_LG_VER}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
castro-fidel's avatar
castro-fidel committed
611 612 613
        fi
    fi
else
614 615 616 617
    if [[ $PW_WINE_USE == PROTON_LG ]] ; then
        export PW_DEFAULT_WINE_USE="${PW_PROTON_LG_VER}!${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
    elif [[ $PW_WINE_USE == WINE_*_LG ]] ; then
        export PW_DEFAULT_WINE_USE="${PW_WINE_LG_VER}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
castro-fidel's avatar
castro-fidel committed
618
    else
castro-fidel's avatar
castro-fidel committed
619
        if [[ "${PW_WINE_USE}" == "${PW_PROTON_LG_VER}" ]] ; then
620 621
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE" 
        elif [[ "${PW_WINE_USE}" == "${PW_WINE_LG_VER}" ]] ; then
castro-fidel's avatar
castro-fidel committed
622
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE" 
castro-fidel's avatar
castro-fidel committed
623
        else
castro-fidel's avatar
castro-fidel committed
624
            export DIST_ADD_TO_GUI=$(echo "${DIST_ADD_TO_GUI}" | sed -e s/"\!${PW_WINE_USE}$//g")
625
            export PW_DEFAULT_WINE_USE="${PW_WINE_USE}!${PW_WINE_LG_VER}!${PW_PROTON_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
castro-fidel's avatar
castro-fidel committed
626 627
        fi     
    fi
castro-fidel's avatar
castro-fidel committed
628
    unset PW_GUI_DISABLED_CS
castro-fidel's avatar
castro-fidel committed
629
fi
630 631
if [[ -f "${portwine_exe}" ]] ; then
    if [[ "${PW_GUI_DISABLED_CS}" != 1 ]] ; then 
castro-fidel's avatar
castro-fidel committed
632
        pw_create_gui_png
castro-fidel's avatar
castro-fidel committed
633 634
        grep -il "${portwine_exe}" "${HOME}/.local/share/applications"/*.desktop
        if [[ "$?" != "0" ]] ; then
fidel's avatar
fidel committed
635
            PW_SHORTCUT="${loc_gui_create_shortcut}!$PW_GUI_ICON_PATH/separator.png!${loc_create_shortcut}:100"
castro-fidel's avatar
castro-fidel committed
636
        else
fidel's avatar
fidel committed
637
            PW_SHORTCUT="${loc_gui_delete_shortcut}!$PW_GUI_ICON_PATH/separator.png!${loc_delete_shortcut}:98"
castro-fidel's avatar
castro-fidel committed
638
        fi
639
        OUTPUT_START=$("${pw_yad}" --text-align=center --text "$PW_COMMENT_DB" --borders=${YAD_BORDERS} --form \
fidel's avatar
fidel committed
640
        --title "${portname}-${install_ver} (${scripts_install_ver})" --image "${PW_ICON_FOR_YAD}" --separator=";" --keep-icon-size \
641
        --window-icon="$PW_GUI_ICON_PATH/portproton.svg" \
castro-fidel's avatar
castro-fidel committed
642 643 644
        --field="3D API  : :CB" "${PW_DEFAULT_VULKAN_USE}" \
        --field="  WINE  : :CB" "${PW_DEFAULT_WINE_USE}" \
        --field="PREFIX  : :CBE" "${PW_ADD_PREFIXES_TO_GUI}" \
castro-fidel's avatar
castro-fidel committed
645
        --field=":LBL" "" \
fidel's avatar
fidel committed
646
        --button="${loc_gui_vkbasalt_start}"!"$PW_GUI_ICON_PATH/separator.png"!"${ENABLE_VKBASALT_INFO}":120 \
647
        --button="${loc_gui_mh_start}"!"$PW_GUI_ICON_PATH/separator.png"!"${ENABLE_MANGOHUD_INFO}":122 \
fidel's avatar
fidel committed
648
        --button="${loc_gui_edit_db_start}"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_edit_db} ${PORTWINE_DB}":118 \
castro-fidel's avatar
castro-fidel committed
649
        --button="${PW_SHORTCUT}" \
fidel's avatar
fidel committed
650
        --button="${loc_gui_debug}"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_debug}":102 \
651
        --button="${loc_gui_launch}"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_launch}":106 2>/dev/null)
castro-fidel's avatar
castro-fidel committed
652 653
        export PW_YAD_SET="$?"
        if [[ "$PW_YAD_SET" == "1" || "$PW_YAD_SET" == "252" ]] ; then exit 0 ; fi
castro-fidel's avatar
castro-fidel committed
654
        export VULKAN_MOD=$(echo "${OUTPUT_START}" | grep \;\; | awk -F";" '{print $1}')
castro-fidel's avatar
castro-fidel committed
655 656
        export PW_WINE_VER=$(echo "${OUTPUT_START}" | grep \;\; | awk -F";" '{print $2}')
        export PW_PREFIX_NAME=$(echo "${OUTPUT_START}" | grep \;\; | awk -F";" '{print $3}' | sed -e s/[[:blank:]]/_/g)
657
        if [[ -z "${PW_PREFIX_NAME}" ]] || [[ ! -z "$(echo "${PW_PREFIX_NAME}" | grep -E '^_.*' )" ]] ; then
castro-fidel's avatar
castro-fidel committed
658
            export PW_PREFIX_NAME="DEFAULT"
castro-fidel's avatar
castro-fidel committed
659
        else
castro-fidel's avatar
castro-fidel committed
660
            export PW_PREFIX_NAME="${PW_PREFIX_NAME^^}"
castro-fidel's avatar
castro-fidel committed
661
        fi
662
    elif [[ -f "${PORTWINE_DB_FILE}" ]] ; then
castro-fidel's avatar
castro-fidel committed
663 664 665 666
        portwine_launch
    fi
else
    button_click () {
667 668
        [[ ! -z "$1" ]] && echo "$1" > "${PORT_WINE_TMP_PATH}/tmp_yad_form"
        if [[ ! -z $(pidof -s yad) ]] || [[ ! -z $(pidof -s yad_v12_3) ]] ; then
669
            kill -s SIGUSR1 $(pgrep -a yad | grep "\--key=${KEY} \--notebook" | awk '{print $1}') > /dev/null 2>&1
castro-fidel's avatar
castro-fidel committed
670 671 672 673
        fi
    }
    export -f button_click

fidel's avatar
fidel committed
674
    run_desktop_b_click () {
675 676
        [[ ! -z "$1" ]] && echo "$1" > "${PORT_WINE_TMP_PATH}/tmp_yad_form"
        if [[ ! -z $(pidof -s yad) ]] || [[ ! -z $(pidof -s yad_v12_3) ]] ; then
677
            kill -s SIGUSR1 $(pgrep -a yad | grep "\--key=${KEY} \--notebook" | awk '{print $1}') > /dev/null 2>&1
fidel's avatar
fidel committed
678
        fi
679

680
        if grep -i "flatpak" /etc/os-release &>/dev/null ;
681 682 683
        then PW_EXEC_FROM_DESKTOP="$(cat "${PORT_WINE_PATH}/${PW_YAD_SET//¬/" "}" | grep Exec | head -n 1 | sed 's|flatpak run com.castrofidel.portproton|\"${PORT_SCRIPTS_PATH}/start.sh\"|' | awk -F'=' '{print $2}')"
        else PW_EXEC_FROM_DESKTOP="$(cat "${PORT_WINE_PATH}/${PW_YAD_SET//¬/" "}" | grep Exec | head -n 1 | awk -F"=env " '{print $2}')"
        fi
fidel's avatar
fidel committed
684

685
        print_info "Restarting PP after choose desktop file..."
fidel's avatar
fidel committed
686
        # stop_portwine
687
        export SKIP_CHECK_UPDATES=1
Mikhail Tergoev's avatar
Mikhail Tergoev committed
688
        /usr/bin/env bash -c "${PW_EXEC_FROM_DESKTOP}" &
689
        exit 0
fidel's avatar
fidel committed
690 691 692
    }
    export -f run_desktop_b_click

castro-fidel's avatar
castro-fidel committed
693
    gui_clear_pfx () {
694
        if yad_question "${port_clear_pfx}" ; then
castro-fidel's avatar
castro-fidel committed
695
            pw_clear_pfx
696
            print_info "Restarting PP after clearing prefix..."
697
            export SKIP_CHECK_UPDATES=1
castro-fidel's avatar
castro-fidel committed
698
            /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
699 700 701 702 703 704
            exit 0
        fi
    }
    export -f gui_clear_pfx

    gui_rm_portproton () {
705
        if yad_question "${port_del2}" ; then
castro-fidel's avatar
castro-fidel committed
706 707 708 709 710 711 712 713 714 715
            rm -fr "${PORT_WINE_PATH}"
            rm -fr "${PORT_WINE_TMP_PATH}"
            rm -fr "${HOME}/PortWINE"
            rm -f $(grep -il PortProton "${HOME}/.local/share/applications"/*)
            update-desktop-database -q "${HOME}/.local/share/applications"
        fi
        exit 0
    }
    export -f gui_rm_portproton

castro-fidel's avatar
castro-fidel committed
716
    gui_pw_update () {
castro-fidel's avatar
castro-fidel committed
717
        try_remove_file "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
718
        print_info "Restarting PP for check update..."
719
        export SKIP_CHECK_UPDATES=1
castro-fidel's avatar
castro-fidel committed
720
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
721 722 723
        exit 0
    }

Mikhail Tergoev's avatar
Mikhail Tergoev committed
724
    change_loc () {
725
        try_remove_file "${PORT_WINE_TMP_PATH}/${portname}_loc"
726
        print_info "Restarting PP for change language..."
727
        export SKIP_CHECK_UPDATES=1
Mikhail Tergoev's avatar
Mikhail Tergoev committed
728 729 730 731
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
        exit 0
    }

castro-fidel's avatar
castro-fidel committed
732 733
    gui_wine_uninstaller () {
        start_portwine
castro-fidel's avatar
castro-fidel committed
734
        pw_run uninstaller
castro-fidel's avatar
castro-fidel committed
735 736 737 738 739 740 741 742 743 744
    }
    export -f gui_wine_uninstaller

    gui_open_user_conf () {
        xdg-open "${PORT_WINE_PATH}/data/user.conf"
    }
    export -f gui_open_user_conf

    gui_open_scripts_from_backup () {
        cd "${PORT_WINE_TMP_PATH}/scripts_backup/"
745 746
        PW_SCRIPT_FROM_BACKUP=$("${pw_yad_v12_3}" --file --borders=${YAD_BORDERS} --width=650 --height=500 --auto-close \
        --window-icon="$PW_GUI_ICON_PATH/portproton.svg" --title "SCRIPTS FROM BACKUP" --file-filter="backup_scripts|scripts_v*.tar.gz" 2>/dev/null )
castro-fidel's avatar
castro-fidel committed
747 748
        YAD_STATUS="$?"
        if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then exit 0 ; fi
castro-fidel's avatar
castro-fidel committed
749
        unpack_tar_gz "$PW_SCRIPT_FROM_BACKUP" "${PORT_WINE_PATH}/data/"
castro-fidel's avatar
castro-fidel committed
750
        echo "0" > "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
751
        print_info "Restarting PP after backup..."
752
        export SKIP_CHECK_UPDATES=1
castro-fidel's avatar
castro-fidel committed
753
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
754 755 756 757
        exit 0
    }
    export -f gui_open_scripts_from_backup

fidel's avatar
fidel committed
758

Mikhail Tergoev's avatar
Mikhail Tergoev committed
759 760 761 762
    export KEY="$RANDOM"
    
    orig_IFS="$IFS" && IFS=$'\n'
    PW_ALL_DF="$(ls ${PORT_WINE_PATH}/ | grep .desktop | grep -vE '(PortProton|readme)')"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
763 764 765 766 767 768 769 770
    if [[ -z "${PW_ALL_DF}" ]]
    then PW_GUI_SORT_TABS=(1 2 3 4 5)
    else PW_GUI_SORT_TABS=(2 3 4 5 1)
    fi  
    PW_GENERATE_BUTTONS="--field=   $loc_create_shortcut_from_gui!${PW_GUI_ICON_PATH}/find_48.png!:FBTN%@bash -c \"button_click pw_find_exe\"%"
    for PW_DESKTOP_FILES in ${PW_ALL_DF} ; do
        PW_NAME_D_ICON="$(cat "${PORT_WINE_PATH}/${PW_DESKTOP_FILES}" | grep Icon | awk -F= '{print $2}')"
        PW_NAME_D_ICON_48="${PW_NAME_D_ICON//".png"/"_48.png"}"
Boria138's avatar
Boria138 committed
771
        if [[ ! -f "${PW_NAME_D_ICON_48}" ]]  && [[ -f "${PW_NAME_D_ICON}" ]] && [[ -x "`command -v "convert" 2>/dev/null`" ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
772 773 774 775
            convert "${PW_NAME_D_ICON}" -resize 48x48 "${PW_NAME_D_ICON_48}" 
        fi
        PW_GENERATE_BUTTONS+="--field=   ${PW_DESKTOP_FILES//".desktop"/""}!${PW_NAME_D_ICON_48}!:FBTN%@bash -c \"run_desktop_b_click "${PW_DESKTOP_FILES//" "}"\"%"
    done
776

Mikhail Tergoev's avatar
Mikhail Tergoev committed
777
    IFS="$orig_IFS"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
778
    old_IFS=$IFS && IFS="%"
779
    "${pw_yad_v12_3}" --plug=$KEY --tabnum=${PW_GUI_SORT_TABS[4]} --form --columns=3 --align-buttons --keep-icon-size --scroll --separator=" " ${PW_GENERATE_BUTTONS} 2>/dev/null &
Mikhail Tergoev's avatar
Mikhail Tergoev committed
780 781
    IFS="$orig_IFS"

782
    "${pw_yad_v12_3}" --plug=${KEY} --tabnum=${PW_GUI_SORT_TABS[3]} --form --columns=3 --align-buttons --keep-icon-size --separator=";" \
fidel's avatar
fidel committed
783 784 785 786 787 788 789 790
    --field="   $loc_gui_pw_reinstall_pp"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_pw_reinstall_pp"' \
    --field="   $loc_gui_rm_pp"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_rm_portproton"' \
    --field="   $loc_gui_upd_pp"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_pw_update"' \
    --field="   $loc_gui_changelog"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click open_changelog"' \
    --field="   $loc_gui_change_loc"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click change_loc"' \
    --field="   $loc_gui_edit_usc"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_open_user_conf"' \
    --field="   $loc_gui_scripts_fb"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_open_scripts_from_backup"' \
    --field="   Xterm"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click pw_start_cont_xterm"' \
791
    --field="   $loc_gui_credits"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_credits"'  2>/dev/null &
fidel's avatar
fidel committed
792

793
    "${pw_yad_v12_3}" --plug=${KEY} --tabnum=${PW_GUI_SORT_TABS[2]} --form --columns=3 --align-buttons --keep-icon-size --separator=";" \
794
    --field="  3D API  : :CB" "${PW_DEFAULT_VULKAN_USE}" \
castro-fidel's avatar
castro-fidel committed
795 796
    --field="  PREFIX  : :CBE" "${PW_ADD_PREFIXES_TO_GUI}" \
    --field="  WINE    : :CB" "${PW_DEFAULT_WINE_USE}" \
797 798 799 800 801
    --field="              $loc_gui_create_pfx_backup"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click pw_create_prefix_backup"' \
    --field="   WINETRICKS"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winetricks}":"FBTN" '@bash -c "button_click WINETRICKS"' \
    --field="   $loc_gui_clear_pfx"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_clear_pfx}":"FBTN" '@bash -c "button_click gui_clear_pfx"' \
    --field="   $loc_gui_download_other_wine"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_download_other_wine}":"FBTN" '@bash -c "button_click gui_proton_downloader"' \
    --field="   $loc_gui_wine_uninstaller"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_wineuninstaller}":"FBTN" '@bash -c "button_click gui_wine_uninstaller"' \
802
    --field="   $loc_gui_wine_cfg     "!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winecfg}":"FBTN" '@bash -c "button_click WINECFG"' \
803 804 805
    --field="   $loc_gui_wine_file"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winefile}":"FBTN" '@bash -c "button_click WINEFILE"' \
    --field="   $loc_gui_wine_cmd"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winecmd}":"FBTN" '@bash -c "button_click WINECMD"' \
    --field="   $loc_gui_wine_reg"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winereg}":"FBTN" '@bash -c "button_click WINEREG"' 2>/dev/null 1> "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan" &
castro-fidel's avatar
castro-fidel committed
806

807
    "${pw_yad_v12_3}" --plug=$KEY --tabnum=${PW_GUI_SORT_TABS[1]} --form --columns=3 --align-buttons --keep-icon-size --scroll  \
Akai's avatar
Akai committed
808 809 810 811 812 813 814 815 816 817 818 819 820
    --field="   Dolphin 5.0"!"$PW_GUI_ICON_PATH/dolphin.png"!"${loc_dolphin}":"FBTN" '@bash -c "button_click PW_DOLPHIN"' \
    --field="   MAME"!"$PW_GUI_ICON_PATH/mame.png"!"${loc_mame}":"FBTN" '@bash -c "button_click PW_MAME"' \
    --field="   RetroArch"!"$PW_GUI_ICON_PATH/retroarch.png"!"${loc_retroarch}":"FBTN" '@bash -c "button_click PW_RETROARCH"' \
    --field="   PPSSPP Windows"!"$PW_GUI_ICON_PATH/ppsspp.png"!"${loc_ppsspp_windows}":"FBTN" '@bash -c "button_click PW_PPSSPP"' \
    --field="   Citra"!"$PW_GUI_ICON_PATH/citra.png"!"${loc_citra}":"FBTN" '@bash -c "button_click PW_CITRA"' \
    --field="   Cemu"!"$PW_GUI_ICON_PATH/cemu.png"!"${loc_cemu}":"FBTN" '@bash -c "button_click PW_CEMU"' \
    --field="   ePSXe"!"$PW_GUI_ICON_PATH/epsxe.png"!"${loc_epsxe}":"FBTN" '@bash -c "button_click PW_EPSXE"' \
    --field="   Project64"!"$PW_GUI_ICON_PATH/project64.png"!"${loc_project64}":"FBTN" '@bash -c "button_click PW_PROJECT64"' \
    --field="   VBA-M"!"$PW_GUI_ICON_PATH/vba-m.png"!"${loc_vba_m}":"FBTN" '@bash -c "button_click PW_VBA-M"' \
    --field="   Yabause"!"$PW_GUI_ICON_PATH/yabause.png"!"${loc_yabause}":"FBTN" '@bash -c "button_click PW_YABAUSE"' \
    --field="   Xenia"!"$PW_GUI_ICON_PATH/xenia.png"!"${loc_xenia}":"FBTN" '@bash -c "button_click PW_XENIA"' \
    --field="   FCEUX"!"$PW_GUI_ICON_PATH/fceux.png"!"${loc_fceux}":"FBTN" '@bash -c "button_click PW_FCEUX"' \
    --field="   xemu"!"$PW_GUI_ICON_PATH/xemu.png"!"${loc_xemu}":"FBTN" '@bash -c "button_click PW_XEMU"' \
821
    --field="   Demul"!"$PW_GUI_ICON_PATH/demul.png"!"${loc_demul}":"FBTN" '@bash -c "button_click PW_DEMUL"' 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
822

823
    "${pw_yad_v12_3}" --plug=$KEY --tabnum=${PW_GUI_SORT_TABS[0]} --form --columns=3 --align-buttons --keep-icon-size --scroll \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
824 825
    --field="   Lesta Game Center"!"$PW_GUI_ICON_PATH/lgc.png"!"":"FBTN" '@bash -c "button_click PW_LGC"' \
    --field="   vkPlay Games Center"!"$PW_GUI_ICON_PATH/mygames.png"!"":"FBTN" '@bash -c "button_click PW_VKPLAY"' \
castro-fidel's avatar
castro-fidel committed
826 827 828 829 830 831 832 833
    --field="   Battle.net Launcher"!"$PW_GUI_ICON_PATH/battle_net.png"!"":"FBTN" '@bash -c "button_click PW_BATTLE_NET"' \
    --field="   Epic Games Launcher"!"$PW_GUI_ICON_PATH/epicgames.png"!"":"FBTN" '@bash -c "button_click PW_EPIC"' \
    --field="   GoG Galaxy Launcher"!"$PW_GUI_ICON_PATH/gog.png"!"":"FBTN" '@bash -c "button_click PW_GOG"' \
    --field="   Ubisoft Game Launcher"!"$PW_GUI_ICON_PATH/ubc.png"!"":"FBTN" '@bash -c "button_click PW_UBC"' \
    --field="   EVE Online Launcher"!"$PW_GUI_ICON_PATH/eve.png"!"":"FBTN" '@bash -c "button_click PW_EVE"' \
    --field="   Rockstar Games Launcher"!"$PW_GUI_ICON_PATH/Rockstar.png"!"":"FBTN" '@bash -c "button_click PW_ROCKSTAR"' \
    --field="   League of Legends"!"$PW_GUI_ICON_PATH/lol.png"!"":"FBTN" '@bash -c "button_click PW_LOL"' \
    --field="   Gameforge Client"!"$PW_GUI_ICON_PATH/gameforge.png"!"":"FBTN" '@bash -c "button_click  PW_GAMEFORGE"' \
834
    --field="   World of Sea Battle (x64)"!"$PW_GUI_ICON_PATH/wosb.png"!"":"FBTN" '@bash -c "button_click PW_WOSB"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
835
    --field="   CALIBER"!"$PW_GUI_ICON_PATH/caliber.png"!"":"FBTN" '@bash -c "button_click PW_CALIBER"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
836
    --field="   Crossout"!"$PW_GUI_ICON_PATH/crossout.png"!"":"FBTN" '@bash -c "button_click PW_CROSSOUT"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
837
    --field="   Warframe"!"$PW_GUI_ICON_PATH/warframe.png"!"":"FBTN" '@bash -c "button_click PW_WARFRAME"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
838
    --field="   Panzar"!"$PW_GUI_ICON_PATH/panzar.png"!"":"FBTN" '@bash -c "button_click PW_PANZAR"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
839
    --field="   STALCRAFT"!"$PW_GUI_ICON_PATH/stalcraft.png"!"":"FBTN" '@bash -c "button_click PW_STALCRAFT"' \
840 841
    --field="   CONTRACT WARS"!"$PW_GUI_ICON_PATH/cwc.png"!"":"FBTN" '@bash -c "button_click PW_CWC"' \
    --field="   Stalker Online"!"$PW_GUI_ICON_PATH/so.png"!"":"FBTN" '@bash -c "button_click PW_SO"' \
valokardin's avatar
valokardin committed
842
    --field="   Modern Warships"!"$PW_GUI_ICON_PATH/mw.png"!"":"FBTN" '@bash -c "button_click PW_MW"' \
843 844
    --field="   Metal War Online"!"$PW_GUI_ICON_PATH/mwo.png"!"":"FBTN" '@bash -c "button_click PW_MWO"' \
    --field="   Ankama Launcher"!"$PW_GUI_ICON_PATH/ankama.png"!"":"FBTN" '@bash -c "button_click PW_ANKAMA"' \
845
    --field="   Indiegala Client"!"$PW_GUI_ICON_PATH/igclient.png"!"":"FBTN" '@bash -c "button_click PW_IGCLIENT"' \
846
    --field="   Plarium Play"!"$PW_GUI_ICON_PATH/plariumplay.png"!"":"FBTN" '@bash -c "button_click PW_PLARIUM_PLAY"' \
847 848 849 850
    --field="   Wargaming Game Center"!"$PW_GUI_ICON_PATH/wgc.png"!"":"FBTN" '@bash -c "button_click PW_WGC"' \
    --field="   OSU"!"$PW_GUI_ICON_PATH/osu.png"!"":"FBTN" '@bash -c "button_click PW_OSU"' \
    --field="   ITCH.IO"!"$PW_GUI_ICON_PATH/itch.png"!"":"FBTN" '@bash -c "button_click PW_ITCH"' \
    --field="   Steam (unstable)"!"$PW_GUI_ICON_PATH/steam.png"!"":"FBTN" '@bash -c "button_click PW_STEAM"' \
851
    --field="   Path of Exile"!"$PW_GUI_ICON_PATH/poe.png"!"":"FBTN" '@bash -c "button_click PW_POE"' \
852
    --field="   Guild Wars 2"!"$PW_GUI_ICON_PATH/gw2.png"!"":"FBTN" '@bash -c "button_click PW_GUILD_WARS_2"' \
Boria138's avatar
Boria138 committed
853
    --field="   Genshin Impact"!"$PW_GUI_ICON_PATH/genshinimpact.png"!"":"FBTN" '@bash -c "button_click PW_GENSHIN_IMPACT"' \
854
    --field="   EA App (TEST)"!"$PW_GUI_ICON_PATH/eaapp.png"!"":"FBTN" '@bash -c "button_click PW_EAAPP"' \
855
    --field="   Battle Of Space Raiders"!"$PW_GUI_ICON_PATH/bsr.png"!"":"FBTN" '@bash -c "button_click PW_BSR"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
856 857
    --field="   Black Desert Online (RU)"!"$PW_GUI_ICON_PATH/bdo.png"!"":"FBTN" '@bash -c "button_click PW_BDO"' \
    --field="   Pulse Online"!"$PW_GUI_ICON_PATH/pulseonline.png"!"":"FBTN" '@bash -c "button_click PW_PULSE_ONLINE"' 2>/dev/null &
858

Mikhail Tergoev's avatar
Mikhail Tergoev committed
859
    # --field="   Secret World Legends (ENG)"!"$PW_GUI_ICON_PATH/swl.png"!"":"FBTN" '@bash -c "button_click PW_SWL"'
castro-fidel's avatar
castro-fidel committed
860
    # --field="   Bethesda.net Launcher"!"$PW_GUI_ICON_PATH/bethesda.png"!"":"FBTN" '@bash -c "button_click PW_BETHESDA"'
861
    # --field="   ROBLOX"!"$PW_GUI_ICON_PATH/roblox.png"!"":"FBTN" '@bash -c "button_click PW_ROBLOX"'
castro-fidel's avatar
castro-fidel committed
862

863 864 865 866 867 868 869 870 871 872
    # if command -v wmctrl &>/dev/null ; then
    #     sleep 2
    #     while [[ -n $(pgrep -a yad_v12_3 | head -n 1 | awk '{print $1}' 2>/dev/null) ]] ; do
    #         sleep 2
    #         PW_MAIN_GUI_SIZE_TMP="$(wmctrl -lG | grep "PortProton-${install_ver}" | awk '{print $5" "$6}' 2>/dev/null)"
    #         if [[ ! -z "${PW_MAIN_GUI_SIZE_TMP}" ]] ; then
    #             echo "${PW_MAIN_GUI_SIZE_TMP}" > "${PORT_WINE_TMP_PATH}/tmp_main_gui_size"
    #         fi
    #     done
    # fi &
Mikhail Tergoev's avatar
Mikhail Tergoev committed
873

874 875
    export START_FROM_PP_GUI=1

Mikhail Tergoev's avatar
Mikhail Tergoev committed
876
    if [[ -z "${PW_ALL_DF}" ]] ; then
877 878
        "${pw_yad_v12_3}" --key=$KEY --notebook --borders=${YAD_BORDERS} --width="${PW_MAIN_SIZE_W}" --height="${PW_MAIN_SIZE_H}" --no-buttons --auto-close \
        --window-icon="$PW_GUI_ICON_PATH/portproton.svg" --title "${portname}-${install_ver} (${scripts_install_ver})" \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
879 880 881 882 883
        --tab-pos=bottom --keep-icon-size \
        --tab="$loc_mg_autoinstall"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_emulators"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_wine_settings"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_portproton_settings"!"$PW_GUI_ICON_PATH/separator.png"!"" \
884
        --tab="$loc_mg_installed"!"$PW_GUI_ICON_PATH/separator.png"!"" 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
885 886
        YAD_STATUS="$?"
    else
887 888
        "${pw_yad_v12_3}" --key=$KEY --notebook --borders=${YAD_BORDERS} --width="${PW_MAIN_SIZE_W}" --height="${PW_MAIN_SIZE_H}" --no-buttons --auto-close \
        --window-icon="$PW_GUI_ICON_PATH/portproton.svg" --title "${portname}-${install_ver} (${scripts_install_ver})" \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
889 890 891 892 893
        --tab-pos=bottom --keep-icon-size \
        --tab="$loc_mg_installed"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_autoinstall"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_emulators"!"$PW_GUI_ICON_PATH/separator.png"!"" \
        --tab="$loc_mg_wine_settings"!"$PW_GUI_ICON_PATH/separator.png"!"" \
894
        --tab="$loc_mg_portproton_settings"!"$PW_GUI_ICON_PATH/separator.png"!"" 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
895 896
        YAD_STATUS="$?"
    fi
Mikhail Tergoev's avatar
Mikhail Tergoev committed
897

castro-fidel's avatar
castro-fidel committed
898 899 900
    if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then exit 0 ; fi

    if [[ -f "${PORT_WINE_TMP_PATH}/tmp_yad_form" ]]; then
castro-fidel's avatar
castro-fidel committed
901
        export PW_YAD_SET=$(cat "${PORT_WINE_TMP_PATH}/tmp_yad_form" | head -n 1 | awk '{print $1}')
castro-fidel's avatar
castro-fidel committed
902 903 904
    fi
    if [[ -f "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan" ]] ; then
        export VULKAN_MOD=$(cat "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan" | grep \;\;  | awk -F";" '{print $1}')
castro-fidel's avatar
castro-fidel committed
905 906
        export PW_PREFIX_NAME=$(cat "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan" | grep \;\;  | awk -F";" '{print $2}' | sed -e "s/[[:blank:]]/_/g" )
        export PW_WINE_VER=$(cat "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan" | grep \;\; | awk -F";" '{print $3}')
907
        if [[ -z "${PW_PREFIX_NAME}" ]] || [[ ! -z "$(echo "${PW_PREFIX_NAME}" | grep -E '^_.*' )" ]] ; then
castro-fidel's avatar
castro-fidel committed
908
            export PW_PREFIX_NAME="DEFAULT"
castro-fidel's avatar
castro-fidel committed
909
        else
castro-fidel's avatar
castro-fidel committed
910
            export PW_PREFIX_NAME="${PW_PREFIX_NAME^^}"
castro-fidel's avatar
castro-fidel committed
911 912 913
        fi
        try_remove_file "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan"
    fi
castro-fidel's avatar
castro-fidel committed
914
    export PW_DISABLED_CREATE_DB=1
castro-fidel's avatar
castro-fidel committed
915 916
fi

Mikhail Tergoev's avatar
Mikhail Tergoev committed
917 918 919 920 921 922
case "${VULKAN_MOD}" in
    "${loc_gui_open_gl}" )          export PW_VULKAN_USE="0" ;;
    "${loc_gui_vulkan_stable}" )    export PW_VULKAN_USE="1" ;;
    "${loc_gui_vulkan_git}" )       export PW_VULKAN_USE="2" ;;
    "${loc_gui_gallium_nine}" )     export PW_VULKAN_USE="3" ;;
esac
castro-fidel's avatar
castro-fidel committed
923 924 925

init_wine_ver

926
if [[ "${PW_DISABLED_CREATE_DB}" != 1 ]] ; then
927
    if [[ ! -z "${PORTWINE_DB}" ]] && [[ -z "${PORTWINE_DB_FILE}" ]] ; then
castro-fidel's avatar
castro-fidel committed
928 929 930 931 932 933 934 935 936 937
        PORTWINE_DB_FILE=$(grep -il "\#${PORTWINE_DB}.exe" "${PORT_SCRIPTS_PATH}/portwine_db"/*)
        if [[ -z "${PORTWINE_DB_FILE}" ]] ; then
            echo "#!/usr/bin/env bash"  > "${portwine_exe}".ppdb
            echo "#Author: "${USER}"" >> "${portwine_exe}".ppdb
            echo "#"${PORTWINE_DB}.exe"" >> "${portwine_exe}".ppdb
            echo "#Rating=1-5" >> "${portwine_exe}".ppdb
            cat "${PORT_SCRIPTS_PATH}/portwine_db/default" | grep "##" >> "${portwine_exe}".ppdb
            export PORTWINE_DB_FILE="${portwine_exe}".ppdb
        fi
    fi
castro-fidel's avatar
castro-fidel committed
938
    edit_db_from_gui PW_VULKAN_USE PW_WINE_USE PW_PREFIX_NAME 
castro-fidel's avatar
castro-fidel committed
939 940
fi

941
[ ! -z "$PW_YAD_SET" ] && case "$PW_YAD_SET" in
castro-fidel's avatar
castro-fidel committed
942 943 944 945
    98) portwine_delete_shortcut ;;
    100) portwine_create_shortcut ;;
    DEBUG|102) portwine_start_debug ;;
    106) portwine_launch ;;
castro-fidel's avatar
castro-fidel committed
946 947 948 949 950 951
    WINECFG|108) pw_winecfg ;;
    WINEFILE|110) pw_winefile ;;
    WINECMD|112) pw_winecmd ;;
    WINEREG|114) pw_winereg ;;
    WINETRICKS|116) pw_prefix_manager ;;
    118) pw_edit_db ;;
castro-fidel's avatar
castro-fidel committed
952 953 954 955
    gui_clear_pfx) gui_clear_pfx ;;
    gui_open_user_conf) gui_open_user_conf ;;
    gui_wine_uninstaller) gui_wine_uninstaller ;;
    gui_rm_portproton) gui_rm_portproton ;;
castro-fidel's avatar
castro-fidel committed
956
    gui_pw_reinstall_pp) pw_reinstall_pp ;;
castro-fidel's avatar
castro-fidel committed
957
    gui_pw_update) gui_pw_update ;;
castro-fidel's avatar
castro-fidel committed
958 959 960
    gui_proton_downloader) gui_proton_downloader ;;
    gui_open_scripts_from_backup) gui_open_scripts_from_backup ;;
    open_changelog) open_changelog ;;
Mikhail Tergoev's avatar
Mikhail Tergoev committed
961
    change_loc) change_loc ;;
castro-fidel's avatar
castro-fidel committed
962
    120) gui_vkBasalt ;;
963
    122) gui_MangoHud ;;
castro-fidel's avatar
castro-fidel committed
964
    pw_create_prefix_backup) pw_create_prefix_backup ;;
castro-fidel's avatar
castro-fidel committed
965
    gui_credits) gui_credits ;;
castro-fidel's avatar
castro-fidel committed
966
    pw_start_cont_xterm) pw_start_cont_xterm ;;
Mikhail Tergoev's avatar
Mikhail Tergoev committed
967
    pw_find_exe) pw_find_exe ;;
castro-fidel's avatar
castro-fidel committed
968
    PW_*) pw_autoinstall_from_db ;;
Mikhail Tergoev's avatar
Mikhail Tergoev committed
969 970
    *.desktop) run_desktop_b_click ;;
    1|252|*) exit 0 ;;
castro-fidel's avatar
castro-fidel committed
971 972 973
esac

stop_portwine