Merge pull request #165112 from toonn/darwin-bundle-Exec-field-codes

desktopToDarwinBundle: Patch Exec field codes
This commit is contained in:
Domen Kožar 2022-04-20 12:24:01 +01:00 committed by GitHub
commit 36bbcc2a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,7 +163,7 @@ convertIconTheme() {
}
iconsdir=$(getIcons "$sharePath" "apps/${iconName}" "$theme")
if [[ -n "$(ls -1 "$iconsdir/"*)" ]]; then
if [[ -n "$(ls -A1 "$iconsdir")" ]]; then
icnsutil compose --toc "$out/${iconName}.icns" "$iconsdir/"*
else
echo "Warning: no icons were found. Creating an empty icon for ${iconName}.icns."
@ -171,12 +171,32 @@ convertIconTheme() {
fi
}
processExecFieldCodes() {
local -r file=$1
local -r execRaw=$(getDesktopParam "${file}" "Exec")
local -r execNoK="${execRaw/\%k/${file}}"
local -r execNoKC="${execNoK/\%c/$(getDesktopParam "${file}" "Name")}"
local -r icon=$(getDesktopParam "${file}" "Icon")
local -r execNoKCI="${execNoKC/\%i/${icon:+--icon }${icon}}"
local -r execNoKCIfu="${execNoKCI/\%[fu]/\$1}"
local -r exec="${execNoKCIfu/\%[FU]/\$@}"
if [[ "$exec" != "$execRaw" ]]; then
echo 1>&2 "desktopToDarwinBundle: Application bundles do not understand desktop entry field codes. Changed '$execRaw' to '$exec'."
fi
echo "$exec"
}
# For a given .desktop file, generate a darwin '.app' bundle for it.
convertDesktopFile() {
local -r file=$1
local -r sharePath=$(dirname "$(dirname "$file")")
local -r name=$(getDesktopParam "${file}" "^Name")
local -r exec=$(getDesktopParam "${file}" "Exec")
local -r macOSExec=$(getDesktopParam "${file}" "X-macOS-Exec")
if [[ "$macOSExec" ]]; then
local -r exec="$macOSExec"
else
local -r exec=$(processExecFieldCodes "${file}")
fi
local -r iconName=$(getDesktopParam "${file}" "^Icon")
local -r squircle=$(getDesktopParam "${file}" "X-macOS-SquircleIcon")