start.sh 48 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

castro-fidel's avatar
castro-fidel committed
4
export NO_AT_BRIDGE=1
castro-fidel's avatar
castro-fidel committed
5
export pw_full_command_line=("$0" $*)
castro-fidel's avatar
castro-fidel committed
6 7 8 9 10
if [ -f "$1" ]; then
    export portwine_exe="$(readlink -f "$1")"
fi
. "$(dirname $(readlink -f "$0"))/runlib"
kill_portwine
11
killall -15 yad_v12_3 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
12
kill -TERM `pgrep -a yad | grep ${portname} | head -n 1 | awk '{print $1}'` 2>/dev/null
castro-fidel's avatar
castro-fidel committed
13 14 15 16 17 18 19

if [[ -f "/usr/bin/portproton" ]] && [[ -f "${HOME}/.local/share/applications/PortProton.desktop" ]] ; then
    /usr/bin/env bash "/usr/bin/portproton" "$@" & 
    exit 0
fi

if [[ "${XDG_SESSION_TYPE}" = "wayland" ]] && [[ ! -f "${PORT_WINE_TMP_PATH}/check_wayland" ]]; then
castro-fidel's avatar
castro-fidel committed
20
    zenity_info "$PW_WAYLAND_INFO"
castro-fidel's avatar
castro-fidel committed
21 22 23
    echo "1" > "${PORT_WINE_TMP_PATH}/check_wayland"
fi

24
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
25 26 27
    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
28 29
    export PW_MAIN_SIZE_W="1100"
    export PW_MAIN_SIZE_H="300"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
30 31
fi    

32
if [[ ! -z $(basename "${portwine_exe}" | grep .ppack) ]] ; then
castro-fidel's avatar
castro-fidel committed
33 34 35 36 37
    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}')
    ${pw_runtime} 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
38 39
    sleep 10
    while true ; do
40
        if [[ ! -z $(pgrep -a xterm | grep ".ppack" | head -n 1 | awk '{print $1}') ]] ; then
castro-fidel's avatar
castro-fidel committed
41 42 43 44 45 46 47 48 49 50
            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
51
    if [[ -f "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/.create_shortcut" ]] ; then
castro-fidel's avatar
castro-fidel committed
52 53
        orig_IFS="$IFS"
        IFS=$'\n'
castro-fidel's avatar
castro-fidel committed
54 55 56
        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
57 58 59 60 61 62 63 64 65 66
        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)
67
    if [[ ! -z "${PW_VIRTUAL_DESKTOP}" && "${PW_VIRTUAL_DESKTOP}" == "1" ]] ; then
castro-fidel's avatar
castro-fidel committed
68
        pw_screen_resolution=$(xrandr --current | grep "*" | awk '{print $1;}' | head -1)
castro-fidel's avatar
castro-fidel committed
69
        pw_run explorer "/desktop=PortProton,${pw_screen_resolution}" ${WINE_WIN_START} "$portwine_exe"
70
    elif [ ! -z "${PORTWINE_MSI}" ]; then
castro-fidel's avatar
castro-fidel committed
71
        pw_run msiexec /i "$portwine_exe"
72
    elif [[ ! -z "${PORTWINE_BAT}" || -n "${portwine_exe}" ]] ; then
castro-fidel's avatar
castro-fidel committed
73
        pw_run ${WINE_WIN_START} "$portwine_exe"
castro-fidel's avatar
castro-fidel committed
74
    else
castro-fidel's avatar
castro-fidel committed
75
        pw_run winefile
castro-fidel's avatar
castro-fidel committed
76 77 78 79 80
    fi
}

