Commit 11eda1a2 authored by Mikhail Tergoev's avatar Mikhail Tergoev

Merge branch 'lnk' of github.com:alex2844/PortWINE into alex2844-lnk

parents b9211f29 69c59da6
......@@ -6029,6 +6029,34 @@ portwine_output_yad_shortcut () {
fi
}
parse_lnk () {
prefix_name=$(echo "$1" | awk -F"/prefixes/" '{print $2}' | awk -F"/" '{print $1}')
if fix_icon_name=$(grep -i "Icon File Name" "${PW_TMPFS_PATH}/exiftool.tmp" 2>/dev/null) \
&& [[ "${fix_icon_name//*.exe/true}" == "true" ]] ; then
link_drive=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/${prefix_name:-DEFAULT}/dosdevices/$link_drive|g" | sed 's/\\/\//g')
else
link_drive=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/${prefix_name:-DEFAULT}/dosdevices/$link_drive|g" | sed 's/\\/\//g')
fi
link_name=$(sed -n 's/^File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|\.lnk||')
link_cmd=$(sed -n 's/^Command Line Arguments\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp")
}
get_lnk () {
if command -v exiftool &>/dev/null ; then
if timeout 3 exiftool "$1" &> "${PW_TMPFS_PATH}/exiftool.tmp" ; then
parse_lnk "$1"
else
print_error "exiftool - broken!"
fi
else
print_warning "use portable exiftool"
env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" "$1" &> "${PW_TMPFS_PATH}/exiftool.tmp"
parse_lnk "$1"
fi
}
pw_auto_create_shortcut () {
if [[ "${PW_CHECK_AUTOINSTALL}" == "1" ]] \
|| [[ "${PW_NO_AUTO_CREATE_SHORTCUT}" == "1" ]] \
......@@ -6049,38 +6077,7 @@ pw_auto_create_shortcut () {
read -r -a SORTED_LINKS < <(echo "${LINKS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
for link_file in "${SORTED_LINKS[@]//#@_@#/ }" ; do
if command -v exiftool &>/dev/null ; then
if timeout 3 exiftool "$link_file" &> "${PW_TMPFS_PATH}/exiftool.tmp" ; then
prefix_name=$(echo "$link_file" | awk -F"/prefixes/" '{print $2}' | awk -F"/" '{print $1}')
if fix_icon_name=$(grep -i "Icon File Name" "${PW_TMPFS_PATH}/exiftool.tmp" 2>/dev/null) \
&& [[ "${fix_icon_name//*.exe/true}" == "true" ]] ; then
link_drive=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$prefix_name/dosdevices/$link_drive|g" | sed 's/\\/\//g')
else
link_drive=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$prefix_name/dosdevices/$link_drive|g" | sed 's/\\/\//g')
fi
link_name=$(sed -n 's/^File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|\.lnk||')
link_cmd=$(sed -n 's/^Command Line Arguments\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp")
else
print_error "exiftool - broken!"
fi
else
print_warning "use portable exiftool"
env PERL5LIB="${PW_PLUGINS_PATH}/portable/lib/perl5" "${PW_PLUGINS_PATH}/portable/bin/exiftool" "$link_file" &> "${PW_TMPFS_PATH}/exiftool.tmp"
prefix_name=$(echo "$link_file" | awk -F"/prefixes/" '{print $2}' | awk -F"/" '{print $1}')
if fix_icon_name=$(grep -i "Icon File Name" "${PW_TMPFS_PATH}/exiftool.tmp" 2>/dev/null) \
&& [[ "${fix_icon_name//*.exe/true}" == "true" ]] ; then
link_drive=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Icon File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$prefix_name/dosdevices/$link_drive|g" | sed 's/\\/\//g')
else
link_drive=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | cut -d: -f1 | awk '{print tolower($0)}')
link_path=$(sed -n 's/^Local Base Path\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|%ProgramFiles(x86)%|C:\\Program Files (x86)|gi;s|%ProgramFiles%|C:\\Program Files|gi' | sed "s|^.|${PORT_WINE_PATH}/data/prefixes/$prefix_name/dosdevices/$link_drive|g" | sed 's/\\/\//g')
fi
link_name=$(sed -n 's/^File Name\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp" | sed 's|\.lnk||')
link_cmd=$(sed -n 's/^Command Line Arguments\s*:\s*//p' "${PW_TMPFS_PATH}/exiftool.tmp")
fi
get_lnk "${link_file}"
if ! exe_path="$(realpath "${link_path}" 2>/dev/null)" ; then
print_warning "Link broken for: $link_name"
else
......
......@@ -19,7 +19,7 @@ Type=Application
Terminal=False
Categories=Game
StartupNotify=true
MimeType=application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program;text/win-bat;
MimeType=application/x-ms-dos-executable;application/x-wine-extension-msp;application/x-msi;application/x-msdos-program;application/x-ms-shortcut;text/win-bat;
Path=${PORT_SCRIPTS_PATH}
Icon=${PORT_WINE_PATH}/data/img/w.png
EOF
......
......@@ -52,7 +52,7 @@ if [[ "${1,,}" =~ .ppack$ ]] ; then
export PW_NO_RESTART_PPDB="1"
export PW_DISABLED_CREATE_DB="1"
portwine_exe="$1"
elif [[ "${1,,}" =~ .(exe|bat|msi|reg)$ ]] ; then
elif [[ "${1,,}" =~ .(exe|bat|msi|reg|lnk)$ ]] ; then
if [[ -f "$1" ]] ; then
portwine_exe="$(realpath -s "$1")"
elif [[ -f "$OLDPWD/$1" ]] ; then
......@@ -61,6 +61,10 @@ elif [[ "${1,,}" =~ .(exe|bat|msi|reg)$ ]] ; then
portwine_exe="$1"
MISSING_DESKTOP_FILE="1"
fi
if [[ -n "${portwine_exe}" && "${1,,}" =~ .lnk$ ]] ; then
get_lnk "${portwine_exe}"
portwine_exe="$(realpath "${link_path}" 2>/dev/null)"
fi
elif [[ "$1" =~ ^--(debug|launch|edit-db)$ && "${2,,}" =~ .(exe|bat|msi|reg)$ ]] ; then
if [[ -f "$2" ]] ; then
portwine_exe="$(realpath -s "$2")"
......
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