Skip to content

Commit

Permalink
Merge branch 'added-flatpak-shortcuts' of https://github.com/Boria138…
Browse files Browse the repository at this point in the history
…/PortWINE into Boria138-added-flatpak-shortcuts
  • Loading branch information
Castro-Fidel committed Feb 4, 2024
2 parents 6d32500 + 60dc1de commit b151d29
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 36 deletions.
36 changes: 18 additions & 18 deletions data_from_portwine/scripts/functions_helper
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ try_download_game () {
[[ -f "${PW_AUTOINSTALL_EXE}" ]] && try_remove_file "${PW_AUTOINSTALL_EXE}"
PW_DOWNLOAD_FILE_NAME="$(basename $1)"
set -o pipefail
wget -O "$2" --read-timeout 300 --retry-connrefused --timeout 3 --tries 2 --no-dns-cache --no-cache \
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1" 2>&1 | \
tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
zenity --progress --percentage=0 --title="Download ${PW_DOWNLOAD_FILE_NAME}" --text=Starting... --auto-close --width=500 --height=90
curl -C - -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' -L "$1" -o "$2" 2>&1 | \
tr '\r' '\n' | sed -u -e 's/#//g' -e 's/ //g' -e 's/\.[[:digit:]]%//' | \
"${pw_yad_v12_3}" --progress --percentage=0 --text="Download ${PW_DOWNLOAD_FILE_NAME}" --auto-close --no-escape \
--auto-kill --center --text-align="center" --fixed --no-buttons --title "PortProton" --width=500 --height=90
if [ "${PIPESTATUS[0]}" != 0 ] ; then
print_error "Failed to download ${PW_DOWNLOAD_FILE_NAME}."
return 1
Expand All @@ -133,17 +133,17 @@ try_download_game () {
try_download () {
PW_DOWNLOAD_FILE_NAME="$(basename $1)"
set -o pipefail
wget -c -O "$2" --read-timeout 300 --retry-connrefused --timeout 3 --tries 2 --no-dns-cache --no-cache \
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1" 2>&1 | \
tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
zenity --progress --percentage=0 --title="Download ${PW_DOWNLOAD_FILE_NAME}" --text=Starting... --auto-close --width=500 --height=90
curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' -L "$1" -o "$2" 2>&1 | \
tr '\r' '\n' | sed -u -e 's/#//g' -e 's/ //g' -e 's/\.[[:digit:]]%//' | \
"${pw_yad_v12_3}" --progress --percentage=0 --text="Download ${PW_DOWNLOAD_FILE_NAME}" --auto-close --no-escape \
--auto-kill --center --text-align="center" --fixed --no-buttons --title "PortProton" --width=500 --height=90
if [ "${PIPESTATUS[0]}" != 0 ] ; then
print_error "Failed to download ${PW_DOWNLOAD_FILE_NAME} from GitHub."
print_info "Try download ${PW_DOWNLOAD_FILE_NAME} from FTP"
wget -c -O "$2" --read-timeout 300 --retry-connrefused --timeout 3 --tries 2 --no-dns-cache --no-cache \
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" --ftp-user=anonymous "ftp://171.22.215.18/archives/${PW_DOWNLOAD_FILE_NAME}" 2>&1 | \
tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
zenity --progress --percentage=0 --title="Try download ${PW_DOWNLOAD_FILE_NAME} from FTP" --text=Starting... --auto-close --width=500 --height=90
curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -L "ftp://171.22.215.18/archives/${PW_DOWNLOAD_FILE_NAME}" -o "$2" 2>&1 | \
tr '\r' '\n' | sed -u -e 's/#//g' -e 's/ //g' -e 's/\.[[:digit:]]%//' | \
"${pw_yad_v12_3}" --progress --percentage=0 --text="Download ${PW_DOWNLOAD_FILE_NAME}" --auto-close --no-escape \
--auto-kill --center --text-align="center" --fixed --no-buttons --title "PortProton" --width=500 --height=90
if [ "${PIPESTATUS[0]}" != 0 ] ; then
print_error "Failed to download ${PW_DOWNLOAD_FILE_NAME} from FTP."
return 1
Expand All @@ -154,11 +154,12 @@ try_download () {
}

try_download_to_path () {
PW_DOWNLOAD_FILE_NAME="$(basename $1)"
set -o pipefail
wget --directory-prefix="$2" --read-timeout 300 --retry-connrefused --timeout 4 --tries 2 --no-dns-cache --no-cache \
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1" 2>&1 | \
tr '\r' '\n' | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1\n#Downloading at \1\/, \2\/s, ETA \3/; s/^20[0-9][0-9].*/#Done./' | \
zenity --progress --percentage=0 --title="Download $(basename $1)" --text=Starting... --auto-close --width=500 --height=90
curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' -L "$1" -o "$2/$PW_DOWNLOAD_FILE_NAME" 2>&1 | \
tr '\r' '\n' | sed -u -e 's/#//g' -e 's/ //g' -e 's/\.[[:digit:]]%//' | \
"${pw_yad_v12_3}" --progress --percentage=0 --text="Download ${PW_DOWNLOAD_FILE_NAME}" --auto-close --no-escape \
--auto-kill --center --text-align="center" --fixed --no-buttons --title "PortProton" --width=500 --height=90
if [ "${PIPESTATUS[0]}" != 0 ] ; then
print_error "Failed to download $1."
return 1
Expand All @@ -168,8 +169,7 @@ try_download_to_path () {
}

try_download_silent () {
wget -O "$2" --read-timeout 300 --retry-connrefused --timeout 4 --tries 2 --no-dns-cache --no-cache \
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" "$1"
curl -sS -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' -L "$1" -o "$2"
if [ "${PIPESTATUS[0]}" != 0 ] ; then
print_error "Failed to download $1. Skipping."
try_remove_file "$2"
Expand Down
46 changes: 32 additions & 14 deletions data_from_portwine/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,48 @@
# Author: linux-gaming.ru
. "$(dirname $(readlink -f "$0"))/runlib"

name_desktop="PortProton"
echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Name=${name_desktop}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Exec=env "${PORT_SCRIPTS_PATH}/start.sh %F"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Type=Application" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Terminal=False" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Categories=Game" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "StartupNotify=true" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "MimeType=application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Path="${PORT_SCRIPTS_PATH}/"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Icon="${PORT_WINE_PATH}/data/img/w.png"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
chmod u+x "${PORT_WINE_PATH}/${name_desktop}.desktop"
if [[ $(cat /etc/os-release | grep -i "flatpak") ]] ; then
name_desktop="PortProton"
echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Name=${name_desktop}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Exec=flatpak run com.castrofidel.portproton" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Type=Application" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Terminal=False" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Categories=Game" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "StartupNotify=true" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "MimeType=application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Path="${PORT_SCRIPTS_PATH}/"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Icon="${PORT_WINE_PATH}/data/img/w.png"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
chmod u+x "${PORT_WINE_PATH}/${name_desktop}.desktop"
else
name_desktop="PortProton"
echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Name=${name_desktop}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Exec=env "${PORT_SCRIPTS_PATH}/start.sh %F"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Type=Application" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Terminal=False" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Categories=Game" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "StartupNotify=true" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "MimeType=application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Path="${PORT_SCRIPTS_PATH}/"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Icon="${PORT_WINE_PATH}/data/img/w.png"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
chmod u+x "${PORT_WINE_PATH}/${name_desktop}.desktop"
fi

if [ -z "${PW_AUTOPLAY}" ] ; then
cp -f "${PORT_WINE_PATH}/${name_desktop}.desktop" ${HOME}/.local/share/applications/
fi

update-desktop-database -q "${HOME}/.local/share/applications"
xdg-mime default PortProton.desktop "application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program"

if [[ ! $(cat /etc/os-release | grep -i "flatpak") ]]
xdg-mime default PortProton.desktop "application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program"
fi

name_desktop="readme"
echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Name=${name_desktop}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Version=1.0" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Version=1.3" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Type=Link" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Icon="${PORT_WINE_PATH}/data/img/readme.png"" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "URL=${urlg}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
Expand Down
8 changes: 6 additions & 2 deletions data_from_portwine/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,16 @@ else
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
fi
PW_EXEC_FROM_DESKTOP="$(cat "${PORT_WINE_PATH}/${PW_YAD_SET//¬/" "}" | grep Exec | head -n 1 | awk -F"=env " '{print $2}')"

if [[ $(cat /etc/os-release | grep -i "flatpak") ]] ;
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

print_info "Restarting PP after choose desktop file..."
# stop_portwine
/usr/bin/env bash -c "${PW_EXEC_FROM_DESKTOP}" &
exit 0
exit 0
}
export -f run_desktop_b_click

Expand Down
10 changes: 8 additions & 2 deletions data_from_portwine/scripts/zen_yad_gui
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,10 @@ portwine_create_shortcut () {

echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Name=${name_desktop}" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Exec=env "\"${PORT_SCRIPTS_PATH}/start.sh\" \"${portwine_exe}\" "" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
if [[ $(cat /etc/os-release | grep -i "flatpak") ]]
then echo "Exec=flatpak run com.castrofidel.portproton \"${portwine_exe}\" " >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
else echo "Exec=env "\"${PORT_SCRIPTS_PATH}/start.sh\" \"${portwine_exe}\" "" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
fi
echo "Type=Application" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "Categories=Game" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
echo "StartupNotify=true" >> "${PORT_WINE_PATH}/${name_desktop}.desktop"
Expand Down Expand Up @@ -690,7 +693,10 @@ portwine_create_shortcut () {
echo "#!/usr/bin/env bash" > "${STEAM_SCRIPTS}/${name_desktop}.sh"
echo "export START_FROM_STEAM=1" >> "${STEAM_SCRIPTS}/${name_desktop}.sh"
echo "export LD_PRELOAD=" >> "${STEAM_SCRIPTS}/${name_desktop}.sh"
echo "\"${PORT_SCRIPTS_PATH}/start.sh\" \"${portwine_exe}\" " >> "${STEAM_SCRIPTS}/${name_desktop}.sh"
if [[ $(cat /etc/os-release | grep -i "flatpak") ]]
then echo "flatpak run com.castrofidel.portproton \"${portwine_exe}\" " >> "${STEAM_SCRIPTS}/${name_desktop}.sh"
else echo "\"${PORT_SCRIPTS_PATH}/start.sh\" \"${portwine_exe}\" " >> "${STEAM_SCRIPTS}/${name_desktop}.sh"
fi
chmod u+x "${STEAM_SCRIPTS}/${name_desktop}.sh"
export SCVDF="shortcuts.vdf"
for STUIDPATH in "${HOME}"/.local/share/Steam/userdata/*/ ; do
Expand Down

0 comments on commit b151d29

Please sign in to comment.