portwine_start_debug () {
    kill_portwine
castro-fidel's avatar
castro-fidel committed
81 82
    export PW_LOG=1
    export PW_WINEDBG_DISABLE=0
castro-fidel's avatar
castro-fidel committed
83 84 85 86 87 88 89 90 91 92
    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
93
    if [ "${PW_USE_RUNTIME}" = 0 ] ; then
castro-fidel's avatar
castro-fidel committed
94 95 96 97 98
        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"
99
    if [ ! -z "${portwine_exe}" ] ; then
castro-fidel's avatar
castro-fidel committed
100 101 102 103 104 105 106
        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
107
    if [[ "${PW_VULKAN_USE}" = "0" ]] ; then 
Mikhail Tergoev's avatar
Mikhail Tergoev committed
108
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - DX9-11 to ${loc_gui_open_gl}" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
109 110
    elif [[ "${PW_VULKAN_USE}" = "3" ]] ; then 
        echo "PW_VULKAN_USE=${PW_VULKAN_USE} - native DX9 on MESA drivers" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
111
    else 
castro-fidel's avatar
castro-fidel committed
112
        echo "PW_VULKAN_USE=${PW_VULKAN_USE}" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
113 114 115
    fi
    echo "--------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Version WINE in the Port:" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
116
    print_var PW_WINE_USE >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
117 118 119 120 121 122 123 124 125
    [ -f "${WINEDIR}/version" ] && cat "${WINEDIR}/version" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "------------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    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"
    echo "----------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Operating system" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
126
    cat /etc/os-release | grep -oP 'PRETTY_NAME="\K[^"]+' >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
    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"
    echo "--------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Kernel" >> "${PORT_WINE_PATH}/${portname}.log"
    uname -r >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "CPU" >> "${PORT_WINE_PATH}/${portname}.log"
    cat /proc/cpuinfo | grep "model name" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "------------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "RAM" >> "${PORT_WINE_PATH}/${portname}.log"
    free -m >> "${PORT_WINE_PATH}/${portname}.log"
    echo "-----------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Graphic cards and drivers:" >> "${PORT_WINE_PATH}/${portname}.log"
143 144
    echo 'lspci | grep VGA:' >> "${PORT_WINE_PATH}/${portname}.log"
    echo $LSPCI_VGA >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
145
    [[ `command -v glxinfo` ]] && glxinfo -B >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
146 147
    echo " " >> "${PORT_WINE_PATH}/${portname}.log"
    echo "inxi -G:" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
148
    "${PW_WINELIB}/portable/bin/inxi" -G >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
149 150
    echo "----------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
    echo "Vulkan info device name:" >> "${PORT_WINE_PATH}/${portname}.log"
Boria138's avatar
Boria138 committed
151
    [[ `command -v vulkaninfo` ]] && vulkaninfo | grep deviceName >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
152
    "${PW_WINELIB}/portable/bin/vkcube" --c 50
castro-fidel's avatar
castro-fidel committed
153 154 155 156 157
    if [ $? -eq 0 ]; then
        echo "Vulkan cube test passed successfully" >> "${PORT_WINE_PATH}/${portname}.log"
    else
        echo "Vkcube test completed with error" >> "${PORT_WINE_PATH}/${portname}.log"
    fi
Boria138's avatar
Boria138 committed
158
    if [ ! -x "$(command -v gamemoderun 2>/dev/null)" ]
castro-fidel's avatar
castro-fidel committed
159 160 161 162 163
    then
        echo "---------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
        echo "!!!gamemod not found!!!"  >> "${PORT_WINE_PATH}/${portname}.log"
    fi
    echo "-------------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
castro-fidel's avatar
castro-fidel committed
164
    if [[ "${PW_USE_D3D_EXTRAS}" != 1 ]]
castro-fidel's avatar
castro-fidel committed
165 166 167 168 169
    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
170
    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
171
    echo "-----------------------------------------" >> "${PORT_WINE_PATH}/${portname}.log"
172
    if [ ! -z "${PORTWINE_DB_FILE}" ]; then
castro-fidel's avatar
castro-fidel committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
        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
189 190
    pw_stop_progress_bar_cover
    unset PW_TIMER
191
    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
192
            sleep 0.005
193
            if [[ ! -z "${line}" ]] && [[ -z "$(echo "${line}" | grep -i "kerberos")" ]] \
castro-fidel's avatar
castro-fidel committed
194 195 196 197
                                    && [[ -z "$(echo "${line}" | grep -i "ntlm")" ]]
            then
                echo "# ${line}"
            fi
castro-fidel's avatar
castro-fidel committed
198
            if [[ "${PW_TIMER}" != 1 ]] ; then
castro-fidel's avatar
castro-fidel committed
199
                sleep 3
castro-fidel's avatar
castro-fidel committed
200
                PW_TIMER=1
castro-fidel's avatar
castro-fidel committed
201
            fi
202
    done < "${PORT_WINE_PATH}/${portname}.log" | "${pw_yad_v12_3}" --text-info --tail --button="STOP":0 --title="DEBUG" \
203
    --skip-taskbar --width=800 --height=400 --text "${port_debug}" 2>/dev/null &&
castro-fidel's avatar
castro-fidel committed
204 205 206 207 208 209 210 211 212
    kill_portwine
#    sleep 1 && zenity --info --title "DEBUG" --text "${port_debug}" --no-wrap &> /dev/null && kill_portwine
    sed -i '/.fx$/d' "${PORT_WINE_PATH}/${portname}.log"
    sed -i '/kerberos/d' "${PORT_WINE_PATH}/${portname}.log"
    sed -i '/ntlm/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"
    deb_text=$(cat "${PORT_WINE_PATH}/${portname}.log"  | awk '! a[$0]++') 
    echo "$deb_text" > "${PORT_WINE_PATH}/${portname}.log"
213
    "$pw_yad" --title="${portname}.log" --borders=3 --no-buttons --text-align=center \
214
    --text-info --show-uri --wrap --width=1200 --height=550  --uri-color=red \
castro-fidel's avatar
castro-fidel committed
215 216 217 218
    --filename="${PORT_WINE_PATH}/${portname}.log"
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
219
pw_winecfg () {
castro-fidel's avatar
castro-fidel committed
220
    start_portwine
castro-fidel's avatar
castro-fidel committed
221
    pw_run winecfg
castro-fidel's avatar
castro-fidel committed
222 223
}

castro-fidel's avatar
castro-fidel committed
224
pw_winefile () {
castro-fidel's avatar
castro-fidel committed
225
    start_portwine
castro-fidel's avatar
castro-fidel committed
226
    pw_run winefile
castro-fidel's avatar
castro-fidel committed
227 228
}

castro-fidel's avatar
castro-fidel committed
229 230
pw_winecmd () {
    export PW_USE_TERMINAL=1
castro-fidel's avatar
castro-fidel committed
231
    start_portwine
castro-fidel's avatar
castro-fidel committed
232 233
    cd "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/drive_c"
    ${pw_runtime} env LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" xterm -e "${WINELOADER}" cmd
castro-fidel's avatar
castro-fidel committed
234 235 236
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
237
pw_winereg () {
castro-fidel's avatar
castro-fidel committed
238
    start_portwine
castro-fidel's avatar
castro-fidel committed
239
    pw_run regedit
castro-fidel's avatar
castro-fidel committed
240 241
}

castro-fidel's avatar
castro-fidel committed
242
pw_prefix_manager () {
castro-fidel's avatar
castro-fidel committed
243 244
    update_winetricks
    start_portwine
castro-fidel's avatar
castro-fidel committed
245 246
    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
247 248
    fi

castro-fidel's avatar
castro-fidel committed
249
    pw_start_progress_bar_block "Starting prefix manager..."
castro-fidel's avatar
castro-fidel committed
250 251 252
    "${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
253
    pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
254 255

    gui_prefix_manager () {
castro-fidel's avatar
castro-fidel committed
256
        pw_start_progress_bar_block "Starting prefix manager..."
castro-fidel's avatar
castro-fidel committed
257 258 259 260
        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
261 262 263 264
        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
265
                else
castro-fidel's avatar
castro-fidel committed
266
                    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
267 268 269 270
                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
271 272 273 274
        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
275
                else
castro-fidel's avatar
castro-fidel committed
276
                    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
277 278 279 280
                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
281 282 283 284
        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
285
                else
castro-fidel's avatar
castro-fidel committed
286
                    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
287 288 289
                fi
            fi
        done < "${PORT_WINE_TMP_PATH}/settings_list"
castro-fidel's avatar
castro-fidel committed
290
        pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
291 292

        KEY_EDIT_MANAGER_GUI=$RANDOM
293
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=1 --list --checklist \
castro-fidel's avatar
castro-fidel committed
294
        --text="Select components to install in prefix: <b>\"${PW_PREFIX_NAME}\"</b>, using wine: <b>\"${PW_WINE_USE}\"</b>" \
295
        --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
296

297
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=2 --list --checklist \
castro-fidel's avatar
castro-fidel committed
298
        --text="Select fonts to install in prefix: <b>\"${PW_PREFIX_NAME}\"</b>, using wine: <b>\"${PW_WINE_USE}\"</b>" \
299
        --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
300

301
        "${pw_yad_v12_3}" --plug=$KEY_EDIT_MANAGER_GUI --tabnum=3 --list --checklist \
castro-fidel's avatar
castro-fidel committed
302
        --text="Change config for prefix: <b>\"${PW_PREFIX_NAME}\"</b>" \
303
        --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
304

305
        "${pw_yad_v12_3}" --key=$KEY_EDIT_MANAGER_GUI --notebook --borders=3 --width=900 --height=800 \
306
        --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "PREFIX MANAGER..." --tab-pos=bottom --tab="DLL" --tab="FONTS" --tab="SETTINGS" 2>/dev/null
castro-fidel's avatar
castro-fidel committed
307 308 309 310 311 312 313 314 315 316
        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
317
            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
318
            if [ "$?" == "1" ] ; then
319
                [[ ! -z "${STPFXMNG}" ]] && SET_FROM_PFX_MANAGER+="$(echo "${STPFXMNG}" | awk -F'|' '{print $2}') "
castro-fidel's avatar
castro-fidel committed
320 321 322 323 324
            fi
        done
        IFS=${old_IFS}
        try_remove_file  "${PORT_WINE_TMP_PATH}/to_winetricks"

325
        if [[ ! -z ${SET_FROM_PFX_MANAGER} ]] ; then
castro-fidel's avatar
castro-fidel committed
326 327 328
            export PW_ADD_TO_ARGS_IN_RUNTIME="--xterm"
            pw_init_runtime
            ${pw_runtime} env PATH="${PATH}" LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}" "${PORT_WINE_TMP_PATH}/winetricks" -q -r -f ${SET_FROM_PFX_MANAGER}
castro-fidel's avatar
castro-fidel committed
329 330 331 332
            gui_prefix_manager
        else
            print_info "Nothing to do. Restarting PortProton..."
            stop_portwine &
castro-fidel's avatar
castro-fidel committed
333
            /usr/bin/env bash -c ${pw_full_command_line[*]} 
castro-fidel's avatar
castro-fidel committed
334 335 336 337 338
        fi
    }
    gui_prefix_manager
}

castro-fidel's avatar
castro-fidel committed
339
pw_winetricks () {
castro-fidel's avatar
castro-fidel committed
340
    update_winetricks
castro-fidel's avatar
castro-fidel committed
341
    export PW_USE_TERMINAL=1
castro-fidel's avatar
castro-fidel committed
342
    start_portwine
castro-fidel's avatar
castro-fidel committed
343
    pw_stop_progress_bar
castro-fidel's avatar
castro-fidel committed
344
    echo "WINETRICKS..." > "${PORT_WINE_TMP_PATH}/update_pfx_log"
castro-fidel's avatar
castro-fidel committed
345
    unset PW_TIMER
346
    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
347
            sleep 0.005
348
            if [[ ! -z "${line}" ]] && [[ -z "$(echo "${line}" | grep -i "gstreamer")" ]] \
castro-fidel's avatar
castro-fidel committed
349 350 351 352 353
                                    && [[ -z "$(echo "${line}" | grep -i "kerberos")" ]] \
                                    && [[ -z "$(echo "${line}" | grep -i "ntlm")" ]]
            then
                echo "# ${line}"
            fi
castro-fidel's avatar
castro-fidel committed
354
            if [[ "${PW_TIMER}" != 1 ]] ; then
castro-fidel's avatar
castro-fidel committed
355
                sleep 3
castro-fidel's avatar
castro-fidel committed
356
                PW_TIMER=1
castro-fidel's avatar
castro-fidel committed
357
            fi
358
    done < "${PORT_WINE_TMP_PATH}/update_pfx_log" | "${pw_yad_v12_3}" --text-info --tail --no-buttons --title="WINETRICKS" \
359
    --auto-close --skip-taskbar --width=$PW_GIF_SIZE_X --height=$PW_GIF_SIZE_Y 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
360 361
    "${PORT_WINE_TMP_PATH}/winetricks" -q -r -f &>>"${PORT_WINE_TMP_PATH}/update_pfx_log"
    try_remove_file "${PORT_WINE_TMP_PATH}/update_pfx_log"
362
    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
363 364 365
    stop_portwine
}

castro-fidel's avatar
castro-fidel committed
366
pw_start_cont_xterm () {
castro-fidel's avatar
castro-fidel committed
367
    cd "$HOME"
castro-fidel's avatar
castro-fidel committed
368 369 370
    unset PW_SANDBOX_HOME_PATH
    # export PW_ADD_TO_ARGS_IN_RUNTIME="--xterm"
    pw_init_runtime
371 372 373 374 375 376 377 378
    ${optirun_on} ${PW_GAMEMODERUN_SLR} ${pw_runtime} \
    env ${PW_MANGOHUD_SLR} \
    PATH="${PATH}" \
    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}" \
    xterm
castro-fidel's avatar
castro-fidel committed
379 380
}

