From 50c52e6b735b0f963f176d0fb0458800103f1cde Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:40:44 +0200 Subject: [PATCH 1/8] Add new option "icon-theme" ...to allow launchers using custoom icon themes, see https://github.com/ivan-hc/AM/issues/922 --- APP-MANAGER | 5 +++-- modules/management.am | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 2cbbdc0ff..c913e9c71 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8.1.1-2" +AMVERSION="8.2-beta1" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" @@ -287,7 +287,7 @@ _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 \ + home icon-theme 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 \ --less --pkg --rollback --disable-sandbox --sandbox --system --user" @@ -1095,6 +1095,7 @@ case "$1" in ;; 'backup'|'-b'|\ 'downgrade'|'--rollback'|\ + 'icon-theme'|\ 'launcher'|'--launcher'|\ 'lock'|'unlock'|\ 'nolibfuse'|\ diff --git a/modules/management.am b/modules/management.am index fe1ac9604..4d4c8c438 100644 --- a/modules/management.am +++ b/modules/management.am @@ -105,6 +105,15 @@ function _downgrade() { echo "ROLLBACK SUCCESSFUL!" } +# ICON THEME CHANGER +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 +} + # LAUNCHER function _launcher_appimage_extract() { "$arg" --appimage-extract share/icons/*/*/* 1>/dev/null @@ -332,6 +341,18 @@ case "$1" in done ;; + 'icon-theme') + # 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@.* @@') + else + ARGS="$(echo "$@" | cut -f2- -d ' ')" + fi + for arg in $ARGS; do + _icon_theme "${@}" + done + ;; + 'launcher'|'--launcher') # Place local AppImages into the menu by dragging and dropping them into the terminal ARGS="$(echo "$@" | cut -f2- -d ' ')" From f6ff33b84ae9793762a54208120ddbfb29700417 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:49:32 +0200 Subject: [PATCH 2/8] New option "icon-theme"*: export existing icons to the $HOME... ...as a fallback. *"icon-theme" is still a temporary option name. --- modules/management.am | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/management.am b/modules/management.am index 4d4c8c438..0e466d034 100644 --- a/modules/management.am +++ b/modules/management.am @@ -106,12 +106,18 @@ function _downgrade() { } # ICON THEME CHANGER +function _icon_theme_export_to_datadir() { + [ -d "$APPSPATH/$arg/icons" ] && mkdir -p "$DATADIR"/icons && rsync -avq "$APPSPATH"/"$arg"/icons/* "$DATADIR"/icons/ \ + && find "$DATADIR"/icons -type f ! -name "*.*" -exec mv {} {}.png \; +} + 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 } # LAUNCHER From 789974a70a65178d71f79f67941d431cc1d62136 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:59:41 +0200 Subject: [PATCH 3/8] Option for the icons: do not overwrite the existing ones --- modules/management.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/management.am b/modules/management.am index 0e466d034..3adc6efaf 100644 --- a/modules/management.am +++ b/modules/management.am @@ -107,8 +107,9 @@ function _downgrade() { # ICON THEME CHANGER function _icon_theme_export_to_datadir() { - [ -d "$APPSPATH/$arg/icons" ] && mkdir -p "$DATADIR"/icons && rsync -avq "$APPSPATH"/"$arg"/icons/* "$DATADIR"/icons/ \ - && find "$DATADIR"/icons -type f ! -name "*.*" -exec mv {} {}.png \; + [ -d "$APPSPATH/$arg/icons" ] && mkdir -p "$DATADIR"/icons \ + && find "$APPSPATH"/"$arg"/icons -type f ! -name "*.*" -exec cp {} {}.png \; \ + && rsync -avq "$APPSPATH"/"$arg"/icons/*.png "$DATADIR"/icons/ && rm -f "$APPSPATH"/"$arg"/icons/*.png } function _icon_theme() { From 675c77061738f6138628f800bdee5452060aa616 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:35:01 -0400 Subject: [PATCH 4/8] Add .png or .svg symlinks to icons management.am --- modules/management.am | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/management.am b/modules/management.am index 3adc6efaf..7385069f5 100644 --- a/modules/management.am +++ b/modules/management.am @@ -107,9 +107,17 @@ function _downgrade() { # ICON THEME CHANGER function _icon_theme_export_to_datadir() { - [ -d "$APPSPATH/$arg/icons" ] && mkdir -p "$DATADIR"/icons \ - && find "$APPSPATH"/"$arg"/icons -type f ! -name "*.*" -exec cp {} {}.png \; \ - && rsync -avq "$APPSPATH"/"$arg"/icons/*.png "$DATADIR"/icons/ && rm -f "$APPSPATH"/"$arg"/icons/*.png + 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() { @@ -118,7 +126,7 @@ function _icon_theme() { else sed -i "s#Icon=$APPSPATH/$arg/icons/#Icon=#g" "$DATADIR"/applications/"$arg"*AM.desktop 2>/dev/null fi - _icon_theme_export_to_datadir + _icon_theme_export_to_datadir 2>/dev/null } # LAUNCHER @@ -306,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() { @@ -318,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 {} \; } ########################################################################### From b83f09d60c94c9ab93b29450ba09262dd4268408 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:09:00 +0200 Subject: [PATCH 5/8] New option for icons: add prompt to allow the change (default N) --- modules/management.am | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/management.am b/modules/management.am index 7385069f5..0baa6d19b 100644 --- a/modules/management.am +++ b/modules/management.am @@ -362,12 +362,19 @@ case "$1" in # 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 - for arg in $ARGS; do - _icon_theme "${@}" - done ;; 'launcher'|'--launcher') From 69aa349f0bf37799a5691e10af90c16b5893791e Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:26:31 +0200 Subject: [PATCH 6/8] Rename the new option to "icons"/"--icons" --- APP-MANAGER | 19 +++++++++++++++---- modules/management.am | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index cf8d00dc7..7168a95bd 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -288,9 +288,9 @@ _am_newrepo_check "$@" # COMPLETION LIST available_options="about add apikey backup clean config disable downgrade download enable extra files \ - home icon-theme 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() { @@ -716,6 +716,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} @@ -1096,7 +1107,7 @@ case "$1" in ;; 'backup'|'-b'|\ 'downgrade'|'--rollback'|\ - 'icon-theme'|\ + 'icons'|'--icons'|\ 'launcher'|'--launcher'|\ 'lock'|'unlock'|\ 'nolibfuse'|\ diff --git a/modules/management.am b/modules/management.am index 0baa6d19b..e877186ee 100644 --- a/modules/management.am +++ b/modules/management.am @@ -358,7 +358,7 @@ case "$1" in done ;; - 'icon-theme') + '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@.* @@') From 26c2853d4b8f033a13899d48952a54e8605b52e6 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:52:55 +0200 Subject: [PATCH 7/8] Update README.md ...add new option "icons" --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) 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} From 4d82bcf30ad16aec34080bb7711df4aa25f75124 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:54:06 +0200 Subject: [PATCH 8/8] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 6fcc541ee..c20c54b98 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8.2-beta1" +AMVERSION="8.2" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"