summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2024-03-10 22:17:20 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2024-03-10 22:17:20 +0100
commit322a1547c217314b278acb9c8929378e9378bfb7 (patch)
treef676530eb06cec1fea0aa6c9443a6ecaecb2a3d6
parent9e9808917137fecd34d5683409f78a976a155510 (diff)
downloadmemory-leaks-322a1547c217314b278acb9c8929378e9378bfb7.tar.xz
Teach apps activation script to set XDG_DATA_DIRS
This allows systemd to find units, and desktop environments to find application entries.
-rw-r--r--guides/setups/operating-systems/apps-demo/activate33
-rw-r--r--guides/setups/operating-systems/apps.org4
2 files changed, 33 insertions, 4 deletions
diff --git a/guides/setups/operating-systems/apps-demo/activate b/guides/setups/operating-systems/apps-demo/activate
index 434924a..fbf522c 100644
--- a/guides/setups/operating-systems/apps-demo/activate
+++ b/guides/setups/operating-systems/apps-demo/activate
@@ -1,12 +1,41 @@
# Hey Emacs; this is a -*- shell-script -*-.
# Hopefully invoked by bash 🤞
-_apps_dir=$(dirname ${BASH_SOURCE})
+_apps_dir=$(realpath --no-symlinks $(dirname ${BASH_SOURCE}))
_apps_PATH=$(
shopt -s nullglob
bins=( "${_apps_dir}"/*/bin )
IFS=: eval 'echo "${bins[*]}"'
)
-
export PATH=${_apps_PATH}:${PATH}
+
+_apps_XDG_DATA_DIRS=$(
+ shopt -s nullglob
+ # We could set globstar and let Bash loose, searching the depths
+ # of _apps_dir for
+ # **/{applications/*.desktop,systemd/user/*.service}
+ # but it seems like asking for trouble. Make some assumptions
+ # about where applications typically dump their XDG-related files.
+ datadirs=($(
+ {
+ for dkentry in "${_apps_dir}"/*/share/applications/*.desktop
+ do
+ echo ${dkentry%/applications/*.desktop}
+ done
+ for unit in "${_apps_dir}"/*/lib*/systemd/user/*.service
+ do
+ echo ${unit%/systemd/user/*.service}
+ done
+ } | sort -u
+ ))
+ IFS=: eval 'echo "${datadirs[*]}"'
+)
+export XDG_DATA_DIRS=$(
+ if test "${XDG_DATA_DIRS}"
+ then
+ echo "${_apps_XDG_DATA_DIRS}:${XDG_DATA_DIRS}"
+ else
+ echo "${_apps_XDG_DATA_DIRS}"
+ fi
+)
diff --git a/guides/setups/operating-systems/apps.org b/guides/setups/operating-systems/apps.org
index efede03..0ff0184 100644
--- a/guides/setups/operating-systems/apps.org
+++ b/guides/setups/operating-systems/apps.org
@@ -113,7 +113,7 @@ infopath-no-defaults=On
EOF
#+end_src
-* TODO systemd services
+* DONE systemd services
=systemd.unit(5)= § "User Unit Search Path" mentions a couple of
variables that we could append:
@@ -153,7 +153,7 @@ files). Serendipitously, [[https://github.com/systemd/systemd/blob/1d87a00a951d
*/
#+end_src
-* TODO Desktop entry files
+* DONE Desktop entry files
The Freedesktop [[https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html][Desktop Menu]] and [[https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html][Desktop Entry]] specs spell out how
=XDG_DATA_DIRS= will be searched for =applications/*.desktop= files.