castro-fidel's avatar
castro-fidel committed
381
pw_create_prefix_backup () {
castro-fidel's avatar
castro-fidel committed
382
    cd "$HOME"
383
    PW_PREFIX_TO_BACKUP=$("${pw_yad_v12_3}" --file --directory --borders=3 --width=650 --height=500 --auto-close \
384
    --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "BACKUP PREFIX TO..." 2>/dev/null )
castro-fidel's avatar
castro-fidel committed
385 386
    YAD_STATUS="$?"
    if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then exit 0 ; fi
387
    if [[ ! -z "$(grep "/${PW_PREFIX_NAME}/" "${PORT_WINE_PATH}"/*.desktop )" ]] ; then
castro-fidel's avatar
castro-fidel committed
388 389 390
        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
391
    fi
castro-fidel's avatar
castro-fidel committed
392 393 394 395 396
    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
397 398
    sleep 10
    while true ; do
399
        if [[ ! -z $(pgrep -a xterm | grep ".ppack.part" | head -n 1 | awk '{print $1}') ]] ; then
castro-fidel's avatar
castro-fidel committed
400 401 402 403 404 405 406 407 408 409
            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
410 411 412
    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"
        zenity_info "Backup for prefix \"${PW_PREFIX_NAME}\" successfully created."
castro-fidel's avatar
castro-fidel committed
413
    else 
castro-fidel's avatar
castro-fidel committed
414
        zenity_error "An error occurred while creating a backup for prefix: \"${PW_PREFIX_NAME}\" !"
castro-fidel's avatar
castro-fidel committed
415 416 417 418
    fi
    return 0
}

