From a68c21884bfc0cbb07a1a3d509f781f9f6a9df88 Mon Sep 17 00:00:00 2001 From: Kron4ek Date: Wed, 12 Apr 2023 01:58:02 +0500 Subject: [PATCH] Preserve environment variables when exporting desktop files Not all environment variables, but those related to Conty. --- conty-start.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/conty-start.sh b/conty-start.sh index 450102b..99de562 100755 --- a/conty-start.sh +++ b/conty-start.sh @@ -19,7 +19,7 @@ script_version="1.22" # Important variables to manually adjust after modification! # Needed to avoid problems with mounting due to an incorrect offset. -script_size=26757 +script_size=27087 utils_size=2507588 # Full path to the script @@ -794,7 +794,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ exit fi - if [ "$1" = "-d" ]; then + if [ "$1" = "-d" ] && [ -z "${script_is_symlink}" ]; then applications_dir="${HOME}"/.local/share/applications/Conty if [ -d "${applications_dir}" ]; then @@ -807,6 +807,18 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ mkdir -p "${applications_dir}" cd "${mount_point}"/usr/share/applications || exit 1 + unset variables + vars="BASE_DIR DISABLE_NET DISABLE_X11 HOME_DIR SANDBOX SANDBOX_LEVEL USE_SYS_UTILS" + for v in ${vars}; do + if [ -n "${!v}" ]; then + variables="${v}=\"${!v}\" ${variables}" + fi + done + + if [ -n "${variables}" ]; then + variables="env ${variables} " + fi + echo "Exporting..." shift for f in *.desktop */ */*.desktop; do @@ -822,7 +834,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ if [ "${line_function}" = "Name" ]; then line="${line} (Conty)" elif [ "${line_function}" = "Exec" ]; then - line="Exec=\"${script}\" $@ $(echo "${line}" | tail -c +6)" + line="Exec=${variables}\"${script}\" $@ $(echo "${line}" | tail -c +6)" elif [ "${line_function}" = "TryE" ]; then continue fi