Skip to content

Commit

Permalink
Merge pull request #924 from ivan-hc/dev
Browse files Browse the repository at this point in the history
"AM" 8.2: added an option to remove icon path and allow the use of custom icon themes
  • Loading branch information
ivan-hc authored Sep 5, 2024
2 parents 03b5b1b + 4d82bcf commit 146d43c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
20 changes: 16 additions & 4 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="8.1.1-2"
AMVERSION="8.2"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down Expand Up @@ -289,9 +289,9 @@ _am_newrepo_check "$@"

# COMPLETION LIST
available_options="about add apikey backup clean config disable downgrade download enable extra files \
home info install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite \
purge query remove sandbox select sync template test unlock update --appimages --apps --byname \
--config --convert --debug --devmode-disable --devmode-enable --force-latest --home --launcher \
home icons info install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite \
purge query remove sandbox select sync template test unlock update --all --appimages --apps --byname \
--config --convert --debug --devmode-disable --devmode-enable --force-latest --home --icons --launcher \
--less --pkg --rollback --disable-sandbox --sandbox --system --user"

function _completion_lists() {
Expand Down Expand Up @@ -717,6 +717,17 @@ ${Gold}home, -H, --home\033[0m
Description: Set a dedicated \$HOME directory for one or more AppImages.
${Gold}icons, --icons\033[0m
${LightBlue}$AMCLI --icons {PROGRAM}
${LightBlue}$AMCLI --icons --all\033[0m
Description: Allow installed apps to use system icon themes. You can specify \
the name of the apps to change or use the \"--all\" flag to change all of them \
at once. This will remove the icon path from the .desktop file and add the \
symbolic link of all available icons in the $DATADIR/icons/hicolor/scalable/apps \
directory.
${Gold}install, -i\033[0m
${LightBlue}$AMCLI -i {PROGRAM}
Expand Down Expand Up @@ -1097,6 +1108,7 @@ case "$1" in
;;
'backup'|'-b'|\
'downgrade'|'--rollback'|\
'icons'|'--icons'|\
'launcher'|'--launcher'|\
'lock'|'unlock'|\
'nolibfuse'|\
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,13 @@ Description: Prints this message.

Description: Set a dedicated $HOME directory for one or more AppImages.

### `icons, --icons`

--icons {PROGRAM}
--icons --all

Description: Allow installed apps to use system icon themes. You can specify the name of the apps to change or use the "--all" flag to change all of them at once. This will remove the icon path from the .desktop file and add the symbolic link of all available icons in the $HOME/.local/share/icons/hicolor/scalable/apps directory.

### `install, -i`

-i {PROGRAM}
Expand Down
45 changes: 45 additions & 0 deletions modules/management.am
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ function _downgrade() {
echo "ROLLBACK SUCCESSFUL!"
}

# ICON THEME CHANGER
function _icon_theme_export_to_datadir() {
PNG="$(file "$APPSPATH"/*/icons/* | grep -i '.png' | awk -F":" '{print $1}' | grep -vi .png)"
SVG="$(file "$APPSPATH"/*/icons/* | grep -i '.svg' | awk -F":" '{print $1}' | grep -vi .svg)"
for file in $PNG; do
ln -s "$file" "${file}".png
done
for file in $SVG; do
ln -s "$file" "${file}".svg
done
mkdir -p "$DATADIR"/icons/hicolor/scalable/apps
find "$DATADIR"/icons/hicolor/scalable/apps -xtype l -exec rm {} \;
ln -s "$APPSPATH"/*/icons/*.* "$DATADIR"/icons/hicolor/scalable/apps
}

function _icon_theme() {
if [ "$AMCLI" = am ]; then
$SUDOCMD sed -i "s#Icon=$APPSPATH/$arg/icons/#Icon=#g" /usr/local/share/applications/"$arg"*AM.desktop 2>/dev/null
else
sed -i "s#Icon=$APPSPATH/$arg/icons/#Icon=#g" "$DATADIR"/applications/"$arg"*AM.desktop 2>/dev/null
fi
_icon_theme_export_to_datadir 2>/dev/null
}

# LAUNCHER
function _launcher_appimage_extract() {
"$arg" --appimage-extract share/icons/*/*/* 1>/dev/null
Expand Down Expand Up @@ -290,6 +314,7 @@ function _remove() {
sleep 0.1
echo -e " \"${Green}$2\033[0m\" has been removed!"
fi
[ -d "$DATADIR"/icons/hicolor/scalable/apps ] && find "$DATADIR"/icons/hicolor/scalable/apps -xtype l -exec rm {} \;
}

function _hard_remove() {
Expand All @@ -302,6 +327,7 @@ function _hard_remove() {
$SUDOCMD "$APPSPATH"/"$arg"/remove || return 1
sleep 0.1
echo -e " \"${Green}$2\033[0m\" has been removed!"
[ -d "$DATADIR"/icons/hicolor/scalable/apps ] && find "$DATADIR"/icons/hicolor/scalable/apps -xtype l -exec rm {} \;
}

###########################################################################
Expand Down Expand Up @@ -332,6 +358,25 @@ case "$1" in
done
;;

'icons'|'--icons')
# Place local AppImages into the menu by dragging and dropping them into the terminal
if [ "$2" = "--all" ]; then
ARGS=$(find . -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2>/dev/null | sort -rh | sed 's@.* @@')
read -r -p " ◆ Do you wish to allow custom icon theming for ALL the apps? (y,N) " yn
else
ARGS="$(echo "$@" | cut -f2- -d ' ')"
read -r -p " ◆ Do you wish to allow custom icon theming for the selected apps? (y,N) " yn
fi
if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
for arg in $ARGS; do
_icon_theme "${@}"
done
echo " ✔ Success!"
else
echo " ✖ Aborted!"
fi
;;

'launcher'|'--launcher')
# Place local AppImages into the menu by dragging and dropping them into the terminal
ARGS="$(echo "$@" | cut -f2- -d ' ')"
Expand Down

0 comments on commit 146d43c

Please sign in to comment.