castro-fidel's avatar
castro-fidel committed
419 420
pw_edit_db () {
    pw_gui_for_edit_db \
421
    PW_MANGOHUD PW_MANGOHUD_x32 PW_MANGOHUD_USER_CONF ENABLE_VKBASALT PW_NO_ESYNC PW_NO_FSYNC PW_USE_RAY_TRACING \
422
    PW_USE_NVAPI_AND_DLSS PW_USE_FAKE_DLSS PW_WINE_FULLSCREEN_FSR PW_HIDE_NVIDIA_GPU PW_VIRTUAL_DESKTOP PW_USE_TERMINAL \
423
    PW_GUI_DISABLED_CS PW_USE_GAMEMODE PW_DX12_DISABLE PW_PRIME_RENDER_OFFLOAD PW_USE_D3D_EXTRAS PW_FIX_VIDEO_IN_GAME PW_REDUCE_PULSE_LATENCY \
Boria138's avatar
Boria138 committed
424
    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
castro-fidel's avatar
castro-fidel committed
425
    if [ "$?" == 0 ] ; then
426
        print_info "Restarting PP after update ppdb file..."
castro-fidel's avatar
castro-fidel committed
427
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
428 429
        exit 0
    fi
430
    # PW_WINE_ALLOW_XIM PW_FORCE_USE_VSYNC PW_WINEDBG_DISABLE PW_USE_AMDVLK_DRIVER
castro-fidel's avatar
castro-fidel committed
431 432
}

castro-fidel's avatar
castro-fidel committed
433 434
pw_autoinstall_from_db () {
    export PW_USER_TEMP="${PORT_WINE_TMP_PATH}"
435
    export PW_FORCE_LARGE_ADDRESS_AWARE=1
castro-fidel's avatar
castro-fidel committed
436 437 438 439 440
    export PW_USE_GAMEMODE=0
    export PW_CHECK_AUTOINSTAL=1
    export PW_GUI_DISABLED_CS=1
    export PW_WINEDBG_DISABLE=1
    export PW_NO_WRITE_WATCH=0
441
    export PW_VULKAN_USE=1
442
    export PW_USE_EAC_AND_BE=0
castro-fidel's avatar
castro-fidel committed
443 444
    export PW_NO_FSYNC=1
    export PW_NO_ESYNC=1
castro-fidel's avatar
castro-fidel committed
445
    unset PORTWINE_CREATE_SHORTCUT_NAME
castro-fidel's avatar
castro-fidel committed
446 447
    export PW_DISABLED_CREATE_DB=1
    export PW_MANGOHUD=0
castro-fidel's avatar
castro-fidel committed
448
    export ENABLE_VKBASALT=0
castro-fidel's avatar
castro-fidel committed
449 450
    export PW_USE_D3D_EXTRAS=1
    . "${PORT_SCRIPTS_PATH}/pw_autoinstall/${PW_YAD_SET}"
castro-fidel's avatar
castro-fidel committed
451 452 453 454 455 456 457 458
}

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

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

castro-fidel's avatar
castro-fidel committed
460 461 462 463 464
# HOTFIX CALIBRE
if [[ ! -z "$(echo ${1} | grep '/Caliber/')" ]] ; then
    export PW_WINE_USE=PROTON_STEAM_6.3-8
fi

fidel's avatar
fidel committed
465
# CLI
castro-fidel's avatar
castro-fidel committed
466 467
case "${1}" in
    '--help' )
fidel's avatar
fidel committed
468 469 470 471 472 473 474 475 476
        files_from_autoinstall=$(ls "${PORT_SCRIPTS_PATH}/pw_autoinstall") 
        echo -e "
usege: [--reinstall] [--autoinstall]

--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
477 478 479 480 481
        exit 0 ;;

    '--reinstall' )
        export PW_REINSTALL_FROM_TERMINAL=1
        pw_reinstall_pp ;;
fidel's avatar
fidel committed
482 483 484 485 486

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

castro-fidel's avatar
castro-fidel committed
489 490 491
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
492

493
# 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
494
#     export PW_PREFIX_NAME="${PW_PREFIX_NAME}!`echo "${PORTWINE_DB}" | sed -e s/[[:blank:]]/_/g`"
castro-fidel's avatar
castro-fidel committed
495 496
# fi

castro-fidel's avatar
castro-fidel committed
497
unset PW_ADD_PREFIXES_TO_GUI
castro-fidel's avatar
castro-fidel committed
498 499
IFS_OLD=$IFS
IFS=$'\n'
castro-fidel's avatar
castro-fidel committed
500
for PAIG in ${PW_ALL_PREFIXES[*]} ; do 
castro-fidel's avatar
castro-fidel committed
501
    [[ "${PAIG}" != $(echo "${PORTWINE_DB^^}" | sed -e s/[[:blank:]]/_/g) ]] && \
castro-fidel's avatar
castro-fidel committed
502
    export PW_ADD_PREFIXES_TO_GUI="${PW_ADD_PREFIXES_TO_GUI}!${PAIG}"
castro-fidel's avatar
castro-fidel committed
503 504
done
IFS=$IFS_OLD
castro-fidel's avatar
castro-fidel committed
505
export PW_ADD_PREFIXES_TO_GUI="${PW_PREFIX_NAME^^}${PW_ADD_PREFIXES_TO_GUI}"
castro-fidel's avatar
castro-fidel committed
506

