-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WIP]: Add termux_step_install_icons
to generate and install application icons.
#24920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
TomJo2000
wants to merge
3
commits into
termux:master
Choose a base branch
from
TomJo2000:add-app-icons
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−44
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# shellcheck shell=bash | ||
termux_step_install_icons() { | ||
local termux_run_wrapper='' | ||
# Check if we need to wrap calls to `imagemagick` with `termux-proot-run`. | ||
if [[ "$TERMUX_ON_DEVICE_BUILD" != 'true' ]]; then | ||
termux_setup_proot | ||
termux_run_wrapper='termux-proot-run' | ||
fi | ||
|
||
local -a ICON_SIZES=() ICON_NAMES=() ICONS=() | ||
local res icon_name icon idx | ||
|
||
# defaults to (16 24 32 48 64 128 256) | ||
while read -r res; do | ||
ICON_SIZES+=("$res") | ||
done <<< "${TERMUX_PKG_ICON_SIZES//,/$'\n'}" | ||
|
||
while read -r icon; do | ||
ICONS+=("$icon") | ||
done <<< "${TERMUX_PKG_ICONS//,/$'\n'}" | ||
|
||
if [[ -n "${TERMUX_PKG_ICON_NAMES}" ]]; then | ||
while read -r icon_name; do | ||
ICON_NAMES+=("$icon_name") | ||
done <<< "${TERMUX_PKG_ICON_NAMES//,/$'\n'}" | ||
else # If we have no names given just take off the extensions from the icon filenames. | ||
for icon in "${ICONS[@]}"; do | ||
: "$(basename "$icon")" | ||
ICON_NAMES+=("${_%.*}") | ||
done | ||
fi | ||
|
||
# Make sure we have a matching abmount of icons and icon names. | ||
if (( ${#ICONS[*]} != ${#ICON_NAMES[*]} )); then | ||
echo "termux_step_install_icons: error: mismatch between amount of icons and icon names" | ||
echo "ICONS : (${#ICONS[*]}) ${ICONS[*]}" | ||
echo "ICON_NAMES: (${#ICON_NAMES[*]}) ${ICON_NAMES[*]}" | ||
return 1 | ||
fi | ||
|
||
# Loop over the list of icons and put them in the appropriate directory | ||
for (( idx = 0 ; idx < ${#ICONS[*]} ; idx++ )); do | ||
printf '%s' "Generating icons for ${ICON_NAMES[$idx]}:" | ||
|
||
# Is this a symbolic vector icon? | ||
if [[ "${ICONS[$idx]}" == *'symbolic'*'.svg' ]]; then | ||
install -Dm644 "${ICONS[$idx]}" "${TERMUX_PREFIX}/share/icons/hicolor/symbolic/apps/${ICON_NAMES[$idx]}.svg" | ||
printf ' %s\n' "symbolic" | ||
continue | ||
fi | ||
|
||
# Generate the different sizes | ||
for res in "${ICON_SIZES[@]}"; do | ||
# Make a ${res}x${res} version of the icon | ||
mkdir -p "${TERMUX_PREFIX}/share/icons/hicolor/${res}x${res}/apps" | ||
${termux_run_wrapper:-} magick "${ICONS[$idx]}" \ | ||
-resize "${res}x${res}" \ | ||
"${TERMUX_PREFIX}/share/icons/hicolor/${res}x${res}/apps/${ICON_NAMES[$idx]}.png" | ||
printf ' %s' "${res}x${res}" | ||
done | ||
|
||
# Is this a vector icon? | ||
if [[ "${ICONS[$idx]}" == *'.svg' ]]; then | ||
install -Dm644 "${ICONS[$idx]}" "${TERMUX_PREFIX}/share/icons/hicolor/scalable/apps/${ICON_NAMES[$idx]}.svg" | ||
printf ' %s' "scalable" | ||
fi | ||
echo | ||
done | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.