Skip to content

Commit

Permalink
"AM" 9.0.2, allow to use icon theme immediately after installation (#…
Browse files Browse the repository at this point in the history
…1091)

* Move the function to export the icons to the main CLI

* Allow use of custom icon themes after installation

* Update APP-MANAGER

* Update README.md
  • Loading branch information
ivan-hc authored Nov 7, 2024
1 parent bf5a43b commit bb681f6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 40 deletions.
37 changes: 30 additions & 7 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="9.0.1"
AMVERSION="9.0.2"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down Expand Up @@ -176,6 +176,23 @@ function _determine_args() {
# use "argpath=$(echo "$ARGPATHS" | grep "/$arg$")" to determine the full path of "arg"
}

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
if [ -n "$APPMAN_APPSPATH" ]; then
PNG="$(file "$APPMAN_APPSPATH"/*/icons/* | grep -i '.png' | awk -F":" '{print $1}' | grep -vi .png)"
SVG="$(file "$APPMAN_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
fi
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
[ -n "$APPMAN_APPSPATH" ] && ln -s "$APPMAN_APPSPATH"/*/icons/*.* "$DATADIR"/icons/hicolor/scalable/apps
}

################################################################################
# FINALIZE
################################################################################
Expand Down Expand Up @@ -1078,21 +1095,23 @@ case "$1" in
${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.
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. The \"--icons\" option can be used as \"flag\" in the \"-i\" and \"-ia\" options.
${Gold}install, -i\033[0m
${LightBlue}$AMCLI -i {PROGRAM}
${LightBlue}$AMCLI -i --debug {PROGRAM}
${LightBlue}$AMCLI -i --force-latest {PROGRAM}\033[0m
${LightBlue}$AMCLI -i --force-latest {PROGRAM}
${LightBlue}$AMCLI -i --icons {PROGRAM}\033[0m
Description: Install one or more programs or libraries from the list. With the \"--debug\" option you can see log messages to debug the script. For more details on \"--force-latest\", see the dedicated option, below.
Description: Install one or more programs or libraries from the list. With the \"--debug\" option you can see log messages to debug the script. For more details on \"--force-latest\", see the dedicated option, below. Use the \"--icons\" flag to allow the program to use icon themes.
${Gold}install-appimage, -ia\033[0m
${LightBlue}$AMCLI -ia {PROGRAM}
${LightBlue}$AMCLI -ia --debug {PROGRAM}
${LightBlue}$AMCLI -ia --force-latest {PROGRAM}\033[0m
${LightBlue}$AMCLI -ia --force-latest {PROGRAM}
${LightBlue}$AMCLI -ia --icons {PROGRAM}\033[0m
Description: Same as \"install\" (see above) but for AppImages only.
Expand Down Expand Up @@ -1253,14 +1272,18 @@ case "$1" in
${LightBlue}am -i --user --debug {PROGRAM}\033[0m
${LightBlue}am -i --user --force-latest {PROGRAM}
${LightBlue}am -i --user --debug --force-latest {PROGRAM}\033[0m
${LightBlue}am -i --user --icons {PROGRAM}
${LightBlue}am -i --user --debug --force-latest {PROGRAM}
${LightBlue}am -i --user --debug --force-latest --icons {PROGRAM}\033[0m
- Same for AppImages only, option \"-ia\" or \"install-appimage\":
${LightBlue}am -ia --user {PROGRAM}\033[0m
${LightBlue}am -ia --user --debug {PROGRAM}
${LightBlue}am -ia --user --force-latest {PROGRAM}
${LightBlue}am -ia --user --debug --force-latest {PROGRAM}\033[0m
${LightBlue}am -ia --user --icons {PROGRAM}
${LightBlue}am -ia --user --debug --force-latest {PROGRAM}
${LightBlue}am -ia --user --debug --force-latest --icons {PROGRAM}\033[0m
- External AppImages can be installed like this as well, option \"-e\" or \"extra\":
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,27 +374,30 @@ Set a dedicated $HOME directory for one or more AppImages.

**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 `~/.local/share/icons/hicolor/scalable/apps` directory.
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 `~/.local/share/icons/hicolor/scalable/apps` directory. The "`--icons`"
option can be used as "flag" in the "`-i`" and "`-ia`" options.

------------------------------------------------------------------------
### `install`, `-i`

am -i {PROGRAM}
am -i --debug {PROGRAM}
am -i --force-latest {PROGRAM}
am -i {PROGRAM}
am -i --debug {PROGRAM}
am -i --force-latest {PROGRAM}
am -i --icons {PROGRAM}

**Description**:

Install one or more programs or libraries from the list. With the "`--debug`" option you can see log messages to debug the script. For more details on "`--force-latest`", see the dedicated option, below.
Install one or more programs or libraries from the list. With the "`--debug`" option you can see log messages to debug the script. For more details on "`--force-latest`", see the dedicated option, below. Use the "`--icons`" flag to allow the program to use icon themes.

NOTE: Since this is an "install" option, you can add the "`--user`" flag to install apps locally. See "`--user`" at the bottom to learn more.

------------------------------------------------------------------------
### `install-appimage`, `-ia`

am -ia {PROGRAM}
am -ia --debug {PROGRAM}
am -ia --force-latest {PROGRAM}
am -ia {PROGRAM}
am -ia --debug {PROGRAM}
am -ia --force-latest {PROGRAM}
am -ia --icons {PROGRAM}

**Description**:

Expand Down Expand Up @@ -624,16 +627,20 @@ The "`--user`" option can also be used just as a "flag" for installation options

- Also suboptions of "`-i`" can work with this flag:

am -i --user --debug {PROGRAM}
am -i --user --force-latest {PROGRAM}
am -i --user --debug --force-latest {PROGRAM}
am -i --user --debug {PROGRAM}
am -i --user --force-latest {PROGRAM}
am -i --user --icons {PROGRAM}
am -i --user --debug --force-latest {PROGRAM}
am -i --user --debug --force-latest --icons {PROGRAM}

- Same for AppImages only, option "`-ia`" or "`install-appimage`":

am -ia --user --user {PROGRAM}
am -ia --user --debug {PROGRAM}
am -ia --user --force-latest {PROGRAM}
am -ia --user --debug --force-latest {PROGRAM}
am -ia --user {PROGRAM}
am -ia --user --debug {PROGRAM}
am -ia --user --force-latest {PROGRAM}
am -ia --user --icons {PROGRAM}
am -ia --user --debug --force-latest {PROGRAM}
am -ia --user --debug --force-latest --icons {PROGRAM}

- External AppImages can be installed like this as well, option "`-e`" or "`extra`":

Expand Down
15 changes: 14 additions & 1 deletion modules/install.am
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ _download() {

#--------------------------------------------------------------------------
# INSTALL
# If you use the --latest option, add the "latest" flag to scripts that point to a very common "release"
_if_latest() {
if echo "$FLAGS" | grep -q -- '--force-latest'; then
# If you use the --latest option, add the "latest" flag to scripts that point to a very common "release"
sed -i 's#/releases #/releases/latest #g' ./"$arg"
fi
}

_if_icons() {
if echo "$FLAGS" | grep -q -- '--icons'; then
# Install the app so that it can rely on an icon theme (if available)
sed -i "s#Icon=/opt/\$APP/icons/#Icon=#g" ./"$arg"
fi
}

_if_debug() {
if ! echo "$FLAGS" | grep -q -- "--debug" && wget --version | head -1 | grep -q ' 1.'; then
# Patch "wget" (version 1.x) to have a progress bar and fix errors when applying patches
Expand Down Expand Up @@ -121,6 +128,10 @@ _post_installation_processes() {
-e "s#Exec=/usr/bin/#Exec=$BINDIR/#g" \
-e "s#Exec=/opt/#Exec=$BINDIR/#g" "$DATADIR"/applications/*-AM.desktop 2>/dev/null
fi
if echo "$FLAGS" | grep -q -- '--icons'; then
# Export all icons for hicolor theme usage
_icon_theme_export_to_datadir 2>/dev/null
fi
}

# End of the installation process
Expand Down Expand Up @@ -229,6 +240,7 @@ _install_arg() {
fi
_spooky_check || return 1
_if_debug
_if_icons
_if_latest
_apply_patches
echo ""
Expand Down Expand Up @@ -335,6 +347,7 @@ case "$1" in
echo " USAGE: $AMCLI $1 [ARGUMENT]"
echo " USAGE: $AMCLI $1 --debug [ARGUMENT]"
echo " USAGE: $AMCLI $1 --force-latest [ARGUMENT]"
echo " USAGE: $AMCLI $1 --icons [ARGUMENT]"
[ "$AMCLI" = "am" ] && echo " USAGE: $AMCLI $1 --user [ARGUMENT]"
exit 1
;;
Expand Down
17 changes: 0 additions & 17 deletions modules/management.am
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,6 @@ function _downgrade() {
}

# 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
if [ -n "$APPMAN_APPSPATH" ]; then
PNG="$(file "$APPMAN_APPSPATH"/*/icons/* | grep -i '.png' | awk -F":" '{print $1}' | grep -vi .png)"
SVG="$(file "$APPMAN_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
fi
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
[ -n "$APPMAN_APPSPATH" ] && ln -s "$APPMAN_APPSPATH"/*/icons/*.* "$DATADIR"/icons/hicolor/scalable/apps
}

function _icon_theme() {
if [ "$AMCLI" = am ] && test -f /usr/local/share/applications/"$arg"*AM.desktop; then
$SUDOCMD sed -i "s#Icon=$argpath/icons/#Icon=#g" /usr/local/share/applications/"$arg"*AM.desktop 2>/dev/null
Expand Down

0 comments on commit bb681f6

Please sign in to comment.