507
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")
castro-fidel's avatar
castro-fidel committed
508
unset DIST_ADD_TO_GUI
castro-fidel's avatar
castro-fidel committed
509
for DAIG in ${PW_ALL_DIST}
castro-fidel's avatar
castro-fidel committed
510 511 512
do
    export DIST_ADD_TO_GUI="${DIST_ADD_TO_GUI}!${DAIG}"
done
513 514 515 516 517 518 519 520 521 522 523 524 525 526

if [[ $VULKAN_API_DRIVER_VERSION == 1.[1-2].* ]]
then check_variables PW_VULKAN_USE "1"
else check_variables PW_VULKAN_USE "2"
fi
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

527
if [[ ! -z "${PORTWINE_DB_FILE}" ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
528
    [[ -z "${PW_COMMENT_DB}" ]] && PW_COMMENT_DB="${loc_gui_db_comments} <b>${PORTWINE_DB}</b>."
529
    if [[ ! -z $(echo "${PW_WINE_USE}" | grep "^PROTON_LG$") ]] ; then
530
        export PW_DEFAULT_WINE_USE="${PW_PROTON_LG_VER}!${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
531
    elif [[ ! -z $(echo "${PW_WINE_USE}" | grep "^PROTON_GE$") ]] ; then
532
        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
533
    else
castro-fidel's avatar
castro-fidel committed
534
        if [[ "${PW_WINE_USE}" == "${PW_PROTON_LG_VER}" ]] ; then
535 536
            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
537
            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
538
        else
castro-fidel's avatar
castro-fidel committed
539
            export DIST_ADD_TO_GUI=$(echo "${DIST_ADD_TO_GUI}" | sed -e s/"\!${PW_WINE_USE}$//g")
540
            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
541 542 543
        fi
    fi
else
544 545 546 547
    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
548
    else
castro-fidel's avatar
castro-fidel committed
549
        if [[ "${PW_WINE_USE}" == "${PW_PROTON_LG_VER}" ]] ; then
550 551
            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
552
            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
553
        else
castro-fidel's avatar
castro-fidel committed
554
            export DIST_ADD_TO_GUI=$(echo "${DIST_ADD_TO_GUI}" | sed -e s/"\!${PW_WINE_USE}$//g")
555
            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
556 557
        fi     
    fi
castro-fidel's avatar
castro-fidel committed
558
    unset PW_GUI_DISABLED_CS
castro-fidel's avatar
castro-fidel committed
559
fi
560
if [ ! -z "${portwine_exe}" ]; then
castro-fidel's avatar
castro-fidel committed
561 562
    if [[ -z "${PW_GUI_DISABLED_CS}" || "${PW_GUI_DISABLED_CS}" == 0 ]] ; then  
        pw_create_gui_png
castro-fidel's avatar
castro-fidel committed
563 564
        grep -il "${portwine_exe}" "${HOME}/.local/share/applications"/*.desktop
        if [[ "$?" != "0" ]] ; then
fidel's avatar
fidel committed
565
            PW_SHORTCUT="${loc_gui_create_shortcut}!$PW_GUI_ICON_PATH/separator.png!${loc_create_shortcut}:100"
castro-fidel's avatar
castro-fidel committed
566
        else
fidel's avatar
fidel committed
567
            PW_SHORTCUT="${loc_gui_delete_shortcut}!$PW_GUI_ICON_PATH/separator.png!${loc_delete_shortcut}:98"
castro-fidel's avatar
castro-fidel committed
568
        fi
569
        OUTPUT_START=$("${pw_yad}" --text-align=center --text "$PW_COMMENT_DB" --borders=3 --form \
fidel's avatar
fidel committed
570
        --title "${portname}-${install_ver} (${scripts_install_ver})" --image "${PW_ICON_FOR_YAD}" --separator=";" --keep-icon-size \
castro-fidel's avatar
castro-fidel committed
571 572 573 574
        --window-icon="$PW_GUI_ICON_PATH/port_proton.png" \
        --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
575
        --field=":LBL" "" \
fidel's avatar
fidel committed
576 577
        --button="${loc_gui_vkbasalt_start}"!"$PW_GUI_ICON_PATH/separator.png"!"${ENABLE_VKBASALT_INFO}":120 \
        --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
578
        --button="${PW_SHORTCUT}" \
fidel's avatar
fidel committed
579
        --button="${loc_gui_debug}"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_debug}":102 \
580
        --button="${loc_gui_launch}"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_launch}":106 2>/dev/null)
castro-fidel's avatar
castro-fidel committed
581 582
        export PW_YAD_SET="$?"
        if [[ "$PW_YAD_SET" == "1" || "$PW_YAD_SET" == "252" ]] ; then exit 0 ; fi
castro-fidel's avatar
castro-fidel committed
583
        export VULKAN_MOD=$(echo "${OUTPUT_START}" | grep \;\; | awk -F";" '{print $1}')
castro-fidel's avatar
castro-fidel committed
584 585
        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)
586
        if [[ -z "${PW_PREFIX_NAME}" ]] || [[ ! -z "$(echo "${PW_PREFIX_NAME}" | grep -E '^_.*' )" ]] ; then
castro-fidel's avatar
castro-fidel committed
587
            export PW_PREFIX_NAME="DEFAULT"
castro-fidel's avatar
castro-fidel committed
588
        else
castro-fidel's avatar
castro-fidel committed
589
            export PW_PREFIX_NAME="${PW_PREFIX_NAME^^}"
castro-fidel's avatar
castro-fidel committed
590
        fi
591
    elif [ ! -z "${PORTWINE_DB_FILE}" ]; then
castro-fidel's avatar
castro-fidel committed
592 593 594 595
        portwine_launch
    fi
else
    button_click () {
596 597 598
        [[ ! -z "$1" ]] && echo "$1" > "${PORT_WINE_TMP_PATH}/tmp_yad_form"
        if [[ ! -z $(pidof -s yad) ]] || [[ ! -z $(pidof -s yad_v12_3) ]] ; then
            kill -s SIGUSR1 $(pgrep -a yad | grep "\--key=${KEY} \-\-notebook" | awk '{print $1}') > /dev/null 2>&1
castro-fidel's avatar
castro-fidel committed
599 600 601 602
        fi
    }
    export -f button_click

fidel's avatar
fidel committed
603
    run_desktop_b_click () {
604 605 606
        [[ ! -z "$1" ]] && echo "$1" > "${PORT_WINE_TMP_PATH}/tmp_yad_form"
        if [[ ! -z $(pidof -s yad) ]] || [[ ! -z $(pidof -s yad_v12_3) ]] ; then
            kill -s SIGUSR1 $(pgrep -a yad | grep "\--key=${KEY} \-\-notebook" | awk '{print $1}') > /dev/null 2>&1
fidel's avatar
fidel committed
607
        fi
Mikhail Tergoev's avatar
Mikhail Tergoev committed
608
        PW_EXEC_FROM_DESKTOP="$(cat "${PORT_WINE_PATH}/${PW_YAD_SET//¬/" "}" | grep Exec | head -n 1 | awk -F"=env " '{print $2}')"
fidel's avatar
fidel committed
609

610
        print_info "Restarting PP after choose desktop file..."
fidel's avatar
fidel committed
611
        # stop_portwine
Mikhail Tergoev's avatar
Mikhail Tergoev committed
612
        /usr/bin/env bash -c "${PW_EXEC_FROM_DESKTOP}" &
fidel's avatar
fidel committed
613 614 615 616
        exit 0 
    }
    export -f run_desktop_b_click

castro-fidel's avatar
castro-fidel committed
617 618
    gui_clear_pfx () {
        if gui_question "${port_clear_pfx}" ; then
castro-fidel's avatar
castro-fidel committed
619
            pw_clear_pfx
620
            print_info "Restarting PP after clearing prefix..."
castro-fidel's avatar
castro-fidel committed
621
            /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
            exit 0
        fi
    }
    export -f gui_clear_pfx

    gui_rm_portproton () {
        if gui_question "${port_del2}" ; then
            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
639
    gui_pw_update () {
castro-fidel's avatar
castro-fidel committed
640
        try_remove_file "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
641
        print_info "Restarting PP for check update..."
castro-fidel's avatar
castro-fidel committed
642
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
643 644 645
        exit 0
    }

Mikhail Tergoev's avatar
Mikhail Tergoev committed
646
    change_loc () {
647
        try_remove_file "${PORT_WINE_TMP_PATH}/${portname}_loc"
648
        print_info "Restarting PP for change language..."
Mikhail Tergoev's avatar
Mikhail Tergoev committed
649 650 651 652
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
        exit 0
    }

castro-fidel's avatar
castro-fidel committed
653 654
    gui_wine_uninstaller () {
        start_portwine
castro-fidel's avatar
castro-fidel committed
655
        pw_run uninstaller
castro-fidel's avatar
castro-fidel committed
656 657 658 659 660 661 662 663 664 665
    }
    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/"
666
        PW_SCRIPT_FROM_BACKUP=$("${pw_yad_v12_3}" --file --borders=3 --width=650 --height=500 --auto-close \
667
        --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "SCRIPTS FROM BACKUP" --file-filter="backup_scripts|scripts_v*.tar.gz" 2>/dev/null )
castro-fidel's avatar
castro-fidel committed
668 669
        YAD_STATUS="$?"
        if [[ "$YAD_STATUS" == "1" || "$YAD_STATUS" == "252" ]] ; then exit 0 ; fi
castro-fidel's avatar
castro-fidel committed
670
        unpack_tar_gz "$PW_SCRIPT_FROM_BACKUP" "${PORT_WINE_PATH}/data/"
castro-fidel's avatar
castro-fidel committed
671
        echo "0" > "${PORT_WINE_TMP_PATH}/scripts_update_notifier"
672
        print_info "Restarting PP after backup..."
castro-fidel's avatar
castro-fidel committed
673
        /usr/bin/env bash -c ${pw_full_command_line[*]} &
castro-fidel's avatar
castro-fidel committed
674 675 676 677
        exit 0
    }
    export -f gui_open_scripts_from_backup

fidel's avatar
fidel committed
678

Mikhail Tergoev's avatar
Mikhail Tergoev committed
679 680 681 682
    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
683 684 685 686 687 688 689 690
    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
691
        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
692 693 694 695
            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
696

Mikhail Tergoev's avatar
Mikhail Tergoev committed
697
    IFS="$orig_IFS"
Mikhail Tergoev's avatar
Mikhail Tergoev committed
698
    old_IFS=$IFS && IFS="%"
699
    "${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
700 701
    IFS="$orig_IFS"

702
    "${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
703 704 705 706 707 708 709 710
    --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"' \
711
    --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
712

713
    "${pw_yad_v12_3}" --plug=${KEY} --tabnum=${PW_GUI_SORT_TABS[2]} --form --columns=3 --align-buttons --keep-icon-size --separator=";" \
714
    --field="  3D API  : :CB" "${PW_DEFAULT_VULKAN_USE}" \
castro-fidel's avatar
castro-fidel committed
715 716
    --field="  PREFIX  : :CBE" "${PW_ADD_PREFIXES_TO_GUI}" \
    --field="  WINE    : :CB" "${PW_DEFAULT_WINE_USE}" \
717 718 719 720 721
    --field="              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="   CLEAR PREFIX"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_clear_pfx"' \
    --field="   DOWNLOAD OTHER WINE"!"$PW_GUI_ICON_PATH/separator.png"!"${loc_download_other_wine}":"FBTN" '@bash -c "button_click gui_proton_downloader"' \
    --field="   WINE UNINSTALLER"!"$PW_GUI_ICON_PATH/separator.png"!"":"FBTN" '@bash -c "button_click gui_wine_uninstaller"' \
fidel's avatar
fidel committed
722 723 724
    --field='   WINECFG'!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winecfg}":"FBTN" '@bash -c "button_click WINECFG"' \
    --field='   WINEFILE'!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winefile}":"FBTN" '@bash -c "button_click WINEFILE"' \
    --field='   WINECMD'!"$PW_GUI_ICON_PATH/separator.png"!"${loc_winecmd}":"FBTN" '@bash -c "button_click WINECMD"' \
725
    --field='   WINEREG'!"$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
726

727
    "${pw_yad_v12_3}" --plug=$KEY --tabnum=${PW_GUI_SORT_TABS[1]} --form --columns=3 --align-buttons --keep-icon-size --scroll  \
castro-fidel's avatar
castro-fidel committed
728 729 730 731 732 733 734 735 736 737 738
    --field="   Dolphin 5.0"!"$PW_GUI_ICON_PATH/dolphin.png"!"":"FBTN" '@bash -c "button_click PW_DOLPHIN"' \
    --field="   MAME"!"$PW_GUI_ICON_PATH/mame.png"!"":"FBTN" '@bash -c "button_click PW_MAME"' \
    --field="   ScummVM"!"$PW_GUI_ICON_PATH/scummvm.png"!"":"FBTN" '@bash -c "button_click PW_SCUMMVM"' \
    --field="   RetroArch"!"$PW_GUI_ICON_PATH/retroarch.png"!"":"FBTN" '@bash -c "button_click PW_RETROARCH"' \
    --field="   PPSSPP Windows"!"$PW_GUI_ICON_PATH/ppsspp.png"!"":"FBTN" '@bash -c "button_click PW_PPSSPP"' \
    --field="   Citra"!"$PW_GUI_ICON_PATH/citra.png"!"":"FBTN" '@bash -c "button_click PW_CITRA"' \
    --field="   Cemu"!"$PW_GUI_ICON_PATH/cemu.png"!"":"FBTN" '@bash -c "button_click PW_CEMU"' \
    --field="   DuckStation"!"$PW_GUI_ICON_PATH/duckstation.png"!"":"FBTN" '@bash -c "button_click PW_DUCKSTATION"' \
    --field="   ePSXe"!"$PW_GUI_ICON_PATH/epsxe.png"!"":"FBTN" '@bash -c "button_click PW_EPSXE"' \
    --field="   Project64"!"$PW_GUI_ICON_PATH/project64.png"!"":"FBTN" '@bash -c "button_click PW_PROJECT64"' \
    --field="   VBA-M"!"$PW_GUI_ICON_PATH/vba-m.png"!"":"FBTN" '@bash -c "button_click PW_VBA-M"' \
739 740 741 742 743
    --field="   Yabause"!"$PW_GUI_ICON_PATH/yabause.png"!"":"FBTN" '@bash -c "button_click PW_YABAUSE"' \
    --field="   Xenia"!"$PW_GUI_ICON_PATH/xenia.png"!"":"FBTN" '@bash -c "button_click PW_XENIA"' \
    --field="   FCEUX"!"$PW_GUI_ICON_PATH/fceux.png"!"":"FBTN" '@bash -c "button_click PW_FCEUX"' \
    --field="   xemu"!"$PW_GUI_ICON_PATH/xemu.png"!"":"FBTN" '@bash -c "button_click PW_XEMU"' \
    --field="   Demul"!"$PW_GUI_ICON_PATH/demul.png"!"":"FBTN" '@bash -c "button_click PW_DEMUL"' \
744
    --field="   Rpcs3"!"$PW_GUI_ICON_PATH/rpcs3.png"!"":"FBTN" '@bash -c "button_click PW_RPCS3"' 2>/dev/null &
castro-fidel's avatar
castro-fidel committed
745

746
    "${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
747 748
    --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
749 750 751 752 753 754 755 756 757
    --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"' \
    --field="   World of Sea Battle (BETA)"!"$PW_GUI_ICON_PATH/wosb.png"!"":"FBTN" '@bash -c "button_click PW_WOSB"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
758
    --field="   CALIBER"!"$PW_GUI_ICON_PATH/caliber.png"!"":"FBTN" '@bash -c "button_click PW_CALIBER"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
759
    --field="   Crossout"!"$PW_GUI_ICON_PATH/crossout.png"!"":"FBTN" '@bash -c "button_click PW_CROSSOUT"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
760
    --field="   Warframe"!"$PW_GUI_ICON_PATH/warframe.png"!"":"FBTN" '@bash -c "button_click PW_WARFRAME"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
761
    --field="   Panzar"!"$PW_GUI_ICON_PATH/panzar.png"!"":"FBTN" '@bash -c "button_click PW_PANZAR"' \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
762
    --field="   STALCRAFT"!"$PW_GUI_ICON_PATH/stalcraft.png"!"":"FBTN" '@bash -c "button_click PW_STALCRAFT"' \
763 764 765 766
    --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"' \
    --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"' \
767
    --field="   Indiegala Client"!"$PW_GUI_ICON_PATH/igclient.png"!"":"FBTN" '@bash -c "button_click PW_IGCLIENT"' \
768
    --field="   Plarium Play"!"$PW_GUI_ICON_PATH/plariumplay.png"!"":"FBTN" '@bash -c "button_click PW_PLARIUM_PLAY"' \
769 770 771 772
    --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"' \
773
    --field="   Path of Exile"!"$PW_GUI_ICON_PATH/poe.png"!"":"FBTN" '@bash -c "button_click PW_POE"' \
774
    --field="   Guild Wars 2"!"$PW_GUI_ICON_PATH/gw2.png"!"":"FBTN" '@bash -c "button_click PW_GUILD_WARS_2"' \
Boria138's avatar
Boria138 committed
775
    --field="   Genshin Impact"!"$PW_GUI_ICON_PATH/genshinimpact.png"!"":"FBTN" '@bash -c "button_click PW_GENSHIN_IMPACT"' \
776
    --field="   Battle Of Space Raiders"!"$PW_GUI_ICON_PATH/bsr.png"!"":"FBTN" '@bash -c "button_click PW_BSR"' &
777 778
    
    # --field="   Electronic Arts App"!"$PW_GUI_ICON_PATH/eaapp.png"!"":"FBTN" '@bash -c "button_click PW_EAAPP"' 
Mikhail Tergoev's avatar
Mikhail Tergoev committed
779
    # --field="   Secret World Legends (ENG)"!"$PW_GUI_ICON_PATH/swl.png"!"":"FBTN" '@bash -c "button_click PW_SWL"'
780
    # --field="   ROBLOX"!"$PW_GUI_ICON_PATH/roblox.png"!"":"FBTN" '@bash -c "button_click PW_ROBLOX"' 2>/dev/null 
castro-fidel's avatar
castro-fidel committed
781 782
    # --field="   Bethesda.net Launcher"!"$PW_GUI_ICON_PATH/bethesda.png"!"":"FBTN" '@bash -c "button_click PW_BETHESDA"'

Boria138's avatar
Boria138 committed
783
    if  [[ `command -v wmctrl` ]] &>/dev/null ; then
784
        sleep 2
785
        while [[ $(pgrep -a yad_v12_3 | head -n 1 | awk '{print $1}' 2>/dev/null) ]] ; do
786
            sleep 2
Mikhail Tergoev's avatar
Mikhail Tergoev committed
787
            PW_MAIN_GUI_SIZE_TMP="$(wmctrl -lG | grep PortProton-1.0 | awk '{print $5" "$6}' 2>/dev/null)"
788
            if [[ ! -z "${PW_MAIN_GUI_SIZE_TMP}" ]] ; then
Mikhail Tergoev's avatar
Mikhail Tergoev committed
789 790
                echo "${PW_MAIN_GUI_SIZE_TMP}" > "${PORT_WINE_TMP_PATH}/tmp_main_gui_size"
            fi
791 792
        done
    fi &
Mikhail Tergoev's avatar
Mikhail Tergoev committed
793

Mikhail Tergoev's avatar
Mikhail Tergoev committed
794
    if [[ -z "${PW_ALL_DF}" ]] ; then
795
        "${pw_yad_v12_3}" --key=$KEY --notebook --borders=3 --width="${PW_MAIN_SIZE_W}" --height="${PW_MAIN_SIZE_H}" --no-buttons --auto-close \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
796 797 798 799 800 801
        --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "${portname}-${install_ver} (${scripts_install_ver})" \
        --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"!"" \
802
        --tab="$loc_mg_installed"!"$PW_GUI_ICON_PATH/separator.png"!"" 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
803 804
        YAD_STATUS="$?"
    else
805
        "${pw_yad_v12_3}" --key=$KEY --notebook --borders=3 --width="${PW_MAIN_SIZE_W}" --height="${PW_MAIN_SIZE_H}" --no-buttons --auto-close \
Mikhail Tergoev's avatar
Mikhail Tergoev committed
806 807 808 809 810 811
        --window-icon="$PW_GUI_ICON_PATH/port_proton.png" --title "${portname}-${install_ver} (${scripts_install_ver})" \
        --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"!"" \
812
        --tab="$loc_mg_portproton_settings"!"$PW_GUI_ICON_PATH/separator.png"!"" 2>/dev/null
Mikhail Tergoev's avatar
Mikhail Tergoev committed
813 814
        YAD_STATUS="$?"
    fi
Mikhail Tergoev's avatar
Mikhail Tergoev committed
815

castro-fidel's avatar
castro-fidel committed
816 817 818
    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
819
        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
820 821 822
    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
823 824
        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}')
825
        if [[ -z "${PW_PREFIX_NAME}" ]] || [[ ! -z "$(echo "${PW_PREFIX_NAME}" | grep -E '^_.*' )" ]] ; then
castro-fidel's avatar
castro-fidel committed
826
            export PW_PREFIX_NAME="DEFAULT"
castro-fidel's avatar
castro-fidel committed
827
        else
castro-fidel's avatar
castro-fidel committed
828
            export PW_PREFIX_NAME="${PW_PREFIX_NAME^^}"
castro-fidel's avatar
castro-fidel committed
829 830 831
        fi
        try_remove_file "${PORT_WINE_TMP_PATH}/tmp_yad_form_vulkan"
    fi
castro-fidel's avatar
castro-fidel committed
832
    export PW_DISABLED_CREATE_DB=1
castro-fidel's avatar
castro-fidel committed
833 834
fi

Mikhail Tergoev's avatar
Mikhail Tergoev committed
835 836 837 838 839 840
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
841 842 843

init_wine_ver

castro-fidel's avatar
castro-fidel committed
844
if [[ -z "${PW_DISABLED_CREATE_DB}" ]] ; then
845
    if [[ ! -z "${PORTWINE_DB}" ]] && [[ -z "${PORTWINE_DB_FILE}" ]] ; then
castro-fidel's avatar
castro-fidel committed
846 847 848 849 850 851 852 853 854 855
        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
856
    edit_db_from_gui PW_VULKAN_USE PW_WINE_USE PW_PREFIX_NAME 
castro-fidel's avatar
castro-fidel committed
857 858
fi

859
[ ! -z "$PW_YAD_SET" ] && case "$PW_YAD_SET" in
castro-fidel's avatar
castro-fidel committed
860 861 862 863
    98) portwine_delete_shortcut ;;
    100) portwine_create_shortcut ;;
    DEBUG|102) portwine_start_debug ;;
    106) portwine_launch ;;
castro-fidel's avatar
castro-fidel committed
864 865 866 867 868 869
    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
870 871 872 873
    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
874
    gui_pw_reinstall_pp) pw_reinstall_pp ;;
castro-fidel's avatar
castro-fidel committed
875
    gui_pw_update) gui_pw_update ;;
castro-fidel's avatar
castro-fidel committed
876 877 878
    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
879
    change_loc) change_loc ;;
castro-fidel's avatar
castro-fidel committed
880
    120) gui_vkBasalt ;;
castro-fidel's avatar
castro-fidel committed
881
    pw_create_prefix_backup) pw_create_prefix_backup ;;
castro-fidel's avatar
castro-fidel committed
882
    gui_credits) gui_credits ;;
castro-fidel's avatar
castro-fidel committed
883
    pw_start_cont_xterm) pw_start_cont_xterm ;;
Mikhail Tergoev's avatar
Mikhail Tergoev committed
884
    pw_find_exe) pw_find_exe ;;
castro-fidel's avatar
castro-fidel committed
885
    PW_*) pw_autoinstall_from_db ;;
Mikhail Tergoev's avatar
Mikhail Tergoev committed
886 887
    *.desktop) run_desktop_b_click ;;
    1|252|*) exit 0 ;;
castro-fidel's avatar
castro-fidel committed
888 889 890
esac

stop_portwine