Skip to content

Commit

Permalink
export: fix list-apps path search for custom home dirs, Fix #1226
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Feb 22, 2024
1 parent 24a008f commit e9f9eff
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -553,33 +553,12 @@ export_application() {
# a list of exported apps
# or error code.
list_exported_applications() {
canon_dirs=""

IFS=":"
if [ -n "${XDG_DATA_DIRS}" ]; then
for xdg_data_home in ${XDG_DATA_HOME}; do
[ -d "${xdg_data_home}/applications" ] && canon_dirs="${canon_dirs} ${xdg_data_home}/applications"
done
else
[ -d /usr/share/applications ] && canon_dirs="/usr/share/applications"
[ -d /usr/local/share/applications ] && canon_dirs="${canon_dirs} /usr/local/share/applications"
[ -d /var/lib/flatpak/exports/share/applications ] && canon_dirs="${canon_dirs} /var/lib/flatpak/exports/share/applications"
fi
if [ -n "${XDG_DATA_HOME}" ]; then
for xdg_data_dir in ${XDG_DATA_DIRS}; do
[ -d "${xdg_data_dir}/applications" ] && canon_dirs="${canon_dirs} ${xdg_data_dir}/applications"
done
else
[ -d "${HOME}/.local/share/applications" ] && canon_dirs="${canon_dirs} ${HOME}/.local/share/applications"
fi
unset IFS

# In this phase we search for applications exported.
# First find command will grep through all files in the canonical directories
# and only list files that contain the $DISTROBOX_ENTER_PATH.
desktop_files=$(
# shellcheck disable=SC2086
find ${canon_dirs} -type f -print -o -type l -print 2> /dev/null | sed 's/./\\&/g' |
find "/run/host${host_home}/.local/share/applications" -type f -print -o -type l -print 2> /dev/null | sed 's/./\\&/g' |
xargs -I{} grep -l -e "Exec=.*${DISTROBOX_ENTER_PATH:-"distrobox.*enter"}.*" "{}" | sed 's/./\\&/g' |
xargs -I{} printf "%s@" "{}"
)
Expand Down

0 comments on commit e9f9eff

Please sign in to comment.