Unverified Commit bfbe8430 authored by Boria138's avatar Boria138 Committed by Boris Yumankulov

Added automatic detection and creation of shortcuts

parent 53238e06
......@@ -998,6 +998,41 @@ stop_portwine () {
if [[ ! -z "$(pgrep -a yad_gui_pp | grep "\--notification" | awk '{print $1}')" ]] ; then
kill -s SIGUSR1 "$(pgrep -a yad_gui_pp | grep "\--notification" | awk '{print $1}')" 2>/dev/null
fi
for prefix_dir in "${PORT_WINE_PATH}"/prefixes/*; do
DESKTOP_DIRS+=(
"${prefix_dir}/drive_c/users/steamuser/Desktop"
"${prefix_dir}/drive_c/users/Public/Desktop"
)
done
for dir in "${DESKTOP_DIRS[@]}" ; do
while IFS= read -r -d '' link_file; do
LINKS+=("$link_file")
done < <(find "$dir" -type f -iname "*.lnk" -print0 2>/dev/null | sort -u)
done
for link_file in "${LINKS[@]}"; do
if command -v exiftool &>/dev/null
link_drive=$(exiftool -LocalBasePath "$link_file" | sed -n 's/^Local Base Path\s*:\s*//p' | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(exiftool -LocalBasePath "$link_file" | sed -n 's/^Local Base Path\s*:\s*//p' | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$PW_PREFIX_NAME/dosdevices/$link_drive|g" | sed 's/\\/\//g')
link_name=$(exiftool -FileName "$link_file" | sed -n 's/^File Name\s*:\s*//p' | sed 's|\.lnk||')
link_cmd=$(exiftool -CommandLineArguments "$link_file" | sed -n 's/^Command Line Arguments\s*:\s*//p')
else
link_drive=$(env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" -LocalBasePath "$link_file" | sed -n 's/^Local Base Path\s*:\s*//p' | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" -LocalBasePath "$link_file" | sed -n 's/^Local Base Path\s*:\s*//p' | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$PW_PREFIX_NAME/dosdevices/$link_drive|g" | sed 's/\\/\//g')
link_name=$(env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" -FileName "$link_file" | sed -n 's/^File Name\s*:\s*//p' | sed 's|\.lnk||')
link_cmd=$(env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" -CommandLineArguments "$link_file" | sed -n 's/^Command Line Arguments\s*:\s*//p')
fi
exe_path="$(realpath "$link_path")"
if ! [[ "$(grep -il "${exe_path}" "${PORT_WINE_PATH}"/*.desktop)" ]] || \
! [[ "$(grep -il "${exe_path}" "${HOME}/.local/share/applications"/*.desktop)" ]] || \
! [[ "$(grep -il "${exe_path}" "$(xdg-user-dir DESKTOP)"/*.desktop)" ]] ; then
create_shortcut_from_link
print_info "Created link for $link_name"
fi
done
add_in_stop_portwine
unset SKIP_CHECK_UPDATES
exit 0
......@@ -1294,6 +1329,62 @@ check_nvidia_rtx () {
return 1
}
create_shortcut_from_link(){
PORTPROTON_NAME="$link_name"
PW_RESIZE_TO=128
try_remove_file "${PORT_WINE_PATH}/data/img/setup.png"
try_remove_file "${PORT_WINE_PATH}/data/img/Setup.png"
try_remove_file "${PORT_WINE_PATH}/data/img/launcher.png"
try_remove_file "${PORT_WINE_PATH}/data/img/Launcher.png"
if [[ ! -f "${PORT_WINE_PATH}/data/img/${PORTPROTON_NAME}.png" ]] ; then
if command -v exe-thumbnailer &>/dev/null ; then
exe-thumbnailer -s 128 "$(readlink -f "${portwine_exe}")" "${PORT_WINE_PATH}/data/img/${PORTPROTON_NAME}.png"
else
env PYTHONPATH="${PW_PLUGINS_PATH}/portable/lib/python3.9/site-packages/" \
LD_LIBRARY_PATH="${PW_PLUGINS_PATH}/portable/lib/lib64" \
"${PW_WINELIB}/runtime/files/bin/python3.9" \
"${PW_PLUGINS_PATH}/portable/bin/exe-thumbnailer" -s 128 "$(readlink -f "${portwine_exe}")" "${PORT_WINE_PATH}/data/img/${PORTPROTON_NAME}.png"
fi
fi
echo "[Desktop Entry]" > "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
echo "Name=${PORTPROTON_NAME}" >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
if [[ ! -z "$link_cmd" ]] ; then
if check_flatpak
then echo "Exec=flatpak run ru.linux_gaming.PortProton \"${exe_path}\" \"${link_cmd}\"" >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
else echo "Exec=env \"${PORT_SCRIPTS_PATH}/start.sh\" \"${exe_path}\" \"${link_cmd}\"" >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
fi
else
if check_flatpak
then echo "Exec=flatpak run ru.linux_gaming.PortProton \"${exe_path}\"" >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
else echo "Exec=env \"${PORT_SCRIPTS_PATH}/start.sh\" \"${exe_path}\"" >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
fi
fi
{
echo "Type=Application"
echo "Categories=Game"
echo "StartupNotify=true"
echo "Path=${PORT_SCRIPTS_PATH}/"
echo "Icon=${PORT_WINE_PATH}/data/img/${PORTPROTON_NAME}.png"
} >> "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
chmod u+x "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop"
if [[ "$DESKTOP_SESSION" =~ "gnome" ]] ; then
try_remove_file "${HOME}/.local/share/applications/${PORTPROTON_NAME}.desktop"
cp -f "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop" "${HOME}/.local/share/applications/"
else
if [[ -d "${HOME}/Desktop" ]] ; then
cp -f "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop" "${HOME}/Desktop/"
elif [[ -d "${HOME}/Рабочий стол" ]] ; then
cp -f "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop" "${HOME}/Рабочий стол/"
elif [[ $(xdg-user-dir DESKTOP) ]] ; then
cp -f "${PORT_WINE_PATH}/${PORTPROTON_NAME}.desktop" "$(xdg-user-dir DESKTOP)"
fi
fi
}
pw_init_db () {
if [[ -f "${portwine_exe}" ]] ; then
PORTWINE_DB="$(basename "${portwine_exe}" .exe)"
......@@ -4622,6 +4713,8 @@ portwine_delete_shortcut () {
elif [[ $(xdg-user-dir DESKTOP) ]] ; then
rm -f "$(grep -il "${portwine_exe}" "$(xdg-user-dir DESKTOP)"/*.desktop)" &>/dev/null
fi
rm -f "$(grep -il "${portwine_exe}" " ${PORT_WINE_PATH}/data/prefixes/$PW_PREFIX_NAME/drive_c/users/steamuser/Desktop"/*.lnk)" &>/dev/null
rm -f "$(grep -il "${portwine_exe}" " ${PORT_WINE_PATH}/data/prefixes/$PW_PREFIX_NAME/drive_c/users/Public/Desktop"/*.lnk)" &>/dev/null
}
portwine_missing_shortcut () {
......
......@@ -17,7 +17,3 @@ export PW_FORCE_LARGE_ADDRESS_AWARE=1 # Force Wine to enable the LARGE_
export PW_DLL_INSTALL=""
# export WINEDLLOVERRIDES="mscoree,mshtml="
export PW_WINE_USE=WINE_LG
add_in_stop_portwine () {
pw_find_exe news
}
......@@ -3,6 +3,7 @@
########################################################################
export LAUNCH_PARAMETERS=("/S" "/D=c:\Program Files (x86)\Ubisoft Game Launcher")
export PW_AUTOINSTALL_EXE="${PW_USER_TEMP}/UbisoftConnectInstaller.exe"
export PORTWINE_CREATE_SHORTCUT_NAME="Ubisoft Connect"
start_portwine
if try_download "https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UbisoftConnectInstaller.exe" "${PW_AUTOINSTALL_EXE}" no_mirror
then
......
......@@ -172,7 +172,7 @@ then
else
# shellcheck source=/dev/null
source "$PW_GUI_THEMES_PATH/default.pptheme"
echo 'export GUI_THEME="default"' >> "$USER_CONF"
echo 'export GUI_THEME="default"' >> "$USER_CONF"
fi
# choose branch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment