diff --git a/APP-MANAGER b/APP-MANAGER index d883146de..c20c54b98 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -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" @@ -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() { @@ -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} @@ -1097,6 +1108,7 @@ case "$1" in ;; 'backup'|'-b'|\ 'downgrade'|'--rollback'|\ + 'icons'|'--icons'|\ 'launcher'|'--launcher'|\ 'lock'|'unlock'|\ 'nolibfuse'|\ diff --git a/README.md b/README.md index 9671f8dc1..92def074f 100644 --- a/README.md +++ b/README.md @@ -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} diff --git a/modules/management.am b/modules/management.am index fe1ac9604..e877186ee 100644 --- a/modules/management.am +++ b/modules/management.am @@ -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 @@ -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() { @@ -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 {} \; } ########################################################################### @@ -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 ' ')"